From patchwork Mon Jul 22 00:16:50 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: 13738134 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 589ABC3DA61 for ; Mon, 22 Jul 2024 00:18:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgjg-0002N9-8Z; Sun, 21 Jul 2024 20:17:04 -0400 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 1sVgje-0002Lg-7j for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:02 -0400 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 1sVgjc-0005h0-N1 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607418; 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=x7lYzPlslzs28OpL2JOdMIA3bwyrM1HvLLKU1gK7kNg=; b=eq3pynZ+uENv5+MYhh6Mi4Fr7g155OQ/v5c8iqfoi7BqA6a/mwRD29W7cWNUeC6GARgAeo J8T0BT/981Wo2BdqXGvAbCJ+P7smFbxQRMh5BhfpdOhvwv9fWR+RVJrNY5K3dQV0CwgEgA 8egRcun8vcyW+lMatavNRC97+7X4H9o= 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-694-4nHZaR3APFaO5eSRKXDczg-1; Sun, 21 Jul 2024 20:16:56 -0400 X-MC-Unique: 4nHZaR3APFaO5eSRKXDczg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-427b7a2052bso37773355e9.2 for ; Sun, 21 Jul 2024 17:16:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607415; x=1722212215; 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=x7lYzPlslzs28OpL2JOdMIA3bwyrM1HvLLKU1gK7kNg=; b=XBTFC1VKzG9JqcU5W7HJUSPpFm6WxOyLHPueya1EKNXFvzQY7Jp7ZohjVqyUBeAU5U fPpeQJHIo5vlw/6a+/3h/6bRrz1oqBqQ9oqv8CYb7f1ZERQxzOokxoia4Cc9GcVf9ZI7 tEXrzFMV2wqowamIABcIZWTsI9CbtcIYIOS94ripPzhBt23ug9gK4tHXpWpCS52byb7x UH5Q+h6f/+aZBV/SUVJ0tMpMJ/zUSAoACl9HtTuRArGspdoYvIAD9xj07VoZjNYUppWy qmqX2R3QCH7M8mDP0kxr+9Ynp6i1KeW/U2ARUEr6kp7R5+2n9q8pHPk92u293r1tV2Wm 4viQ== X-Gm-Message-State: AOJu0Yzw1MgZ2X8bdqbyFp4JhSNbQAwFDglalx8kiqwleOOLvkwwcLsd uhKs5fBQcOQfsr1rc17vlaHtY3O+sYS0nuTUPW/YHPsWm6YnHX2UeIOYXoOLlublZskNz60zaVP S4I0zazbMIESEBh0rGWthY0571bMpI+d+PVY5tHTB2sMzfMs6jkTL9Jn5RjzAFeeW9ljFdl9qU2 L4emmEUpLg1eWTmMqC56U1inCjzmLvoQ== X-Received: by 2002:a05:600c:5125:b0:426:6fd2:e14b with SMTP id 5b1f17b1804b1-427df7aaadbmr25998535e9.11.1721607413877; Sun, 21 Jul 2024 17:16:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQHpan3kjP1E1Bnwiin8yCv3Lsx7Xxh8sIlTO0AFok6pw9t9aKNChdy0WRI2nBCr2gOQ+3Nw== X-Received: by 2002:a05:600c:5125:b0:426:6fd2:e14b with SMTP id 5b1f17b1804b1-427df7aaadbmr25998295e9.11.1721607412650; Sun, 21 Jul 2024 17:16:52 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d69013fasm105740125e9.12.2024.07.21.17.16.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:16:51 -0700 (PDT) Date: Sun, 21 Jul 2024 20:16:50 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zheyu Ma , "Gonglei (Arei)" Subject: [PULL 01/63] hw/virtio/virtio-crypto: Fix op_code assignment in virtio_crypto_create_asym_session Message-ID: <89cf6574bc4bcdb99894e9401ecea0063d8212ce.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Zheyu Ma Currently, if the function fails during the key_len check, the op_code does not have a proper value, causing virtio_crypto_free_create_session_req not to free the memory correctly, leading to a memory leak. By setting the op_code before performing any checks, we ensure that virtio_crypto_free_create_session_req has the correct context to perform cleanup operations properly, thus preventing memory leaks. ASAN log: ==3055068==ERROR: LeakSanitizer: detected memory leaks Direct leak of 512 byte(s) in 1 object(s) allocated from: #0 0x5586a75e6ddd in malloc llvm/compiler-rt/lib/asan/asan_malloc_linux.cpp:129:3 #1 0x7fb6b63b6738 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x5e738) #2 0x5586a864bbde in virtio_crypto_handle_ctrl hw/virtio/virtio-crypto.c:407:19 #3 0x5586a94fc84c in virtio_queue_notify_vq hw/virtio/virtio.c:2277:9 #4 0x5586a94fc0a2 in virtio_queue_host_notifier_read hw/virtio/virtio.c:3641:9 Signed-off-by: Zheyu Ma Message-Id: <20240702211835.3064505-1-zheyuma97@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index bbe8aa4b99..5034768bff 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -205,6 +205,7 @@ virtio_crypto_create_asym_session(VirtIOCrypto *vcrypto, int queue_index; uint32_t algo, keytype, keylen; + sreq->info.op_code = opcode; algo = ldl_le_p(&sess_req->para.algo); keytype = ldl_le_p(&sess_req->para.keytype); keylen = ldl_le_p(&sess_req->para.keylen); @@ -224,7 +225,6 @@ virtio_crypto_create_asym_session(VirtIOCrypto *vcrypto, iov_discard_front(&iov, &out_num, keylen); } - sreq->info.op_code = opcode; asym_info = &sreq->info.u.asym_sess_info; asym_info->algo = algo; asym_info->keytype = keytype; From patchwork Mon Jul 22 00:16:53 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: 13738132 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 C4995C3DA63 for ; Mon, 22 Jul 2024 00:17:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgjj-0002aO-Ho; Sun, 21 Jul 2024 20:17:07 -0400 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 1sVgji-0002UL-0s for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:06 -0400 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 1sVgjg-0005hU-9P for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607423; 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=fgG/mkRDkzGxJm+xP/ZVe4hG5yYRqISPsjfYjXIDy78=; b=Qrm2VYQ/5n6m9w6OBlzSAr0/KudmrbrGaYo71brbBhmpPXQixw9Pp04Yi3sF66zdSevEz/ 9GfL5rabEC3czbFQtm9/cx0RwPvUGDeI0jZmLhSS/F451g5fFvxWo9NjZ9xcvx8yEiEQJb U+oTLsNLWtk1nQVCCHZ0gQhPE42Gkg0= 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-127-Wsl84XdrO2K-Th-HdTzQ7w-1; Sun, 21 Jul 2024 20:16:57 -0400 X-MC-Unique: Wsl84XdrO2K-Th-HdTzQ7w-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-427e369f757so6935595e9.0 for ; Sun, 21 Jul 2024 17:16:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607415; x=1722212215; 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=fgG/mkRDkzGxJm+xP/ZVe4hG5yYRqISPsjfYjXIDy78=; b=RZVRBUwQh4b6XBgRXgqNjh4cE2o8SD09OnErPXymrznraPfbpr1OnQ2xDKXaGRi5uA Lm3V48+sa56hqd+AjkTOWjtKPTvdaGjoXUHiDhtMepihO9t4Lx3pVwcubIquhKUuD5h3 xjvs+vBG1o2TtsDi7CFbKAkj7WYgc2rLfCdHrzQLqYPzNrE+ox4SsKG0U2tVHHCufr0J FrXKl1f0+u/OzJAG62hxoSweSulToOPHs/1kDUwV5XBK6HExlVML1nnmna8jOT5qRgX8 auOUXTcANq+T7tBQ43u4nW8VVu4XSK2sX//N9DMyoJbusd+8wFiv8K3vM46iKbiOtdZR cmUQ== X-Gm-Message-State: AOJu0YweQbMgvvO4Gj3QlP1Jf6gvdaXgxk8wmNb/j7FMNc5z/YlN3tPF UnhDFYTaHlF+TO89X1vVBtJGZqYNveGyVA2x2X1gQkiA2v6k2CwjTy0rxukbHrhs9kYSAPWxS9M +J1p1MSJEjsSRRtDasbDuFVHw7JCYAnaLR90HTRVlVLA0Y3XpXlDaPOpL5Hwlpvvu7KSRjGAQGU 0RlUeR4wnOWlqYdKIryIqNbPWiusOZ3A== X-Received: by 2002:a05:600c:a085:b0:426:6f87:65fc with SMTP id 5b1f17b1804b1-427dc527fcemr38494465e9.17.1721607415550; Sun, 21 Jul 2024 17:16:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPnFDRryGdHj2f+jEDHtdDbCppv6tQ6L8GFqd/fm4YVJiIjnNt4v0Fz2vgQzXUwuJDgMxFGg== X-Received: by 2002:a05:600c:a085:b0:426:6f87:65fc with SMTP id 5b1f17b1804b1-427dc527fcemr38494325e9.17.1721607414987; Sun, 21 Jul 2024 17:16:54 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a947fasm133276815e9.43.2024.07.21.17.16.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:16:54 -0700 (PDT) Date: Sun, 21 Jul 2024 20:16:53 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , Alex =?utf-8?q?Benn=C3=A9e?= , Philippe =?utf-8?q?M?= =?utf-8?q?athieu-Daud=C3=A9?= , Thomas Huth , Michael Tokarev Subject: [PULL 02/63] MAINTAINERS: add Stefano Garzarella as vhost/vhost-user reviewer Message-ID: <7967b7e0b17cb5e700ca040e0b68ba8fb0035c0d.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Stefano Garzarella I have recently been working on supporting vhost-user on any POSIX, so I want to help maintain it. Cc: Michael S. Tsirkin Signed-off-by: Stefano Garzarella Message-Id: <20240704081336.21208-1-sgarzare@redhat.com> Reviewed-by: Alex Bennée Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7d9811458c..b7e9ced3e8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2209,6 +2209,7 @@ F: docs/devel/vfio-iommufd.rst vhost M: Michael S. Tsirkin +R: Stefano Garzarella S: Supported F: hw/*/*vhost* F: docs/interop/vhost-user.json From patchwork Mon Jul 22 00:16:55 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: 13738166 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 72F2AC3DA63 for ; Mon, 22 Jul 2024 00:24:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgjp-0002wu-DE; Sun, 21 Jul 2024 20:17:13 -0400 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 1sVgjn-0002pX-Cr for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:11 -0400 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 1sVgjl-0005jG-L7 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607426; 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=CF9wnkqMRVtlUyE0ujh6CTNBrHFoLR3JIkaPiCQ6bXA=; b=EyLmg3JpxqfuSaFHPmnNbtvwI8C2BXRES4COKC1oi2dhNq51cCgCP34MEwjsRnYNNeBPAP jZh4P4Lbrj1pAuSpo/+MphR7iedRw2slooxekOenmOYN/zEX1mgi0cTMPU1cfPfa/o/nZ9 C8SUNNis6FNS7+q7lteNJz8GtgDJU2Q= 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-209-avx2uitnPguTYZ8K-9beLw-1; Sun, 21 Jul 2024 20:17:02 -0400 X-MC-Unique: avx2uitnPguTYZ8K-9beLw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42668699453so37761475e9.3 for ; Sun, 21 Jul 2024 17:16:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607417; x=1722212217; 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=CF9wnkqMRVtlUyE0ujh6CTNBrHFoLR3JIkaPiCQ6bXA=; b=JKQhyrJOIfhOiTxzYS+T92DjzKXJ+06LFB3EAtB8ZSGojPAnCYR/k98LNJkCZHANGJ YQDWfL6DG3s8GBoV7eFV/DrkL7WJMSN3cny+D+vmr1JkKMSzvXVf17+a9YP3S1e6kcRh ZvX7bJ8ZeqCeCrKfoFlu4mDIrClMVo8f7wHofuaSLwqIos3iSiXRhTHfQm1rppWFA4c9 H5fSASi0dPlLyKwSthCqoJoYqU5QDBz3KNfOT6FFBMvH8jny0KmjPipCoKh0S8XBxZY/ Z06dU7z+rlPs8+H7V9QvwerADkdWFa950iP+KZtxvt7mjqj2NnnvpzGQ/mhyRpxSGx9n x/Bg== X-Gm-Message-State: AOJu0YxN963PJ+0PO4Zpp2vwMrG6g2mlA845LXH5P/CZYq/Khea0zXmK RpLN1qWzcDn7KHOKaLm+CYWB6wpjFOpETSWpoYMcDfXrAwRI0OGZVKLCHYeX3rq+CHRs49kdZds xY5q5uoGQAsF3QcwpGNt36zmrogTODzrMI1epv9XRBMFFAX3MVjD5KXxa7Bm5KSTASwF6cHxt39 os5jGUgZZmhfeD0PCCtOYpEbvg20dkSQ== X-Received: by 2002:a05:600c:45ce:b0:426:5520:b835 with SMTP id 5b1f17b1804b1-427dc515ce5mr41304855e9.5.1721607417691; Sun, 21 Jul 2024 17:16:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZ1ZIUina0IxNB8IX3esuxwgnc83668GYDaHHrcjKhXw3xSTXpr1FAcv260bDz6VyoIzp+LQ== X-Received: by 2002:a05:600c:45ce:b0:426:5520:b835 with SMTP id 5b1f17b1804b1-427dc515ce5mr41304685e9.5.1721607416990; Sun, 21 Jul 2024 17:16:56 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36878811899sm6976742f8f.116.2024.07.21.17.16.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:16:56 -0700 (PDT) Date: Sun, 21 Jul 2024 20:16:55 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Jonathan Cameron Subject: [PULL 03/63] hw/cxl/cxl-mailbox-utils: remove unneeded mailbox output payload space zeroing 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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 The whole mailbox output payload space is already zeroed after copying out the input payload, which happens before processing the specific mailbox command: https://elixir.bootlin.com/qemu/v8.2.1/source/hw/cxl/cxl-device-utils.c#L204 Signed-off-by: Fan Ni Link: https://lore.kernel.org/r/20240221221824.1092966-1-nifan.cxl@gmail.com Signed-off-by: Jonathan Cameron Message-Id: <20240705113956.941732-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 74eeb6fde7..facec42dc8 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -235,7 +235,6 @@ static CXLRetCode cmd_events_get_records(const struct cxl_cmd *cmd, log_type = payload_in[0]; pl = (CXLGetEventPayload *)payload_out; - memset(pl, 0, sizeof(*pl)); max_recs = (cxlds->payload_size - CXL_EVENT_PAYLOAD_HDR_SIZE) / CXL_EVENT_RECORD_SIZE; @@ -273,7 +272,6 @@ static CXLRetCode cmd_events_get_interrupt_policy(const struct cxl_cmd *cmd, CXLEventLog *log; policy = (CXLEventInterruptPolicy *)payload_out; - memset(policy, 0, sizeof(*policy)); log = &cxlds->event_logs[CXL_EVENT_TYPE_INFO]; if (log->irq_enabled) { @@ -372,7 +370,6 @@ static CXLRetCode cmd_infostat_identify(const struct cxl_cmd *cmd, QEMU_BUILD_BUG_ON(sizeof(*is_identify) != 18); is_identify = (void *)payload_out; - memset(is_identify, 0, sizeof(*is_identify)); is_identify->pcie_vid = class->vendor_id; is_identify->pcie_did = class->device_id; if (object_dynamic_cast(OBJECT(cci->d), TYPE_CXL_USP)) { @@ -606,7 +603,6 @@ static CXLRetCode cmd_infostat_bg_op_sts(const struct cxl_cmd *cmd, QEMU_BUILD_BUG_ON(sizeof(*bg_op_status) != 8); bg_op_status = (void *)payload_out; - memset(bg_op_status, 0, sizeof(*bg_op_status)); bg_op_status->status = cci->bg.complete_pct << 1; if (cci->bg.runtime > 0) { bg_op_status->status |= 1U << 0; @@ -647,7 +643,6 @@ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, } fw_info = (void *)payload_out; - memset(fw_info, 0, sizeof(*fw_info)); fw_info->slots_supported = 2; fw_info->slot_info = BIT(0) | BIT(3); @@ -805,7 +800,6 @@ static CXLRetCode cmd_identify_memory_device(const struct cxl_cmd *cmd, } id = (void *)payload_out; - memset(id, 0, sizeof(*id)); snprintf(id->fw_revision, 0x10, "BWFW VERSION %02d", 0); @@ -1095,7 +1089,6 @@ static CXLRetCode cmd_media_get_poison_list(const struct cxl_cmd *cmd, out_pl_len = sizeof(*out) + record_count * sizeof(out->records[0]); assert(out_pl_len <= CXL_MAILBOX_MAX_PAYLOAD_SIZE); - memset(out, 0, out_pl_len); QLIST_FOREACH(ent, poison_list, node) { uint64_t start, stop; From patchwork Mon Jul 22 00:16: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: 13738152 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 DAACCC3DA61 for ; Mon, 22 Jul 2024 00:21:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgjk-0002dh-CK; Sun, 21 Jul 2024 20:17:08 -0400 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 1sVgji-0002Wc-IR for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:06 -0400 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 1sVgjg-0005il-Ud for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607424; 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=hdw2m0bn75zRr+MYU0d0hXAq7eMAE3t8pjHbmVXVlwk=; b=I7QFFMR6BizUyx6Q72rEbsvommJ7ovAv1Bp+BXlqVfiTQV9jnqnnGi1fTDqruF7HvD3672 GnixfEnSSdDA6nseA6mrlpNoCRqAk0ky4Ac6F9bdc5WiEiFKRAqCRwfJ/FyFqefc0+R52t pMlNqyJWujICz6e1foMfc/3McuJq/1E= 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-279-CicUJZ8OMxeW78EOQ6s8Mg-1; Sun, 21 Jul 2024 20:17:01 -0400 X-MC-Unique: CicUJZ8OMxeW78EOQ6s8Mg-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3687529b63fso2066646f8f.2 for ; Sun, 21 Jul 2024 17:17:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607419; x=1722212219; 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=hdw2m0bn75zRr+MYU0d0hXAq7eMAE3t8pjHbmVXVlwk=; b=IJS8x0Y/cWbinQwpV0pJ3dYYMzZFXu4/O1xtWmLS+tBGpmGbF/sAOQuh3THmcCpWMm QCyHEletDcNFeJqcKiYl/aFDG8LGYsS4cxwuecGWQw2DrOATxPELP626RzK9WqbQSBJF h8a6yplfTc73IhiTnqhwMzq3l9I3hElN6pPa4KdsHpWB2Ad+gMyNZ7RxLwNhgYPyGDX9 n53vdJTq6kJyQhfCFJQUmldV2Bt1I5SZkgETyMEFDSjyuz7LS8h0egcRDuHcDitWmFmD IKoS3yl2nZPzc9wFNonFKPQW1YflTrhzilD1GvhOhQONVq3qKFTjVuvSGLoVWy/wECNz In9A== X-Gm-Message-State: AOJu0Yy7GcFLUTQFJLOsZ9/uMdD2QSxqY2gwAl+kKdXyDx6j3959jxKc 3QesrLQ7MabmPkkCTwzF0oPWcovC2iMkkK9ybZ4x8Z+3JAtv2NKKbkkQcaTDDFzyvhbB2M3RTOD y16ZSHEybgG6cbe5CXSme90hHOjbAVNgIBEG0R5khw9/GBHvDL8c42XBZyMml8gppI3TwfgBRNY KN05UODbaiTcrBCOTHTge73k+g0qSHTg== X-Received: by 2002:a5d:490e:0:b0:366:f041:935d with SMTP id ffacd0b85a97d-369bbc91e34mr2694911f8f.60.1721607419558; Sun, 21 Jul 2024 17:16:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEdV4xbC9k1ETsh7gGyBAbNToEi3yyHBAODFbEZB/YQRsymI6klh7+Wzcn7/9PQh0uu4fyvw== X-Received: by 2002:a5d:490e:0:b0:366:f041:935d with SMTP id ffacd0b85a97d-369bbc91e34mr2694898f8f.60.1721607419025; Sun, 21 Jul 2024 17:16:59 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787ed551sm7004209f8f.113.2024.07.21.17.16.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:16:58 -0700 (PDT) Date: Sun, 21 Jul 2024 20:16:57 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 04/63] hw/cxl: Check for multiple mappings of memory backends. Message-ID: <9de2049c95e1a94e27430e71a9d9ace07ec8eda6.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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 Similar protection to that provided for -numa memdev=x to make sure that memory used to back a type3 device is not also mapped as normal RAM, or for multiple type3 devices. This is an easy footgun to remove and seems multiple people have run into it. Signed-off-by: Jonathan Cameron Message-Id: <20240705113956.941732-4-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/cxl_type3.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 35ac59883a..e7fbbb4d51 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -737,6 +737,11 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) error_setg(errp, "volatile memdev must have backing device"); return false; } + if (host_memory_backend_is_mapped(ct3d->hostvmem)) { + error_setg(errp, "memory backend %s can't be used multiple times.", + object_get_canonical_path_component(OBJECT(ct3d->hostvmem))); + return false; + } memory_region_set_nonvolatile(vmr, false); memory_region_set_enabled(vmr, true); host_memory_backend_set_mapped(ct3d->hostvmem, true); @@ -760,6 +765,11 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) error_setg(errp, "persistent memdev must have backing device"); return false; } + if (host_memory_backend_is_mapped(ct3d->hostpmem)) { + error_setg(errp, "memory backend %s can't be used multiple times.", + object_get_canonical_path_component(OBJECT(ct3d->hostpmem))); + return false; + } memory_region_set_nonvolatile(pmr, true); memory_region_set_enabled(pmr, true); host_memory_backend_set_mapped(ct3d->hostpmem, true); @@ -790,6 +800,11 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) return false; } + if (host_memory_backend_is_mapped(ct3d->dc.host_dc)) { + error_setg(errp, "memory backend %s can't be used multiple times.", + object_get_canonical_path_component(OBJECT(ct3d->dc.host_dc))); + return false; + } /* * Set DC regions as volatile for now, non-volatile support can * be added in the future if needed. From patchwork Mon Jul 22 00:16:59 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: 13738187 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 4FB88C3DA61 for ; Mon, 22 Jul 2024 00:28:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgjl-0002j1-NN; Sun, 21 Jul 2024 20:17:09 -0400 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 1sVgjk-0002dI-7A for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:08 -0400 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 1sVgji-0005j7-Iz for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607425; 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=hZD245xzKw4cLzLRxCGiV82CoDTUudcvSV2j3dFC7Ks=; b=d+VjAqvbVFdR7/xcIgJWXvJVhT8mCfuBBck9chqNKIjAnwV2tzs7ti27oPV214CcAW2PhJ Scan55/3kdOFbvjnKNntcrXnW5IM0iRvXKbWRcJaTZDbJTBEiJkMVlaW8JEaIJlZdmFgNt XloYIb/VBw4UUwc5iLJPNS1Rph+XhL0= 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-359-yBQfGQhBMH2cw1mc4TA_kA-1; Sun, 21 Jul 2024 20:17:03 -0400 X-MC-Unique: yBQfGQhBMH2cw1mc4TA_kA-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-36878581685so1839455f8f.2 for ; Sun, 21 Jul 2024 17:17:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607421; x=1722212221; 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=hZD245xzKw4cLzLRxCGiV82CoDTUudcvSV2j3dFC7Ks=; b=avJaB5L5JARSxI45a5Dp7LN1p6ayshhEYg6RAUyKYCSJA8YuAhSnivVzqoNorP7Kee +lglCR1ADZHvpcmuSxMqBOzOlQqTzv3C10xzkGa6CzWuhwoaSZvVGaFn9okY85nnFW/y 2qbKP3Um8p6y1ntLX1FPZN2rs97a4SLcfokx3vdQ1JSI7pKifATfO8I+5E7cl+2n/MC3 7niiWpQA8ZQ9jHxwc21238YenGcdn52HovdJqn6oVE9l/ppALV8Yqf+V42yaFonFTD+s +tZXY1HTuBiYgyrL5LCj5eIlOy86eci2jsGTC7Ccd5fyj3SysakeuwSeSUN4pCBcdnMh E6Hw== X-Gm-Message-State: AOJu0YybtIw/7hfPaQtLhphPF9wt1tbXgoIxLkkz+7VM53JoYg3Fk/8e GjBwif8R3c6rZwYfa0WwPG0cU7SK6msH6TG5wJiK7MA4T7+ErDcdJN9RdFSZ3QdDVURMGcaneZ0 ynhQYPVUcEvdk1ReSduIESPeWEkjloAuxNCfCwtxo2PKW8RMWdfQGD3a4JOaYenh2uvQcZ1pfPP FWuysNQZPOLxHsyx1NAGL3bzjwpG8Xuw== X-Received: by 2002:a5d:5886:0:b0:367:9d2c:9602 with SMTP id ffacd0b85a97d-369bb2ea299mr3680070f8f.49.1721607421671; Sun, 21 Jul 2024 17:17:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIPN0bUTHueCCZAZkrvBfTTbWJUeBe160eDE0jW48zMtw3sia+t9s2jconmIjLbpfYc0gbiw== X-Received: by 2002:a5d:5886:0:b0:367:9d2c:9602 with SMTP id ffacd0b85a97d-369bb2ea299mr3680052f8f.49.1721607421162; Sun, 21 Jul 2024 17:17:01 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d68fa493sm107385825e9.10.2024.07.21.17.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:00 -0700 (PDT) Date: Sun, 21 Jul 2024 20:16:59 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Li Zhijian , Xingtao Yao , Jonathan Cameron , Fan Ni Subject: [PULL 05/63] hw/cxl/cxl-host: Fix segmentation fault when getting cxl-fmw property 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Zhao Liu QEMU crashes (Segmentation fault) when getting cxl-fmw property via qmp: (QEMU) qom-get path=machine property=cxl-fmw This issue is caused by accessing wrong callback (opaque) type in machine_get_cfmw(). cxl_machine_init() sets the callback as `CXLState *` type but machine_get_cfmw() treats the callback as `CXLFixedMemoryWindowOptionsList **`. Fix this error by casting opaque to `CXLState *` type in machine_get_cfmw(). Fixes: 03b39fcf64bc ("hw/cxl: Make the CXL fixed memory window setup a machine parameter.") Signed-off-by: Zhao Liu Reviewed-by: Li Zhijian Reviewed-by: Xingtao Yao Link: https://lore.kernel.org/r/20240704093404.1848132-1-zhao1.liu@linux.intel.com Signed-off-by: Jonathan Cameron Message-Id: <20240705113956.941732-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-host.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c index c5f5fcfd64..e9f2543c43 100644 --- a/hw/cxl/cxl-host.c +++ b/hw/cxl/cxl-host.c @@ -315,7 +315,8 @@ static void machine_set_cxl(Object *obj, Visitor *v, const char *name, static void machine_get_cfmw(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - CXLFixedMemoryWindowOptionsList **list = opaque; + CXLState *state = opaque; + CXLFixedMemoryWindowOptionsList **list = &state->cfmw_list; visit_type_CXLFixedMemoryWindowOptionsList(v, name, list, errp); } From patchwork Mon Jul 22 00:17:01 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: 13738173 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 4A173C3DA61 for ; Mon, 22 Jul 2024 00:25:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgjs-00038I-3S; Sun, 21 Jul 2024 20:17:16 -0400 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 1sVgjp-0002y6-KU for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:13 -0400 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 1sVgjm-0005jV-QT for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607429; 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=0rKx/2elztiRwGmRFbkqmZWz2N64JAUbTIAqb5EmVbY=; b=dZcGSY00LeWX3jsqg457rJyl4SCv/E22xaryUhUFBv4WuHI1v7QJxYzxAcuHzDj5QYXfPs IFbkaFOKahYMVBaWm/jC4owp2hqOutB6bx7i0h9eDxvmOrA182DIx8I1a9TWoRQsxR905m fW0aysajcKiWxVJD8NEC0soP22QZ77A= 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-517-QBbZbeZpNtii2upM3jANPA-1; Sun, 21 Jul 2024 20:17:05 -0400 X-MC-Unique: QBbZbeZpNtii2upM3jANPA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42667cc80e8so28030035e9.2 for ; Sun, 21 Jul 2024 17:17:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607424; x=1722212224; 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=0rKx/2elztiRwGmRFbkqmZWz2N64JAUbTIAqb5EmVbY=; b=krvF0wiuBiXRqp2NTmy+KXLehfnnCHKkiGBWUPqRPp+oHQML+tdKR5aQyMghOIijj2 qyOZhIjPF5PPx4dyFb4i5grFkPHzxSPmpQKKxgswcbOJjNbm4nbSFIS6bQN3l3xxc85b kgZ2Bs6KDUHEr8jievHdUJn5cf3gzg7flSdCRVzzDR0urIoe0cDjgmiRavVgqapmg031 Jj77qByGrmGLVPX4O62/UApKz77gnkK3zV3ypJi6XGhsqk6mPw5Oe3oTdQqGCmO3sZKu 2icmnFIDi9/PAnvVx6YQd00FgDaMIaaajJ7kCcuaYkUSX/Txsh2ibTaS9SW049NLBPVM ecQQ== X-Gm-Message-State: AOJu0YzTpkTXLi8+WEIIzfzZTz/8OAHfD5LtBg8ST3rMjRWjXtSLJTgm P1HCKrrPWJU2uKMz6tjXvHb8QzhfdRObnAWypI3K7UKVN2PomtGaPXqP1USFMka8HCXKhzI3iql 49Y44ogCx/E4p95PhKYGt6sl7DLjkAdAWN0I0VfGejI+iINMwrVv8sAWmPWXHyu+s6UBmADnuWu ecBBwUeHD+WdoAXNU9BMr8XrqBWWMPEA== X-Received: by 2002:a05:600c:5103:b0:426:63b8:2cce with SMTP id 5b1f17b1804b1-427dc52063amr31229565e9.7.1721607424053; Sun, 21 Jul 2024 17:17:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFysCcQK5e38VJa0pNczvdVQkxycJUntWwJ+k3bXHMRvEzgMwiQi97zbWzb4f8SJXynduzysA== X-Received: by 2002:a05:600c:5103:b0:426:63b8:2cce with SMTP id 5b1f17b1804b1-427dc52063amr31229385e9.7.1721607423401; Sun, 21 Jul 2024 17:17:03 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d68fa0a6sm106371885e9.9.2024.07.21.17.17.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:02 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Jonathan Cameron , Fan Ni Subject: [PULL 06/63] hw/cxl: Add get scan media capabilities cmd 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.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Davidlohr Bueso Use simple heuristics to determine the cost of scanning any given chunk, assuming cost is equal across the whole device, without differentiating between volatile or persistent partitions. This is aligned to the fact that these constraints are not enforced in respective poison query commands. Signed-off-by: Davidlohr Bueso Link: https://lore.kernel.org/r/20230908073152.4386-3-dave@stgolabs.net Signed-off-by: Jonathan Cameron Message-Id: <20240705120643.959422-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 9 ++ hw/cxl/cxl-mailbox-utils.c | 211 +++++++++++++++++++++++++++++++++++- hw/mem/cxl_type3.c | 22 ++-- 3 files changed, 233 insertions(+), 9 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 0a4fcb2800..b5beb7f90e 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -397,6 +397,11 @@ static inline void __toggle_media(CXLDeviceState *cxl_dstate, int val) #define cxl_dev_enable_media(cxlds) \ do { __toggle_media((cxlds), 0x1); } while (0) +static inline bool scan_media_running(CXLCCI *cci) +{ + return !!cci->bg.runtime && cci->bg.opcode == 0x4304; +} + static inline bool sanitize_running(CXLCCI *cci) { return !!cci->bg.runtime && cci->bg.opcode == 0x4400; @@ -491,6 +496,9 @@ struct CXLType3Dev { unsigned int poison_list_cnt; bool poison_list_overflowed; uint64_t poison_list_overflow_ts; + /* Poison Injection - backup */ + CXLPoisonList poison_list_bkp; + CXLPoisonList scan_media_results; struct dynamic_capacity { HostMemoryBackend *host_dc; @@ -558,6 +566,7 @@ CXLRetCode cxl_event_clear_records(CXLDeviceState *cxlds, void cxl_event_irq_assert(CXLType3Dev *ct3d); void cxl_set_poison_list_overflowed(CXLType3Dev *ct3d); +void cxl_clear_poison_list_overflowed(CXLType3Dev *ct3d); CXLDCRegion *cxl_find_dc_region(CXLType3Dev *ct3d, uint64_t dpa, uint64_t len); diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index facec42dc8..8ae9c6a699 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -83,6 +83,8 @@ enum { #define GET_POISON_LIST 0x0 #define INJECT_POISON 0x1 #define CLEAR_POISON 0x2 + #define GET_SCAN_MEDIA_CAPABILITIES 0x3 + #define SCAN_MEDIA 0x4 DCD_CONFIG = 0x48, #define GET_DC_CONFIG 0x0 #define GET_DYN_CAP_EXT_LIST 0x1 @@ -1110,6 +1112,10 @@ static CXLRetCode cmd_media_get_poison_list(const struct cxl_cmd *cmd, out->flags = (1 << 1); stq_le_p(&out->overflow_timestamp, ct3d->poison_list_overflow_ts); } + if (scan_media_running(cci)) { + out->flags |= (1 << 2); + } + stw_le_p(&out->count, record_count); *len_out = out_pl_len; return CXL_MBOX_SUCCESS; @@ -1139,6 +1145,16 @@ static CXLRetCode cmd_media_inject_poison(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } } + /* + * Freeze the list if there is an on-going scan media operation. + */ + if (scan_media_running(cci)) { + /* + * XXX: Spec is ambiguous - is this case considered + * a successful return despite not adding to the list? + */ + goto success; + } if (ct3d->poison_list_cnt == CXL_POISON_LIST_LIMIT) { return CXL_MBOX_INJECT_POISON_LIMIT; @@ -1154,6 +1170,7 @@ static CXLRetCode cmd_media_inject_poison(const struct cxl_cmd *cmd, */ QLIST_INSERT_HEAD(poison_list, p, node); ct3d->poison_list_cnt++; +success: *len_out = 0; return CXL_MBOX_SUCCESS; @@ -1193,6 +1210,17 @@ static CXLRetCode cmd_media_clear_poison(const struct cxl_cmd *cmd, } } + /* + * Freeze the list if there is an on-going scan media operation. + */ + if (scan_media_running(cci)) { + /* + * XXX: Spec is ambiguous - is this case considered + * a successful return despite not removing from the list? + */ + goto success; + } + QLIST_FOREACH(ent, poison_list, node) { /* * Test for contained in entry. Simpler than general case @@ -1203,7 +1231,7 @@ static CXLRetCode cmd_media_clear_poison(const struct cxl_cmd *cmd, } } if (!ent) { - return CXL_MBOX_SUCCESS; + goto success; } QLIST_REMOVE(ent, node); @@ -1240,11 +1268,180 @@ static CXLRetCode cmd_media_clear_poison(const struct cxl_cmd *cmd, } /* Any fragments have been added, free original entry */ g_free(ent); +success: *len_out = 0; return CXL_MBOX_SUCCESS; } +/* + * CXL r3.1 section 8.2.9.9.4.4: Get Scan Media Capabilities + */ +static CXLRetCode +cmd_media_get_scan_media_capabilities(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct get_scan_media_capabilities_pl { + uint64_t pa; + uint64_t length; + } QEMU_PACKED; + + struct get_scan_media_capabilities_out_pl { + uint32_t estimated_runtime_ms; + }; + + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + CXLDeviceState *cxl_dstate = &ct3d->cxl_dstate; + struct get_scan_media_capabilities_pl *in = (void *)payload_in; + struct get_scan_media_capabilities_out_pl *out = (void *)payload_out; + uint64_t query_start; + uint64_t query_length; + + query_start = ldq_le_p(&in->pa); + /* 64 byte alignment required */ + if (query_start & 0x3f) { + return CXL_MBOX_INVALID_INPUT; + } + query_length = ldq_le_p(&in->length) * CXL_CACHE_LINE_SIZE; + + if (query_start + query_length > cxl_dstate->static_mem_size) { + return CXL_MBOX_INVALID_PA; + } + + /* + * Just use 400 nanosecond access/read latency + 100 ns for + * the cost of updating the poison list. For small enough + * chunks return at least 1 ms. + */ + stl_le_p(&out->estimated_runtime_ms, + MAX(1, query_length * (0.0005L / 64))); + + *len_out = sizeof(*out); + return CXL_MBOX_SUCCESS; +} + +static void __do_scan_media(CXLType3Dev *ct3d) +{ + CXLPoison *ent; + unsigned int results_cnt = 0; + + QLIST_FOREACH(ent, &ct3d->scan_media_results, node) { + results_cnt++; + } + + /* only scan media may clear the overflow */ + if (ct3d->poison_list_overflowed && + ct3d->poison_list_cnt == results_cnt) { + cxl_clear_poison_list_overflowed(ct3d); + } +} + +/* + * CXL r3.1 section 8.2.9.9.4.5: Scan Media + */ +static CXLRetCode cmd_media_scan_media(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct scan_media_pl { + uint64_t pa; + uint64_t length; + uint8_t flags; + } QEMU_PACKED; + + struct scan_media_pl *in = (void *)payload_in; + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + CXLDeviceState *cxl_dstate = &ct3d->cxl_dstate; + uint64_t query_start; + uint64_t query_length; + CXLPoison *ent, *next; + + query_start = ldq_le_p(&in->pa); + /* 64 byte alignment required */ + if (query_start & 0x3f) { + return CXL_MBOX_INVALID_INPUT; + } + query_length = ldq_le_p(&in->length) * CXL_CACHE_LINE_SIZE; + + if (query_start + query_length > cxl_dstate->static_mem_size) { + return CXL_MBOX_INVALID_PA; + } + if (ct3d->dc.num_regions && query_start + query_length >= + cxl_dstate->static_mem_size + ct3d->dc.total_capacity) { + return CXL_MBOX_INVALID_PA; + } + + if (in->flags == 0) { /* TODO */ + qemu_log_mask(LOG_UNIMP, + "Scan Media Event Log is unsupported\n"); + } + + /* any previous results are discarded upon a new Scan Media */ + QLIST_FOREACH_SAFE(ent, &ct3d->scan_media_results, node, next) { + QLIST_REMOVE(ent, node); + g_free(ent); + } + + /* kill the poison list - it will be recreated */ + if (ct3d->poison_list_overflowed) { + QLIST_FOREACH_SAFE(ent, &ct3d->poison_list, node, next) { + QLIST_REMOVE(ent, node); + g_free(ent); + ct3d->poison_list_cnt--; + } + } + + /* + * Scan the backup list and move corresponding entries + * into the results list, updating the poison list + * when possible. + */ + QLIST_FOREACH_SAFE(ent, &ct3d->poison_list_bkp, node, next) { + CXLPoison *res; + + if (ent->start >= query_start + query_length || + ent->start + ent->length <= query_start) { + continue; + } + + /* + * If a Get Poison List cmd comes in while this + * scan is being done, it will see the new complete + * list, while setting the respective flag. + */ + if (ct3d->poison_list_cnt < CXL_POISON_LIST_LIMIT) { + CXLPoison *p = g_new0(CXLPoison, 1); + + p->start = ent->start; + p->length = ent->length; + p->type = ent->type; + QLIST_INSERT_HEAD(&ct3d->poison_list, p, node); + ct3d->poison_list_cnt++; + } + + res = g_new0(CXLPoison, 1); + res->start = ent->start; + res->length = ent->length; + res->type = ent->type; + QLIST_INSERT_HEAD(&ct3d->scan_media_results, res, node); + + QLIST_REMOVE(ent, node); + g_free(ent); + } + + cci->bg.runtime = MAX(1, query_length * (0.0005L / 64)); + *len_out = 0; + + return CXL_MBOX_BG_STARTED; +} + /* * CXL r3.1 section 8.2.9.9.9.1: Get Dynamic Capacity Configuration * (Opcode: 4800h) @@ -1857,6 +2054,11 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = { cmd_media_inject_poison, 8, 0 }, [MEDIA_AND_POISON][CLEAR_POISON] = { "MEDIA_AND_POISON_CLEAR_POISON", cmd_media_clear_poison, 72, 0 }, + [MEDIA_AND_POISON][GET_SCAN_MEDIA_CAPABILITIES] = { + "MEDIA_AND_POISON_GET_SCAN_MEDIA_CAPABILITIES", + cmd_media_get_scan_media_capabilities, 16, 0 }, + [MEDIA_AND_POISON][SCAN_MEDIA] = { "MEDIA_AND_POISON_SCAN_MEDIA", + cmd_media_scan_media, 17, BACKGROUND_OPERATION }, }; static const struct cxl_cmd cxl_cmd_set_dcd[256][256] = { @@ -1988,8 +2190,13 @@ static void bg_timercb(void *opaque) cxl_dev_enable_media(&ct3d->cxl_dstate); } break; - case 0x4304: /* TODO: scan media */ + case 0x4304: /* scan media */ + { + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + + __do_scan_media(ct3d); break; + } default: __builtin_unreachable(); break; diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index e7fbbb4d51..e763b9bff0 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1319,6 +1319,12 @@ void cxl_set_poison_list_overflowed(CXLType3Dev *ct3d) cxl_device_get_timestamp(&ct3d->cxl_dstate); } +void cxl_clear_poison_list_overflowed(CXLType3Dev *ct3d) +{ + ct3d->poison_list_overflowed = false; + ct3d->poison_list_overflow_ts = 0; +} + void qmp_cxl_inject_poison(const char *path, uint64_t start, uint64_t length, Error **errp) { @@ -1355,19 +1361,21 @@ void qmp_cxl_inject_poison(const char *path, uint64_t start, uint64_t length, } } - if (ct3d->poison_list_cnt == CXL_POISON_LIST_LIMIT) { - cxl_set_poison_list_overflowed(ct3d); - return; - } - p = g_new0(CXLPoison, 1); p->length = length; p->start = start; /* Different from injected via the mbox */ p->type = CXL_POISON_TYPE_INTERNAL; - QLIST_INSERT_HEAD(&ct3d->poison_list, p, node); - ct3d->poison_list_cnt++; + if (ct3d->poison_list_cnt < CXL_POISON_LIST_LIMIT) { + QLIST_INSERT_HEAD(&ct3d->poison_list, p, node); + ct3d->poison_list_cnt++; + } else { + if (!ct3d->poison_list_overflowed) { + cxl_set_poison_list_overflowed(ct3d); + } + QLIST_INSERT_HEAD(&ct3d->poison_list_bkp, p, node); + } } /* For uncorrectable errors include support for multiple header recording */ From patchwork Mon Jul 22 00:17: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: 13738157 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 B939DC3DA5D for ; Mon, 22 Jul 2024 00:23:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgjp-0002wU-99; Sun, 21 Jul 2024 20:17:13 -0400 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 1sVgjn-0002rd-TG for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:11 -0400 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 1sVgjm-0005jZ-61 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607429; 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=qA9H4BX2NYCarA+XIitFOqcduT5OCfIk2f7Otx3d0Y8=; b=cPt86WhNAO+kUaZpZRakSD7rBASBWEuOLv//yN0Lq5tqavZ1RWKmpha1d37lGsUrmIAF0I m4LKrHo06ySp/wXcVO1HH9mBZXeCJfjtAapznblxkvmK/Om7OubVItH2GQQhRYscld7HTE uKbFI97i78kVIYXzF98izld5q7hzLTI= 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-327-XlpJsrqCM6G_OvikDWXMAA-1; Sun, 21 Jul 2024 20:17:08 -0400 X-MC-Unique: XlpJsrqCM6G_OvikDWXMAA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-42674318a4eso37850155e9.1 for ; Sun, 21 Jul 2024 17:17:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607426; x=1722212226; 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=qA9H4BX2NYCarA+XIitFOqcduT5OCfIk2f7Otx3d0Y8=; b=rdNEwwF0NFenq4+TE7H3zM9TAGjxEiWFr0E19evXnJ0B3G2E/ojrydM4XIEi88IttI ZJZFrz5Y2Iara+qAVrs4aHEyenv+N8vtHctLdA1AnmsF2hxcbEtel1Ld2TIpTvZWvZOL O580hcniTdXFFBh9+Dwzntq8OktoiUtY6s4DYYLzAuw3waTOPav0K0K32d1+m16ewTZh 10BuRuz5fwiGgEx3lFfpWSI5TF2sWz/55ulTdi64LovUfXmQWPlCPYOnXT8i+PnEjf17 NMtlsHk6lO3ZNHvT2EUgtCB6DipdC5ikMrOAIEIHUBWWOh3wthtixX8Bf7PPreP3nE6a XmHA== X-Gm-Message-State: AOJu0YyV6mNd9KMYe+tEReo63h5V5QhCCf13KLuZsfY3J6dC8m39VLBc u3oehax3z166WMaD0hygIMlZNrroVomPlGzhAdhpU+V9XqAwqoHYHzbz6IanUxula2zPU/8RZ8G 4C/RB0rLRJlxOdvKYs6sHMbxaWQLdGdQD0Ag/1Qco2vQC6Z3QyofzsQs4hWOBrlqcSau6UyC6AC KkcEtUN63jHwoJRft6XsC1+FYqokSxsA== X-Received: by 2002:a05:600c:4452:b0:426:63f1:9a1b with SMTP id 5b1f17b1804b1-427dc56b427mr32399035e9.33.1721607426192; Sun, 21 Jul 2024 17:17:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFivj+uXK1YnjsJcS2RjrYlQxadCXM/o+Wr7wcjk59Zt/VvZqz+Z8XrEjHWX+0nhVktQu8RMw== X-Received: by 2002:a05:600c:4452:b0:426:63f1:9a1b with SMTP id 5b1f17b1804b1-427dc56b427mr32398875e9.33.1721607425589; Sun, 21 Jul 2024 17:17:05 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d6929981sm105837535e9.36.2024.07.21.17.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:04 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:03 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Davidlohr Bueso , Jonathan Cameron , Fan Ni Subject: [PULL 07/63] hw/cxl/mbox: replace sanitize_running() with cxl_dev_media_disabled() Message-ID: <75b800dd3bd8042503ddd4e8a4169f34349325e2.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> The spec states that reads/writes should have no effect and a part of commands should be ignored when the media is disabled, not when the sanitize command is running. Introduce cxl_dev_media_disabled() to check if the media is disabled and replace sanitize_running() with it. Make sure that the media has been correctly disabled during sanitation by adding an assert to __toggle_media(). Now, enabling when already enabled or vice versa results in an assert() failure. Suggested-by: Davidlohr Bueso Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Link: https://lore.kernel.org/r/20231222090051.3265307-4-42.hyeyoo@gmail.com Signed-off-by: Jonathan Cameron Message-Id: <20240705120643.959422-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 10 +++++----- hw/cxl/cxl-mailbox-utils.c | 29 +++++++++++++++++------------ hw/mem/cxl_type3.c | 4 ++-- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index b5beb7f90e..42a622197e 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -397,16 +397,16 @@ static inline void __toggle_media(CXLDeviceState *cxl_dstate, int val) #define cxl_dev_enable_media(cxlds) \ do { __toggle_media((cxlds), 0x1); } while (0) +static inline bool cxl_dev_media_disabled(CXLDeviceState *cxl_dstate) +{ + uint64_t dev_status_reg = cxl_dstate->mbox_reg_state64[R_CXL_MEM_DEV_STS]; + return FIELD_EX64(dev_status_reg, CXL_MEM_DEV_STS, MEDIA_STATUS) == 0x3; +} static inline bool scan_media_running(CXLCCI *cci) { return !!cci->bg.runtime && cci->bg.opcode == 0x4304; } -static inline bool sanitize_running(CXLCCI *cci) -{ - return !!cci->bg.runtime && cci->bg.opcode == 0x4400; -} - typedef struct CXLError { QTAILQ_ENTRY(CXLError) node; int type; /* Error code as per FE definition */ diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 8ae9c6a699..522d9aa589 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -2108,6 +2108,7 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, int ret; const struct cxl_cmd *cxl_cmd; opcode_handler h; + CXLDeviceState *cxl_dstate; *len_out = 0; cxl_cmd = &cci->cxl_cmd_set[set][cmd]; @@ -2128,18 +2129,22 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, return CXL_MBOX_BUSY; } - /* forbid any selected commands while overwriting */ - if (sanitize_running(cci)) { - if (h == cmd_events_get_records || - h == cmd_ccls_get_partition_info || - h == cmd_ccls_set_lsa || - h == cmd_ccls_get_lsa || - h == cmd_logs_get_log || - h == cmd_media_get_poison_list || - h == cmd_media_inject_poison || - h == cmd_media_clear_poison || - h == cmd_sanitize_overwrite) { - return CXL_MBOX_MEDIA_DISABLED; + /* forbid any selected commands while the media is disabled */ + if (object_dynamic_cast(OBJECT(cci->d), TYPE_CXL_TYPE3)) { + cxl_dstate = &CXL_TYPE3(cci->d)->cxl_dstate; + + if (cxl_dev_media_disabled(cxl_dstate)) { + if (h == cmd_events_get_records || + h == cmd_ccls_get_partition_info || + h == cmd_ccls_set_lsa || + h == cmd_ccls_get_lsa || + h == cmd_logs_get_log || + h == cmd_media_get_poison_list || + h == cmd_media_inject_poison || + h == cmd_media_clear_poison || + h == cmd_sanitize_overwrite) { + return CXL_MBOX_MEDIA_DISABLED; + } } } diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index e763b9bff0..c7910687ae 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1142,7 +1142,7 @@ MemTxResult cxl_type3_read(PCIDevice *d, hwaddr host_addr, uint64_t *data, return MEMTX_ERROR; } - if (sanitize_running(&ct3d->cci)) { + if (cxl_dev_media_disabled(&ct3d->cxl_dstate)) { qemu_guest_getrandom_nofail(data, size); return MEMTX_OK; } @@ -1164,7 +1164,7 @@ MemTxResult cxl_type3_write(PCIDevice *d, hwaddr host_addr, uint64_t data, return MEMTX_ERROR; } - if (sanitize_running(&ct3d->cci)) { + if (cxl_dev_media_disabled(&ct3d->cxl_dstate)) { return MEMTX_OK; } From patchwork Mon Jul 22 00:17: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: 13738193 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 27A36C3DA61 for ; Mon, 22 Jul 2024 00:30:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgjt-0003CA-7z; Sun, 21 Jul 2024 20:17:17 -0400 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 1sVgjq-0002zt-0h for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:14 -0400 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 1sVgjo-0005jq-2F for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607431; 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=EH7iZz7W3GpWmzCfYcERS56IxpqGZ9YSdfDypAnOEA4=; b=NzD8DJ3PVx3PojtHtC+CXF1bHXXV8akoTS5IHnUChMWgs2i4Vvp/q0AymTQ/bq6qAMccGg I88IZcian0d4PAkT3R5KByxjWLIjMbEQZB5JnXXQmBCpXvvKgJrrnBiny6SX5GPe8Ff8V5 nX3gYwaaESQNbjFG7SoI5ZGPzKemiOw= 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-417-7ZxqRsqBMBuZ8dU0OeePQg-1; Sun, 21 Jul 2024 20:17:10 -0400 X-MC-Unique: 7ZxqRsqBMBuZ8dU0OeePQg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-42725ec6e0aso25420995e9.0 for ; Sun, 21 Jul 2024 17:17:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607428; x=1722212228; 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=EH7iZz7W3GpWmzCfYcERS56IxpqGZ9YSdfDypAnOEA4=; b=aimsgtScHAG10JiMmd6oL8fbdRfwaQ/2dM3aWaXYlP94Gt51C+5/wdlv/EvxsjVUWM DNN/9IryvFujWxYItzN9tU1PTpXPFJynjD8QS57dWhVhUuNLxGMs0cSAUDx2J7M6kgAX ydRFE8SBcv0QOHttIY9yRF0SqRIWIPh+PgjS2DHZbrfJuLx/0I/CjiMjneJcJMdvMQCs X0iq5RZkdhSa5flLRwrT+Y3keoza4nHy5sIoMqHKwi76jyI+zxWW3d94OejPUQpPMsLf 6wxKls6ebXw4GfoMsrtAxu0xnufJRIPOPSKVadzwLmODMeRtDxBkHoZqWEZybkdwievZ BamQ== X-Gm-Message-State: AOJu0YwkS4dd1U+iQsb1rya2wZoT9ptu7ZOl6vKe1tDgu4VwxdBxxNZi ZYHR15r5loqert3ZglYI1bMpD6LkvE3IrzAhvkw26ldC4gDasicYxixiWUPfC2FHqUWqZL4OTUp H6w/rhQZplcUnN49iGZODkSzjLVU2koO1UDoDVOGnDLEOPRKdEK8Vn2qU9V8mmWb3nFuXFr+Eoy HVFYmpzguDSsC7v5caL9NLZFiFGFRq9Q== X-Received: by 2002:a05:600c:3147:b0:426:61e8:fb3b with SMTP id 5b1f17b1804b1-427dc559db9mr32413695e9.27.1721607428356; Sun, 21 Jul 2024 17:17:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHeLExCdg1NSZDe3hG1l+pFeoHWQ3wP7TS2oYCzpq/5DTY9TeuF0VD29B0tBm3XMshdeQ8WHA== X-Received: by 2002:a05:600c:3147:b0:426:61e8:fb3b with SMTP id 5b1f17b1804b1-427dc559db9mr32413525e9.27.1721607427874; Sun, 21 Jul 2024 17:17:07 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36878684253sm7164773f8f.4.2024.07.21.17.17.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:07 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Davidlohr Bueso , Jonathan Cameron , Fan Ni Subject: [PULL 08/63] hw/cxl/events: discard all event records during sanitation Message-ID: <7d65874ba0ea8cdb2a5ac51c397d721d7d49d828.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> Per CXL r3.1 Section 8.2.9.9.5.1: Sanitize (Opcode 4400h), the sanitize command should delete all event logs. Introduce cxl_discard_all_event_logs() and call this in __do_sanitization(). Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Davidlohr Bueso Link: https://lore.kernel.org/r/20231222090051.3265307-5-42.hyeyoo@gmail.com Signed-off-by: Jonathan Cameron Message-Id: <20240705120643.959422-4-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 1 + hw/cxl/cxl-events.c | 13 +++++++++++++ hw/cxl/cxl-mailbox-utils.c | 1 + 3 files changed, 15 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 42a622197e..0509d961c3 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -562,6 +562,7 @@ CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds, CXLGetEventPayload *pl, size_t *len); CXLRetCode cxl_event_clear_records(CXLDeviceState *cxlds, CXLClearEventPayload *pl); +void cxl_discard_all_event_records(CXLDeviceState *cxlds); void cxl_event_irq_assert(CXLType3Dev *ct3d); diff --git a/hw/cxl/cxl-events.c b/hw/cxl/cxl-events.c index d397718b1b..12dee2e467 100644 --- a/hw/cxl/cxl-events.c +++ b/hw/cxl/cxl-events.c @@ -139,6 +139,19 @@ bool cxl_event_insert(CXLDeviceState *cxlds, CXLEventLogType log_type, return cxl_event_count(log) == 1; } +void cxl_discard_all_event_records(CXLDeviceState *cxlds) +{ + CXLEventLogType log_type; + CXLEventLog *log; + + for (log_type = 0; log_type < CXL_EVENT_TYPE_MAX; log_type++) { + log = &cxlds->event_logs[log_type]; + while (!cxl_event_empty(log)) { + cxl_event_delete_head(cxlds, log_type, log); + } + } +} + CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds, CXLGetEventPayload *pl, uint8_t log_type, int max_recs, size_t *len) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 522d9aa589..3c9600c39c 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -949,6 +949,7 @@ static void __do_sanitization(CXLType3Dev *ct3d) memset(lsa, 0, memory_region_size(mr)); } } + cxl_discard_all_event_records(&ct3d->cxl_dstate); } /* From patchwork Mon Jul 22 00:17: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: 13738135 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 808FDC3DA61 for ; Mon, 22 Jul 2024 00:18:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgju-0003GD-1I; Sun, 21 Jul 2024 20:17:18 -0400 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 1sVgjs-0003Ai-Li for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:16 -0400 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 1sVgjq-0005kE-Mc for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607434; 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=V7i/ikH3mbc0bL34LgKCgRiXDl4kA7AlgZAMAJaf21I=; b=hQe5NJnR7tOdqJSnavW+kZxoniqBWSVeoWuCouMzV1royp8TfKsuySEFkataII+IrQQLBD /ArJRWkgeVMgjU0IO697Ipl5Uy9U3Wvlu4vTntSVoheJv7B+ajZ5GSZCKH1RyftQKzaToC rlJJDkcnNVQ2B75eKmdaFFz+S9pxnD0= 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-55-waYYuEumMh-Iyo0fxTg8Yw-1; Sun, 21 Jul 2024 20:17:12 -0400 X-MC-Unique: waYYuEumMh-Iyo0fxTg8Yw-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-368442fef36so2960144f8f.0 for ; Sun, 21 Jul 2024 17:17:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607431; x=1722212231; 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=V7i/ikH3mbc0bL34LgKCgRiXDl4kA7AlgZAMAJaf21I=; b=q9OSP0UikJolX/ocX5Gnu7l6OqckwWiB1mvZ/QmTwyuZHsh6rhxTvQZ66ys1ESHfjY 3zgcesQsJ32i1gJdW1O1VYMJupvTFbFoJI4nGnKT3+XNcHtOhiwv4sayCm4dk7lsAPSj 7tQHkeL1Nlkb5eywV7ZPgUGCaUGRVTrVBOHDKCpSpMSNzBJV+4BaxYP/WOn0x6xVJYBW KiXIkWforgGIjjFUsulXDCCr1cWWXEzBtPeDta0BWqVrdAgkaHS9suYfgfBun4MDgvB/ 8aKr81CacNX8j4TEQzlt0JSnmettk2T9+Ww5sfd4b3i1l72xepNTToX648xfit3DeiP+ CL3Q== X-Gm-Message-State: AOJu0YwaYCpSnUeIkelfurCU+iYlzdr7ZFabHIW2A/rx/R5EuGHc7sRM IkQmloJrYrVEcPD847ci3SUqnJNKwH5tnG9jNUOUXHEpm23D/0m6CQTSaIVZHe1SFFI5e9+uoIL jravZWtpLuDEgRN4TcZ9K7K9rI/vMb35clIRzP+YRyyQGQPSpVjZydfVbzbN5RGer3ZC7ZGJEiz j03YBdz768OxL5afNqfK70cXrw3A0RFA== X-Received: by 2002:a5d:64ed:0:b0:368:5e34:4b53 with SMTP id ffacd0b85a97d-369bae39577mr5052873f8f.10.1721607430655; Sun, 21 Jul 2024 17:17:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2PWPBEz1EVKL5ZT2lNtQoM+DZa1LY060UIbafpJdR1kleUkP+uiMtlPDZkMyHkGcOuAyjmA== X-Received: by 2002:a5d:64ed:0:b0:368:5e34:4b53 with SMTP id ffacd0b85a97d-369bae39577mr5052853f8f.10.1721607430013; Sun, 21 Jul 2024 17:17:10 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787ed551sm7004460f8f.113.2024.07.21.17.17.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:09 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Jonathan Cameron , Fan Ni Subject: [PULL 09/63] hw/cxl: Add get scan media results cmd support Message-ID: <89b5cfcc31e655a40919698a7f95a9208d6f12a3.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Davidlohr Bueso Iterate over the list keeping the output payload size into account, returning the results from a previous scan media operation. The scan media operation does not fail prematurely due to device being out of storage, so this implementation does not deal with the retry/restart functionality. Signed-off-by: Davidlohr Bueso Link: https://lore.kernel.org/r/20230908073152.4386-5-dave@stgolabs.net Signed-off-by: Jonathan Cameron Message-Id: <20240705120643.959422-5-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 1 + hw/cxl/cxl-mailbox-utils.c | 85 +++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 0509d961c3..cc98553583 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -499,6 +499,7 @@ struct CXLType3Dev { /* Poison Injection - backup */ CXLPoisonList poison_list_bkp; CXLPoisonList scan_media_results; + bool scan_media_hasrun; struct dynamic_capacity { HostMemoryBackend *host_dc; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 3c9600c39c..82120a6e7b 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -85,6 +85,7 @@ enum { #define CLEAR_POISON 0x2 #define GET_SCAN_MEDIA_CAPABILITIES 0x3 #define SCAN_MEDIA 0x4 + #define GET_SCAN_MEDIA_RESULTS 0x5 DCD_CONFIG = 0x48, #define GET_DC_CONFIG 0x0 #define GET_DYN_CAP_EXT_LIST 0x1 @@ -1339,6 +1340,8 @@ static void __do_scan_media(CXLType3Dev *ct3d) ct3d->poison_list_cnt == results_cnt) { cxl_clear_poison_list_overflowed(ct3d); } + /* scan media has run since last conventional reset */ + ct3d->scan_media_hasrun = true; } /* @@ -1443,6 +1446,85 @@ static CXLRetCode cmd_media_scan_media(const struct cxl_cmd *cmd, return CXL_MBOX_BG_STARTED; } +/* + * CXL r3.1 section 8.2.9.9.4.6: Get Scan Media Results + */ +static CXLRetCode cmd_media_get_scan_media_results(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct get_scan_media_results_out_pl { + uint64_t dpa_restart; + uint64_t length; + uint8_t flags; + uint8_t rsvd1; + uint16_t count; + uint8_t rsvd2[0xc]; + struct { + uint64_t addr; + uint32_t length; + uint32_t resv; + } QEMU_PACKED records[]; + } QEMU_PACKED; + + struct get_scan_media_results_out_pl *out = (void *)payload_out; + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + CXLPoisonList *scan_media_results = &ct3d->scan_media_results; + CXLPoison *ent, *next; + uint16_t total_count = 0, record_count = 0, i = 0; + uint16_t out_pl_len; + + if (!ct3d->scan_media_hasrun) { + return CXL_MBOX_UNSUPPORTED; + } + + /* + * Calculate limits, all entries are within the same address range of the + * last scan media call. + */ + QLIST_FOREACH(ent, scan_media_results, node) { + size_t rec_size = record_count * sizeof(out->records[0]); + + if (sizeof(*out) + rec_size < CXL_MAILBOX_MAX_PAYLOAD_SIZE) { + record_count++; + } + total_count++; + } + + out_pl_len = sizeof(*out) + record_count * sizeof(out->records[0]); + assert(out_pl_len <= CXL_MAILBOX_MAX_PAYLOAD_SIZE); + + memset(out, 0, out_pl_len); + QLIST_FOREACH_SAFE(ent, scan_media_results, node, next) { + uint64_t start, stop; + + if (i == record_count) { + break; + } + + start = ROUND_DOWN(ent->start, 64ull); + stop = ROUND_DOWN(ent->start, 64ull) + ent->length; + stq_le_p(&out->records[i].addr, start | (ent->type & 0x7)); + stl_le_p(&out->records[i].length, (stop - start) / CXL_CACHE_LINE_SIZE); + i++; + + /* consume the returning entry */ + QLIST_REMOVE(ent, node); + g_free(ent); + } + + stw_le_p(&out->count, record_count); + if (total_count > record_count) { + out->flags = (1 << 0); /* More Media Error Records */ + } + + *len_out = out_pl_len; + return CXL_MBOX_SUCCESS; +} + /* * CXL r3.1 section 8.2.9.9.9.1: Get Dynamic Capacity Configuration * (Opcode: 4800h) @@ -2060,6 +2142,9 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = { cmd_media_get_scan_media_capabilities, 16, 0 }, [MEDIA_AND_POISON][SCAN_MEDIA] = { "MEDIA_AND_POISON_SCAN_MEDIA", cmd_media_scan_media, 17, BACKGROUND_OPERATION }, + [MEDIA_AND_POISON][GET_SCAN_MEDIA_RESULTS] = { + "MEDIA_AND_POISON_GET_SCAN_MEDIA_RESULTS", + cmd_media_get_scan_media_results, 0, 0 }, }; static const struct cxl_cmd cxl_cmd_set_dcd[256][256] = { From patchwork Mon Jul 22 00:17: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: 13738195 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 95E3FC3DA61 for ; Mon, 22 Jul 2024 00:31:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgjx-0003Sc-6e; Sun, 21 Jul 2024 20:17:21 -0400 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 1sVgjv-0003KR-29 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:19 -0400 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 1sVgjs-0005kM-RL for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607435; 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=CYkvuehHMuB8FFNUkACRvfP0TVqplBGSaMD83Q0lWBg=; b=OqYYV1rf7a3YwmHjudzZ6kCUNBVGAWZAXziGq7j9IytzpHRqLJOZ/CEh7v8+gy2BFp0/mW 9cR2Y4TuZsJhCHbUQmGKi5oaM1syISeGfFrk3KR7JhBupqSIdcc062YIndUi4jMnSPkw/6 WV0yXcfaJ3z14GWVnflcf77EiLcz8ng= 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-657-9DsFoTTsMLqPzCgW_HgPQA-1; Sun, 21 Jul 2024 20:17:14 -0400 X-MC-Unique: 9DsFoTTsMLqPzCgW_HgPQA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-426d316a96cso26613315e9.0 for ; Sun, 21 Jul 2024 17:17:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607432; x=1722212232; 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=CYkvuehHMuB8FFNUkACRvfP0TVqplBGSaMD83Q0lWBg=; b=pMmCWIMLyNa48yLAH53zODqHbFaAM8kZm8Shf7Y7f5/i4eS9yzlcYMoAJXLU041dWK +oikNhWzd0RtvY52fRbV0C1T9VV4yt1kKG+utju3CSjyqAQ9Gd5ZmL29+S5QBLk2ukR2 0arfreDoi6gerGrjjdw3ymoSS+LJUHyhEWx7albEtqYdjctQddKjW9bJ1gtEWd4hg43O i/eaLhFviOvYk6tksaaD6Q+ha+ynALMriFcc3oaoGTIKjJ3gytpUCs9YA89K1/Sxvs5I Zuzc2iZEa4qYsov+C6Fdwhn7LqynzYjlkW4mwfjLR0Nv+9Dpq2X4RVzvOa6jih9eYMe+ 3J4w== X-Gm-Message-State: AOJu0Yx5xwgSirDhFTDMxQDKS3qpYVvCG+D9jAj23EQUAqvdKwGVkbof 5FYLIvV4Ptrt1UvIovM3eqpGcjoopIK5bh88qj8ZBFjQ/jkca/+SbnoZSbWS1VNHSXqVimxr5TZ NNUUSIt83+S55KJanW1itHqwiuQ1MwlVoYxo6gKZLtWz7uoP6M3F3M2W1Y4joJWDTX41ViExlzU ER3JZzB/JDamdIz8c8ZkefHH9uz0iVTw== X-Received: by 2002:a05:600c:3b23:b0:427:9a8f:9717 with SMTP id 5b1f17b1804b1-427dc4ce7b4mr41789355e9.0.1721607432482; Sun, 21 Jul 2024 17:17:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGtVb8sDZfpVROb/qgYFPEqNvG4gBNRZpDKPCdJeXjnwQqUkexsWbERyI3WUdWU/FdtPZGlfw== X-Received: by 2002:a05:600c:3b23:b0:427:9a8f:9717 with SMTP id 5b1f17b1804b1-427dc4ce7b4mr41789165e9.0.1721607431908; Sun, 21 Jul 2024 17:17:11 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8d930sm133892055e9.32.2024.07.21.17.17.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:11 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Gregory Price , Gregory Price , Jonathan Cameron , Fan Ni Subject: [PULL 10/63] cxl/mailbox: move mailbox effect definitions to a header Message-ID: <25da36d5d04deb8869bd6ad1223832f09f3efe79.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Gregory Price Preparation for allowing devices to define their own CCI commands Signed-off-by: Gregory Price Link: https://lore.kernel.org/r/20230906001517.324380-2-gregory.price@memverge.com Signed-off-by: Jonathan Cameron Message-Id: <20240705123039.963781-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_mailbox.h | 18 ++++++++++++++++++ hw/cxl/cxl-mailbox-utils.c | 34 +++++++++++++++------------------- 2 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 include/hw/cxl/cxl_mailbox.h diff --git a/include/hw/cxl/cxl_mailbox.h b/include/hw/cxl/cxl_mailbox.h new file mode 100644 index 0000000000..beb048052e --- /dev/null +++ b/include/hw/cxl/cxl_mailbox.h @@ -0,0 +1,18 @@ +/* + * QEMU CXL Mailbox + * + * This work is licensed under the terms of the GNU GPL, version 2. See the + * COPYING file in the top-level directory. + */ + +#ifndef CXL_MAILBOX_H +#define CXL_MAILBOX_H + +#define CXL_MBOX_IMMEDIATE_CONFIG_CHANGE (1 << 1) +#define CXL_MBOX_IMMEDIATE_DATA_CHANGE (1 << 2) +#define CXL_MBOX_IMMEDIATE_POLICY_CHANGE (1 << 3) +#define CXL_MBOX_IMMEDIATE_LOG_CHANGE (1 << 4) +#define CXL_MBOX_SECURITY_STATE_CHANGE (1 << 5) +#define CXL_MBOX_BACKGROUND_OPERATION (1 << 6) + +#endif diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 82120a6e7b..dbaa83a110 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -12,6 +12,7 @@ #include "hw/pci/msix.h" #include "hw/cxl/cxl.h" #include "hw/cxl/cxl_events.h" +#include "hw/cxl/cxl_mailbox.h" #include "hw/pci/pci.h" #include "hw/pci-bridge/cxl_upstream_port.h" #include "qemu/cutils.h" @@ -2095,28 +2096,21 @@ static CXLRetCode cmd_dcd_release_dyn_cap(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } -#define IMMEDIATE_CONFIG_CHANGE (1 << 1) -#define IMMEDIATE_DATA_CHANGE (1 << 2) -#define IMMEDIATE_POLICY_CHANGE (1 << 3) -#define IMMEDIATE_LOG_CHANGE (1 << 4) -#define SECURITY_STATE_CHANGE (1 << 5) -#define BACKGROUND_OPERATION (1 << 6) - static const struct cxl_cmd cxl_cmd_set[256][256] = { [EVENTS][GET_RECORDS] = { "EVENTS_GET_RECORDS", cmd_events_get_records, 1, 0 }, [EVENTS][CLEAR_RECORDS] = { "EVENTS_CLEAR_RECORDS", - cmd_events_clear_records, ~0, IMMEDIATE_LOG_CHANGE }, + cmd_events_clear_records, ~0, CXL_MBOX_IMMEDIATE_LOG_CHANGE }, [EVENTS][GET_INTERRUPT_POLICY] = { "EVENTS_GET_INTERRUPT_POLICY", cmd_events_get_interrupt_policy, 0, 0 }, [EVENTS][SET_INTERRUPT_POLICY] = { "EVENTS_SET_INTERRUPT_POLICY", cmd_events_set_interrupt_policy, - ~0, IMMEDIATE_CONFIG_CHANGE }, + ~0, CXL_MBOX_IMMEDIATE_CONFIG_CHANGE }, [FIRMWARE_UPDATE][GET_INFO] = { "FIRMWARE_UPDATE_GET_INFO", cmd_firmware_update_get_info, 0, 0 }, [TIMESTAMP][GET] = { "TIMESTAMP_GET", cmd_timestamp_get, 0, 0 }, [TIMESTAMP][SET] = { "TIMESTAMP_SET", cmd_timestamp_set, - 8, IMMEDIATE_POLICY_CHANGE }, + 8, CXL_MBOX_IMMEDIATE_POLICY_CHANGE }, [LOGS][GET_SUPPORTED] = { "LOGS_GET_SUPPORTED", cmd_logs_get_supported, 0, 0 }, [LOGS][GET_LOG] = { "LOGS_GET_LOG", cmd_logs_get_log, 0x18, 0 }, @@ -2126,9 +2120,11 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = { cmd_ccls_get_partition_info, 0, 0 }, [CCLS][GET_LSA] = { "CCLS_GET_LSA", cmd_ccls_get_lsa, 8, 0 }, [CCLS][SET_LSA] = { "CCLS_SET_LSA", cmd_ccls_set_lsa, - ~0, IMMEDIATE_CONFIG_CHANGE | IMMEDIATE_DATA_CHANGE }, + ~0, CXL_MBOX_IMMEDIATE_CONFIG_CHANGE | CXL_MBOX_IMMEDIATE_DATA_CHANGE }, [SANITIZE][OVERWRITE] = { "SANITIZE_OVERWRITE", cmd_sanitize_overwrite, 0, - IMMEDIATE_DATA_CHANGE | SECURITY_STATE_CHANGE | BACKGROUND_OPERATION }, + (CXL_MBOX_IMMEDIATE_DATA_CHANGE | + CXL_MBOX_SECURITY_STATE_CHANGE | + CXL_MBOX_BACKGROUND_OPERATION)}, [PERSISTENT_MEM][GET_SECURITY_STATE] = { "GET_SECURITY_STATE", cmd_get_security_state, 0, 0 }, [MEDIA_AND_POISON][GET_POISON_LIST] = { "MEDIA_AND_POISON_GET_POISON_LIST", @@ -2141,7 +2137,7 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = { "MEDIA_AND_POISON_GET_SCAN_MEDIA_CAPABILITIES", cmd_media_get_scan_media_capabilities, 16, 0 }, [MEDIA_AND_POISON][SCAN_MEDIA] = { "MEDIA_AND_POISON_SCAN_MEDIA", - cmd_media_scan_media, 17, BACKGROUND_OPERATION }, + cmd_media_scan_media, 17, CXL_MBOX_BACKGROUND_OPERATION }, [MEDIA_AND_POISON][GET_SCAN_MEDIA_RESULTS] = { "MEDIA_AND_POISON_GET_SCAN_MEDIA_RESULTS", cmd_media_get_scan_media_results, 0, 0 }, @@ -2155,10 +2151,10 @@ static const struct cxl_cmd cxl_cmd_set_dcd[256][256] = { 8, 0 }, [DCD_CONFIG][ADD_DYN_CAP_RSP] = { "DCD_ADD_DYNAMIC_CAPACITY_RESPONSE", cmd_dcd_add_dyn_cap_rsp, - ~0, IMMEDIATE_DATA_CHANGE }, + ~0, CXL_MBOX_IMMEDIATE_DATA_CHANGE }, [DCD_CONFIG][RELEASE_DYN_CAP] = { "DCD_RELEASE_DYNAMIC_CAPACITY", cmd_dcd_release_dyn_cap, - ~0, IMMEDIATE_DATA_CHANGE }, + ~0, CXL_MBOX_IMMEDIATE_DATA_CHANGE }, }; static const struct cxl_cmd cxl_cmd_set_sw[256][256] = { @@ -2166,8 +2162,8 @@ static const struct cxl_cmd cxl_cmd_set_sw[256][256] = { [INFOSTAT][BACKGROUND_OPERATION_STATUS] = { "BACKGROUND_OPERATION_STATUS", cmd_infostat_bg_op_sts, 0, 0 }, [TIMESTAMP][GET] = { "TIMESTAMP_GET", cmd_timestamp_get, 0, 0 }, - [TIMESTAMP][SET] = { "TIMESTAMP_SET", cmd_timestamp_set, 0, - IMMEDIATE_POLICY_CHANGE }, + [TIMESTAMP][SET] = { "TIMESTAMP_SET", cmd_timestamp_set, 8, + CXL_MBOX_IMMEDIATE_POLICY_CHANGE }, [LOGS][GET_SUPPORTED] = { "LOGS_GET_SUPPORTED", cmd_logs_get_supported, 0, 0 }, [LOGS][GET_LOG] = { "LOGS_GET_LOG", cmd_logs_get_log, 0x18, 0 }, @@ -2210,7 +2206,7 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, } /* Only one bg command at a time */ - if ((cxl_cmd->effect & BACKGROUND_OPERATION) && + if ((cxl_cmd->effect & CXL_MBOX_BACKGROUND_OPERATION) && cci->bg.runtime > 0) { return CXL_MBOX_BUSY; } @@ -2235,7 +2231,7 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, } ret = (*h)(cxl_cmd, pl_in, len_in, pl_out, len_out, cci); - if ((cxl_cmd->effect & BACKGROUND_OPERATION) && + if ((cxl_cmd->effect & CXL_MBOX_BACKGROUND_OPERATION) && ret == CXL_MBOX_BG_STARTED) { *bg_started = true; } else { From patchwork Mon Jul 22 00:17: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: 13738150 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 32DF3C3DA61 for ; Mon, 22 Jul 2024 00:21:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgjy-0003WB-4L; Sun, 21 Jul 2024 20:17:22 -0400 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 1sVgjw-0003Q7-IR for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:20 -0400 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 1sVgju-0005kc-Dp for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607437; 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=ugOrV8EJw9eeb5qLhYeR3H1/gihB/jIlqcXCvXTnPcM=; b=DQ+HUvXwbBl91p1cwn7EirsqrYsLiOCDUG0jYA47z+nNQv02PJtUrvVhlEN5NJ3LTfEm8s H+4ARLGKepAemiZJA1dflsXVG/eKP5YlViuTYKMAo5Vpt1JAPVfwtuRRWhEZFi0xayi90U 5rbxG8Y+IXwd4FHTkptybVdd3frLY3A= 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-665-071YkblUPFCiBYeL_Z0kMA-1; Sun, 21 Jul 2024 20:17:16 -0400 X-MC-Unique: 071YkblUPFCiBYeL_Z0kMA-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-427d92bec90so19337785e9.1 for ; Sun, 21 Jul 2024 17:17:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607434; x=1722212234; 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=ugOrV8EJw9eeb5qLhYeR3H1/gihB/jIlqcXCvXTnPcM=; b=F28mf2FRjei01RPJ/jCGVtJuJ1RRQCjWL9fTwIfffyKInR0jTU6O37tdnSCYfQZ/LL QiC33pIB7ohDmZIkekhUVCllhLlAWoND/oEdi8rO+5ni21r8Ab0x+079FwkkcfrnNAFn G6O+ff5XuixGPPS+Edm62fFafyNf5+ciAJXQL/hMYUQj1hGH/xFnmnV8KvUVdmWh/3Hc L1LcDp1XVm+XkiYwebiCivQDv7O8Nhquav2JshLsiNUs5aTdb4U1zZVbU8Mk0csQ0JLe WDtdK0hJyd1VESHw9BS8H41Gfhh2WGk/qYg7hnCnIHrepWKQbdsgQfOYl90RSv317Xl8 N/Gg== X-Gm-Message-State: AOJu0YyKzu3Q8Dw+QIgKH3wxdGNReM5Cno+iKgzN+ptjooJ6xmHUP03u ZJ+/ppRKysaCMT+NC788+nlwB0Yah4ioOk5IC4p/QrGIE/iSt9VbOgV6kPvE3gysvBXXl35ieQD 2wXru2GrzLRQdCFz3pS+2TvCBCsZuxDxIBPCc3v174RcnpqEHfG0JJDlOs9JGco/MhjReW0D1zQ GT1/k5LPmMAHtXIiejvwXwO+66wHXaKg== X-Received: by 2002:a05:600c:1f87:b0:426:67ad:38e3 with SMTP id 5b1f17b1804b1-427daa2135bmr35797175e9.3.1721607434558; Sun, 21 Jul 2024 17:17:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEL39haoVzxK3A7NMK1RgArJGKb6H+U6UJO5NsILwpa0gDHb2CX2rIugNPw4PRCJngp20+K5A== X-Received: by 2002:a05:600c:1f87:b0:426:67ad:38e3 with SMTP id 5b1f17b1804b1-427daa2135bmr35796995e9.3.1721607433938; Sun, 21 Jul 2024 17:17:13 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787ced6dsm6999983f8f.75.2024.07.21.17.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:13 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:12 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Shiju Jose , Davidlohr Bueso , Fan Ni , Jonathan Cameron Subject: [PULL 11/63] hw/cxl/cxl-mailbox-utils: Add support for feature commands (8.2.9.6) 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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.6 describes optional device specific features. CXL devices supports features with changeable attributes. Get Supported Features retrieves the list of supported device specific features. The settings of a feature can be retrieved using Get Feature and optionally modified using Set Feature. Reviewed-by: Davidlohr Bueso Reviewed-by: Fan Ni Signed-off-by: Shiju Jose Link: https://lore.kernel.org/r/20240223085902.1549-2-shiju.jose@huawei.com Signed-off-by: Jonathan Cameron Message-Id: <20240705123039.963781-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 10 ++ hw/cxl/cxl-mailbox-utils.c | 258 ++++++++++++++++++++++++++++++++++++ 2 files changed, 268 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index cc98553583..48ed0d9240 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -464,6 +464,14 @@ typedef struct CXLDCRegion { unsigned long *blk_bitmap; } CXLDCRegion; +typedef struct CXLSetFeatureInfo { + QemuUUID uuid; + uint8_t data_transfer_flag; + bool data_saved_across_reset; + uint16_t data_offset; + size_t data_size; +} CXLSetFeatureInfo; + struct CXLType3Dev { /* Private */ PCIDevice parent_obj; @@ -501,6 +509,8 @@ struct CXLType3Dev { CXLPoisonList scan_media_results; bool scan_media_hasrun; + CXLSetFeatureInfo set_feat_info; + struct dynamic_capacity { HostMemoryBackend *host_dc; AddressSpace host_dc_as; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index dbaa83a110..7b7d8e5eae 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -69,6 +69,10 @@ enum { LOGS = 0x04, #define GET_SUPPORTED 0x0 #define GET_LOG 0x1 + FEATURES = 0x05, + #define GET_SUPPORTED 0x0 + #define GET_FEATURE 0x1 + #define SET_FEATURE 0x2 IDENTIFY = 0x40, #define MEMORY_DEVICE 0x0 CCLS = 0x41, @@ -767,6 +771,248 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } +/* CXL r3.1 section 8.2.9.6: Features */ +/* + * Get Supported Features output payload + * CXL r3.1 section 8.2.9.6.1 Table 8-96 + */ +typedef struct CXLSupportedFeatureHeader { + uint16_t entries; + uint16_t nsuppfeats_dev; + uint32_t reserved; +} QEMU_PACKED CXLSupportedFeatureHeader; + +/* + * Get Supported Features Supported Feature Entry + * CXL r3.1 section 8.2.9.6.1 Table 8-97 + */ +typedef struct CXLSupportedFeatureEntry { + QemuUUID uuid; + uint16_t feat_index; + uint16_t get_feat_size; + uint16_t set_feat_size; + uint32_t attr_flags; + uint8_t get_feat_version; + uint8_t set_feat_version; + uint16_t set_feat_effects; + uint8_t rsvd[18]; +} QEMU_PACKED CXLSupportedFeatureEntry; + +/* + * Get Supported Features Supported Feature Entry + * CXL rev 3.1 section 8.2.9.6.1 Table 8-97 + */ +/* Supported Feature Entry : attribute flags */ +#define CXL_FEAT_ENTRY_ATTR_FLAG_CHANGABLE BIT(0) +#define CXL_FEAT_ENTRY_ATTR_FLAG_DEEPEST_RESET_PERSISTENCE_MASK GENMASK(3, 1) +#define CXL_FEAT_ENTRY_ATTR_FLAG_PERSIST_ACROSS_FIRMWARE_UPDATE BIT(4) +#define CXL_FEAT_ENTRY_ATTR_FLAG_SUPPORT_DEFAULT_SELECTION BIT(5) +#define CXL_FEAT_ENTRY_ATTR_FLAG_SUPPORT_SAVED_SELECTION BIT(6) + +/* Supported Feature Entry : set feature effects */ +#define CXL_FEAT_ENTRY_SFE_CONFIG_CHANGE_COLD_RESET BIT(0) +#define CXL_FEAT_ENTRY_SFE_IMMEDIATE_CONFIG_CHANGE BIT(1) +#define CXL_FEAT_ENTRY_SFE_IMMEDIATE_DATA_CHANGE BIT(2) +#define CXL_FEAT_ENTRY_SFE_IMMEDIATE_POLICY_CHANGE BIT(3) +#define CXL_FEAT_ENTRY_SFE_IMMEDIATE_LOG_CHANGE BIT(4) +#define CXL_FEAT_ENTRY_SFE_SECURITY_STATE_CHANGE BIT(5) +#define CXL_FEAT_ENTRY_SFE_BACKGROUND_OPERATION BIT(6) +#define CXL_FEAT_ENTRY_SFE_SUPPORT_SECONDARY_MAILBOX BIT(7) +#define CXL_FEAT_ENTRY_SFE_SUPPORT_ABORT_BACKGROUND_OPERATION BIT(8) +#define CXL_FEAT_ENTRY_SFE_CEL_VALID BIT(9) +#define CXL_FEAT_ENTRY_SFE_CONFIG_CHANGE_CONV_RESET BIT(10) +#define CXL_FEAT_ENTRY_SFE_CONFIG_CHANGE_CXL_RESET BIT(11) + +enum CXL_SUPPORTED_FEATURES_LIST { + CXL_FEATURE_MAX +}; + +/* Get Feature CXL 3.1 Spec 8.2.9.6.2 */ +/* + * Get Feature input payload + * CXL r3.1 section 8.2.9.6.2 Table 8-99 + */ +/* Get Feature : Payload in selection */ +enum CXL_GET_FEATURE_SELECTION { + CXL_GET_FEATURE_SEL_CURRENT_VALUE, + CXL_GET_FEATURE_SEL_DEFAULT_VALUE, + CXL_GET_FEATURE_SEL_SAVED_VALUE, + CXL_GET_FEATURE_SEL_MAX +}; + +/* Set Feature CXL 3.1 Spec 8.2.9.6.3 */ +/* + * Set Feature input payload + * CXL r3.1 section 8.2.9.6.3 Table 8-101 + */ +typedef struct CXLSetFeatureInHeader { + QemuUUID uuid; + uint32_t flags; + uint16_t offset; + uint8_t version; + uint8_t rsvd[9]; +} QEMU_PACKED QEMU_ALIGNED(16) CXLSetFeatureInHeader; + +/* Set Feature : Payload in flags */ +#define CXL_SET_FEATURE_FLAG_DATA_TRANSFER_MASK 0x7 +enum CXL_SET_FEATURE_FLAG_DATA_TRANSFER { + CXL_SET_FEATURE_FLAG_FULL_DATA_TRANSFER, + CXL_SET_FEATURE_FLAG_INITIATE_DATA_TRANSFER, + CXL_SET_FEATURE_FLAG_CONTINUE_DATA_TRANSFER, + CXL_SET_FEATURE_FLAG_FINISH_DATA_TRANSFER, + CXL_SET_FEATURE_FLAG_ABORT_DATA_TRANSFER, + CXL_SET_FEATURE_FLAG_DATA_TRANSFER_MAX +}; +#define CXL_SET_FEAT_DATA_SAVED_ACROSS_RESET BIT(3) + +/* CXL r3.1 section 8.2.9.6.1: Get Supported Features (Opcode 0500h) */ +static CXLRetCode cmd_features_get_supported(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct { + uint32_t count; + uint16_t start_index; + uint16_t reserved; + } QEMU_PACKED QEMU_ALIGNED(16) * get_feats_in = (void *)payload_in; + + struct { + CXLSupportedFeatureHeader hdr; + CXLSupportedFeatureEntry feat_entries[]; + } QEMU_PACKED QEMU_ALIGNED(16) * get_feats_out = (void *)payload_out; + uint16_t index, req_entries; + uint16_t entry; + + if (!object_dynamic_cast(OBJECT(cci->d), TYPE_CXL_TYPE3)) { + return CXL_MBOX_UNSUPPORTED; + } + if (get_feats_in->count < sizeof(CXLSupportedFeatureHeader) || + /* + * Temporary: suppress compiler error due to unsigned + * comparioson to zero. + */ + true /*get_feats_in->start_index >= CXL_FEATURE_MAX*/) { + return CXL_MBOX_INVALID_INPUT; + } + + req_entries = (get_feats_in->count - + sizeof(CXLSupportedFeatureHeader)) / + sizeof(CXLSupportedFeatureEntry); + req_entries = MIN(req_entries, + (CXL_FEATURE_MAX - get_feats_in->start_index)); + + for (entry = 0, index = get_feats_in->start_index; + entry < req_entries; index++) { + switch (index) { + default: + __builtin_unreachable(); + } + } + get_feats_out->hdr.nsuppfeats_dev = CXL_FEATURE_MAX; + get_feats_out->hdr.entries = req_entries; + *len_out = sizeof(CXLSupportedFeatureHeader) + + req_entries * sizeof(CXLSupportedFeatureEntry); + + return CXL_MBOX_SUCCESS; +} + +/* CXL r3.1 section 8.2.9.6.2: Get Feature (Opcode 0501h) */ +static CXLRetCode cmd_features_get_feature(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct { + QemuUUID uuid; + uint16_t offset; + uint16_t count; + uint8_t selection; + } QEMU_PACKED QEMU_ALIGNED(16) * get_feature; + uint16_t bytes_to_copy = 0; + CXLType3Dev *ct3d; + CXLSetFeatureInfo *set_feat_info; + + if (!object_dynamic_cast(OBJECT(cci->d), TYPE_CXL_TYPE3)) { + return CXL_MBOX_UNSUPPORTED; + } + + ct3d = CXL_TYPE3(cci->d); + get_feature = (void *)payload_in; + + set_feat_info = &ct3d->set_feat_info; + if (qemu_uuid_is_equal(&get_feature->uuid, &set_feat_info->uuid)) { + return CXL_MBOX_FEATURE_TRANSFER_IN_PROGRESS; + } + + if (get_feature->selection != CXL_GET_FEATURE_SEL_CURRENT_VALUE) { + return CXL_MBOX_UNSUPPORTED; + } + if (get_feature->offset + get_feature->count > cci->payload_max) { + return CXL_MBOX_INVALID_INPUT; + } + + *len_out = bytes_to_copy; + + return CXL_MBOX_SUCCESS; +} + +/* CXL r3.1 section 8.2.9.6.3: Set Feature (Opcode 0502h) */ +static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + CXLSetFeatureInHeader *hdr = (void *)payload_in; + CXLSetFeatureInfo *set_feat_info; + uint8_t data_transfer_flag; + CXLType3Dev *ct3d; + + + if (!object_dynamic_cast(OBJECT(cci->d), TYPE_CXL_TYPE3)) { + return CXL_MBOX_UNSUPPORTED; + } + ct3d = CXL_TYPE3(cci->d); + set_feat_info = &ct3d->set_feat_info; + + if (!qemu_uuid_is_null(&set_feat_info->uuid) && + !qemu_uuid_is_equal(&hdr->uuid, &set_feat_info->uuid)) { + return CXL_MBOX_FEATURE_TRANSFER_IN_PROGRESS; + } + if (hdr->flags & CXL_SET_FEAT_DATA_SAVED_ACROSS_RESET) { + set_feat_info->data_saved_across_reset = true; + } else { + set_feat_info->data_saved_across_reset = false; + } + + data_transfer_flag = + hdr->flags & CXL_SET_FEATURE_FLAG_DATA_TRANSFER_MASK; + if (data_transfer_flag == CXL_SET_FEATURE_FLAG_INITIATE_DATA_TRANSFER) { + set_feat_info->uuid = hdr->uuid; + set_feat_info->data_size = 0; + } + set_feat_info->data_transfer_flag = data_transfer_flag; + set_feat_info->data_offset = hdr->offset; + + if (data_transfer_flag == CXL_SET_FEATURE_FLAG_FULL_DATA_TRANSFER || + data_transfer_flag == CXL_SET_FEATURE_FLAG_FINISH_DATA_TRANSFER || + data_transfer_flag == CXL_SET_FEATURE_FLAG_ABORT_DATA_TRANSFER) { + memset(&set_feat_info->uuid, 0, sizeof(QemuUUID)); + set_feat_info->data_transfer_flag = 0; + set_feat_info->data_saved_across_reset = false; + set_feat_info->data_offset = 0; + set_feat_info->data_size = 0; + } + + return CXL_MBOX_SUCCESS; +} + /* CXL r3.1 Section 8.2.9.9.1.1: Identify Memory Device (Opcode 4000h) */ static CXLRetCode cmd_identify_memory_device(const struct cxl_cmd *cmd, uint8_t *payload_in, @@ -2114,6 +2360,18 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = { [LOGS][GET_SUPPORTED] = { "LOGS_GET_SUPPORTED", cmd_logs_get_supported, 0, 0 }, [LOGS][GET_LOG] = { "LOGS_GET_LOG", cmd_logs_get_log, 0x18, 0 }, + [FEATURES][GET_SUPPORTED] = { "FEATURES_GET_SUPPORTED", + cmd_features_get_supported, 0x8, 0 }, + [FEATURES][GET_FEATURE] = { "FEATURES_GET_FEATURE", + cmd_features_get_feature, 0x15, 0 }, + [FEATURES][SET_FEATURE] = { "FEATURES_SET_FEATURE", + cmd_features_set_feature, + ~0, + (CXL_MBOX_IMMEDIATE_CONFIG_CHANGE | + CXL_MBOX_IMMEDIATE_DATA_CHANGE | + CXL_MBOX_IMMEDIATE_POLICY_CHANGE | + CXL_MBOX_IMMEDIATE_LOG_CHANGE | + CXL_MBOX_SECURITY_STATE_CHANGE)}, [IDENTIFY][MEMORY_DEVICE] = { "IDENTIFY_MEMORY_DEVICE", cmd_identify_memory_device, 0, 0 }, [CCLS][GET_PARTITION_INFO] = { "CCLS_GET_PARTITION_INFO", From patchwork Mon Jul 22 00:17:14 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: 13738182 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 19D6DC3DA5D for ; Mon, 22 Jul 2024 00:28:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgk1-0003ie-2H; Sun, 21 Jul 2024 20:17:25 -0400 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 1sVgjz-0003bi-Ah for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:23 -0400 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 1sVgjx-0005ky-9I for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607440; 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=D6a6rs+lqNePMYg6fXsfNOdsN7cy/NFFK4flSLPM9E4=; b=KI89CDbYnmq8TV8VDwft3+PVYryTSll4mPD/N1geAqRKFq/quSMDRdEdF6jYMqgnVyCM8l gJIY9dUojJXz21d2jkM2xpC59j5GykGCJVplhrRT+3cjLxKvRztGz/10+Wvl+8M5fi3PJU j0rQbQ508tBbl2nS6d1XHLjC21E22pM= 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-533-WRKLpZpAMtSOfUyM7xTqCw-1; Sun, 21 Jul 2024 20:17:18 -0400 X-MC-Unique: WRKLpZpAMtSOfUyM7xTqCw-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-369bbbdb5a1so398177f8f.1 for ; Sun, 21 Jul 2024 17:17:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607437; x=1722212237; 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=D6a6rs+lqNePMYg6fXsfNOdsN7cy/NFFK4flSLPM9E4=; b=eBeLEXpR7IPSle6i3PT6EjqWFqMSV8eq+/bP8t8hOZSEhsmLqX448zuAKfhaRK5nvo 5UZivtwbQtUtCpKLTQFnmpJIGND8L8+Lqf1CJVYB66Rd+JCFGBOQJAGD9ZjjlJzincnW FTnHYjubRXElUOaLVRds4uvz67uOcNRtLkazf4qh2OzcDaZbSmVBloKoHCYxtgy15MFy h9sDhPHtDyNHRQjYPo/bDW3VDRr+1lPNPvRQQMGbq3VKuOmpB9cZD2pi7IFARA2KgTeU dLR0R1BDVXuIOmbjgDU9RbHMFnXmxzDqVVjazfkzP+IsYIruPwA17CAkVjGWLUvVPFE5 V38g== X-Gm-Message-State: AOJu0YwP4nDXm1jd6SJkppWKo+pHWiKx9E3ALJK3PVvYamu1WnVo4WTV +d3ksL1+ZIZBpyAp8ga0lJcMF68o20Vi7sw9S8S3/rkAb3XvKaKkVvIsb1U43wT8QgAVUzncZuo xIUdExqjFCM4P8sxx9eIC6gmBPKU7pGhJxuYS8MRg8FNYFmfpQL4kTpTYJWXCbKqXn58GMejWO/ Ez2Xt5Y0ebz0xkQjSGGX/Po9pXh/pIYA== X-Received: by 2002:a5d:4a0c:0:b0:368:3b89:df1d with SMTP id ffacd0b85a97d-36873f18e6cmr5923451f8f.22.1721607436719; Sun, 21 Jul 2024 17:17:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVxRluhAq5w9MJ1JKYm94mQQlhyPAOoginULAlcRF/enWH0o2SP1ntbXkKlQwPvrP89UO5Bg== X-Received: by 2002:a5d:4a0c:0:b0:368:3b89:df1d with SMTP id ffacd0b85a97d-36873f18e6cmr5923436f8f.22.1721607436088; Sun, 21 Jul 2024 17:17:16 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d68fa493sm107390905e9.10.2024.07.21.17.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:15 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:14 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Shiju Jose , Davidlohr Bueso , Fan Ni , Jonathan Cameron Subject: [PULL 12/63] hw/cxl/cxl-mailbox-utils: Add device patrol scrub control feature 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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.1 describes the device patrol scrub control feature. The device patrol scrub proactively locates and makes corrections to errors in regular cycle. The patrol scrub control allows the request to configure patrol scrub input configurations. The patrol scrub control allows the requester to specify the number of hours for which the patrol scrub cycles must be completed, provided that the requested number is not less than the minimum number of hours for the patrol scrub cycle that the device is capable of. In addition, the patrol scrub controls allow the host to disable and enable the feature in case disabling of the feature is needed for other purposes such as performance-aware operations which require the background operations to be turned off. Reviewed-by: Davidlohr Bueso Reviewed-by: Fan Ni Signed-off-by: Shiju Jose Link: https://lore.kernel.org/r/20240223085902.1549-3-shiju.jose@huawei.com Signed-off-by: Jonathan Cameron Message-Id: <20240705123039.963781-4-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 24 +++++++++++ hw/cxl/cxl-mailbox-utils.c | 79 ++++++++++++++++++++++++++++++++++--- hw/mem/cxl_type3.c | 9 +++++ 3 files changed, 107 insertions(+), 5 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 48ed0d9240..2c1df25453 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -427,6 +427,26 @@ typedef struct CXLPoison { typedef QLIST_HEAD(, CXLPoison) CXLPoisonList; #define CXL_POISON_LIST_LIMIT 256 +/* CXL memory device patrol scrub control attributes */ +typedef struct CXLMemPatrolScrubReadAttrs { + uint8_t scrub_cycle_cap; + uint16_t scrub_cycle; + uint8_t scrub_flags; +} QEMU_PACKED CXLMemPatrolScrubReadAttrs; + +typedef struct CXLMemPatrolScrubWriteAttrs { + uint8_t scrub_cycle_hr; + uint8_t scrub_flags; +} QEMU_PACKED CXLMemPatrolScrubWriteAttrs; + +#define CXL_MEMDEV_PS_GET_FEATURE_VERSION 0x01 +#define CXL_MEMDEV_PS_SET_FEATURE_VERSION 0x01 +#define CXL_MEMDEV_PS_SCRUB_CYCLE_CHANGE_CAP_DEFAULT BIT(0) +#define CXL_MEMDEV_PS_SCRUB_REALTIME_REPORT_CAP_DEFAULT BIT(1) +#define CXL_MEMDEV_PS_CUR_SCRUB_CYCLE_DEFAULT 12 +#define CXL_MEMDEV_PS_MIN_SCRUB_CYCLE_DEFAULT 1 +#define CXL_MEMDEV_PS_ENABLE_DEFAULT 0 + #define DCD_MAX_NUM_REGION 8 typedef struct CXLDCExtentRaw { @@ -511,6 +531,10 @@ struct CXLType3Dev { CXLSetFeatureInfo set_feat_info; + /* Patrol scrub control attributes */ + CXLMemPatrolScrubReadAttrs patrol_scrub_attrs; + CXLMemPatrolScrubWriteAttrs patrol_scrub_wr_attrs; + struct dynamic_capacity { HostMemoryBackend *host_dc; AddressSpace host_dc_as; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 7b7d8e5eae..485beb9dba 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -824,6 +824,7 @@ typedef struct CXLSupportedFeatureEntry { #define CXL_FEAT_ENTRY_SFE_CONFIG_CHANGE_CXL_RESET BIT(11) enum CXL_SUPPORTED_FEATURES_LIST { + CXL_FEATURE_PATROL_SCRUB = 0, CXL_FEATURE_MAX }; @@ -865,6 +866,17 @@ enum CXL_SET_FEATURE_FLAG_DATA_TRANSFER { }; #define CXL_SET_FEAT_DATA_SAVED_ACROSS_RESET BIT(3) +/* CXL r3.1 section 8.2.9.9.11.1: Device Patrol Scrub Control Feature */ +static const QemuUUID patrol_scrub_uuid = { + .data = UUID(0x96dad7d6, 0xfde8, 0x482b, 0xa7, 0x33, + 0x75, 0x77, 0x4e, 0x06, 0xdb, 0x8a) +}; + +typedef struct CXLMemPatrolScrubSetFeature { + CXLSetFeatureInHeader hdr; + CXLMemPatrolScrubWriteAttrs feat_data; +} QEMU_PACKED QEMU_ALIGNED(16) CXLMemPatrolScrubSetFeature; + /* CXL r3.1 section 8.2.9.6.1: Get Supported Features (Opcode 0500h) */ static CXLRetCode cmd_features_get_supported(const struct cxl_cmd *cmd, uint8_t *payload_in, @@ -890,11 +902,7 @@ static CXLRetCode cmd_features_get_supported(const struct cxl_cmd *cmd, return CXL_MBOX_UNSUPPORTED; } if (get_feats_in->count < sizeof(CXLSupportedFeatureHeader) || - /* - * Temporary: suppress compiler error due to unsigned - * comparioson to zero. - */ - true /*get_feats_in->start_index >= CXL_FEATURE_MAX*/) { + get_feats_in->start_index >= CXL_FEATURE_MAX) { return CXL_MBOX_INVALID_INPUT; } @@ -907,6 +915,21 @@ static CXLRetCode cmd_features_get_supported(const struct cxl_cmd *cmd, for (entry = 0, index = get_feats_in->start_index; entry < req_entries; index++) { switch (index) { + case CXL_FEATURE_PATROL_SCRUB: + /* Fill supported feature entry for device patrol scrub control */ + get_feats_out->feat_entries[entry++] = + (struct CXLSupportedFeatureEntry) { + .uuid = patrol_scrub_uuid, + .feat_index = index, + .get_feat_size = sizeof(CXLMemPatrolScrubReadAttrs), + .set_feat_size = sizeof(CXLMemPatrolScrubWriteAttrs), + .attr_flags = CXL_FEAT_ENTRY_ATTR_FLAG_CHANGABLE, + .get_feat_version = CXL_MEMDEV_PS_GET_FEATURE_VERSION, + .set_feat_version = CXL_MEMDEV_PS_SET_FEATURE_VERSION, + .set_feat_effects = CXL_FEAT_ENTRY_SFE_IMMEDIATE_CONFIG_CHANGE | + CXL_FEAT_ENTRY_SFE_CEL_VALID, + }; + break; default: __builtin_unreachable(); } @@ -956,6 +979,20 @@ static CXLRetCode cmd_features_get_feature(const struct cxl_cmd *cmd, return CXL_MBOX_INVALID_INPUT; } + if (qemu_uuid_is_equal(&get_feature->uuid, &patrol_scrub_uuid)) { + if (get_feature->offset >= sizeof(CXLMemPatrolScrubReadAttrs)) { + return CXL_MBOX_INVALID_INPUT; + } + bytes_to_copy = sizeof(CXLMemPatrolScrubReadAttrs) - + get_feature->offset; + bytes_to_copy = MIN(bytes_to_copy, get_feature->count); + memcpy(payload_out, + (uint8_t *)&ct3d->patrol_scrub_attrs + get_feature->offset, + bytes_to_copy); + } else { + return CXL_MBOX_UNSUPPORTED; + } + *len_out = bytes_to_copy; return CXL_MBOX_SUCCESS; @@ -970,7 +1007,10 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd, CXLCCI *cci) { CXLSetFeatureInHeader *hdr = (void *)payload_in; + CXLMemPatrolScrubWriteAttrs *ps_write_attrs; + CXLMemPatrolScrubSetFeature *ps_set_feature; CXLSetFeatureInfo *set_feat_info; + uint16_t bytes_to_copy = 0; uint8_t data_transfer_flag; CXLType3Dev *ct3d; @@ -999,11 +1039,40 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd, } set_feat_info->data_transfer_flag = data_transfer_flag; set_feat_info->data_offset = hdr->offset; + bytes_to_copy = len_in - sizeof(CXLSetFeatureInHeader); + + if (qemu_uuid_is_equal(&hdr->uuid, &patrol_scrub_uuid)) { + if (hdr->version != CXL_MEMDEV_PS_SET_FEATURE_VERSION) { + return CXL_MBOX_UNSUPPORTED; + } + + ps_set_feature = (void *)payload_in; + ps_write_attrs = &ps_set_feature->feat_data; + memcpy((uint8_t *)&ct3d->patrol_scrub_wr_attrs + hdr->offset, + ps_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->patrol_scrub_attrs.scrub_cycle &= ~0xFF; + ct3d->patrol_scrub_attrs.scrub_cycle |= + ct3d->patrol_scrub_wr_attrs.scrub_cycle_hr & 0xFF; + ct3d->patrol_scrub_attrs.scrub_flags &= ~0x1; + ct3d->patrol_scrub_attrs.scrub_flags |= + ct3d->patrol_scrub_wr_attrs.scrub_flags & 0x1; + } + } else { + return CXL_MBOX_UNSUPPORTED; + } if (data_transfer_flag == CXL_SET_FEATURE_FLAG_FULL_DATA_TRANSFER || data_transfer_flag == CXL_SET_FEATURE_FLAG_FINISH_DATA_TRANSFER || data_transfer_flag == CXL_SET_FEATURE_FLAG_ABORT_DATA_TRANSFER) { memset(&set_feat_info->uuid, 0, sizeof(QemuUUID)); + if (qemu_uuid_is_equal(&hdr->uuid, &patrol_scrub_uuid)) { + memset(&ct3d->patrol_scrub_wr_attrs, 0, set_feat_info->data_size); + } set_feat_info->data_transfer_flag = 0; set_feat_info->data_saved_across_reset = false; set_feat_info->data_offset = 0; diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index c7910687ae..7c583d80f5 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -908,6 +908,15 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp) } cxl_event_init(&ct3d->cxl_dstate, 2); + /* Set default value for patrol scrub attributes */ + ct3d->patrol_scrub_attrs.scrub_cycle_cap = + CXL_MEMDEV_PS_SCRUB_CYCLE_CHANGE_CAP_DEFAULT | + CXL_MEMDEV_PS_SCRUB_REALTIME_REPORT_CAP_DEFAULT; + ct3d->patrol_scrub_attrs.scrub_cycle = + CXL_MEMDEV_PS_CUR_SCRUB_CYCLE_DEFAULT | + (CXL_MEMDEV_PS_MIN_SCRUB_CYCLE_DEFAULT << 8); + ct3d->patrol_scrub_attrs.scrub_flags = CXL_MEMDEV_PS_ENABLE_DEFAULT; + return; err_release_cdat: From patchwork Mon Jul 22 00:17: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: 13738158 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 50C01C3DA61 for ; Mon, 22 Jul 2024 00:23:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgk1-0003l8-Mf; Sun, 21 Jul 2024 20:17:25 -0400 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 1sVgk0-0003hD-Lc for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:24 -0400 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 1sVgjy-0005l2-Kx for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607442; 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=d+b3iGPXHzRDxcu2/iYzWpqXB4BTdAoJBt36m9nCwv4=; b=DtPmpKdNgqbar9/UJ44calzB8d0WnXODHfTVZtCfkyntyYuDDPZSAv2vx8Dew8sLd2H6Xk YN+tW7D/ycdYohZVWqTvWzlvv5gzy0Byv+N9QCdcyuUhih0p59qA0FXT43O1S4e+dUARWm m7N/3I8sutZakxOBt62eM4WcSaG6jAM= 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-683--wsJRb-3P2CP6oZrB67WRQ-1; Sun, 21 Jul 2024 20:17:20 -0400 X-MC-Unique: -wsJRb-3P2CP6oZrB67WRQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-427d9e61ba8so15905505e9.3 for ; Sun, 21 Jul 2024 17:17:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607439; x=1722212239; 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=d+b3iGPXHzRDxcu2/iYzWpqXB4BTdAoJBt36m9nCwv4=; b=aUzo81l+mGZO0ked/5CJVGu2tc0WOSRmKkl20smwAp2OmkITLkbR1KsF4k72ogpDbS 5x2aiCIwldBb1BlCOuuPzKOQGvSL9yEu/VMaxNmjXqgH/fc6m7TQqX7KHLSAoH4WTQCo Z3uYl3FIyDzzsdIlmgDBQQiHzC1t/KWgKX/ZYYTf2HQpE97ryXP7yHtiI8Mqx3MINVw8 Rrtpbmc2wFybMqaQiYM76b4jkhT1AsVa6VfNvwbRiakLYnwX3juUAYqwnKFP8w7irc+M 28KpQ+pKUHyvSBaDDvaPjpe1K/kT37tIKOrYgCNKd3LRYBW23ndAbFf0b5mAzyOp7d8Y sI4w== X-Gm-Message-State: AOJu0YwLobZpcVx4f1fyt15QZaubgqun2srsgcTWcKq8FYYUAbyp3N8w agCGVHONeI255E8GZdDkzz/Y56I3Jm5ttpk7va8YRICA88VpH90e8HfvO+MixDgrGP/jSL0Qs9x kxjKOZk7HCr7O4WbdWVhKby+Clklx+5wHmHDAlvqTQmE7SCAkyGH8IsFbYCaUp6HgATZ2/nbAJM n+2tSMnInQWbsnqLXcaE2onR7KqhAkGw== X-Received: by 2002:a05:600c:4684:b0:426:61fc:fc22 with SMTP id 5b1f17b1804b1-427dc520b62mr30202775e9.3.1721607438750; Sun, 21 Jul 2024 17:17:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFukwvOCOFPOSTgSGiyG8rAN0PI5KDpNnso5U+cBljW5HZfdQ89CqFjmar8ACeby55poyuAMw== X-Received: by 2002:a05:600c:4684:b0:426:61fc:fc22 with SMTP id 5b1f17b1804b1-427dc520b62mr30202635e9.3.1721607438176; Sun, 21 Jul 2024 17:17:18 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d68fa9b1sm107738965e9.8.2024.07.21.17.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:17 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Shiju Jose , Davidlohr Bueso , Fan Ni , Jonathan Cameron Subject: [PULL 13/63] hw/cxl/cxl-mailbox-utils: Add device DDR5 ECS control feature Message-ID: <2d41ce38fb9af3e66f85c8b8f9c3f83148c3d549.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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. The Error Check Scrub (ECS) is a feature defined in JEDEC DDR5 SDRAM Specification (JESD79-5) and allows the DRAM to internally read, correct single-bit errors, and write back corrected data bits to the DRAM array while providing transparency to error counts. The ECS control feature allows the request to configure ECS input configurations during system boot or at run-time. The ECS control allows the requester to change the log entry type, the ECS threshold count provided that the request is within the definition specified in DDR5 mode registers, change mode between codeword mode and row count mode, and reset the ECS counter. Reviewed-by: Davidlohr Bueso Reviewed-by: Fan Ni Signed-off-by: Shiju Jose Link: https://lore.kernel.org/r/20240223085902.1549-4-shiju.jose@huawei.com Signed-off-by: Jonathan Cameron Message-Id: <20240705123039.963781-5-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 24 +++++++++++++ hw/cxl/cxl-mailbox-utils.c | 71 +++++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3.c | 14 ++++++++ 3 files changed, 109 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 2c1df25453..5cae7159e6 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -447,6 +447,27 @@ typedef struct CXLMemPatrolScrubWriteAttrs { #define CXL_MEMDEV_PS_MIN_SCRUB_CYCLE_DEFAULT 1 #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 +#define CXL_ECS_REALTIME_REPORT_CAP_DEFAULT 1 +#define CXL_ECS_THRESHOLD_COUNT_DEFAULT 3 /* 3: 256, 4: 1024, 5: 4096 */ +#define CXL_ECS_MODE_DEFAULT 0 +#define CXL_ECS_NUM_MEDIA_FRUS 3 /* Default */ + #define DCD_MAX_NUM_REGION 8 typedef struct CXLDCExtentRaw { @@ -534,6 +555,9 @@ struct CXLType3Dev { /* Patrol scrub control attributes */ 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]; struct dynamic_capacity { HostMemoryBackend *host_dc; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 485beb9dba..0621f686f4 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -825,6 +825,7 @@ typedef struct CXLSupportedFeatureEntry { enum CXL_SUPPORTED_FEATURES_LIST { CXL_FEATURE_PATROL_SCRUB = 0, + CXL_FEATURE_ECS, CXL_FEATURE_MAX }; @@ -877,6 +878,20 @@ typedef struct CXLMemPatrolScrubSetFeature { CXLMemPatrolScrubWriteAttrs feat_data; } QEMU_PACKED QEMU_ALIGNED(16) CXLMemPatrolScrubSetFeature; +/* + * CXL r3.1 section 8.2.9.9.11.2: + * DDR5 Error Check Scrub (ECS) Control Feature + */ +static const QemuUUID ecs_uuid = { + .data = UUID(0xe5b13f22, 0x2328, 0x4a14, 0xb8, 0xba, + 0xb9, 0x69, 0x1e, 0x89, 0x33, 0x86) +}; + +typedef struct CXLMemECSSetFeature { + CXLSetFeatureInHeader hdr; + CXLMemECSWriteAttrs feat_data[]; +} QEMU_PACKED QEMU_ALIGNED(16) CXLMemECSSetFeature; + /* CXL r3.1 section 8.2.9.6.1: Get Supported Features (Opcode 0500h) */ static CXLRetCode cmd_features_get_supported(const struct cxl_cmd *cmd, uint8_t *payload_in, @@ -930,6 +945,23 @@ static CXLRetCode cmd_features_get_supported(const struct cxl_cmd *cmd, CXL_FEAT_ENTRY_SFE_CEL_VALID, }; break; + case CXL_FEATURE_ECS: + /* Fill supported feature entry for device DDR5 ECS control */ + get_feats_out->feat_entries[entry++] = + (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), + .attr_flags = CXL_FEAT_ENTRY_ATTR_FLAG_CHANGABLE, + .get_feat_version = CXL_ECS_GET_FEATURE_VERSION, + .set_feat_version = CXL_ECS_SET_FEATURE_VERSION, + .set_feat_effects = CXL_FEAT_ENTRY_SFE_IMMEDIATE_CONFIG_CHANGE | + CXL_FEAT_ENTRY_SFE_CEL_VALID, + }; + break; default: __builtin_unreachable(); } @@ -989,6 +1021,18 @@ static CXLRetCode cmd_features_get_feature(const struct cxl_cmd *cmd, memcpy(payload_out, (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)) { + return CXL_MBOX_INVALID_INPUT; + } + bytes_to_copy = CXL_ECS_NUM_MEDIA_FRUS * + 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, + bytes_to_copy); } else { return CXL_MBOX_UNSUPPORTED; } @@ -1009,10 +1053,13 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd, CXLSetFeatureInHeader *hdr = (void *)payload_in; CXLMemPatrolScrubWriteAttrs *ps_write_attrs; CXLMemPatrolScrubSetFeature *ps_set_feature; + CXLMemECSWriteAttrs *ecs_write_attrs; + CXLMemECSSetFeature *ecs_set_feature; CXLSetFeatureInfo *set_feat_info; uint16_t bytes_to_copy = 0; uint8_t data_transfer_flag; CXLType3Dev *ct3d; + uint16_t count; if (!object_dynamic_cast(OBJECT(cci->d), TYPE_CXL_TYPE3)) { @@ -1062,6 +1109,28 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd, ct3d->patrol_scrub_attrs.scrub_flags |= ct3d->patrol_scrub_wr_attrs.scrub_flags & 0x1; } + } else if (qemu_uuid_is_equal(&hdr->uuid, + &ecs_uuid)) { + if (hdr->version != CXL_ECS_SET_FEATURE_VERSION) { + return CXL_MBOX_UNSUPPORTED; + } + + ecs_set_feature = (void *)payload_in; + ecs_write_attrs = ecs_set_feature->feat_data; + 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) { + 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; + } + } } else { return CXL_MBOX_UNSUPPORTED; } @@ -1072,6 +1141,8 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd, memset(&set_feat_info->uuid, 0, sizeof(QemuUUID)); 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); } 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 7c583d80f5..d648192ab9 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -844,6 +844,7 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp) uint8_t *pci_conf = pci_dev->config; unsigned short msix_num = 6; int i, rc; + uint16_t count; QTAILQ_INIT(&ct3d->error_list); @@ -917,6 +918,19 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp) (CXL_MEMDEV_PS_MIN_SCRUB_CYCLE_DEFAULT << 8); ct3d->patrol_scrub_attrs.scrub_flags = CXL_MEMDEV_PS_ENABLE_DEFAULT; + /* Set default value for DDR5 ECS read attributes */ + 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 = + CXL_ECS_REALTIME_REPORT_CAP_DEFAULT; + ct3d->ecs_attrs[count].ecs_config = + CXL_ECS_THRESHOLD_COUNT_DEFAULT | + (CXL_ECS_MODE_DEFAULT << 3); + /* Reserved */ + ct3d->ecs_attrs[count].ecs_flags = 0; + } + return; err_release_cdat: From patchwork Mon Jul 22 00:17:18 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: 13738147 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 B9B8BC3DA63 for ; Mon, 22 Jul 2024 00:21:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgk4-0003w2-Du; Sun, 21 Jul 2024 20:17:28 -0400 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 1sVgk2-0003po-S8 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:26 -0400 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 1sVgk0-0005lF-LI for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607444; 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=qcwAVQlpIclpTqaGgIStn6XGFvx5TOswyNM1MDIov58=; b=QB6HWg4rUMjzTBwDpgi4F4ddmsvLK/Fco0TF9vw314BQkzvZOJ0jmKKAUNihLXkJ++kLKn V4hXtw+7IyptIng78ehhiZa/J+eyEQs/d54Ckmn51COyBRiN8ZYx51+ks+Q1Gm1LbURK1d 3C9XTApR5dIM94PTrvIPpblqme3lNNQ= 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-9-rOTwcKz7Ph-zPO7Uhsxjkg-1; Sun, 21 Jul 2024 20:17:22 -0400 X-MC-Unique: rOTwcKz7Ph-zPO7Uhsxjkg-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3686658856fso2063493f8f.0 for ; Sun, 21 Jul 2024 17:17:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607441; x=1722212241; 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=qcwAVQlpIclpTqaGgIStn6XGFvx5TOswyNM1MDIov58=; b=WnpJxGGRe0urFSmp5M+4Yk1brNUHCZ0keJs8DnwvpHNgSlTr2nKWFd8L9uUl6Bqr4t O4+SJZWi/SX0NAqsEZmYDisz5j5psx5RYrpNT5/xeO/+fsf86pQm/+zAo3oWbl5MDkdp XbSt5d0SqQQUmoWq5MWtdK/UrF/hrxAfaTi1kzPus9KH0FEgV5jISGIbiMZHdl9Wbnuo se6fuC6GSjBOrAjZvNEW4Eiq+eSrvfNBi3rKKWaygdObLsNi2R4nMNMJ29BthDzHU5W/ 9vcnVao+U7daiLTgCTho1oA/FJv7vxsj4J+Rr9Ef/Ivwxy+H8V+87fNzDiTykM14Rqkq xhYw== X-Gm-Message-State: AOJu0YwRKouZfWZUrQMoJ0763lV0Aug1B2i2aTVzK+W3ZyBd5RSpkoml rTQbxtDUsVbTULDOb033mwiQb9OoYSQfykkOye3zTGGXbLuLJAJMdM1vAmU3mZ+82tMB5sgPNW4 Jdrd0Pbm6gWPkxbkzSk7a3ap/jn6rN4+4cvhiwUGUr6+A3TmJOc1Kk0EizIhPCkrz4yy9INT7tp 7Zg579FYHFHSCJHkVX1yPI+D07wpg8ag== X-Received: by 2002:adf:f042:0:b0:368:3f60:8725 with SMTP id ffacd0b85a97d-3683f608818mr8977647f8f.39.1721607440900; Sun, 21 Jul 2024 17:17:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8W/bAnBLxFz1Tq7Rw/oQ74W8m1tRam0K9WYugH7Jbmr6PY5Jg+6S4KYwtcoWXGvcHmV6+sA== X-Received: by 2002:adf:f042:0:b0:368:3f60:8725 with SMTP id ffacd0b85a97d-3683f608818mr8977631f8f.39.1721607440246; Sun, 21 Jul 2024 17:17:20 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868b3d5sm7037446f8f.36.2024.07.21.17.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:19 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:18 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Jonathan Cameron , Fan Ni Subject: [PULL 14/63] hw/cxl: Support firmware updates Message-ID: <3c1e1e5e240e683f0611b96cd325471639f22c6d.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Davidlohr Bueso Implement transfer and activate functionality per 3.1 spec for supporting update metadata (no actual buffers). Transfer times are arbitrarily set to ten and two seconds for full and part transfers, respectively. cxl update-firmware mem0 -F fw.img cxl update-firmware mem0 "memdev":"mem0", "pmem_size":"1024.00 MiB (1073.74 MB)", "serial":"0", "host":"0000:0d:00.0", "firmware":{ "num_slots":2, "active_slot":1, "online_activate_capable":true, "slot_1_version":"BWFW VERSION 0", "fw_update_in_progress":true, "remaining_size":22400 } } cxl update-firmware mem0 { "memdev":"mem0", "pmem_size":"1024.00 MiB (1073.74 MB)", "serial":"0", "host":"0000:0d:00.0", "firmware":{ "num_slots":2, "active_slot":1, "staged_slot":2, "online_activate_capable":true, "slot_1_version":"BWFW VERSION 0", "slot_2_version":"BWFW VERSION 1", "fw_update_in_progress":false } } Signed-off-by: Davidlohr Bueso Link: https://lore.kernel.org/r/20240627164912.25630-1-dave@stgolabs.net Signed-off-by: Jonathan Cameron Message-Id: <20240705125915.991672-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 15 +++ hw/cxl/cxl-mailbox-utils.c | 205 +++++++++++++++++++++++++++++++++++- 2 files changed, 215 insertions(+), 5 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 5cae7159e6..fdd0f4e62b 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -181,6 +181,21 @@ typedef struct CXLCCI { uint64_t runtime; QEMUTimer *timer; } bg; + + /* firmware update */ + struct { + uint8_t active_slot; + uint8_t staged_slot; + bool slot[4]; + uint8_t curr_action; + uint8_t curr_slot; + /* handle partial transfers */ + bool transferring; + size_t prev_offset; + size_t prev_len; + time_t last_partxfer; + } fw; + size_t payload_max; /* Pointer to device hosting the CCI */ DeviceState *d; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 0621f686f4..b752920ec8 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -63,6 +63,8 @@ enum { #define SET_INTERRUPT_POLICY 0x3 FIRMWARE_UPDATE = 0x02, #define GET_INFO 0x0 + #define TRANSFER 0x1 + #define ACTIVATE 0x2 TIMESTAMP = 0x03, #define GET 0x0 #define SET 0x1 @@ -622,6 +624,9 @@ static CXLRetCode cmd_infostat_bg_op_sts(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } +#define CXL_FW_SLOTS 2 +#define CXL_FW_SIZE 0x02000000 /* 32 mb */ + /* CXL r3.1 Section 8.2.9.3.1: Get FW Info (Opcode 0200h) */ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, uint8_t *payload_in, @@ -652,15 +657,192 @@ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, fw_info = (void *)payload_out; - fw_info->slots_supported = 2; - fw_info->slot_info = BIT(0) | BIT(3); - fw_info->caps = 0; - pstrcpy(fw_info->fw_rev1, sizeof(fw_info->fw_rev1), "BWFW VERSION 0"); + fw_info->slots_supported = CXL_FW_SLOTS; + fw_info->slot_info = (cci->fw.active_slot & 0x7) | + ((cci->fw.staged_slot & 0x7) << 3); + fw_info->caps = BIT(0); /* online update supported */ + + if (cci->fw.slot[0]) { + pstrcpy(fw_info->fw_rev1, sizeof(fw_info->fw_rev1), "BWFW VERSION 0"); + } + if (cci->fw.slot[1]) { + pstrcpy(fw_info->fw_rev2, sizeof(fw_info->fw_rev2), "BWFW VERSION 1"); + } *len_out = sizeof(*fw_info); return CXL_MBOX_SUCCESS; } +/* CXL r3.1 section 8.2.9.3.2: Transfer FW (Opcode 0201h) */ +#define CXL_FW_XFER_ALIGNMENT 128 + +#define CXL_FW_XFER_ACTION_FULL 0x0 +#define CXL_FW_XFER_ACTION_INIT 0x1 +#define CXL_FW_XFER_ACTION_CONTINUE 0x2 +#define CXL_FW_XFER_ACTION_END 0x3 +#define CXL_FW_XFER_ACTION_ABORT 0x4 + +static CXLRetCode cmd_firmware_update_transfer(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct { + uint8_t action; + uint8_t slot; + uint8_t rsvd1[2]; + uint32_t offset; + uint8_t rsvd2[0x78]; + uint8_t data[]; + } QEMU_PACKED *fw_transfer = (void *)payload_in; + size_t offset, length; + + if (fw_transfer->action == CXL_FW_XFER_ACTION_ABORT) { + /* + * At this point there aren't any on-going transfers + * running in the bg - this is serialized before this + * call altogether. Just mark the state machine and + * disregard any other input. + */ + cci->fw.transferring = false; + return CXL_MBOX_SUCCESS; + } + + offset = fw_transfer->offset * CXL_FW_XFER_ALIGNMENT; + length = len - sizeof(*fw_transfer); + if (offset + length > CXL_FW_SIZE) { + return CXL_MBOX_INVALID_INPUT; + } + + if (cci->fw.transferring) { + if (fw_transfer->action == CXL_FW_XFER_ACTION_FULL || + fw_transfer->action == CXL_FW_XFER_ACTION_INIT) { + return CXL_MBOX_FW_XFER_IN_PROGRESS; + } + /* + * Abort partitioned package transfer if over 30 secs + * between parts. As opposed to the explicit ABORT action, + * semantically treat this condition as an error - as + * if a part action were passed without a previous INIT. + */ + if (difftime(time(NULL), cci->fw.last_partxfer) > 30.0) { + cci->fw.transferring = false; + return CXL_MBOX_INVALID_INPUT; + } + } else if (fw_transfer->action == CXL_FW_XFER_ACTION_CONTINUE || + fw_transfer->action == CXL_FW_XFER_ACTION_END) { + return CXL_MBOX_INVALID_INPUT; + } + + /* allow back-to-back retransmission */ + if ((offset != cci->fw.prev_offset || length != cci->fw.prev_len) && + (fw_transfer->action == CXL_FW_XFER_ACTION_CONTINUE || + fw_transfer->action == CXL_FW_XFER_ACTION_END)) { + /* verify no overlaps */ + if (offset < cci->fw.prev_offset + cci->fw.prev_len) { + return CXL_MBOX_FW_XFER_OUT_OF_ORDER; + } + } + + switch (fw_transfer->action) { + case CXL_FW_XFER_ACTION_FULL: /* ignores offset */ + case CXL_FW_XFER_ACTION_END: + if (fw_transfer->slot == 0 || + fw_transfer->slot == cci->fw.active_slot || + fw_transfer->slot > CXL_FW_SLOTS) { + return CXL_MBOX_FW_INVALID_SLOT; + } + + /* mark the slot used upon bg completion */ + break; + case CXL_FW_XFER_ACTION_INIT: + if (offset != 0) { + return CXL_MBOX_INVALID_INPUT; + } + + cci->fw.transferring = true; + cci->fw.prev_offset = offset; + cci->fw.prev_len = length; + break; + case CXL_FW_XFER_ACTION_CONTINUE: + cci->fw.prev_offset = offset; + cci->fw.prev_len = length; + break; + default: + return CXL_MBOX_INVALID_INPUT; + } + + if (fw_transfer->action == CXL_FW_XFER_ACTION_FULL) { + cci->bg.runtime = 10 * 1000UL; + } else { + cci->bg.runtime = 2 * 1000UL; + } + /* keep relevant context for bg completion */ + cci->fw.curr_action = fw_transfer->action; + cci->fw.curr_slot = fw_transfer->slot; + *len_out = 0; + + return CXL_MBOX_BG_STARTED; +} + +static void __do_firmware_xfer(CXLCCI *cci) +{ + switch (cci->fw.curr_action) { + case CXL_FW_XFER_ACTION_FULL: + case CXL_FW_XFER_ACTION_END: + cci->fw.slot[cci->fw.curr_slot - 1] = true; + cci->fw.transferring = false; + break; + case CXL_FW_XFER_ACTION_INIT: + case CXL_FW_XFER_ACTION_CONTINUE: + time(&cci->fw.last_partxfer); + break; + default: + break; + } +} + +/* CXL r3.1 section 8.2.9.3.3: Activate FW (Opcode 0202h) */ +static CXLRetCode cmd_firmware_update_activate(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct { + uint8_t action; + uint8_t slot; + } QEMU_PACKED *fw_activate = (void *)payload_in; + QEMU_BUILD_BUG_ON(sizeof(*fw_activate) != 0x2); + + if (fw_activate->slot == 0 || + fw_activate->slot == cci->fw.active_slot || + fw_activate->slot > CXL_FW_SLOTS) { + return CXL_MBOX_FW_INVALID_SLOT; + } + + /* ensure that an actual fw package is there */ + if (!cci->fw.slot[fw_activate->slot - 1]) { + return CXL_MBOX_FW_INVALID_SLOT; + } + + switch (fw_activate->action) { + case 0: /* online */ + cci->fw.active_slot = fw_activate->slot; + break; + case 1: /* reset */ + cci->fw.staged_slot = fw_activate->slot; + break; + default: + return CXL_MBOX_INVALID_INPUT; + } + + return CXL_MBOX_SUCCESS; +} + /* CXL r3.1 Section 8.2.9.4.1: Get Timestamp (Opcode 0300h) */ static CXLRetCode cmd_timestamp_get(const struct cxl_cmd *cmd, uint8_t *payload_in, @@ -2494,6 +2676,10 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = { ~0, CXL_MBOX_IMMEDIATE_CONFIG_CHANGE }, [FIRMWARE_UPDATE][GET_INFO] = { "FIRMWARE_UPDATE_GET_INFO", cmd_firmware_update_get_info, 0, 0 }, + [FIRMWARE_UPDATE][TRANSFER] = { "FIRMWARE_UPDATE_TRANSFER", + cmd_firmware_update_transfer, ~0, CXL_MBOX_BACKGROUND_OPERATION }, + [FIRMWARE_UPDATE][ACTIVATE] = { "FIRMWARE_UPDATE_ACTIVATE", + cmd_firmware_update_activate, 2, CXL_MBOX_BACKGROUND_OPERATION }, [TIMESTAMP][GET] = { "TIMESTAMP_GET", cmd_timestamp_get, 0, 0 }, [TIMESTAMP][SET] = { "TIMESTAMP_SET", cmd_timestamp_set, 8, CXL_MBOX_IMMEDIATE_POLICY_CHANGE }, @@ -2622,7 +2808,9 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, h == cmd_media_get_poison_list || h == cmd_media_inject_poison || h == cmd_media_clear_poison || - h == cmd_sanitize_overwrite) { + h == cmd_sanitize_overwrite || + h == cmd_firmware_update_transfer || + h == cmd_firmware_update_activate) { return CXL_MBOX_MEDIA_DISABLED; } } @@ -2667,6 +2855,9 @@ static void bg_timercb(void *opaque) cci->bg.complete_pct = 100; cci->bg.ret_code = ret; switch (cci->bg.opcode) { + case 0x0201: /* fw transfer */ + __do_firmware_xfer(cci); + break; case 0x4400: /* sanitize */ { CXLType3Dev *ct3d = CXL_TYPE3(cci->d); @@ -2738,6 +2929,10 @@ void cxl_init_cci(CXLCCI *cci, size_t payload_max) cci->bg.runtime = 0; cci->bg.timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, bg_timercb, cci); + + memset(&cci->fw, 0, sizeof(cci->fw)); + cci->fw.active_slot = 1; + cci->fw.slot[cci->fw.active_slot - 1] = true; } static void cxl_copy_cci_commands(CXLCCI *cci, const struct cxl_cmd (*cxl_cmds)[256]) From patchwork Mon Jul 22 00:17: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: 13738136 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 AB102C3DA5D for ; Mon, 22 Jul 2024 00:18:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgk6-00043E-6y; Sun, 21 Jul 2024 20:17:30 -0400 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 1sVgk4-0003vx-Bn for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:28 -0400 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 1sVgk2-0005lT-WB for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607446; 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=b1DVK7w17GPjd2vAQhHKtU0B8nNst/5eqxCLxdYr+cI=; b=gf2Mlax2Aq2RDQ8p/rv6Y3/H9Wz1vZYBlrpRQIaesLCX1jS5bReXAOYbYb3U0eDa4Qn8L2 DXttJ0TZoIgby0+pgqZXtI/n4sCLu6f+tvu3sBNnOeTBHUdVo6X1m+yoet/jNlV03N7nCw iYFld16NFiGtn3Dry4koNfiLMBCIhhI= 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-651-sWw6uVoTO4ivVzH9403SXw-1; Sun, 21 Jul 2024 20:17:24 -0400 X-MC-Unique: sWw6uVoTO4ivVzH9403SXw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42666ed2d5fso25930045e9.3 for ; Sun, 21 Jul 2024 17:17:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607443; x=1722212243; 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=b1DVK7w17GPjd2vAQhHKtU0B8nNst/5eqxCLxdYr+cI=; b=EpEhzD9008AJpXNf04z7HvRWZnvhxT16XqEjcPWyGjgLfKcLLm3wP09wJHUQMaI8Ix Gok2CQTRCFDrRyhXjqkf0qkMMyV1vsR0iooWiEDj//M5aA0cqppwiY9KYVJMo0ARBnsv VO24iB5QqbB6MmoSlSI0FQSBd+iaeveaoRhnDEbWsOhU62OleYSrdYZqJGb5+d87C6B/ wZwaXK2gK0c675Gh9D6wEapKC1urHTYGML7SVIOMMRYWbwzIuVhoX7ZIpKMREb9nGk5s bVdJwCu5Elu7idZCPkXVUX+FT22OyrWazxH+i1s8wGZ3p4AnoWQHKYiEUrSoDeOOs1oY Fp2g== X-Gm-Message-State: AOJu0YyPMBXXq5Ckf0LxRGysUufPNZFNfVYcEoe09Fq2Yra6YADJI3TS YmqPko9mkoAkzxesUH7E17DvEovHMszv9I33UBv6NGjmjjMzSrkQLoI6SVrICe06kWnSqphyI6O j/qazkoI4+W8fkA7Mqk2a9kVKtaoxV8jleepjjHBz4AttbvY/IV4RdJPGA+fJq0F+KuAn9viAnS 1HAY35sK1x+m2XSKPkwubSRLF6hnbxyw== X-Received: by 2002:a05:600c:314d:b0:426:5dca:50a with SMTP id 5b1f17b1804b1-427dc531d47mr32801935e9.21.1721607443168; Sun, 21 Jul 2024 17:17:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGE5ezX0uRHXNslnNmqbBgg7RqX0cIh811EpZ5bWGJHemxROVr893VGvhfDGBfkANjzJjW24w== X-Received: by 2002:a05:600c:314d:b0:426:5dca:50a with SMTP id 5b1f17b1804b1-427dc531d47mr32801755e9.21.1721607442241; Sun, 21 Jul 2024 17:17:22 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d68fa171sm107667915e9.1.2024.07.21.17.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:21 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:20 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Yi Liu , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Thomas Huth , Michael Tokarev Subject: [PULL 15/63] MAINTAINERS: Add myself as a VT-d reviewer 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Yi Liu Signed-off-by: Yi Liu Message-Id: <20240708032112.796339-1-yi.l.liu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index b7e9ced3e8..8ad64ff76b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3659,6 +3659,7 @@ F: tests/uefi-test-tools/ VT-d Emulation M: Michael S. Tsirkin R: Jason Wang +R: Yi Liu S: Supported F: hw/i386/intel_iommu.c F: hw/i386/intel_iommu_internal.h From patchwork Mon Jul 22 00:17:22 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: 13738171 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 21ED4C3DA61 for ; Mon, 22 Jul 2024 00:24:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgk7-00049c-U9; Sun, 21 Jul 2024 20:17:31 -0400 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 1sVgk6-00044g-L2 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:30 -0400 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 1sVgk4-0005lj-Tg for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607448; 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=zREGtvMmaAWc2fUmFmGbArMdM6d/DlgtDgvgzTwqaes=; b=NkrJvr+zWpDePBJnoWnPCbBzrxT/5qEptLqK3hRCmH4+PU3yJoQDkrlkxZ1b3Gl2FNp3Rw Qy8uGoco14pn55lNshfkojpkZQMBLQBnbkHaW09mZSwd/9EFbr3rKIRQsAgq5vsh5iY48b mskTv/wtNy4Luu4wpdAPMniOCsshOjU= 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-460-uJShbmzxOB2RLQ6p_99-Tw-1; Sun, 21 Jul 2024 20:17:26 -0400 X-MC-Unique: uJShbmzxOB2RLQ6p_99-Tw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42666ed2d5fso25930155e9.3 for ; Sun, 21 Jul 2024 17:17:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607445; x=1722212245; 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=zREGtvMmaAWc2fUmFmGbArMdM6d/DlgtDgvgzTwqaes=; b=oidGNEsuWkU7wfajMCoKAfuOJdRFwn8NPnX7yQ8LcWG6pd2TXEM+aX17YnWUk76NoD bnC32n6iaMmXokvBUYvZOhTL5D7EObDQws126mWo5VHQ7ZZCwCK7f//bLYKfe/SoVvOx 0BaPphOuyPcL5Mb/MUzzVDYYaJBGcWwB9cie7GE0PtvsNw/uhUNMRw+bjly/rupDyjMp kbjhnkthvvzc6Tfi/1+lglOERFHphMgGKLcUXOzUXHgnQyCm5UzYVvibScvshVOws8A0 KHD02zNmSUky+QWbwbLhpTyOiAvBBFcOX3lbvjKpsxEOyUYm0Xd/SYJJtrO3Z6MX8jfP lfSQ== X-Gm-Message-State: AOJu0Yy6pmrTQ8F4XagefCVRv53etNeqodwprV70lyltUtm3faw37EOw x/D8pHBjzWieyB+Mw/1CR9rpt6Y+AeiZOS5PkPW1V0N39GSpLcX32VV8vBTTlLt7NSs/+edaiqC np7Bm48vFcQWKdzioD0pATN4SxDMUcP0jH/erR/KULnlon5Q+AQs3OSOEaJlH/NMTy7Vu4DzT+Y 3ygL/sJT4pQEJcc86bEROhAxQ9FzDUqQ== X-Received: by 2002:a05:600c:46c3:b0:426:5416:67d7 with SMTP id 5b1f17b1804b1-427dc565861mr32833425e9.27.1721607445077; Sun, 21 Jul 2024 17:17:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEX+7jt/cKkCQuWa6td34PAuX1JghZUy/71bqc+4lPplwNpiM5yyty1WbRkja1b74Z//mY+7A== X-Received: by 2002:a05:600c:46c3:b0:426:5416:67d7 with SMTP id 5b1f17b1804b1-427dc565861mr32833255e9.27.1721607444382; Sun, 21 Jul 2024 17:17:24 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a94c30sm134759845e9.47.2024.07.21.17.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:23 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:22 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Zheyu Ma , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Gerd Hoffmann Subject: [PULL 16/63] virtio-snd: add max size bounds check in input cb Message-ID: <98e77e3dd8dd6e7aa9a7dffa60f49c8c8a49d4e3.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Manos Pitsidianakis When reading input audio in the virtio-snd input callback, virtio_snd_pcm_in_cb(), we do not check whether the iov can actually fit the data buffer. This is because we use the buffer->size field as a total-so-far accumulator instead of byte-size-left like in TX buffers. This triggers an out of bounds write if the size of the virtio queue element is equal to virtio_snd_pcm_status, which makes the available space for audio data zero. This commit adds a check for reaching the maximum buffer size before attempting any writes. Reported-by: Zheyu Ma Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2427 Signed-off-by: Manos Pitsidianakis Message-Id: Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/audio/virtio-snd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index 5993f4f040..e6432ac959 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -1261,7 +1261,7 @@ static void virtio_snd_pcm_in_cb(void *data, int available) { VirtIOSoundPCMStream *stream = data; VirtIOSoundPCMBuffer *buffer; - size_t size; + size_t size, max_size; WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { while (!QSIMPLEQ_EMPTY(&stream->queue)) { @@ -1275,7 +1275,12 @@ static void virtio_snd_pcm_in_cb(void *data, int available) continue; } + max_size = iov_size(buffer->elem->in_sg, buffer->elem->in_num); for (;;) { + if (buffer->size >= max_size) { + return_rx_buffer(stream, buffer); + break; + } size = AUD_read(stream->voice.in, buffer->data + buffer->size, MIN(available, (stream->params.period_bytes - From patchwork Mon Jul 22 00:17:24 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: 13738137 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 65E15C3DA5D for ; Mon, 22 Jul 2024 00:18:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkB-0004OV-1v; Sun, 21 Jul 2024 20:17:35 -0400 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 1sVgk9-0004JJ-P9 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:33 -0400 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 1sVgk7-0005lz-UU for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607451; 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=g0S4hWSM06AIIIvMLr4s6kHBfIjfxBV9+M5h/WPYNyI=; b=YNP6aoaKCOK+C2Wj3Q6kfahdola9ecE+ahAOU6d5tQTqsVpLJzW06RZYxPOnl/ePAGUyiH J7jneUCF8Y0Fu3zlQBw4y0FTqotInI3zpuYMZqmPPIVUcmnEiSLyez8TIZ80n6aWRwmnLu 2OsBqWz1d5y7ccwNpv5v0wWU+vOkKQQ= 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-466-NgXSa-MrNfSg4Yeq_85D-w-1; Sun, 21 Jul 2024 20:17:28 -0400 X-MC-Unique: NgXSa-MrNfSg4Yeq_85D-w-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42660bca669so25378775e9.0 for ; Sun, 21 Jul 2024 17:17:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607447; x=1722212247; 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=g0S4hWSM06AIIIvMLr4s6kHBfIjfxBV9+M5h/WPYNyI=; b=vuOFc1i96HSux8WVpXQ3gowrk4Or0NdkrwUQVAOTvJ69yg2jGpKMw42iAL6m1d0Uey z3Dv8JelzVN9UHdRTyT3jsU9jA31IF4ibzRs3gbWZKBPPS8Hg4EH8Z9Cg5fVmNcbCW3w 6Ybd/5OTbQhOhIbfg0U5v+IxC21jvtAtKzQreGi3uSRoDZZEdgKvtzTnCkyk9F1SjjoJ sGt3VaCzh2Z0OoibJ0SAtZ/jRPBnd4zOBpM2iWSvEc/6SZnBFuT09HmPITImln46L8mK zDuFv9sA0hPgzr+uVPcyyOR68tIaUhh/Pf4Qr64wRD8S1552bukOo8jMAMIYToB/lH9s kIMw== X-Gm-Message-State: AOJu0YycUA+cEBZr+cA6cDg7yAxCkl2d8jqQTP0xRmEFib1OZQ3iTuKi xAw4i4Ifui3LmDkooidNevTqbIaX4/BgMVk369YqybjBjF1u6caZpzaCxkJlMei1NLo9qBPJ8Vl TLMxyAMEkmjcufceA9ld3af6NCdwgSkpspanyq8Xuh9K26d3fumnyGqNvRiEXBNlIAcJJmX2Tcr EXHxHeA7RFiNQn9g2vMPfPXzK8Sj3Odw== X-Received: by 2002:a05:600c:190d:b0:426:66e9:b844 with SMTP id 5b1f17b1804b1-427dc515427mr37324255e9.8.1721607447028; Sun, 21 Jul 2024 17:17:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvOb5riDtOVlMPVBcHkq5z28fjXS2hMV8i3Kx8UR/J/hWvBBqkXqNeuu1QvzANlYuQ03P3iA== X-Received: by 2002:a05:600c:190d:b0:426:66e9:b844 with SMTP id 5b1f17b1804b1-427dc515427mr37324065e9.8.1721607446515; Sun, 21 Jul 2024 17:17:26 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a94380sm133711655e9.39.2024.07.21.17.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:25 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Zheyu Ma , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Gerd Hoffmann Subject: [PULL 17/63] virtio-snd: check for invalid param shift operands Message-ID: <9b6083465fb8311f2410615f8303a41f580a2a20.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Manos Pitsidianakis When setting the parameters of a PCM stream, we compute the bit flag with the format and rate values as shift operand to check if they are set in supported_formats and supported_rates. If the guest provides a format/rate value which when shifting 1 results in a value bigger than the number of bits in supported_formats/supported_rates, we must report an error. Previously, this ended up triggering the not reached assertions later when converting to internal QEMU values. Reported-by: Zheyu Ma Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2416 Signed-off-by: Manos Pitsidianakis Message-Id: Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/audio/virtio-snd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index e6432ac959..e5196aa4bb 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -282,11 +282,13 @@ uint32_t virtio_snd_set_pcm_params(VirtIOSound *s, error_report("Number of channels is not supported."); return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP); } - if (!(supported_formats & BIT(params->format))) { + if (BIT(params->format) > sizeof(supported_formats) || + !(supported_formats & BIT(params->format))) { error_report("Stream format is not supported."); return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP); } - if (!(supported_rates & BIT(params->rate))) { + if (BIT(params->rate) > sizeof(supported_rates) || + !(supported_rates & BIT(params->rate))) { error_report("Stream rate is not supported."); return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP); } From patchwork Mon Jul 22 00:17:26 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: 13738139 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 28FD2C3DA61 for ; Mon, 22 Jul 2024 00:19:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkF-0004dU-1I; Sun, 21 Jul 2024 20:17:39 -0400 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 1sVgkD-0004WT-1K for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:37 -0400 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 1sVgkB-0005m9-5S for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607453; 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=AzUslSpv+tevRPtwsSDiIptOoVAEmUbWgTJDTpf/8Eg=; b=WSA52J5cl4c3SEVM1GYjObqHkJSnaws7sIWBLUDU6Bn4VrGvCqcsp7eBmV0zFqgl9np93x Scj2pOrPvFmIFwzfTud0U5R8TCjA45VdFxQkHr6bTZVIEzBMk6IgyV+ByP67inmf6hwMJI 2ei94va1XsLnGL/5RJGCOgSNx+qUfUA= 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-288-8w3H2CeZPC-5ZQ1Yoc1QFg-1; Sun, 21 Jul 2024 20:17:31 -0400 X-MC-Unique: 8w3H2CeZPC-5ZQ1Yoc1QFg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4279418eb2bso25990315e9.1 for ; Sun, 21 Jul 2024 17:17:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607449; x=1722212249; 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=AzUslSpv+tevRPtwsSDiIptOoVAEmUbWgTJDTpf/8Eg=; b=MAytey9XOvNl9KWrNcJEUswPCy0+MtlBF4s9g1FV9iih/5oTGC1cjnIYWpiphWJ+Ah yA38wwP059N7yxeE3WFLs2clB4gRLzDegNsH4Z8xWTGFd7y8jdBijwdkjxx4KT05Gg3D FBAcuIIBysyaYJLQLsU6HJezDtuF2fPmb17EMXmfDXFX3K6yazO4U5/Fm4TPh59duHOh 4SU5WEOMzVjfztZOGxZoSF2VvfEJYY+khiC/wREBSWkFF2COZmxlLLTADUoalexwQ7Dz 2gwJZyDFDjfXvntbjB5qDQuXQMWx5bF1vGqFAebN5oCGU1tCB6X3xILwxDVk2cF/brH/ rByQ== X-Gm-Message-State: AOJu0YwyKydOKVDlP2BgjOSrJMnrA+++Dln6r66HC3Rr29E1g+wpcubN KUr0H7aWYfhSjdEpUkVHXOmXiUeasxKOMkw3z8H4ulw2oRhbjyngHzVQK9rnmOH3u5RBpvxEhOg qqRw5RMcQ9IEcP4wcdev5S33Ib29fvOxly0It7bCWPpTmWgwl5oEllndS5RAzojAiOkrfOh2eBk 2g2bsvH4C6u4Wbm0QTY4Mx4/x4VlJ8+w== X-Received: by 2002:a05:600c:4f45:b0:426:6f0e:a60 with SMTP id 5b1f17b1804b1-427dc529c91mr30252355e9.17.1721607449479; Sun, 21 Jul 2024 17:17:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErTcgERCTX1yip86aFVsMTM9zQ1FTRH83ANvbTXnBpQ2vdFULKucimSOqrY6Rvez7ku0S6sw== X-Received: by 2002:a05:600c:4f45:b0:426:6f0e:a60 with SMTP id 5b1f17b1804b1-427dc529c91mr30252185e9.17.1721607448879; Sun, 21 Jul 2024 17:17:28 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d6901781sm105984705e9.14.2024.07.21.17.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:28 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?q?Cl=C3=A9ment?= Mathieu--Drif , Yi Liu , Zhenzhong Duan , Minwoo Im , Jason Wang , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 18/63] intel_iommu: fix FRCD construction macro 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Clément Mathieu--Drif The constant must be unsigned, otherwise the two's complement overrides the other fields when a PASID is present. Fixes: 1b2b12376c8a ("intel-iommu: PASID support") Signed-off-by: Clément Mathieu--Drif Reviewed-by: Yi Liu Reviewed-by: Zhenzhong Duan Reviewed-by: Minwoo Im Message-Id: <20240709142557.317271-2-clement.mathieu--drif@eviden.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index f8cf99bddf..cbc4030031 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -267,7 +267,7 @@ /* For the low 64-bit of 128-bit */ #define VTD_FRCD_FI(val) ((val) & ~0xfffULL) #define VTD_FRCD_PV(val) (((val) & 0xffffULL) << 40) -#define VTD_FRCD_PP(val) (((val) & 0x1) << 31) +#define VTD_FRCD_PP(val) (((val) & 0x1ULL) << 31) #define VTD_FRCD_IR_IDX(val) (((val) & 0xffffULL) << 48) /* DMA Remapping Fault Conditions */ From patchwork Mon Jul 22 00:17: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: 13738159 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 80092C3DA7E for ; Mon, 22 Jul 2024 00:23:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkG-0004lF-T6; Sun, 21 Jul 2024 20:17:40 -0400 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 1sVgkE-0004d0-Rb for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:38 -0400 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 1sVgkD-0005mH-5i for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607456; 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=Kj1I/08pd2fWVIr2fyGlScWsVaYM95BuB4yW1kFmRKk=; b=jFKpmV7/xLs0nS81xkHgE75VGKbA5G4t0inEehdfkNJu6DklDXg0PuPx/5vlVLsscdcLda ntKtfymoWER9R0RK5+n277oHkOslKFEW1V9yvF4soj3hwzLnL8JH7tYgCh1DIAEJF/06pg GD9DUCSukTsIiJIbMNUv5uYy5Cp3EFg= 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-433-jJopziRlODWWH4sjWJToTQ-1; Sun, 21 Jul 2024 20:17:33 -0400 X-MC-Unique: jJopziRlODWWH4sjWJToTQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-42725d3ae3eso27669245e9.3 for ; Sun, 21 Jul 2024 17:17:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607452; x=1722212252; 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=Kj1I/08pd2fWVIr2fyGlScWsVaYM95BuB4yW1kFmRKk=; b=kcIpAu1684WwDDJFe494jz9jTD9CrsOZF/GAeGlnBvpr8J2+d0FVqmDEUhQzg5dd7T hMgw3pziHqnKOKh+5uVfKqxgg7jcQ2N3jzw8hxw9ouBuLSQmJFHevzn6kPq/zlAR4BAC mZm1et1xOEfu1R8t8dpH6kBQhWQgbOH3ZLBHYfLHfNfyLOE53mntw0vvhWbh850hV5+e YYDn1ycmJBRY3sIVL3lq0SR1+L6WuQZZ8R1I8JhOM78tQ4Se1AUhxxR1hrwTu9FYhWww TLIEZvVEwx+yOGCjWWsNnKq5/qz9R10v+tYejKAaS69Lf5cY44yWlSyJ+8R2J/FLggNo Yi+Q== X-Gm-Message-State: AOJu0YxTsGuIQplPnUYC4q4P+u26y4SehCbmWrMYSf8KgCbCWufYAS6W 4IGV3CvKBIDrjMNovm+y7xn5Fw82BzUsOpYs1llsvvmhzC1PYE3H99rvZvtp5UVpjbhQApnSZJo KOQrfW/PYMiIFzBMLIHg2ykahpjzgC5ROdiMMxdGvX9nR23LAl4Nx8KxWa8s3ylE9Txln9D1QJP lPvZA0tu2wEraf/YgQ7EWOAyAD6M5n8Q== X-Received: by 2002:a05:600c:4506:b0:426:6157:7ad3 with SMTP id 5b1f17b1804b1-427dc524d30mr31190695e9.19.1721607451917; Sun, 21 Jul 2024 17:17:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0/AfmVnPXaQvyme9KTq90TTEdPEvgb+Hp/7nQjdJ0PUxbp5XBMyeNiHGulFfEikaiYC0hmA== X-Received: by 2002:a05:600c:4506:b0:426:6157:7ad3 with SMTP id 5b1f17b1804b1-427dc524d30mr31190495e9.19.1721607451380; Sun, 21 Jul 2024 17:17:31 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d69019a5sm105703575e9.18.2024.07.21.17.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:30 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?q?Cl=C3=A9ment?= Mathieu--Drif , Minwoo Im , Yi Liu , Jason Wang , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 19/63] intel_iommu: move VTD_FRCD_PV and VTD_FRCD_PP declarations Message-ID: <3a23554f91c01cf75705a36a5eed3ebef6636d41.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Clément Mathieu--Drif These 2 macros are for high 64-bit of the FRCD registers. Declarations have to be moved accordingly. Signed-off-by: Clément Mathieu--Drif Reviewed-by: Minwoo Im Reviewed-by: Yi Liu Message-Id: <20240709142557.317271-3-clement.mathieu--drif@eviden.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index cbc4030031..faea23e8d6 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -264,10 +264,10 @@ #define VTD_FRCD_FR(val) (((val) & 0xffULL) << 32) #define VTD_FRCD_SID_MASK 0xffffULL #define VTD_FRCD_SID(val) ((val) & VTD_FRCD_SID_MASK) -/* For the low 64-bit of 128-bit */ -#define VTD_FRCD_FI(val) ((val) & ~0xfffULL) #define VTD_FRCD_PV(val) (((val) & 0xffffULL) << 40) #define VTD_FRCD_PP(val) (((val) & 0x1ULL) << 31) +/* For the low 64-bit of 128-bit */ +#define VTD_FRCD_FI(val) ((val) & ~0xfffULL) #define VTD_FRCD_IR_IDX(val) (((val) & 0xffffULL) << 48) /* DMA Remapping Fault Conditions */ From patchwork Mon Jul 22 00:17:31 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: 13738172 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 87497C3DA5D for ; Mon, 22 Jul 2024 00:25:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkH-0004oW-L0; Sun, 21 Jul 2024 20:17:41 -0400 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 1sVgkG-0004hu-2R for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:40 -0400 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 1sVgkE-0005mT-0N for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607457; 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=WC1Cgro28U3oLUDw8Qk8X84jYg2eBltkPTuz6OTl0qY=; b=T1YK+n1bzWgO5x5nWLZMqdBCiXx8cAVHi6nYZ1QkJqs1nyp9deN60Iil5hFxJ61qVrvHC6 eCL9w22he07cmHevtMYVemInJ7PzfAMCcqGMO1zcBLuB5s0YmggUzK+fvbDehC5HPQnR6y iFhgz8Q4FnXk8Ul4h74scLkvrON4v/8= 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-695-9-1Z4KQIP8WAZSAi1yvGvg-1; Sun, 21 Jul 2024 20:17:35 -0400 X-MC-Unique: 9-1Z4KQIP8WAZSAi1yvGvg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-368442fef36so2960287f8f.0 for ; Sun, 21 Jul 2024 17:17:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607454; x=1722212254; 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=WC1Cgro28U3oLUDw8Qk8X84jYg2eBltkPTuz6OTl0qY=; b=ia5aaE657XQa3nx/kwzH1qpwnSyd0YqrArGw6bUg4LlUOCPhFBX51/KqEo5ig9HAq2 b4Fj4lFbC9dqSCZZZ69ol160tzAJl8f2cVwEuumPQj4M6+r1IlIO7Qn2o33GJIMRtqq9 6Qwuo+mAcZRjaW9vxpPf7qMD/QbUMxzzh3bB5fWaG+/7xqsZ6bIPKWFN6zNqL10iBGcN 6n/Sp5DE20p3Eju7QqLtEttBmg/D7W1MGCM5zP3nb84msBA7ndjmRGhLQeQLgUGdXano 7/ParfO0IOYpz4Z0y9mf1s42dLoloq0C76ro7c2ap/dRy8f+ST3cVouol4vFmk+CMQVm MI2w== X-Gm-Message-State: AOJu0YxMsFRwfjidKxVFTAz0k+jW6/0XkhxwcsOguuGrnf9LeXYKyZbR qLbl2AVJ90XaTCJSxh3QNZ0QdihdKw4NfcBWqebH4oFewXM0ezSP73N3iQIJb76pB0NbC5doYTC 94qJH8XF7GhXEMSti1B6Bf+yi77zajbMzKKXH8N4wyl7pU6XaLbq8ipX/VYk6MZpWinT3e2mY6a LXEfVQA3njr7FTPtN67phyDFI8S4qzQg== X-Received: by 2002:a5d:64ed:0:b0:368:5e34:4b53 with SMTP id ffacd0b85a97d-369bae39577mr5053411f8f.10.1721607454212; Sun, 21 Jul 2024 17:17:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFhI25xxo5osTRvdNcXeoB9bvPfLQg2AUhQStlCujqDKb/VG+XxYCw1Q57Lft6axRvoWbrdpQ== X-Received: by 2002:a5d:64ed:0:b0:368:5e34:4b53 with SMTP id ffacd0b85a97d-369bae39577mr5053388f8f.10.1721607453623; Sun, 21 Jul 2024 17:17:33 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36878684801sm7066955f8f.11.2024.07.21.17.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:33 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:31 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?q?Cl=C3=A9ment?= Mathieu--Drif , Minwoo Im , Yi Liu , Jason Wang , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 20/63] intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Clément Mathieu--Drif Per the below code, it can overflow as am can be larger than 8 according to the CH 6.5.2.3 IOTLB Invalidate. Use uint64_t to avoid overflows. Fixes: b5a280c00840 ("intel-iommu: add IOTLB using hash table") Signed-off-by: Clément Mathieu--Drif Reviewed-by: Minwoo Im Reviewed-by: Yi Liu Message-Id: <20240709142557.317271-4-clement.mathieu--drif@eviden.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index faea23e8d6..5f32c36943 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -436,7 +436,7 @@ struct VTDIOTLBPageInvInfo { uint16_t domain_id; uint32_t pasid; uint64_t addr; - uint8_t mask; + uint64_t mask; }; typedef struct VTDIOTLBPageInvInfo VTDIOTLBPageInvInfo; From patchwork Mon Jul 22 00:17:33 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: 13738146 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 3CD5CC3DA61 for ; Mon, 22 Jul 2024 00:20:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkL-00052J-ML; Sun, 21 Jul 2024 20:17:45 -0400 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 1sVgkJ-0004tj-0G for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:43 -0400 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 1sVgkH-0005mk-8f for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607459; 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=y5oJRr4r3YF/yxB2ziPoT4Qctv1Z09qYy5SwcSzq9dE=; b=Qp1khyoOFNNaH500RsTgANlv71/iLUavH2Q9CxCSP5TG8fZVBbXV8y9lPWeL+r2eCKwrDk STNQmEg+09NZuzhfNza3e7AH844SsvpvuMDDuUpBOIW2cfL8izXPhoX9x/Bs8dvkXokf7I hFHx8DhFsLjJt3i47xobbMfgUCy3qaU= 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-480-0GBAiiTaNf-TmBFS4uQZvQ-1; Sun, 21 Jul 2024 20:17:37 -0400 X-MC-Unique: 0GBAiiTaNf-TmBFS4uQZvQ-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42725ec6e0aso25422355e9.0 for ; Sun, 21 Jul 2024 17:17:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607456; x=1722212256; 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=y5oJRr4r3YF/yxB2ziPoT4Qctv1Z09qYy5SwcSzq9dE=; b=kbMKPYcYGZVN7Uxc2msm06Rfe2bUBuf3Cj9T3ZaWan+Q0x+PAQ3b40EmT1PIKxySQT 3QnKpQ5gOQWvJdqzdpV/r+wdL1/c4GnxlTlvcdVjshVe6kQPCMnHfiK9H8WUy7rQU5Fj 64gQnAr3QJky9t0HPscaHi4x4fkyJYo5+FRtxckxTm0pWh30Fb2IkRBhJr6K7qJPOtxe 9p3RIZCSUSs1/8do93jOWIDVbhE3DbmKDa5pWT1Fq40vciU+f90UhKXez4JZYfloXAfD SWr3wPTxZwXtUtU0JqRBRsQAyXUsQF9v5+ttvF0KTrzt3+PG7Fz7SVt8iTJZ9/mRbYCi 9IZg== X-Gm-Message-State: AOJu0YzjqI4BVFRtidi6dEKzHrN5cTG9rcH69IaiEObITBJTG4uXlT69 E1xfZq04NQUzOgxAtuO1Y+i0Cvpv/zs/tCMwOktDc7udgmoPgUJmtYxqB+OTDWaZRUVL4pvfPvP otXSEjqrWUHPlc1y3dq+bwMFIEsbKnyi3vKGfzpaJZgbKXZrutjKyFSZ3D2Mw0vjZiYXJ4vWCij Or0bRdpozDkqd/QS6hgn1+11QvYx6P3A== X-Received: by 2002:a05:600c:5129:b0:426:5e91:391e with SMTP id 5b1f17b1804b1-427dc558d2dmr32695225e9.26.1721607456311; Sun, 21 Jul 2024 17:17:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmriSrPMO2X+wYZOHqhPwzm4PwCxaGtLFiAnrJdioaOdaIuckIq37pRMFbSW3gojIom+Y4iQ== X-Received: by 2002:a05:600c:5129:b0:426:5e91:391e with SMTP id 5b1f17b1804b1-427dc558d2dmr32695065e9.26.1721607455829; Sun, 21 Jul 2024 17:17:35 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a63c8dsm134270105e9.20.2024.07.21.17.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:35 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:33 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?q?Cl=C3=A9ment?= Mathieu--Drif , Yi Liu , Jason Wang , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 21/63] intel_iommu: make type match 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Clément Mathieu--Drif The 'level' field in vtd_iotlb_key is an unsigned integer. We don't need to store level as an int in vtd_lookup_iotlb. This is not an issue by itself, but using unsigned here seems cleaner. Signed-off-by: Clément Mathieu--Drif Reviewed-by: Yi Liu Message-Id: <20240709142557.317271-5-clement.mathieu--drif@eviden.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 37c21a0aec..be0cb39b5c 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -358,7 +358,7 @@ static VTDIOTLBEntry *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id, { struct vtd_iotlb_key key; VTDIOTLBEntry *entry; - int level; + unsigned level; for (level = VTD_SL_PT_LEVEL; level < VTD_SL_PML4_LEVEL; level++) { key.gfn = vtd_get_iotlb_gfn(addr, level); From patchwork Mon Jul 22 00:17:36 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: 13738194 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 C7F6AC3DA61 for ; Mon, 22 Jul 2024 00:31:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkT-0005dE-47; Sun, 21 Jul 2024 20:17:53 -0400 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 1sVgkJ-0004vr-Fc for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:43 -0400 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 1sVgkH-0005my-VU for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607461; 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=Hq4UcO9VA6wUCWPh+nsmUKYS4qa8nT+9OsSYlXgNtFk=; b=Y2EJ3wE5QTXmE7bOcNRJuAhkWQg1+FclH4U6pKH42BousPCXhZ9iWFvhiKBxPDgvQvCLnW 70YIpOnuG3N/YD02TBzwd0Z4ciHPBaYrygu4qfpnsGwcD2gtEIzsrfW8+mDIwuw6ampiqA Et8RPtbBvU1tNseIRXwX9QUsyZVxa/M= 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-155-OeoBagRXP3i6ylR6C7YQhw-1; Sun, 21 Jul 2024 20:17:40 -0400 X-MC-Unique: OeoBagRXP3i6ylR6C7YQhw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42794cb8251so27668055e9.2 for ; Sun, 21 Jul 2024 17:17:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607458; x=1722212258; 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=Hq4UcO9VA6wUCWPh+nsmUKYS4qa8nT+9OsSYlXgNtFk=; b=BZVxI+O1XbNiZKhGYtfUPFyQVbY08gx7/Z4sS/chuJid5XQZhYzypZPBXEjAOGIo9j 1KWoV9y5nMnSdEZ3sJOZQ+roSU0OcMwQruSewARPVZQJ6sxTk/BxQK65kOpaWKHhpoyl pD+Kyfe0V8REp2CNlBKN+BJKKHJrd2Pr7TLdvDk3lknPJarywfx4UUkvTL8Y7EbX4SEA ZgWT/HXTdwgmWY65bf0tgat92NbMTaQV3aK8mL7bWoC7T+tpS+VX0eDQ28LprQAODWwD 00Sl4MKUlfl5dpmjIqmh2gXAPb5aZXZNKFV+RjExHlXSIapDmBJANEm0/Aqs3Eni9gTp OVlw== X-Gm-Message-State: AOJu0YxFg55EAI266JMHFQG3XPaFRiwSIlBZVxonXr/haytFy9UEIKDG 2tZZJwa4HVpFL51Vb7oSTnYqxrYMnzq4Am23HKA4QVhhZ9AyB9+6F3dMdqQR4pT22X1/xIIVB7N RFmUEUJgPo275zgqLiecyM2bv8Mi4OmZgBvsVjV1X4kWGLmAo2/WubrqWq2mP1NGsxE8Bh+mD8Q lG4djSGSJJdwuibjsqC+fVC+8wV24Y4w== X-Received: by 2002:a05:600c:1382:b0:426:59fe:ac2d with SMTP id 5b1f17b1804b1-427daa67bf1mr45721625e9.32.1721607458350; Sun, 21 Jul 2024 17:17:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwvFge4rwZI56iLkZl/PCaNan9herVq7KHSmll6AqeFAkQ5nA2CQV89md2XvnhlGsw9BpX+Q== X-Received: by 2002:a05:600c:1382:b0:426:59fe:ac2d with SMTP id 5b1f17b1804b1-427daa67bf1mr45721465e9.32.1721607457770; Sun, 21 Jul 2024 17:17:37 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868b7d9sm7024234f8f.42.2024.07.21.17.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:37 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:36 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?b?UMOpcmV6?= Subject: [PULL 22/63] virtio: Add bool to VirtQueueElement 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Jonah Palmer Add the boolean 'in_order_filled' member to the VirtQueueElement structure. The use of this boolean will signify whether the element has been processed and is ready to be flushed (so long as the element is in-order). This boolean is used to support the VIRTIO_F_IN_ORDER feature. Reviewed-by: Eugenio Pérez Signed-off-by: Jonah Palmer Message-Id: <20240710125522.4168043-2-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 7512afbc84..fdc827f82e 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -69,6 +69,8 @@ typedef struct VirtQueueElement unsigned int ndescs; unsigned int out_num; unsigned int in_num; + /* Element has been processed (VIRTIO_F_IN_ORDER) */ + bool in_order_filled; hwaddr *in_addr; hwaddr *out_addr; struct iovec *in_sg; From patchwork Mon Jul 22 00:17:37 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: 13738175 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 4FBD3C3DA61 for ; Mon, 22 Jul 2024 00:26:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkW-0006AL-1a; Sun, 21 Jul 2024 20:17:56 -0400 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 1sVgkQ-0005XK-H7 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:51 -0400 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 1sVgkN-0005nR-GY for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607465; 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=qR3YDVYd2Wg1NGSld2m3zgomMPSJCBgN770Yvk3JKto=; b=jLd9vTxsDfy3/5krU7qmKxO01yA1Rgkr1d3Gddv9E+EaOlVxuNeM7wkHODrscPAbevElsE ieZvwtoBePzrhSeaD/3rZ12zacBYEZ6YXovtLlz67lDzgsHvII5xk/MYonUaupg1DgZTuR gae5yKpW44hHT0TYJOa8nRbUobi5s28= 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-169-s0_JJ5xfPiuPJ8_vON2Phw-1; Sun, 21 Jul 2024 20:17:44 -0400 X-MC-Unique: s0_JJ5xfPiuPJ8_vON2Phw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42725ef39e2so26912025e9.0 for ; Sun, 21 Jul 2024 17:17:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607460; x=1722212260; 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=qR3YDVYd2Wg1NGSld2m3zgomMPSJCBgN770Yvk3JKto=; b=Tx2Lo0VpfVXPYcR6uRuCT4WP20j4+9FKD59rLC16BCDg52gp85qQb0J8JNeSDM2BnA wFcYxfpqo0QREoDAHunJ1P+GewEQ45LtDRdDslP8yvSqtArVYl4JNciyp8biUXbkRPef OwKXgS5uP1Ocdpr0MH71nUe5YyO0s9skdpPr4HRquMk7JF1GfoLDZvCV8tot+K679/nr zpgAXi4G40u3vjyBSuNWTS1wJwh1Y9Dcx+Cu8d8CHFJhr2Vlpilgdb4HwjQMHPVkKCcU 3QVrjDJch5edKHOyusL1D7qbC0xOBs1JiinzyK8oeXAJ1ImYuju91eGeoY72tGXEUCZ3 E6HQ== X-Gm-Message-State: AOJu0Ywl1z/+VCY4ySlw1rz0wMh7z08oHU4Rfk8nYLibkW+akt3bBGRu hP/kzyE6hob3Mc9PchD+ujMad10H2D/DYf23uTbNALj598kEfs1tEf0U5dZqfn+Iu7IonJjO/Se dIxkwrQf1WgsVsbhmmwjzPXezcoWLaweloakGcYQbZhcqG+uIm1lLRRbnfnkooe2DdSnsb/T7wn EeP1oAgoio40m0b4xVPT+dp/uOZIBtDA== X-Received: by 2002:a05:600c:1547:b0:425:5ec3:570b with SMTP id 5b1f17b1804b1-427dc578efdmr28707605e9.35.1721607460207; Sun, 21 Jul 2024 17:17:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEje2D6euFaTQKRQVbBqxfL0t+RH1yWtfKfyi7Q4xwxL40Wm8Gat+um29Oj2O0ti0ja3MpU3g== X-Received: by 2002:a05:600c:1547:b0:425:5ec3:570b with SMTP id 5b1f17b1804b1-427dc578efdmr28707485e9.35.1721607459701; Sun, 21 Jul 2024 17:17:39 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d6934ec6sm106843415e9.41.2024.07.21.17.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:39 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?b?UMOpcmV6?= Subject: [PULL 23/63] virtio: virtqueue_pop - VIRTIO_F_IN_ORDER support Message-ID: <2256e8482b2bba88abcc734dbc6951b825773f0b.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Jonah Palmer Add VIRTIO_F_IN_ORDER feature support in virtqueue_split_pop and virtqueue_packed_pop. VirtQueueElements popped from the available/descritpor ring are added to the VirtQueue's used_elems array in-order and in the same fashion as they would be added the used and descriptor rings, respectively. This will allow us to keep track of the current order, what elements have been written, as well as an element's essential data after being processed. Reviewed-by: Eugenio Pérez Signed-off-by: Jonah Palmer Message-Id: <20240710125522.4168043-3-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 583a224163..98eb601b09 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1505,7 +1505,7 @@ static void *virtqueue_alloc_element(size_t sz, unsigned out_num, unsigned in_nu static void *virtqueue_split_pop(VirtQueue *vq, size_t sz) { - unsigned int i, head, max; + unsigned int i, head, max, idx; VRingMemoryRegionCaches *caches; MemoryRegionCache indirect_desc_cache; MemoryRegionCache *desc_cache; @@ -1629,6 +1629,13 @@ static void *virtqueue_split_pop(VirtQueue *vq, size_t sz) elem->in_sg[i] = iov[out_num + i]; } + if (virtio_vdev_has_feature(vdev, VIRTIO_F_IN_ORDER)) { + idx = (vq->last_avail_idx - 1) % vq->vring.num; + vq->used_elems[idx].index = elem->index; + vq->used_elems[idx].len = elem->len; + vq->used_elems[idx].ndescs = elem->ndescs; + } + vq->inuse++; trace_virtqueue_pop(vq, elem, elem->in_num, elem->out_num); @@ -1762,6 +1769,13 @@ static void *virtqueue_packed_pop(VirtQueue *vq, size_t sz) elem->index = id; elem->ndescs = (desc_cache == &indirect_desc_cache) ? 1 : elem_entries; + + if (virtio_vdev_has_feature(vdev, VIRTIO_F_IN_ORDER)) { + vq->used_elems[vq->last_avail_idx].index = elem->index; + vq->used_elems[vq->last_avail_idx].len = elem->len; + vq->used_elems[vq->last_avail_idx].ndescs = elem->ndescs; + } + vq->last_avail_idx += elem->ndescs; vq->inuse += elem->ndescs; From patchwork Mon Jul 22 00:17:39 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: 13738153 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 64F05C3DA5D for ; Mon, 22 Jul 2024 00:21:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkX-0006GJ-4u; Sun, 21 Jul 2024 20:17:57 -0400 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 1sVgkP-0005UG-Lu for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:51 -0400 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 1sVgkN-0005nP-Fm for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607465; 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=c/XwQGLmqpOnXFp7/p1VkjvkoBY6YC9rGIfU0QombD0=; b=cV1EDsLfKftHtTaKRy2dS2i4t+bttodTBVImOzNYseZAZBl0bsComtMN/ePQ02+XbvX+WT CgDE+WdL+W4rDIEVaxpbcKk5oZ+HPTTgazEpz9rZPGvdnMryZq1khxnloegIFV0jnTyTv7 4PCCsifPRvXWl5x+w/SPPmeU3p75vnU= 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-311-mkhygVVhMSGSN0DXmumMUw-1; Sun, 21 Jul 2024 20:17:44 -0400 X-MC-Unique: mkhygVVhMSGSN0DXmumMUw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42668857c38so27733565e9.1 for ; Sun, 21 Jul 2024 17:17:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607462; x=1722212262; 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=c/XwQGLmqpOnXFp7/p1VkjvkoBY6YC9rGIfU0QombD0=; b=hs6RFPuJouLjzqfpgiOX9O4q3qoB/ngPahtfDAa7yFR2Fx7wKTtmNzaKPKFtPe6HAA RTx2FQurx2It4kRjkXe2lFgf+07/UBSprmcBzymCjw3rZQfYBj/uL38KWNMIvn8+US4J LVM/+EIRDXXfh+wUqYeuu13sPII68Vd3ooqQYIpLhbe5EFhZxHJcvi2wQdwX4/QzJ1sr r5pXUWvGFzY288H3xpOdvNMbhwQ4wr7KbeOV2UkNSG3wSX8sTIQ3op+bBAAuj41JaJ+r e+EHaoNnyvsiBcyU5FGJ+ayJQicrm5CP+FrpteHAwBhidz+zu14KbgMSWoGSZxrCIjnE +v8A== X-Gm-Message-State: AOJu0YxPf94Q3gEGC4Z8mCtYYiMRATKX666J8pbxchEc1qYGuscEqNS7 Mxi0P5z6+q5U88+8Cem2bvCuIGymZjp4lHr67pZ/P4rXRn272IcEKb4bQCtEoMa9sWmohFCKTbH dmoBFTi6bLOzeop6IqtUnwn3f3ukRX5GnEWEAqmjfcHnFWzg0M9nqCIBx8eOSOKzj8rr6xCtdrE Ba/Gbr+mjMVevitTpepYqTMODL3dEyqg== X-Received: by 2002:a5d:4e49:0:b0:368:4e4f:cec5 with SMTP id ffacd0b85a97d-369bae2512fmr3157333f8f.35.1721607462356; Sun, 21 Jul 2024 17:17:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEI0hcKUSqjqAPe3LpGpBgRRLTIFf68etQr4hG7y1zIoqyZNvpLZgqNuqa9ti212/xeQtGQzw== X-Received: by 2002:a5d:4e49:0:b0:368:4e4f:cec5 with SMTP id ffacd0b85a97d-369bae2512fmr3157319f8f.35.1721607461659; Sun, 21 Jul 2024 17:17:41 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368786943d3sm7034880f8f.50.2024.07.21.17.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:41 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?b?UMOpcmV6?= Subject: [PULL 24/63] virtio: virtqueue_ordered_fill - VIRTIO_F_IN_ORDER 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.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Jonah Palmer Add VIRTIO_F_IN_ORDER feature support for the virtqueue_fill operation. The goal of the virtqueue_ordered_fill operation when the VIRTIO_F_IN_ORDER feature has been negotiated is to search for this now-used element, set its length, and mark the element as filled in the VirtQueue's used_elems array. By marking the element as filled, it will indicate that this element has been processed and is ready to be flushed, so long as the element is in-order. Reviewed-by: Eugenio Pérez Signed-off-by: Jonah Palmer Message-Id: <20240710125522.4168043-4-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 98eb601b09..0000a7b41c 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -872,6 +872,46 @@ static void virtqueue_packed_fill(VirtQueue *vq, const VirtQueueElement *elem, vq->used_elems[idx].ndescs = elem->ndescs; } +static void virtqueue_ordered_fill(VirtQueue *vq, const VirtQueueElement *elem, + unsigned int len) +{ + unsigned int i, steps, max_steps; + + i = vq->used_idx % vq->vring.num; + steps = 0; + /* + * We shouldn't need to increase 'i' by more than the distance + * between used_idx and last_avail_idx. + */ + max_steps = (vq->last_avail_idx - vq->used_idx) % vq->vring.num; + + /* Search for element in vq->used_elems */ + while (steps <= max_steps) { + /* Found element, set length and mark as filled */ + if (vq->used_elems[i].index == elem->index) { + vq->used_elems[i].len = len; + vq->used_elems[i].in_order_filled = true; + break; + } + + i += vq->used_elems[i].ndescs; + steps += vq->used_elems[i].ndescs; + + if (i >= vq->vring.num) { + i -= vq->vring.num; + } + } + + /* + * We should be able to find a matching VirtQueueElement in + * used_elems. If we don't, this is an error. + */ + if (steps >= max_steps) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: %s cannot fill buffer id %u\n", + __func__, vq->vdev->name, elem->index); + } +} + static void virtqueue_packed_fill_desc(VirtQueue *vq, const VirtQueueElement *elem, unsigned int idx, @@ -922,7 +962,9 @@ void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem, return; } - if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED)) { + if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_IN_ORDER)) { + virtqueue_ordered_fill(vq, elem, len); + } else if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED)) { virtqueue_packed_fill(vq, elem, len, idx); } else { virtqueue_split_fill(vq, elem, len, idx); From patchwork Mon Jul 22 00:17:41 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: 13738141 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 6B986C3DA61 for ; Mon, 22 Jul 2024 00:19:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkU-000613-TZ; Sun, 21 Jul 2024 20:17:54 -0400 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 1sVgkQ-0005Z3-Vc for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:51 -0400 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 1sVgkP-0005nh-02 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607467; 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=qh9R5tJPsU6nQaE9x9stYdkZI3361sYm/2KiRgpRciY=; b=c54RqwRuQpaNNIXdoFJQ/SHjNekZ0ywyuU+vaZnk5tVQA56PENBz+TpNAxqS+5V/KvrKpl naa71TYl4as7IwJjDLSdbEnQsQsmgari59eMhlPKQrPBiJ6w0q4mwiMMycnbYyWJc/ehWh GQ+4QlrAudTadobVE1TnUw6JTa24iDw= 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-381-hVi_YfOnM_e9a_IX8GAmCw-1; Sun, 21 Jul 2024 20:17:45 -0400 X-MC-Unique: hVi_YfOnM_e9a_IX8GAmCw-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-36831873b39so1861898f8f.1 for ; Sun, 21 Jul 2024 17:17:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607464; x=1722212264; 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=qh9R5tJPsU6nQaE9x9stYdkZI3361sYm/2KiRgpRciY=; b=cdRGnErZJBDmLBhKqb2mppWU214kABYng8PB1+IhV/Z3OIhE1coyMcbPOm01u7s38v LbuQRvXpu2SOYkLyAgHZkg9ZiCDgyISVMFx4ahnOwgiOVocXgOg8tK/u6UGxKgq2tz1B yLiu2Z1UK5ieoTolSFn3CRzH6/pyzM4ykgW/vR/2EofsRVRsoEGX0ylk3fENrUhqZU2u m/IMT/7J77Q6C+k0cxfrPnddRas6B+FaBsxBHJzWADIYn3Eeb+itsnJGXukM8Udtdck4 +tkSjwHayLHfgPyt+qAflV5EOpuTEXyYjkkGeQ5Ss6NyhMAV1MIV66ng7/+A4XXgm+ws OOng== X-Gm-Message-State: AOJu0YybcIZH1fhnXEYcR9QzGXWFZHaWdkWAkN2DF7Jjm+5CxOvqsHTi woBxlKGr3iSWsRovnq3u5F3Az14VvsIYNbftrEXu5/oCGn2IFQ6WqyosQTKWo7ZVS7AUmKnLy3m Dyay9lK3i9q/fL1+tj7gvVHNDMjmYytOP/XzhmofHEy9eW3y3AjNSAO00EuoLldXSMDfeYV87WS Em/KkCyGa3vsLQWCfsnjyctCEV1VYTnA== X-Received: by 2002:a5d:5441:0:b0:368:37d5:3f2e with SMTP id ffacd0b85a97d-36837d53fdcmr8248834f8f.32.1721607464433; Sun, 21 Jul 2024 17:17:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjcErND1fbND0ixpQbnVRCuRdnwW/Dwtjo26+SmsSamirHgBekXhlee7K8TbSQke9dxftQLQ== X-Received: by 2002:a5d:5441:0:b0:368:37d5:3f2e with SMTP id ffacd0b85a97d-36837d53fdcmr8248823f8f.32.1721607463652; Sun, 21 Jul 2024 17:17:43 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787ced33sm7052068f8f.86.2024.07.21.17.17.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:43 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:41 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?b?UMOpcmV6?= Subject: [PULL 25/63] virtio: virtqueue_ordered_flush - VIRTIO_F_IN_ORDER support Message-ID: <844619147c5110f335cbbbad51cda6a898c7ef33.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Jonah Palmer Add VIRTIO_F_IN_ORDER feature support for the virtqueue_flush operation. The goal of the virtqueue_ordered_flush operation when the VIRTIO_F_IN_ORDER feature has been negotiated is to write elements to the used/descriptor ring in-order and then update used_idx. The function iterates through the VirtQueueElement used_elems array in-order starting at vq->used_idx. If the element is valid (filled), the element is written to the used/descriptor ring. This process continues until we find an invalid (not filled) element. For packed VQs, the first entry (at vq->used_idx) is written to the descriptor ring last so the guest doesn't see any invalid descriptors. If any elements were written, the used_idx is updated. Signed-off-by: Jonah Palmer Message-Id: <20240710125522.4168043-5-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Eugenio Pérez --- hw/virtio/virtio.c | 71 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 0000a7b41c..397c261c3c 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1023,6 +1023,73 @@ static void virtqueue_packed_flush(VirtQueue *vq, unsigned int count) } } +static void virtqueue_ordered_flush(VirtQueue *vq) +{ + unsigned int i = vq->used_idx % vq->vring.num; + unsigned int ndescs = 0; + uint16_t old = vq->used_idx; + uint16_t new; + bool packed; + VRingUsedElem uelem; + + packed = virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED); + + if (packed) { + if (unlikely(!vq->vring.desc)) { + return; + } + } else if (unlikely(!vq->vring.used)) { + return; + } + + /* First expected in-order element isn't ready, nothing to do */ + if (!vq->used_elems[i].in_order_filled) { + return; + } + + /* Search for filled elements in-order */ + while (vq->used_elems[i].in_order_filled) { + /* + * First entry for packed VQs is written last so the guest + * doesn't see invalid descriptors. + */ + if (packed && i != vq->used_idx) { + virtqueue_packed_fill_desc(vq, &vq->used_elems[i], ndescs, false); + } else if (!packed) { + uelem.id = vq->used_elems[i].index; + uelem.len = vq->used_elems[i].len; + vring_used_write(vq, &uelem, i); + } + + vq->used_elems[i].in_order_filled = false; + ndescs += vq->used_elems[i].ndescs; + i += vq->used_elems[i].ndescs; + if (i >= vq->vring.num) { + i -= vq->vring.num; + } + } + + if (packed) { + virtqueue_packed_fill_desc(vq, &vq->used_elems[vq->used_idx], 0, true); + vq->used_idx += ndescs; + if (vq->used_idx >= vq->vring.num) { + vq->used_idx -= vq->vring.num; + vq->used_wrap_counter ^= 1; + vq->signalled_used_valid = false; + } + } else { + /* Make sure buffer is written before we update index. */ + smp_wmb(); + new = old + ndescs; + vring_used_idx_set(vq, new); + if (unlikely((int16_t)(new - vq->signalled_used) < + (uint16_t)(new - old))) { + vq->signalled_used_valid = false; + } + } + vq->inuse -= ndescs; +} + void virtqueue_flush(VirtQueue *vq, unsigned int count) { if (virtio_device_disabled(vq->vdev)) { @@ -1030,7 +1097,9 @@ void virtqueue_flush(VirtQueue *vq, unsigned int count) return; } - if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED)) { + if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_IN_ORDER)) { + virtqueue_ordered_flush(vq); + } else if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED)) { virtqueue_packed_flush(vq, count); } else { virtqueue_split_flush(vq, count); From patchwork Mon Jul 22 00:17: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: 13738178 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 91767C3DA61 for ; Mon, 22 Jul 2024 00:27:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkd-0006to-35; Sun, 21 Jul 2024 20:18:03 -0400 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 1sVgkU-0005zq-JX for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:54 -0400 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 1sVgkS-0005oQ-WD for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607471; 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=q0Npoi3B/pjRdsmZv/oBnj6YQVo4m4QtFoQ2kZEEzmA=; b=HXpGrA/N6nq6qujW1wirLS1Iz2/ATyg6ufXal2ntbFDPMFWAO2al9AR++ze9XaFJO5hJFW 0B2m00wQpwDf7WDMN+VM68CoYtGGNMlE1ZHDqaZ/cM+MQoPyYZrwJ8xiYlnqXsCtH4JJxf +SylT+uj4dHw6MwlwM0ZTnyjcxOm2to= 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-447-QZPpxJ0gMyeQT9k_5wwDuA-1; Sun, 21 Jul 2024 20:17:48 -0400 X-MC-Unique: QZPpxJ0gMyeQT9k_5wwDuA-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-367962f0cb0so2112067f8f.1 for ; Sun, 21 Jul 2024 17:17:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607467; x=1722212267; 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=q0Npoi3B/pjRdsmZv/oBnj6YQVo4m4QtFoQ2kZEEzmA=; b=qw82qnSNyRUmS7GLwHwFItjjcMv6Q8PRcp1ncA73/4s0cOy4YYP6C1dIcinbPnjViU qUNNPAyJ24vSCxHGa09Ab9hFs3JKoyppfONA8A7mLtaZP1QNvWyp6WZfqEHCprbsI+f7 atrobemUlFWdC4qfpuoPm3sb1Pt6b3XMWy9q8Sl3ENwI7P88l5knp/NErWCOk6iqhFpJ dzIJL2nYnKfjIg6PrXxtvdJisV5jC85iKsb8a5sSJji+S5bjsyS8I/h62vCEwPVaS+Is OD+xWED/e8DaoqN2crcvri7lmeGdrayoeA80IuxPYJqPF+6LsC/Sp/h6a0p7smO0gLhr JZeA== X-Gm-Message-State: AOJu0Yx6J2PGqFIAc57vsX1/YEWM/QtzZ8bmj5nUgiCxUy2bPb3aqKX9 wctpiTVIGC7VivsA+NxVb40bZ454Hbb+d/NqkxpLD9Ty2l39EWR4Na6WoXjzaSRNLuYwP/vW98E WR8/GqINhdvIqDiAlrEo7u9D5NtzGpc2YzAw9muYrD/AlsIZ8walz+Ou2v8+7hCoJJBr6iYQ+GZ biKZpDBEtJIRXFaXy9ECGnlirZS5S/1g== X-Received: by 2002:a05:6000:2c5:b0:367:340e:d6e6 with SMTP id ffacd0b85a97d-369bae6b60fmr3663983f8f.41.1721607466771; Sun, 21 Jul 2024 17:17:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyCGS6cMtVG4huKFXj5jl7hY2dhn1IKxyz+6NWtnQ2nMWq5dn/i/i8MurQn4yijHcgSgejLQ== X-Received: by 2002:a05:6000:2c5:b0:367:340e:d6e6 with SMTP id ffacd0b85a97d-369bae6b60fmr3663962f8f.41.1721607466210; Sun, 21 Jul 2024 17:17:46 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787ed5adsm6960164f8f.109.2024.07.21.17.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:45 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?b?UMOpcmV6?= , Raphael Norwitz , Stefano Garzarella , Kevin Wolf , Hanna Reitz , Jason Wang , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , qemu-block@nongnu.org, virtio-fs@lists.linux.dev Subject: [PULL 26/63] vhost,vhost-user: Add VIRTIO_F_IN_ORDER to vhost feature bits 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Jonah Palmer Add support for the VIRTIO_F_IN_ORDER feature across a variety of vhost devices. The inclusion of VIRTIO_F_IN_ORDER in the feature bits arrays for these devices ensures that the backend is capable of offering and providing support for this feature, and that it can be disabled if the backend does not support it. Acked-by: Eugenio Pérez Signed-off-by: Jonah Palmer Message-Id: <20240710125522.4168043-6-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/block/vhost-user-blk.c | 1 + hw/net/vhost_net.c | 2 ++ hw/scsi/vhost-scsi.c | 1 + hw/scsi/vhost-user-scsi.c | 1 + hw/virtio/vhost-user-fs.c | 1 + hw/virtio/vhost-user-vsock.c | 1 + net/vhost-vdpa.c | 1 + 7 files changed, 8 insertions(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index fdbc30b9ce..5b7f46bbb0 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -51,6 +51,7 @@ static const int user_feature_bits[] = { VIRTIO_F_RING_PACKED, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_RESET, + VIRTIO_F_IN_ORDER, VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 18898afe81..a788e6937e 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -48,6 +48,7 @@ static const int kernel_feature_bits[] = { VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, VIRTIO_F_RING_RESET, + VIRTIO_F_IN_ORDER, VIRTIO_F_NOTIFICATION_DATA, VIRTIO_NET_F_HASH_REPORT, VHOST_INVALID_FEATURE_BIT @@ -78,6 +79,7 @@ static const int user_feature_bits[] = { VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, VIRTIO_F_RING_RESET, + VIRTIO_F_IN_ORDER, VIRTIO_NET_F_RSS, VIRTIO_NET_F_HASH_REPORT, VIRTIO_NET_F_GUEST_USO4, diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 3d5fe0994d..49cff2a0cb 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -38,6 +38,7 @@ static const int kernel_feature_bits[] = { VIRTIO_RING_F_EVENT_IDX, VIRTIO_SCSI_F_HOTPLUG, VIRTIO_F_RING_RESET, + VIRTIO_F_IN_ORDER, VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index cc91ade525..55e4be5b34 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -36,6 +36,7 @@ static const int user_feature_bits[] = { VIRTIO_RING_F_EVENT_IDX, VIRTIO_SCSI_F_HOTPLUG, VIRTIO_F_RING_RESET, + VIRTIO_F_IN_ORDER, VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index ae48cc1c96..32ee7f496d 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -33,6 +33,7 @@ static const int user_feature_bits[] = { VIRTIO_F_RING_PACKED, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_RESET, + VIRTIO_F_IN_ORDER, VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 802b44a07d..da3b0e0229 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -21,6 +21,7 @@ static const int user_feature_bits[] = { VIRTIO_RING_F_INDIRECT_DESC, VIRTIO_RING_F_EVENT_IDX, VIRTIO_F_NOTIFY_ON_EMPTY, + VIRTIO_F_IN_ORDER, VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index daa38428c5..03457ead66 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -62,6 +62,7 @@ const int vdpa_feature_bits[] = { VIRTIO_F_RING_PACKED, VIRTIO_F_RING_RESET, VIRTIO_F_VERSION_1, + VIRTIO_F_IN_ORDER, VIRTIO_F_NOTIFICATION_DATA, VIRTIO_NET_F_CSUM, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, From patchwork Mon Jul 22 00:17:46 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: 13738188 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 A5501C3DA5D for ; Mon, 22 Jul 2024 00:28:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkZ-0006Wr-Og; Sun, 21 Jul 2024 20:17:59 -0400 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 1sVgkV-00066r-9m for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:55 -0400 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 1sVgkT-0005oX-B4 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607472; 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=DoP8zpcWwKhsBbn/dEN5fS4FX6tEBJxOhfXfCwMS67w=; b=jQt9Ee1BKVxosGHEgJgI3ok4MsXevqOQaBexdahO8dxELjeSSFMgQ6ppQUMqX3nrrtj0yY 5XGe/EYeVM1+cowwL6sKrIF8jrcvY0yeWxNZrr9tXYGEQ2vfUeXlam7tRTDy1hpKZ2TJwX q3FTMpyfw/bLAIgRuEYs9lfMUjzjQDc= 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-524-FggoodaAMDmBBq5Qa4aLig-1; Sun, 21 Jul 2024 20:17:50 -0400 X-MC-Unique: FggoodaAMDmBBq5Qa4aLig-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-427df7c3a2aso8282805e9.1 for ; Sun, 21 Jul 2024 17:17:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607468; x=1722212268; 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=DoP8zpcWwKhsBbn/dEN5fS4FX6tEBJxOhfXfCwMS67w=; b=MIokNB+dAWXyKXPA5ZTxgV8e/ro24xuvZH1GEJv5uh8NaTy8M2KYLgUr7B3oFyWS4M m4ELjofnWXXIqRyA+di2pbVf2BlRHfEr5zA8/JIr+16tD6VOKGcEka3oRhhyv2qZFEBn LJ3jaOicA8k+a3eTpE3RylRGhJ35iWzAZlll+od4tS/XlUXwn0dtDV5DXbWmJctsN9+f 7iMEjKZCIS1Pk9PLrkCa+GO0jrPQ4xXPL18SaZfjkfXp2Y+yXMovYcLulLSp1nwh7LJK 98ZLczl3B69vNG9SAQvQJ6z3kYsrLxYqWM85bcAYFSY3LWa9NhjB4leZVgnoeoU+SXBB YieA== X-Gm-Message-State: AOJu0YywvGYzSaChkcdGdGJwXZHQryv82Q4saEOVe/meNUjJm6krCXYi Vde5oKmD26/KFjUHduLRU/RX4VN5cHtWRMztHjiiYaeI6cIJxFZ4jE5+MsOnds4c/OKtJLKzxdo q0RnXa+yj2LEm4k68H33pjA7+vvQLZkW6l7uBZYqufC/YBDAxO8klBtPnfeLQI36w4pi4CdL78X Ip7A0reWi0qb4DRVv6FbQk2Pw2iMJrhA== X-Received: by 2002:a05:600c:45ce:b0:426:63b4:73b0 with SMTP id 5b1f17b1804b1-427dc578924mr33154185e9.34.1721607468669; Sun, 21 Jul 2024 17:17:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8vGqR+6paOoX3WFlbtQkcPhOJkEXiY8yAI9yDoCw0uVZxpX+/1DUpo+4dnCgTIzHW/oGFKg== X-Received: by 2002:a05:600c:45ce:b0:426:63b4:73b0 with SMTP id 5b1f17b1804b1-427dc578924mr33154045e9.34.1721607468119; Sun, 21 Jul 2024 17:17:48 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8d930sm133904045e9.32.2024.07.21.17.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:47 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:46 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?b?UMOpcmV6?= Subject: [PULL 27/63] virtio: Add VIRTIO_F_IN_ORDER property definition Message-ID: <0b0bb34f342f04ab8255a64edb7c6aec7105dc94.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Jonah Palmer Extend the virtio device property definitions to include the VIRTIO_F_IN_ORDER feature. The default state of this feature is disabled, allowing it to be explicitly enabled where it's supported. Acked-by: Eugenio Pérez Signed-off-by: Jonah Palmer Message-Id: <20240710125522.4168043-7-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index fdc827f82e..d2a1938757 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -373,7 +373,9 @@ typedef struct VirtIORNGConf VirtIORNGConf; DEFINE_PROP_BIT64("packed", _state, _field, \ VIRTIO_F_RING_PACKED, false), \ DEFINE_PROP_BIT64("queue_reset", _state, _field, \ - VIRTIO_F_RING_RESET, true) + VIRTIO_F_RING_RESET, true), \ + DEFINE_PROP_BIT64("in_order", _state, _field, \ + VIRTIO_F_IN_ORDER, false) hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n); bool virtio_queue_enabled_legacy(VirtIODevice *vdev, int n); From patchwork Mon Jul 22 00:17: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: 13738143 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 A69BBC3DA61 for ; Mon, 22 Jul 2024 00:19:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkb-0006lJ-DW; Sun, 21 Jul 2024 20:18:01 -0400 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 1sVgkY-0006Lt-10 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:58 -0400 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 1sVgkW-0005ot-I5 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607475; 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=RbreE3gRMg3HkdLWMl2uNhF2Or3FkZXwY0kwp8ati68=; b=HvwmU7w5HoDnZs42uxB2Bxiitw7mtfU73fd8T7Q8QTDgAKqEvCKZu60pHq6rHY2ked5sJs L3nJ77YCjmlTjPdiHHiuwoIwkFe2xKFKIzGr8gNbggsw7fplytAJFiuxa9eersW3yJNnV+ wiqLiay3tfC8LvK5FEMF9Qes1XyRgfg= 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-477-r6xD_lWiNQCrUiv5ATiWjg-1; Sun, 21 Jul 2024 20:17:52 -0400 X-MC-Unique: r6xD_lWiNQCrUiv5ATiWjg-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-369bf135b49so665206f8f.0 for ; Sun, 21 Jul 2024 17:17:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607471; x=1722212271; 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=RbreE3gRMg3HkdLWMl2uNhF2Or3FkZXwY0kwp8ati68=; b=YzoUu4GD5XIBc03Fn6MtXBdMQn3cwumd+whR7Ultap4eKiXx6FzeJdJjcmKPh49dlf RzNDOX1uk8aTyQP0+s3Gd8IPVlayHcxyzjNyTG0ENN43JeOcg72cAEdkcc/R7LmzstTR hzIv5niwvru1s0f5FQyHfcM/n9kso6lbeCFTuNDD86N7NqI/H2f0/zPjyTsH/5+hMfZ4 56h6PMDo5HDWiZGuQ5laPpOfI6FpxLkws4KNH7Zz7Nr93BhK+CrGkKr3XKG1qm30srTU Q7JYjCd96eJs7Sw5ZIzMvp2hIe5aQrIEJ8xKKnG1gFbS+B7nLFjbpscX/QwtADQxYwMJ dN7w== X-Gm-Message-State: AOJu0Yz8Pag2tP6JsGRXafxYWJ4qI/3iMrMy9bKE+kNGymXogCGfMK4J EtLap0/r2qi3j2zjrtWfblM7drVMKczyDPrCfPJ9R3UYja9R7TV46q9bIh+XG1xP0vT16ZDGsFv y+y0NGfKnv3sYyWcLrs4u7I39+neyG4rw4j7aRYbWma/LLKigB87KbZe4VeKp500ZAgh5pDtGi4 JwnkwTPjU72U70sxkQmMdpuZV7W3ieyQ== X-Received: by 2002:adf:ef02:0:b0:368:35b8:129e with SMTP id ffacd0b85a97d-36873ed7c49mr4990094f8f.13.1721607470835; Sun, 21 Jul 2024 17:17:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMr+xClpJWFy3DqUbuV6wkHl7tYSkOhCuLKOaeCVEsVlkB6uE2ZqPBS/Voc9BN0tX6PU98EA== X-Received: by 2002:adf:ef02:0:b0:368:35b8:129e with SMTP id ffacd0b85a97d-36873ed7c49mr4990079f8f.13.1721607470242; Sun, 21 Jul 2024 17:17:50 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868bc42sm7025824f8f.46.2024.07.21.17.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:49 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , changpeng.liu@intel.com, Raphael Norwitz Subject: [PULL 28/63] contrib/vhost-user-blk: fix overflowing expression Message-ID: <99d7c1b99a3fdb69213c09da6b7614243f877bee.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Stefano Garzarella Coverity reported: >>> CID 1549454: Integer handling issues (OVERFLOW_BEFORE_WIDEN) >>> Potentially overflowing expression "le32_to_cpu(desc->num_sectors) << 9" with type "uint32_t" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "uint64_t" (64 bits, unsigned). 199 le32_to_cpu(desc->num_sectors) << 9 }; Coverity noticed this issue after commit ab04420c3 ("contrib/vhost-user-*: use QEMU bswap helper functions"), but it was pre-existing and introduced from the beginning by commit caa1ee4313 ("vhost-user-blk: add discard/write zeroes features support"). Explicitly cast the 32-bit value before the shift to fix this issue. Fixes: Coverity CID 1549454 Fixes: 5ab04420c3 ("contrib/vhost-user-*: use QEMU bswap helper functions") Fixes: caa1ee4313 ("vhost-user-blk: add discard/write zeroes features support") Cc: changpeng.liu@intel.com Suggested-by: Peter Maydell Signed-off-by: Stefano Garzarella Message-Id: <20240712153857.207440-1-sgarzare@redhat.com> Reviewed-by: Peter Maydell Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/vhost-user-blk/vhost-user-blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c index 9492146855..6cc18a1c04 100644 --- a/contrib/vhost-user-blk/vhost-user-blk.c +++ b/contrib/vhost-user-blk/vhost-user-blk.c @@ -196,7 +196,7 @@ vub_discard_write_zeroes(VubReq *req, struct iovec *iov, uint32_t iovcnt, VubDev *vdev_blk = req->vdev_blk; desc = buf; uint64_t range[2] = { le64_to_cpu(desc->sector) << 9, - le32_to_cpu(desc->num_sectors) << 9 }; + (uint64_t)le32_to_cpu(desc->num_sectors) << 9 }; if (type == VIRTIO_BLK_T_DISCARD) { if (ioctl(vdev_blk->blk_fd, BLKDISCARD, range) == 0) { g_free(buf); From patchwork Mon Jul 22 00:17:50 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: 13738181 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 98477C3DA61 for ; Mon, 22 Jul 2024 00:27:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgka-0006b9-5Q; Sun, 21 Jul 2024 20:18:00 -0400 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 1sVgkX-0006LW-Ty for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:58 -0400 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 1sVgkW-0005ov-Hb for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:17:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607475; 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=iDyrc4b0PIQEqc1nWX9kZEf6YpDLGOOzQo+gBLAOsk4=; b=B2xFPQgdleBrJAEOw4tEZeu1urQDmTbaiwmTTnOF+TV42oaqhMAGbUsqXqDN8QjF84MJ1M l+USvArZ1s25oJIEeyTx88U64Ot+1JjZoNrkzav57SG6z3g3maKDbyPXApEvMPImrI6Opa egNs+yu2lURc416XpY2JM1jxCec0mqE= 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-600-Bt3Re3quOYeNdzGycGvwvg-1; Sun, 21 Jul 2024 20:17:54 -0400 X-MC-Unique: Bt3Re3quOYeNdzGycGvwvg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4279418eb2bso25991745e9.1 for ; Sun, 21 Jul 2024 17:17:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607473; x=1722212273; 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=iDyrc4b0PIQEqc1nWX9kZEf6YpDLGOOzQo+gBLAOsk4=; b=TbIiZ09nmrdw/xIMvcrMLp7zeb3fCZI3VRKmQaz4qOUBqH5uwpykQUjtubjTW+k+HH xbuHD092sxSp9dEIAiRwLFh3pQ7iGkMIV8EIYWacxR2TjJtqmuPR2HiV9epdP1vA0Qkq C9momPu+2AnqaCmD2FSxDDwVNmJGrr3fQkg8DayreebTuCzGmrsxZLhT3XiiG0zpSjBM 450dboaMZlxoWtDRJhYCCdx27/yjt+mp3GfJlnQpE9fF+Ly6lY4vLlStjf6nxZg9opXp Rwk7XU1GB8jnXIeJQO9NyyRpNguVtiRCNnMf4W1g8YmrSY8Q1P+fEdey3Fdlci91aPbE QRJA== X-Gm-Message-State: AOJu0YxJPKyyhqBaQHurcR3+SJLm2VMqHWX30JePQ9sv5MqUrc08AfAl ruVVlBsMhxccmzHfPlggA27heDx0g+VSgQX1uWocApQ0FZmn6wkDNtmMpukUPuwwxh1WmDVGqYm DOdMUcPCIMgAogGw1KJYmsUxj6d6Xd8z6zApgKVfB49tlwm7yjDDcH1a/68hacuUb/pEYqcp3uJ /fdDZH6Um8q5oSyJ56Glitxsik3V76og== X-Received: by 2002:a05:600c:3592:b0:426:689b:65b7 with SMTP id 5b1f17b1804b1-427dc564cc3mr29068005e9.25.1721607473015; Sun, 21 Jul 2024 17:17:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsSEqgOYjfl9TwHoHeW1baixVS5O2dlX15A1Ba+C3DUAo4DtfREdIpP3z/OVbieWhnH7C7Vg== X-Received: by 2002:a05:600c:3592:b0:426:689b:65b7 with SMTP id 5b1f17b1804b1-427dc564cc3mr29067875e9.25.1721607472310; Sun, 21 Jul 2024 17:17:52 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a5c356sm133089805e9.18.2024.07.21.17.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:51 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:50 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Yui Washizu , Marcel Apfelbaum Subject: [PULL 29/63] hw/pci: Do not add ROM BAR for SR-IOV VF Message-ID: <54f3a29f08900bef796953971d2482d64ddf9969.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Akihiko Odaki A SR-IOV VF cannot have a ROM BAR. Co-developed-by: Yui Washizu Signed-off-by: Akihiko Odaki Message-Id: <20240715-sriov-v5-1-3f5539093ffc@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 4c7be52951..bd956637bc 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2359,6 +2359,14 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom, return; } + if (pci_is_vf(pdev)) { + if (pdev->rom_bar == ON_OFF_AUTO_ON) { + error_setg(errp, "ROM BAR cannot be enabled for SR-IOV VF"); + } + + return; + } + if (load_file || pdev->romsize == UINT32_MAX) { path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile); if (path == NULL) { From patchwork Mon Jul 22 00:17:52 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: 13738177 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 F22C0C3DA61 for ; Mon, 22 Jul 2024 00:27:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkf-000736-6R; Sun, 21 Jul 2024 20:18:05 -0400 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 1sVgka-0006g3-I0 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:00 -0400 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 1sVgkZ-0005pE-26 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607478; 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=soMn3N89ArRoaYuQiMsJlwiF6/+Rw+/Rmo1xZeCfdvc=; b=YFHFZ9T09vM57pAxUE2WMNJ66WBNJcJoL+VV9LIoO+8AKJzsjg2dAO5kH3DRcm+dogFDOe dBqr1QauC+QIei6c5AH1i62306hupF6Rd9szJ3sO+tmFTiX+yt+UZIeBPZPxNl+gyoiwPF UcMYMVvM5s7YnvXhbh64KyWrTRVw+c4= 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-219-oWOwnOjrMjCqXNFvFaWVwQ-1; Sun, 21 Jul 2024 20:17:56 -0400 X-MC-Unique: oWOwnOjrMjCqXNFvFaWVwQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42671a6fb9dso25237095e9.3 for ; Sun, 21 Jul 2024 17:17:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607474; x=1722212274; 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=soMn3N89ArRoaYuQiMsJlwiF6/+Rw+/Rmo1xZeCfdvc=; b=shl9sFUHQU2Wg0CQcy60PtLd5AD2vp5Y9YcaHKnXLdXwnq7UH+w8Ac5OMMnj7nk5LS hMFmE4rBd6y90HCytPY984AD875CkojGq3Ngv0MzF5z2/a61i7LbNZ/3izHZ4ptQ+apP WLsteVVfcOaqBoWOO5pCRY39NEFkpWvhQXyEKJnZt3Vc54/N4NVGHQlCEan8vmbf7PLL +9a5I2QHhaqlgy20jkqJtPT3MazUDPPsl8pg6uBBL/c0n74Aw9hgsQlaIdus9X2Z244h S1dz25zf3+CJSe46cRViTQrB8+VWdbhJ6Y1KSuSHMDkiy1GhiY49f2OEZaWMg8K5g+8g k2lw== X-Gm-Message-State: AOJu0YxamrPub8uX0xTuAbFLmfgm4VOA7TzYn5Uos2tRzDY92nmEEmiC Zzl0zf/IgS0jOPU9P9ovx48AnXH8uZlfVpbsIjXiZ+9XY/Zb2urph/OU07s+Rwm9z3AYVIg1aiD I8Q/PPILURHdvkEISjQGEp3M1y1AegzgpEY3g+noYErx1fZhSkg79VUpo1Ps73a3H5QireEf+ke Hr1Aj7gWBiPLUrtJuNBc1nwskvcUk++A== X-Received: by 2002:a05:600c:314e:b0:426:5f06:5462 with SMTP id 5b1f17b1804b1-427dc57aa7amr27894405e9.37.1721607474795; Sun, 21 Jul 2024 17:17:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1iYZUnOy73eGeFVQLduVJTMa5mysV8XLVpBf34WOI6n3BPgBUvysJuvzSx9JZynd5/Q5NVQ== X-Received: by 2002:a05:600c:314e:b0:426:5f06:5462 with SMTP id 5b1f17b1804b1-427dc57aa7amr27894305e9.37.1721607474246; Sun, 21 Jul 2024 17:17:54 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d6934ec6sm106848325e9.41.2024.07.21.17.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:53 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL 30/63] hw/pci: Fix SR-IOV VF number calculation 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Akihiko Odaki pci_config_get_bar_addr() had a division by vf_stride. vf_stride needs to be non-zero when there are multiple VFs, but the specification does not prohibit to make it zero when there is only one VF. Do not perform the division for the first VF to avoid division by zero. Signed-off-by: Akihiko Odaki Message-Id: <20240715-sriov-v5-2-3f5539093ffc@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index bd956637bc..dbd954f1fe 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1437,7 +1437,11 @@ static pcibus_t pci_config_get_bar_addr(PCIDevice *d, int reg, pci_get_word(pf->config + sriov_cap + PCI_SRIOV_VF_OFFSET); uint16_t vf_stride = pci_get_word(pf->config + sriov_cap + PCI_SRIOV_VF_STRIDE); - uint32_t vf_num = (d->devfn - (pf->devfn + vf_offset)) / vf_stride; + uint32_t vf_num = d->devfn - (pf->devfn + vf_offset); + + if (vf_num) { + vf_num /= vf_stride; + } if (type & PCI_BASE_ADDRESS_MEM_TYPE_64) { new_addr = pci_get_quad(pf->config + bar); From patchwork Mon Jul 22 00:17: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: 13738174 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 E8EC0C3DA5D for ; Mon, 22 Jul 2024 00:26:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkf-00072j-2x; Sun, 21 Jul 2024 20:18:05 -0400 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 1sVgkc-0006pD-2D for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:02 -0400 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 1sVgka-0005pN-Kb for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607480; 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=YsjbOlvo43JAEesCygimaYMAVGDqCDgHnftdBHHCG1k=; b=Jame7BYmofqLV6GV69L3RedE6CjHhulOVvdR0wgaIkjyO8qqM+mOicf3X3kZJg4lrAW15k LiOEBk7BJfuO05vCX0Ibln2chn4a99fT50IwtPjbFMW3bixnIMUEwTFo1S1C29i6fbHzD5 hEk0xTVwmCcACRYZAVBO9httV8+swdg= 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-515-f4JoZPfWN3KzAKWpCl5yVA-1; Sun, 21 Jul 2024 20:17:58 -0400 X-MC-Unique: f4JoZPfWN3KzAKWpCl5yVA-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-367962f0cb0so2112121f8f.1 for ; Sun, 21 Jul 2024 17:17:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607477; x=1722212277; 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=YsjbOlvo43JAEesCygimaYMAVGDqCDgHnftdBHHCG1k=; b=aoYUySKaNmm5iVLyApRTbTwE1R+YSShC9RpyUxZIzaZ1fLstjZ2xbL8T4oMSUOersn H+cqxCZ6XNcVmIctBrq4/oChZ0e5VfdtS69dLsZTZrvsqZD+vOVZmD2W/APxT+IqPD/y GZzn8Mn2w3gXWkaCA0xGucFm+VazXWSnTDJVsc6OLEOr3LtLeQ+ugJ/Q9zXLTyFHvG0b 3NgVJ6mglgLclIiWEPoa2VOlFiVBsvftz3rA/FCPendYDqPj8LzlsNfFaVA2MagYURyP YfGQokysYKegIGzFwdWcS8nKc+9hLNUlTiXVzzW2809KOwQBIPofZvYqpe/dWygE5u/R 0EFg== X-Gm-Message-State: AOJu0Yw/9RIcryC5m34GZFwYr0pP3z53wZoHLUcFb2osvBalfD4VZwy2 gBhoG6PAOEZrP/JZ1K8aHMljgvHU+J47mjT2/zhjQFSN/CUdn90XjpJ0FocEW9vxUNjlRwcoH73 pDJqW41u50A7nKDF557K47hslCAY8qPXAGBE0mielY/sx/+YzaUV29h35/arGThWk8XH6Pg6Rg7 5s1VkP1IYwg/wCo0ZCbSLiTAViGz2L5Q== X-Received: by 2002:a5d:6d08:0:b0:367:8fc3:a25b with SMTP id ffacd0b85a97d-369bae6adcdmr3890739f8f.42.1721607476970; Sun, 21 Jul 2024 17:17:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHp9fc8vx9XKKXRF9DrIWuQQZ1Rq8vZati0wdVvpF80Fnjy8lhkZuVDG8DEWdOFP6jNLoipXA== X-Received: by 2002:a5d:6d08:0:b0:367:8fc3:a25b with SMTP id ffacd0b85a97d-369bae6adcdmr3890723f8f.42.1721607476204; Sun, 21 Jul 2024 17:17:56 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787ceda0sm7006837f8f.87.2024.07.21.17.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:55 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL 31/63] pcie_sriov: Ensure PF and VF are mutually exclusive Message-ID: <22c343dd303098c9ae2e19363b3571aedb383052.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Akihiko Odaki A device cannot be a SR-IOV PF and a VF at the same time. Signed-off-by: Akihiko Odaki Message-Id: <20240715-sriov-v5-3-3f5539093ffc@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pcie_sriov.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 56523ab4e8..6c79658b4c 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -42,6 +42,11 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, uint8_t *cfg = dev->config + offset; uint8_t *wmask; + if (pci_is_vf(dev)) { + error_setg(errp, "a device cannot be both an SR-IOV PF and a VF"); + return false; + } + if (total_vfs) { uint16_t ari_cap = pcie_find_capability(dev, PCI_EXT_CAP_ID_ARI); uint16_t first_vf_devfn = dev->devfn + vf_offset; From patchwork Mon Jul 22 00:17: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: 13738180 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 EDC96C3DA63 for ; Mon, 22 Jul 2024 00:27:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkf-00075M-Ma; Sun, 21 Jul 2024 20:18:05 -0400 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 1sVgkd-0006wf-Nb for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:03 -0400 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 1sVgkc-0005pb-AY for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607481; 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=+eij6Bxq47w2bciZE/Rv+DzW/akdlQrWlADFCMstsmc=; b=R2rOPGcDnMvlQE4m6kpIPBQMVCtNFZFbHv61HpLwIFSJeZ53sj39CgvFj0FnBzJWyIzIDs SvKbWP0bAquMm/3EN2BhOOGscKbchSKM2Hkf2UbfzHkyadFja6V3MGBYDprlC9P4paNImK KJvJDQxKk/i+r06SIIKMpTgv2yx29EY= 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-519-UPG4eHjlMLegMQ8l1PYRUQ-1; Sun, 21 Jul 2024 20:18:00 -0400 X-MC-Unique: UPG4eHjlMLegMQ8l1PYRUQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42668857c38so27734975e9.1 for ; Sun, 21 Jul 2024 17:18:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607478; x=1722212278; 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=+eij6Bxq47w2bciZE/Rv+DzW/akdlQrWlADFCMstsmc=; b=xMcYrEYf+tvs/anh4l9PnLcZHAu2lwQyMVzfbEHs4LFEBAGUzdDl2srYiecOfiPRf8 uIyZFF4L+gR6RnSEWx2wRSKGz2AECUvLy+bfxq9vfjZjwCETtyMfYtNMZVubTz/V+NEU OGLsG5QyifaQM/01vJkFXj4g1y7FrOvhmWRbCoCOpA0gcKO06o9dakDfOtcI5Cns7LZe pm7yPY+OoxRMYlFpwEKHsvIpeTfhl2EHJAsY03mpLV9GNjRnw3YHu90bN7g/DXycjmpk 20HUOVgqBh3b/k1CVeRkxvPbcc7Ixs+pQ8E/C7jwqDdZNL6aaDcnhCGIbfybzIBE61AR gdnQ== X-Gm-Message-State: AOJu0Yy4UyCK6dHfwzINr6hp9Nk9W/f+juEwgaPyFdPcuSA4D0XK8La7 9EawFTyedHKXr2VrLfXgWcM41M79t52+SIyEdFg0UeTKqT74F5pbG+hfcJwUcIRpIX2N7LOpZgK QfuVi73rePH7R0rh16vgBaYjcMKMEaG+MBuSh5iQRT4CyIOODtuzNV30zKF2dymbuDzDF9U3UXy pNTCQ22N+gnCbn8crL4D5HzkkeZ5+ASg== X-Received: by 2002:a05:600c:3ba9:b0:426:647b:1bfc with SMTP id 5b1f17b1804b1-427dc5584d8mr28430685e9.30.1721607478733; Sun, 21 Jul 2024 17:17:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfAToW3g7nzJrtU6eFvr3vVXZ/4lypIFreDDV7ozbONpqf31axrZlekR03YbUNNpmKEmaeMA== X-Received: by 2002:a05:600c:3ba9:b0:426:647b:1bfc with SMTP id 5b1f17b1804b1-427dc5584d8mr28430535e9.30.1721607478233; Sun, 21 Jul 2024 17:17:58 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d692998csm106210135e9.32.2024.07.21.17.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:57 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL 32/63] pcie_sriov: Check PCI Express for SR-IOV PF 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Akihiko Odaki SR-IOV requires PCI Express. Signed-off-by: Akihiko Odaki Message-Id: <20240715-sriov-v5-4-3f5539093ffc@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pcie_sriov.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 6c79658b4c..15a4aac1f4 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -42,6 +42,11 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, uint8_t *cfg = dev->config + offset; uint8_t *wmask; + if (!pci_is_express(dev)) { + error_setg(errp, "PCI Express is required for SR-IOV PF"); + return false; + } + if (pci_is_vf(dev)) { error_setg(errp, "a device cannot be both an SR-IOV PF and a VF"); return false; From patchwork Mon Jul 22 00:17:58 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: 13738148 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 B9B4FC3DA5D for ; Mon, 22 Jul 2024 00:21:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkk-0007Up-W4; Sun, 21 Jul 2024 20:18:11 -0400 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 1sVgkj-0007Nt-CY for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:09 -0400 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 1sVgkg-0005rP-Qr for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607486; 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=tGGZEhtbp9ay4AH88sYN+WiW+/lZSrz5NaUQDZ8AZbM=; b=XXl+ktruxzup652ORPAQi8mY1yvT0/aaiynV1i2xtKq1Jk4scx42PjAs4yHOXHDt1fRy0j ayr1RwiZSAYgtqHYm/Nxb/cNLKtWJRsSvU6Iqk9FsjX8xrPExpd4ei6s3HI9wRAwM8FGvT +qzjpnYNm7r66nGsBwHCTaWC84ZRMxY= 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-626-hB-eVHUzOBeteQBWJSHIaw-1; Sun, 21 Jul 2024 20:18:02 -0400 X-MC-Unique: hB-eVHUzOBeteQBWJSHIaw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-42668699453so37766545e9.3 for ; Sun, 21 Jul 2024 17:18:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607481; x=1722212281; 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=tGGZEhtbp9ay4AH88sYN+WiW+/lZSrz5NaUQDZ8AZbM=; b=EPCaxcerBkmppil0PZObZ7FPz7KgnJ0Uowf4v+ki7DGF4tekJu0UnJk+e4DUbJ/ddb zU/PooYAHZcTjl8imrLV0aCAKhJ1Hb1MKxe9kJJkH+QDvEZbWSkPjdK7lPxPHL/rbiUd i+UdDoVxNLaGBx7cm1uRuwk4NfK7xURMmFxrMJ1k4jBSpFVjYUPWFNWbn+idWGqwvInK yJmWDLDy7qSNs3GsdK31D3dkLrg9jNiIG35nwEozwxHrDO08gIBZ8BuIBJLTsnXvKYED jRuFHrcq5+jNNWsa5AHqMztkPXM2oK8XAzdwEKcOESIIXt1hi3W8E8yGDg0DlS60TYD2 8z5g== X-Gm-Message-State: AOJu0YzmktMA7jfzFJfMFlyivy1y+lrukt3Ovct1E9BaHFu8mbIU/ohU L3iqZLeRMeMFKSt5lVKR1SiuOSovfifoXytRJh15F+BEabbGl53RA+22fyJ2kF97vxfoM87ZZXP wGictTCtCPTylurZFSdd2uSj/cAJYhEfuyhXY4YXyw11cfs9rn9lKHBDgu9pvYoPYH7FGKqGbrS AYhlR+hG7ux6xwYftNxMBe66M6+Wfi0Q== X-Received: by 2002:a05:600c:3550:b0:426:615f:f715 with SMTP id 5b1f17b1804b1-427dc52920fmr43222435e9.23.1721607480877; Sun, 21 Jul 2024 17:18:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRQblEa7pPLrqaF4bc/48wGfU0JB/dmtRgJTtMsqRR/omgV+Nb56307SBn3MQrSENIHcfACw== X-Received: by 2002:a05:600c:3550:b0:426:615f:f715 with SMTP id 5b1f17b1804b1-427dc52920fmr43222265e9.23.1721607480273; Sun, 21 Jul 2024 17:18:00 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e42bsm135528525e9.30.2024.07.21.17.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:17:59 -0700 (PDT) Date: Sun, 21 Jul 2024 20:17:58 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL 33/63] pcie_sriov: Allow user to create SR-IOV device 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Akihiko Odaki A user can create a SR-IOV device by specifying the PF with the sriov-pf property of the VFs. The VFs must be added before the PF. A user-creatable VF must have PCIDeviceClass::sriov_vf_user_creatable set. Such a VF cannot refer to the PF because it is created before the PF. A PF that user-creatable VFs can be attached calls pcie_sriov_pf_init_from_user_created_vfs() during realization and pcie_sriov_pf_exit() when exiting. Signed-off-by: Akihiko Odaki Message-Id: <20240715-sriov-v5-5-3f5539093ffc@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci_device.h | 6 +- include/hw/pci/pcie_sriov.h | 18 +++ hw/pci/pci.c | 62 +++++--- hw/pci/pcie_sriov.c | 290 ++++++++++++++++++++++++++++-------- 4 files changed, 293 insertions(+), 83 deletions(-) diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index ca15132508..cefd6f7640 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -37,6 +37,8 @@ struct PCIDeviceClass { uint16_t subsystem_id; /* only for header type = 0 */ const char *romfile; /* rom bar */ + + bool sriov_vf_user_creatable; }; enum PCIReqIDType { @@ -160,6 +162,8 @@ struct PCIDevice { /* ID of standby device in net_failover pair */ char *failover_pair_id; uint32_t acpi_index; + + char *sriov_pf; }; static inline int pci_intx(PCIDevice *pci_dev) @@ -192,7 +196,7 @@ static inline int pci_is_express_downstream_port(const PCIDevice *d) static inline int pci_is_vf(const PCIDevice *d) { - return d->exp.sriov_vf.pf != NULL; + return d->sriov_pf || d->exp.sriov_vf.pf != NULL; } static inline uint32_t pci_config_size(const PCIDevice *d) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index c5d2d318d3..f75b8f22ee 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -18,6 +18,7 @@ typedef struct PCIESriovPF { uint8_t vf_bar_type[PCI_NUM_REGIONS]; /* Store type for each VF bar */ PCIDevice **vf; /* Pointer to an array of num_vfs VF devices */ + bool vf_user_created; /* If VFs are created by user */ } PCIESriovPF; typedef struct PCIESriovVF { @@ -40,6 +41,23 @@ void pcie_sriov_pf_init_vf_bar(PCIDevice *dev, int region_num, void pcie_sriov_vf_register_bar(PCIDevice *dev, int region_num, MemoryRegion *memory); +/** + * pcie_sriov_pf_init_from_user_created_vfs() - Initialize PF with user-created + * VFs. + * @dev: A PCIe device being realized. + * @offset: The offset of the SR-IOV capability. + * @errp: pointer to Error*, to store an error if it happens. + * + * Return: The size of added capability. 0 if the user did not create VFs. + * -1 if failed. + */ +int16_t pcie_sriov_pf_init_from_user_created_vfs(PCIDevice *dev, + uint16_t offset, + Error **errp); + +bool pcie_sriov_register_device(PCIDevice *dev, Error **errp); +void pcie_sriov_unregister_device(PCIDevice *dev); + /* * Default (minimal) page size support values * as required by the SR/IOV standard: diff --git a/hw/pci/pci.c b/hw/pci/pci.c index dbd954f1fe..61699b2cb8 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -85,6 +85,7 @@ static Property pci_props[] = { QEMU_PCIE_ERR_UNC_MASK_BITNR, true), DEFINE_PROP_BIT("x-pcie-ari-nextfn-1", PCIDevice, cap_present, QEMU_PCIE_ARI_NEXTFN_1_BITNR, false), + DEFINE_PROP_STRING("sriov-pf", PCIDevice, sriov_pf), DEFINE_PROP_END_OF_LIST() }; @@ -959,13 +960,8 @@ static void pci_init_multifunction(PCIBus *bus, PCIDevice *dev, Error **errp) dev->config[PCI_HEADER_TYPE] |= PCI_HEADER_TYPE_MULTI_FUNCTION; } - /* - * With SR/IOV and ARI, a device at function 0 need not be a multifunction - * device, as it may just be a VF that ended up with function 0 in - * the legacy PCI interpretation. Avoid failing in such cases: - */ - if (pci_is_vf(dev) && - dev->exp.sriov_vf.pf->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) { + /* SR/IOV is not handled here. */ + if (pci_is_vf(dev)) { return; } @@ -998,7 +994,8 @@ static void pci_init_multifunction(PCIBus *bus, PCIDevice *dev, Error **errp) } /* function 0 indicates single function, so function > 0 must be NULL */ for (func = 1; func < PCI_FUNC_MAX; ++func) { - if (bus->devices[PCI_DEVFN(slot, func)]) { + PCIDevice *device = bus->devices[PCI_DEVFN(slot, func)]; + if (device && !pci_is_vf(device)) { error_setg(errp, "PCI: %x.0 indicates single function, " "but %x.%x is already populated.", slot, slot, func); @@ -1283,6 +1280,7 @@ static void pci_qdev_unrealize(DeviceState *dev) pci_unregister_io_regions(pci_dev); pci_del_option_rom(pci_dev); + pcie_sriov_unregister_device(pci_dev); if (pc->exit) { pc->exit(pci_dev); @@ -1314,7 +1312,6 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num, pcibus_t size = memory_region_size(memory); uint8_t hdr_type; - assert(!pci_is_vf(pci_dev)); /* VFs must use pcie_sriov_vf_register_bar */ assert(region_num >= 0); assert(region_num < PCI_NUM_REGIONS); assert(is_power_of_2(size)); @@ -1325,7 +1322,6 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num, assert(hdr_type != PCI_HEADER_TYPE_BRIDGE || region_num < 2); r = &pci_dev->io_regions[region_num]; - r->addr = PCI_BAR_UNMAPPED; r->size = size; r->type = type; r->memory = memory; @@ -1333,22 +1329,35 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num, ? pci_get_bus(pci_dev)->address_space_io : pci_get_bus(pci_dev)->address_space_mem; - wmask = ~(size - 1); - if (region_num == PCI_ROM_SLOT) { - /* ROM enable bit is writable */ - wmask |= PCI_ROM_ADDRESS_ENABLE; - } + if (pci_is_vf(pci_dev)) { + PCIDevice *pf = pci_dev->exp.sriov_vf.pf; + assert(!pf || type == pf->exp.sriov_pf.vf_bar_type[region_num]); - addr = pci_bar(pci_dev, region_num); - pci_set_long(pci_dev->config + addr, type); - - if (!(r->type & PCI_BASE_ADDRESS_SPACE_IO) && - r->type & PCI_BASE_ADDRESS_MEM_TYPE_64) { - pci_set_quad(pci_dev->wmask + addr, wmask); - pci_set_quad(pci_dev->cmask + addr, ~0ULL); + r->addr = pci_bar_address(pci_dev, region_num, r->type, r->size); + if (r->addr != PCI_BAR_UNMAPPED) { + memory_region_add_subregion_overlap(r->address_space, + r->addr, r->memory, 1); + } } else { - pci_set_long(pci_dev->wmask + addr, wmask & 0xffffffff); - pci_set_long(pci_dev->cmask + addr, 0xffffffff); + r->addr = PCI_BAR_UNMAPPED; + + wmask = ~(size - 1); + if (region_num == PCI_ROM_SLOT) { + /* ROM enable bit is writable */ + wmask |= PCI_ROM_ADDRESS_ENABLE; + } + + addr = pci_bar(pci_dev, region_num); + pci_set_long(pci_dev->config + addr, type); + + if (!(r->type & PCI_BASE_ADDRESS_SPACE_IO) && + r->type & PCI_BASE_ADDRESS_MEM_TYPE_64) { + pci_set_quad(pci_dev->wmask + addr, wmask); + pci_set_quad(pci_dev->cmask + addr, ~0ULL); + } else { + pci_set_long(pci_dev->wmask + addr, wmask & 0xffffffff); + pci_set_long(pci_dev->cmask + addr, 0xffffffff); + } } } @@ -2109,6 +2118,11 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp) } } + if (!pcie_sriov_register_device(pci_dev, errp)) { + pci_qdev_unrealize(DEVICE(pci_dev)); + return; + } + /* * A PCIe Downstream Port that do not have ARI Forwarding enabled must * associate only Device 0 with the device attached to the bus diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 15a4aac1f4..0fc9f810b9 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -20,6 +20,8 @@ #include "qapi/error.h" #include "trace.h" +static GHashTable *pfs; + static void unparent_vfs(PCIDevice *dev, uint16_t total_vfs) { for (uint16_t i = 0; i < total_vfs; i++) { @@ -31,14 +33,49 @@ static void unparent_vfs(PCIDevice *dev, uint16_t total_vfs) dev->exp.sriov_pf.vf = NULL; } -bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, - const char *vfname, uint16_t vf_dev_id, - uint16_t init_vfs, uint16_t total_vfs, - uint16_t vf_offset, uint16_t vf_stride, - Error **errp) +static void clear_ctrl_vfe(PCIDevice *dev) +{ + uint8_t *ctrl = dev->config + dev->exp.sriov_cap + PCI_SRIOV_CTRL; + pci_set_word(ctrl, pci_get_word(ctrl) & ~PCI_SRIOV_CTRL_VFE); +} + +static void register_vfs(PCIDevice *dev) +{ + uint16_t num_vfs; + uint16_t i; + uint16_t sriov_cap = dev->exp.sriov_cap; + + assert(sriov_cap > 0); + num_vfs = pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF); + if (num_vfs > pci_get_word(dev->config + sriov_cap + PCI_SRIOV_TOTAL_VF)) { + clear_ctrl_vfe(dev); + return; + } + + trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn), + PCI_FUNC(dev->devfn), num_vfs); + for (i = 0; i < num_vfs; i++) { + pci_set_enabled(dev->exp.sriov_pf.vf[i], true); + } +} + +static void unregister_vfs(PCIDevice *dev) +{ + uint16_t i; + uint8_t *cfg = dev->config + dev->exp.sriov_cap; + + trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn), + PCI_FUNC(dev->devfn)); + for (i = 0; i < pci_get_word(cfg + PCI_SRIOV_TOTAL_VF); i++) { + pci_set_enabled(dev->exp.sriov_pf.vf[i], false); + } +} + +static bool pcie_sriov_pf_init_common(PCIDevice *dev, uint16_t offset, + uint16_t vf_dev_id, uint16_t init_vfs, + uint16_t total_vfs, uint16_t vf_offset, + uint16_t vf_stride, Error **errp) { - BusState *bus = qdev_get_parent_bus(&dev->qdev); - int32_t devfn = dev->devfn + vf_offset; uint8_t *cfg = dev->config + offset; uint8_t *wmask; @@ -100,6 +137,28 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, qdev_prop_set_bit(&dev->qdev, "multifunction", true); + return true; +} + +bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, + const char *vfname, uint16_t vf_dev_id, + uint16_t init_vfs, uint16_t total_vfs, + uint16_t vf_offset, uint16_t vf_stride, + Error **errp) +{ + BusState *bus = qdev_get_parent_bus(&dev->qdev); + int32_t devfn = dev->devfn + vf_offset; + + if (pfs && g_hash_table_contains(pfs, dev->qdev.id)) { + error_setg(errp, "attaching user-created SR-IOV VF unsupported"); + return false; + } + + if (!pcie_sriov_pf_init_common(dev, offset, vf_dev_id, init_vfs, + total_vfs, vf_offset, vf_stride, errp)) { + return false; + } + dev->exp.sriov_pf.vf = g_new(PCIDevice *, total_vfs); for (uint16_t i = 0; i < total_vfs; i++) { @@ -129,7 +188,24 @@ void pcie_sriov_pf_exit(PCIDevice *dev) { uint8_t *cfg = dev->config + dev->exp.sriov_cap; - unparent_vfs(dev, pci_get_word(cfg + PCI_SRIOV_TOTAL_VF)); + if (dev->exp.sriov_pf.vf_user_created) { + uint16_t ven_id = pci_get_word(dev->config + PCI_VENDOR_ID); + uint16_t total_vfs = pci_get_word(dev->config + PCI_SRIOV_TOTAL_VF); + uint16_t vf_dev_id = pci_get_word(dev->config + PCI_SRIOV_VF_DID); + + unregister_vfs(dev); + + for (uint16_t i = 0; i < total_vfs; i++) { + PCIDevice *vf = dev->exp.sriov_pf.vf[i]; + + vf->exp.sriov_vf.pf = NULL; + + pci_config_set_vendor_id(vf->config, ven_id); + pci_config_set_device_id(vf->config, vf_dev_id); + } + } else { + unparent_vfs(dev, pci_get_word(cfg + PCI_SRIOV_TOTAL_VF)); + } } void pcie_sriov_pf_init_vf_bar(PCIDevice *dev, int region_num, @@ -162,74 +238,172 @@ void pcie_sriov_pf_init_vf_bar(PCIDevice *dev, int region_num, void pcie_sriov_vf_register_bar(PCIDevice *dev, int region_num, MemoryRegion *memory) { - PCIIORegion *r; - PCIBus *bus = pci_get_bus(dev); uint8_t type; - pcibus_t size = memory_region_size(memory); - assert(pci_is_vf(dev)); /* PFs must use pci_register_bar */ - assert(region_num >= 0); - assert(region_num < PCI_NUM_REGIONS); + assert(dev->exp.sriov_vf.pf); type = dev->exp.sriov_vf.pf->exp.sriov_pf.vf_bar_type[region_num]; - if (!is_power_of_2(size)) { - error_report("%s: PCI region size must be a power" - " of two - type=0x%x, size=0x%"FMT_PCIBUS, - __func__, type, size); - exit(1); - } - - r = &dev->io_regions[region_num]; - r->memory = memory; - r->address_space = - type & PCI_BASE_ADDRESS_SPACE_IO - ? bus->address_space_io - : bus->address_space_mem; - r->size = size; - r->type = type; - - r->addr = pci_bar_address(dev, region_num, r->type, r->size); - if (r->addr != PCI_BAR_UNMAPPED) { - memory_region_add_subregion_overlap(r->address_space, - r->addr, r->memory, 1); - } + return pci_register_bar(dev, region_num, type, memory); } -static void clear_ctrl_vfe(PCIDevice *dev) +static gint compare_vf_devfns(gconstpointer a, gconstpointer b) { - uint8_t *ctrl = dev->config + dev->exp.sriov_cap + PCI_SRIOV_CTRL; - pci_set_word(ctrl, pci_get_word(ctrl) & ~PCI_SRIOV_CTRL_VFE); + return (*(PCIDevice **)a)->devfn - (*(PCIDevice **)b)->devfn; } -static void register_vfs(PCIDevice *dev) +int16_t pcie_sriov_pf_init_from_user_created_vfs(PCIDevice *dev, + uint16_t offset, + Error **errp) { - uint16_t num_vfs; + GPtrArray *pf; + PCIDevice **vfs; + BusState *bus = qdev_get_parent_bus(DEVICE(dev)); + uint16_t ven_id = pci_get_word(dev->config + PCI_VENDOR_ID); + uint16_t vf_dev_id; + uint16_t vf_offset; + uint16_t vf_stride; uint16_t i; - uint16_t sriov_cap = dev->exp.sriov_cap; - assert(sriov_cap > 0); - num_vfs = pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF); - if (num_vfs > pci_get_word(dev->config + sriov_cap + PCI_SRIOV_TOTAL_VF)) { - clear_ctrl_vfe(dev); - return; + if (!pfs || !dev->qdev.id) { + return 0; } - trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn), - PCI_FUNC(dev->devfn), num_vfs); - for (i = 0; i < num_vfs; i++) { - pci_set_enabled(dev->exp.sriov_pf.vf[i], true); + pf = g_hash_table_lookup(pfs, dev->qdev.id); + if (!pf) { + return 0; } + + if (pf->len > UINT16_MAX) { + error_setg(errp, "too many VFs"); + return -1; + } + + g_ptr_array_sort(pf, compare_vf_devfns); + vfs = (void *)pf->pdata; + + if (vfs[0]->devfn <= dev->devfn) { + error_setg(errp, "a VF function number is less than the PF function number"); + return -1; + } + + vf_dev_id = pci_get_word(vfs[0]->config + PCI_DEVICE_ID); + vf_offset = vfs[0]->devfn - dev->devfn; + vf_stride = pf->len < 2 ? 0 : vfs[1]->devfn - vfs[0]->devfn; + + for (i = 0; i < pf->len; i++) { + if (bus != qdev_get_parent_bus(&vfs[i]->qdev)) { + error_setg(errp, "SR-IOV VF parent bus mismatches with PF"); + return -1; + } + + if (ven_id != pci_get_word(vfs[i]->config + PCI_VENDOR_ID)) { + error_setg(errp, "SR-IOV VF vendor ID mismatches with PF"); + return -1; + } + + if (vf_dev_id != pci_get_word(vfs[i]->config + PCI_DEVICE_ID)) { + error_setg(errp, "inconsistent SR-IOV VF device IDs"); + return -1; + } + + for (size_t j = 0; j < PCI_NUM_REGIONS; j++) { + if (vfs[i]->io_regions[j].size != vfs[0]->io_regions[j].size || + vfs[i]->io_regions[j].type != vfs[0]->io_regions[j].type) { + error_setg(errp, "inconsistent SR-IOV BARs"); + return -1; + } + } + + if (vfs[i]->devfn - vfs[0]->devfn != vf_stride * i) { + error_setg(errp, "inconsistent SR-IOV stride"); + return -1; + } + } + + if (!pcie_sriov_pf_init_common(dev, offset, vf_dev_id, pf->len, + pf->len, vf_offset, vf_stride, errp)) { + return -1; + } + + for (i = 0; i < pf->len; i++) { + vfs[i]->exp.sriov_vf.pf = dev; + vfs[i]->exp.sriov_vf.vf_number = i; + + /* set vid/did according to sr/iov spec - they are not used */ + pci_config_set_vendor_id(vfs[i]->config, 0xffff); + pci_config_set_device_id(vfs[i]->config, 0xffff); + } + + dev->exp.sriov_pf.vf = vfs; + dev->exp.sriov_pf.vf_user_created = true; + + for (i = 0; i < PCI_NUM_REGIONS; i++) { + PCIIORegion *region = &vfs[0]->io_regions[i]; + + if (region->size) { + pcie_sriov_pf_init_vf_bar(dev, i, region->type, region->size); + } + } + + return PCI_EXT_CAP_SRIOV_SIZEOF; } -static void unregister_vfs(PCIDevice *dev) +bool pcie_sriov_register_device(PCIDevice *dev, Error **errp) { - uint16_t i; - uint8_t *cfg = dev->config + dev->exp.sriov_cap; + if (!dev->exp.sriov_pf.vf && dev->qdev.id && + pfs && g_hash_table_contains(pfs, dev->qdev.id)) { + error_setg(errp, "attaching user-created SR-IOV VF unsupported"); + return false; + } - trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn), - PCI_FUNC(dev->devfn)); - for (i = 0; i < pci_get_word(cfg + PCI_SRIOV_TOTAL_VF); i++) { - pci_set_enabled(dev->exp.sriov_pf.vf[i], false); + if (dev->sriov_pf) { + PCIDevice *pci_pf; + GPtrArray *pf; + + if (!PCI_DEVICE_GET_CLASS(dev)->sriov_vf_user_creatable) { + error_setg(errp, "user cannot create SR-IOV VF with this device type"); + return false; + } + + if (!pci_is_express(dev)) { + error_setg(errp, "PCI Express is required for SR-IOV VF"); + return false; + } + + if (!pci_qdev_find_device(dev->sriov_pf, &pci_pf)) { + error_setg(errp, "PCI device specified as SR-IOV PF already exists"); + return false; + } + + if (!pfs) { + pfs = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); + } + + pf = g_hash_table_lookup(pfs, dev->sriov_pf); + if (!pf) { + pf = g_ptr_array_new(); + g_hash_table_insert(pfs, g_strdup(dev->sriov_pf), pf); + } + + g_ptr_array_add(pf, dev); + } + + return true; +} + +void pcie_sriov_unregister_device(PCIDevice *dev) +{ + if (dev->sriov_pf && pfs) { + GPtrArray *pf = g_hash_table_lookup(pfs, dev->sriov_pf); + + if (pf) { + g_ptr_array_remove_fast(pf, dev); + + if (!pf->len) { + g_hash_table_remove(pfs, dev->sriov_pf); + g_ptr_array_free(pf, FALSE); + } + } } } @@ -316,7 +490,7 @@ void pcie_sriov_pf_add_sup_pgsize(PCIDevice *dev, uint16_t opt_sup_pgsize) uint16_t pcie_sriov_vf_number(PCIDevice *dev) { - assert(pci_is_vf(dev)); + assert(dev->exp.sriov_vf.pf); return dev->exp.sriov_vf.vf_number; } From patchwork Mon Jul 22 00:18: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: 13738138 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 9E690C3DA61 for ; Mon, 22 Jul 2024 00:18:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkk-0007Rt-Pp; Sun, 21 Jul 2024 20:18:10 -0400 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 1sVgki-0007ID-Bz for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:08 -0400 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 1sVgkg-0005rN-QV for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607486; 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=X3rdo+GHcXhDhgz/MwpIwvItnaY2iCPaS+aQJmkzF0Q=; b=ZmPPlw9RpuO4oV3+lEWBJRm4kNklgPxQeJ6AfOV500VpFYk5Uji7aT2YTawXl25j8OcQQK dBknLSHRV1IhPp2j3fcggp2hhvj9Nf525zuTHxblJGu37VhX1YSgRy5xOuSWnIgATt7H7g 6P6oredeT1cuOF/kUST2pD8RulHJnTU= 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-656-Ukb7xp5dM9KLklaTTn64gw-1; Sun, 21 Jul 2024 20:18:04 -0400 X-MC-Unique: Ukb7xp5dM9KLklaTTn64gw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42668699453so37766735e9.3 for ; Sun, 21 Jul 2024 17:18:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607483; x=1722212283; 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=X3rdo+GHcXhDhgz/MwpIwvItnaY2iCPaS+aQJmkzF0Q=; b=d5speWoQZLtXhTdnfHBPXHG0/0WGZ5vOYrYdghxz9TI42h/QoP9KhK7Fe9Qpg1ka20 DEISUDeM7kQahDVGoIMMRGMQSgU04JpkIvmsSYfwFB0suyBrPrsdieqHqgaHoo17NEFo YuafhmdgAbdGDTw0OWojPKMwe0l9S8o8n6Xw92/OSr6YTslsLfz5yKiPX911Sol7sVSa qFr29yP3WLvmC46r0Y2FcLgCqRfpTeCxfO79DKUAkmmV9oyxAh7Zvqb0NdA3jbPTZR95 7T5rIvo+JohIAjIl62jGm+J777r5XIyvjSkLRN6Jr2CqQRE3Bws8iUmybFi/PK34g7mp G1Kg== X-Gm-Message-State: AOJu0Yy6DnK8n66TDZATij5Be8SJfQjrYLbNpd5xCjETBOeeeG2ljXNA jkEvZ522iCYtk7eWYFFkKRcd4aHssYxyTAtpVsQfrit+v/ojudunI/xQTajt6Pjh7t0LgNuBVO+ N0hqprOTFDnsNrFk6di7mtYJqFL8XFepLclGayR9mUsABEfM85yE5Y383Y5R4KEiW4oqBI//Eqn cpU04K14AvORBKLh2nmomRzff2fI0wOw== X-Received: by 2002:a5d:64ca:0:b0:368:7868:2d76 with SMTP id ffacd0b85a97d-369bb2b3e33mr4329941f8f.51.1721607482919; Sun, 21 Jul 2024 17:18:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9PsrsT0ngl6b3E+Hlq5IwBHIKYLH1yAfbf5OUyONRqVDVbY/mdxLyfIkyXoDWQzgmYFWRCg== X-Received: by 2002:a5d:64ca:0:b0:368:7868:2d76 with SMTP id ffacd0b85a97d-369bb2b3e33mr4329926f8f.51.1721607482359; Sun, 21 Jul 2024 17:18:02 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868490fsm7049524f8f.6.2024.07.21.17.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:01 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki Subject: [PULL 34/63] virtio-pci: Implement SR-IOV PF 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Akihiko Odaki Allow user to attach SR-IOV VF to a virtio-pci PF. Signed-off-by: Akihiko Odaki Message-Id: <20240715-sriov-v5-6-3f5539093ffc@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-pci.h | 1 + hw/virtio/virtio-pci.c | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index 9e67ba38c7..34539f2f67 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -152,6 +152,7 @@ struct VirtIOPCIProxy { uint32_t modern_io_bar_idx; uint32_t modern_mem_bar_idx; int config_cap; + uint16_t last_pcie_cap_offset; uint32_t flags; bool disable_modern; bool ignore_backend_features; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 9534730bba..0c8fcc5627 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1955,6 +1955,7 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) uint8_t *config; uint32_t size; VirtIODevice *vdev = virtio_bus_get_device(bus); + int16_t res; /* * Virtio capabilities present without @@ -2100,6 +2101,14 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) pci_register_bar(&proxy->pci_dev, proxy->legacy_io_bar_idx, PCI_BASE_ADDRESS_SPACE_IO, &proxy->bar); } + + res = pcie_sriov_pf_init_from_user_created_vfs(&proxy->pci_dev, + proxy->last_pcie_cap_offset, + errp); + if (res > 0) { + proxy->last_pcie_cap_offset += res; + virtio_add_feature(&vdev->host_features, VIRTIO_F_SR_IOV); + } } static void virtio_pci_device_unplugged(DeviceState *d) @@ -2187,7 +2196,7 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp) if (pcie_port && pci_is_express(pci_dev)) { int pos; - uint16_t last_pcie_cap_offset = PCI_CONFIG_SPACE_SIZE; + proxy->last_pcie_cap_offset = PCI_CONFIG_SPACE_SIZE; pos = pcie_endpoint_cap_init(pci_dev, 0); assert(pos > 0); @@ -2207,9 +2216,9 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp) pci_set_word(pci_dev->config + pos + PCI_PM_PMC, 0x3); if (proxy->flags & VIRTIO_PCI_FLAG_AER) { - pcie_aer_init(pci_dev, PCI_ERR_VER, last_pcie_cap_offset, + pcie_aer_init(pci_dev, PCI_ERR_VER, proxy->last_pcie_cap_offset, PCI_ERR_SIZEOF, NULL); - last_pcie_cap_offset += PCI_ERR_SIZEOF; + proxy->last_pcie_cap_offset += PCI_ERR_SIZEOF; } if (proxy->flags & VIRTIO_PCI_FLAG_INIT_DEVERR) { @@ -2234,9 +2243,9 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp) } if (proxy->flags & VIRTIO_PCI_FLAG_ATS) { - pcie_ats_init(pci_dev, last_pcie_cap_offset, + pcie_ats_init(pci_dev, proxy->last_pcie_cap_offset, proxy->flags & VIRTIO_PCI_FLAG_ATS_PAGE_ALIGNED); - last_pcie_cap_offset += PCI_EXT_CAP_ATS_SIZEOF; + proxy->last_pcie_cap_offset += PCI_EXT_CAP_ATS_SIZEOF; } if (proxy->flags & VIRTIO_PCI_FLAG_INIT_FLR) { @@ -2263,6 +2272,7 @@ static void virtio_pci_exit(PCIDevice *pci_dev) bool pcie_port = pci_bus_is_express(pci_get_bus(pci_dev)) && !pci_bus_is_root(pci_get_bus(pci_dev)); + pcie_sriov_pf_exit(&proxy->pci_dev); msix_uninit_exclusive_bar(pci_dev); if (proxy->flags & VIRTIO_PCI_FLAG_AER && pcie_port && pci_is_express(pci_dev)) { From patchwork Mon Jul 22 00:18: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: 13738184 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 B260CC3DA61 for ; Mon, 22 Jul 2024 00:28:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkl-0007Xd-JA; Sun, 21 Jul 2024 20:18:11 -0400 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 1sVgkj-0007Pf-MA for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:09 -0400 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 1sVgki-0005rZ-2c for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607487; 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=Lz5hKldjasJf/3wnZBS+b0jZAsjIEnviapWcUQoy3vQ=; b=K+QWImqFALz7i6jNLJJ3hkXBg15KJz/gFb2q1/GONBVwPPMJ0hnmjSV4JmAJYk1mF3LkX9 5C/HEI8SfkaM4WYOOGpmRjambWtME1z6hO/FF+hrqEuRtZXEi/nDpQHUsZTKHYptUVYOXq uAcaZK6txUB5HhcT6pkx3di6q2YXZRU= 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-641-3DZ32LAZNUa-apNRGX5Rog-1; Sun, 21 Jul 2024 20:18:06 -0400 X-MC-Unique: 3DZ32LAZNUa-apNRGX5Rog-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4279c75c44dso26778985e9.2 for ; Sun, 21 Jul 2024 17:18:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607484; x=1722212284; 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=Lz5hKldjasJf/3wnZBS+b0jZAsjIEnviapWcUQoy3vQ=; b=EdRe3Sa2eDFk10uA8aY+LIOisiidt5XkmTr3H0IcjXbKpSMrwe7alMNk1Azd7Jx2RX TuVq4DyONqTX6A4/fyAoyimygt3yRu9i88tqroWcv1vX1xiey36/vZNC1TfNG/mzz4O0 Z6Tdtf2kxhwywzITPonjc+M2Ary8Bm6+lGty3x4Efe38dIC2+vF2P0PhgaSx9eX6pZ8E fRX/1zbgiQlmlECAnKm1FyWMXk1A2tLWTLblhaSgflltYWh+oEuTX0rrHzpjrGjY0eOx Iiq3nzn+c4SpSABy/wKl5J2EJB+p4/VOpGMeBy6RYvzw78H7//Igt05vGpqoYUlR1Wdt 1rOQ== X-Gm-Message-State: AOJu0YysAFDanDlvgFexKPFJQFXDvFqsJCzp6yAfV4gef1Sb98wvybvl QBNskm975tErmxOjIrD+Wi712JcbyNAO0GBs+Vg2z7QiD/s3yzJouUZCK0uooYGh8kx3GxIHrhp bnuXV69NVxGqRM/KpVe4PoxAZxfevLDJkSEXvglJ+cLr4tnAl8nKf9orbEz2AY903/kpYGtcX/r GmiyGM/JJlNB9ikLVYpjMVGKKmdWnOUg== X-Received: by 2002:a05:600c:4f91:b0:426:6960:34ac with SMTP id 5b1f17b1804b1-427dc578d07mr25724705e9.36.1721607484747; Sun, 21 Jul 2024 17:18:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERw1p3XFSZX6ycE98S/kGgLXCl07MyTFzTP8oCoCxepQoPIafN8aytVQA5D4j0I0rw9zYm2Q== X-Received: by 2002:a05:600c:4f91:b0:426:6960:34ac with SMTP id 5b1f17b1804b1-427dc578d07mr25724585e9.36.1721607484208; Sun, 21 Jul 2024 17:18:04 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868bb00sm7016436f8f.43.2024.07.21.17.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:03 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:02 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki Subject: [PULL 35/63] virtio-net: Implement SR-IOV VF Message-ID: <4051d38a4ea4d1e80047e7d6c042d575e3fd2698.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Akihiko Odaki A virtio-net device can be added as a SR-IOV VF to another virtio-pci device that will be the PF. Signed-off-by: Akihiko Odaki Message-Id: <20240715-sriov-v5-7-3f5539093ffc@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-net-pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/virtio-net-pci.c b/hw/virtio/virtio-net-pci.c index e03543a70a..dba4987d6e 100644 --- a/hw/virtio/virtio-net-pci.c +++ b/hw/virtio/virtio-net-pci.c @@ -75,6 +75,7 @@ static void virtio_net_pci_class_init(ObjectClass *klass, void *data) k->device_id = PCI_DEVICE_ID_VIRTIO_NET; k->revision = VIRTIO_PCI_ABI_VERSION; k->class_id = PCI_CLASS_NETWORK_ETHERNET; + k->sriov_vf_user_creatable = true; set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); device_class_set_props(dc, virtio_net_properties); vpciklass->realize = virtio_net_pci_realize; From patchwork Mon Jul 22 00:18:04 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: 13738149 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 5EFD8C3DA61 for ; Mon, 22 Jul 2024 00:21:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgko-0007ms-KI; Sun, 21 Jul 2024 20:18:14 -0400 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 1sVgkm-0007dU-T6 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:12 -0400 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 1sVgkl-0005ry-4M for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607489; 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=5E7G/VDojDj4ibiTS3jf3QznN/MYs3lrA9S/9uTukCs=; b=QMrvZs1emuF/JtSyfv4Nqfz7+zIAeaTmreNBhbxLo15Tc0/1kicW2wvyDdPUmfcMnUsbQG tGYFUdtZrAHEQhNvgTwm9qLErHJhfzFQwRM18e5BrCIE+4GkveSslxyZfzAqJrXp8YKG+d b6h5IXwm/GIdkjkIGedwWgE373JchI8= 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-27-kvIZR77dPGu_tsauDmmbqg-1; Sun, 21 Jul 2024 20:18:08 -0400 X-MC-Unique: kvIZR77dPGu_tsauDmmbqg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4279837c024so26476995e9.2 for ; Sun, 21 Jul 2024 17:18:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607487; x=1722212287; 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=5E7G/VDojDj4ibiTS3jf3QznN/MYs3lrA9S/9uTukCs=; b=P5fOofpueT2W4EBlRPGWQvHXwPUz9d6UuN05cIFkma7AIjmMCEJK6Md3R5MuOh/d9b CtG2prFcmD75OjC3V9dSk9llAfdGmH9r8igT9oW6jPgOX3oK9YLOjjXWixYt4bQS6+16 fewbDQC70A78dbGG1cS4fI4KnUZvmDnmxS0RC93T6Ibk/8IwxHDV21g3uQq42ZGrb3Rt YgMlZlDjhAvKSK1af+lO/v0AjtLY12cP+Po9Tmbeu5YqNmuENv37SR7FkcowjnL1RpnE 6i4DFVlcFK1Y1wmRH2fCG/uIG05OlQdM8Am4+ImiMkkvTXiAivNY11olTogzu+Aaybkd HVog== X-Gm-Message-State: AOJu0Yyb403fPSDiZI4apjs7l1mVccNP2CHj6O4CVyU00gBRsfqLQI0E yA2IzUcq+ZrYBc6s1H1OaGNspHL7t/qEUBuGvrEvnNqKvUVzHBcqPJHwOnPvr0BKa9eYyLbfe61 LpG77uc4dqAFI5RaU5+vxIl+fbn7SZgB6ZZnUBirJLmo5Nz897I99ovGJ7J8SMHGWqLn310Jsg9 IuIR7XC2xRY5L0c6qZnTHCKpt+BMWStA== X-Received: by 2002:a05:600c:4e0b:b0:426:6960:34b0 with SMTP id 5b1f17b1804b1-427dc548427mr30233945e9.14.1721607486771; Sun, 21 Jul 2024 17:18:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxEVQ3KwS2LR2rWd0mmLiuRESKoOlbbP4m71TqGOKmjnPQ5ZGQPJGqVksckWRSl4u/svDYxA== X-Received: by 2002:a05:600c:4e0b:b0:426:6960:34b0 with SMTP id 5b1f17b1804b1-427dc548427mr30233805e9.14.1721607486158; Sun, 21 Jul 2024 17:18:06 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a721b7sm130681815e9.27.2024.07.21.17.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:05 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL 36/63] docs: Document composable SR-IOV device Message-ID: <7d09142ad4531b2c9f1a6394a591052a325f83c4.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Akihiko Odaki Signed-off-by: Akihiko Odaki Message-Id: <20240715-sriov-v5-8-3f5539093ffc@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- MAINTAINERS | 1 + docs/system/index.rst | 1 + docs/system/sriov.rst | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 docs/system/sriov.rst diff --git a/MAINTAINERS b/MAINTAINERS index 8ad64ff76b..93546cfb14 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2010,6 +2010,7 @@ F: hw/pci-bridge/* F: qapi/pci.json F: docs/pci* F: docs/specs/*pci* +F: docs/system/sriov.rst PCIE DOE M: Huai-Cheng Kuo diff --git a/docs/system/index.rst b/docs/system/index.rst index c21065e519..718e9d3c56 100644 --- a/docs/system/index.rst +++ b/docs/system/index.rst @@ -39,3 +39,4 @@ or Hypervisor.Framework. multi-process confidential-guest-support vm-templating + sriov diff --git a/docs/system/sriov.rst b/docs/system/sriov.rst new file mode 100644 index 0000000000..a851a66a4b --- /dev/null +++ b/docs/system/sriov.rst @@ -0,0 +1,36 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Compsable SR-IOV device +======================= + +SR-IOV (Single Root I/O Virtualization) is an optional extended capability of a +PCI Express device. It allows a single physical function (PF) to appear as +multiple virtual functions (VFs) for the main purpose of eliminating software +overhead in I/O from virtual machines. + +There are devices with predefined SR-IOV configurations, but it is also possible +to compose an SR-IOV device yourself. Composing an SR-IOV device is currently +only supported by virtio-net-pci. + +Users can configure an SR-IOV-capable virtio-net device by adding +virtio-net-pci functions to a bus. Below is a command line example: + +.. code-block:: shell + + -netdev user,id=n -netdev user,id=o + -netdev user,id=p -netdev user,id=q + -device pcie-root-port,id=b + -device virtio-net-pci,bus=b,addr=0x0.0x3,netdev=q,sriov-pf=f + -device virtio-net-pci,bus=b,addr=0x0.0x2,netdev=p,sriov-pf=f + -device virtio-net-pci,bus=b,addr=0x0.0x1,netdev=o,sriov-pf=f + -device virtio-net-pci,bus=b,addr=0x0.0x0,netdev=n,id=f + +The VFs specify the paired PF with ``sriov-pf`` property. The PF must be +added after all VFs. It is the user's responsibility to ensure that VFs have +function numbers larger than one of the PF, and that the function numbers +have a consistent stride. + +You may also need to perform additional steps to activate the SR-IOV feature on +your guest. For Linux, refer to [1]_. + +.. [1] https://docs.kernel.org/PCI/pci-iov-howto.html From patchwork Mon Jul 22 00:18:06 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: 13738154 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 AC221C3DA63 for ; Mon, 22 Jul 2024 00:21:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkq-0007z0-Kl; Sun, 21 Jul 2024 20:18:16 -0400 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 1sVgkp-0007sr-CP for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:15 -0400 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 1sVgkn-0005sR-IE for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607492; 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=wmqhjtW3VVd/s0tK/0z/W3SbHoTTKsvguEWbJfZllQs=; b=HZtJdit3TYKrjLs3HxJGgmq7jLwn2AVhFU3228L1eqgo3qCu/w0G50dFmBAlP9XN7fItNZ iV6fgFmL4h25y3pvJFXn9BJIlgfAYkosjtmWFRfBdDFiGjmJFb7zMqK2gUE+LZzx4ZZr7m SDvKy3QxjCl/mJ4Gr8Tc/67G9rSmfBw= 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-607-o7Bs_ihRNtONSFKEscfEmg-1; Sun, 21 Jul 2024 20:18:10 -0400 X-MC-Unique: o7Bs_ihRNtONSFKEscfEmg-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4272718b9b0so28091815e9.1 for ; Sun, 21 Jul 2024 17:18:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607489; x=1722212289; 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=wmqhjtW3VVd/s0tK/0z/W3SbHoTTKsvguEWbJfZllQs=; b=V4/vOmXPPAHDIWCr9XTBrEyzAgLJ0jyOs63fJfkBsUBj7TaLgEI8M3OigDuSGUOwzs ff+iZE9UbEdd9QRr0MzIBgdCYU28kAAZuAH5303stb6zwJa3BISmBN2EoNGsZH/911R4 p3orgISBEnd+rLtExjPPZPeCUP9LQlmKZzoiwItcZ2D2/i57JmrFkm+acs0Z0p/X2CfH hiB/FpYNEkco5geqnLS3pSBR5620YM9gUDJCYK5tOIXIHparhOikNvaNVIUCvRdfQwcD CVDE9ml1++UFWUMD6CDUzQ0iBDO0KxiF7+3AMA3fyayIsgKsKRZd3b+Kk17WeeSP5QDa gnOQ== X-Gm-Message-State: AOJu0YyIOnpiqoe4rcXbpQMb2T+59cgtCAh6sG+QcwDm/odRRaOYfZG2 PCfFGoPM/oVZz9vR2qJBld4ZD4Nzlh3vOxM41jzxhDK6fqZDQGw3qzvlAXrLxVmFsNfcc08Z8n3 Gqv37BBl7PqJ/aMHbitfWe1eZHG/3B5ZqPO7vdG85xCZckvxhjQ8tG2yk6yYzumtFKIf47QUN0o ebLoVcgl0peP45rwi6t0cCuimypj1JOA== X-Received: by 2002:a05:600c:3acb:b0:427:9dad:e6ac with SMTP id 5b1f17b1804b1-427dc586456mr34493735e9.34.1721607489039; Sun, 21 Jul 2024 17:18:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyOtAeRE+aIwMTy25tqZqKW4tLnyBG1isZ2hLUU44HXIE/i+j23w0grVM+kImYJyDExGnVHw== X-Received: by 2002:a05:600c:3acb:b0:427:9dad:e6ac with SMTP id 5b1f17b1804b1-427dc586456mr34493535e9.34.1721607488551; Sun, 21 Jul 2024 17:18:08 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d6934ec6sm106853125e9.41.2024.07.21.17.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:08 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:06 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Igor Mammedov , Eduardo Habkost , Marcel Apfelbaum , Philippe =?utf-8?q?Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Paolo Bonzini , Richard Henderson , Ani Sinha , qemu-arm@nongnu.org Subject: [PULL 37/63] smbios: make memory device size configurable per Machine Message-ID: <0dd7f4777d1d44fe67f3323b462bc0f0a2f686a2.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Igor Mammedov Currently QEMU describes initial[1] RAM* in SMBIOS as a series of virtual DIMMs (capped at 16Gb max) using type 17 structure entries. Which is fine for the most cases. However when starting guest with terabytes of RAM this leads to too many memory device structures, which eventually upsets linux kernel as it reserves only 64K for these entries and when that border is crossed out it runs out of reserved memory. Instead of partitioning initial RAM on 16Gb DIMMs, use maximum possible chunk size that SMBIOS spec allows[2]. Which lets encode RAM in lower 31 bits of 32bit field (which amounts upto 2047Tb per DIMM). As result initial RAM will generate only one type 17 structure until host/guest reach ability to use more RAM in the future. Compat changes: We can't unconditionally change chunk size as it will break QEMU<->guest ABI (and migration). Thus introduce a new machine class field that would let older versioned machines to use legacy 16Gb chunks, while new(er) machine type[s] use maximum possible chunk size. PS: While it might seem to be risky to rise max entry size this large (much beyond of what current physical RAM modules support), I'd not expect it causing much issues, modulo uncovering bugs in software running within guest. And those should be fixed on guest side to handle SMBIOS spec properly, especially if guest is expected to support so huge RAM configs. In worst case, QEMU can reduce chunk size later if we would care enough about introducing a workaround for some 'unfixable' guest OS, either by fixing up the next machine type or giving users a CLI option to customize it. 1) Initial RAM - is RAM configured with help '-m SIZE' CLI option/ implicitly defined by machine. It doesn't include memory configured with help of '-device' option[s] (pcdimm,nvdimm,...) 2) SMBIOS 3.1.0 7.18.5 Memory Device — Extended Size PS: * tested on 8Tb host with RHEL6 guest, which seems to parse type 17 SMBIOS table entries correctly (according to 'dmidecode'). Signed-off-by: Igor Mammedov Message-Id: <20240715122417.4059293-1-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/boards.h | 4 ++++ hw/arm/virt.c | 1 + hw/core/machine.c | 6 ++++++ hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + hw/smbios/smbios.c | 11 ++++++----- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index ef6f18f2c1..48ff6d8b93 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -237,6 +237,9 @@ typedef struct { * purposes only. * Applies only to default memory backend, i.e., explicit memory backend * wasn't used. + * @smbios_memory_device_size: + * Default size of memory device, + * SMBIOS 3.1.0 "7.18 Memory Device (Type 17)" */ struct MachineClass { /*< private >*/ @@ -304,6 +307,7 @@ struct MachineClass { const CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine); int64_t (*get_default_cpu_node_id)(const MachineState *ms, int idx); ram_addr_t (*fixup_ram_size)(ram_addr_t size); + uint64_t smbios_memory_device_size; }; /** diff --git a/hw/arm/virt.c b/hw/arm/virt.c index b0c68d66a3..719e83e6a1 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3308,6 +3308,7 @@ DEFINE_VIRT_MACHINE_AS_LATEST(9, 1) static void virt_machine_9_0_options(MachineClass *mc) { virt_machine_9_1_options(mc); + mc->smbios_memory_device_size = 16 * GiB; compat_props_add(mc->compat_props, hw_compat_9_0, hw_compat_9_0_len); } DEFINE_VIRT_MACHINE(9, 0) diff --git a/hw/core/machine.c b/hw/core/machine.c index bc38cad7f2..ac30544e7f 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1004,6 +1004,12 @@ static void machine_class_init(ObjectClass *oc, void *data) /* Default 128 MB as guest ram size */ mc->default_ram_size = 128 * MiB; mc->rom_file_has_mr = true; + /* + * SMBIOS 3.1.0 7.18.5 Memory Device — Extended Size + * use max possible value that could be encoded into + * 'Extended Size' field (2047Tb). + */ + mc->smbios_memory_device_size = 2047 * TiB; /* numa node memory size aligned on 8MB by default. * On Linux, each node's border has to be 8MB aligned diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 9445b07b4f..d9e69243b4 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -495,6 +495,7 @@ static void pc_i440fx_machine_9_0_options(MachineClass *m) pc_i440fx_machine_9_1_options(m); m->alias = NULL; m->is_default = false; + m->smbios_memory_device_size = 16 * GiB; compat_props_add(m->compat_props, hw_compat_9_0, hw_compat_9_0_len); compat_props_add(m->compat_props, pc_compat_9_0, pc_compat_9_0_len); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 71d3c6d122..9d108b194e 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -374,6 +374,7 @@ static void pc_q35_machine_9_0_options(MachineClass *m) PCMachineClass *pcmc = PC_MACHINE_CLASS(m); pc_q35_machine_9_1_options(m); m->alias = NULL; + m->smbios_memory_device_size = 16 * GiB; compat_props_add(m->compat_props, hw_compat_9_0, hw_compat_9_0_len); compat_props_add(m->compat_props, pc_compat_9_0, pc_compat_9_0_len); pcmc->isa_bios_alias = false; diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 3b7703489d..a394514264 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -1093,6 +1093,7 @@ static bool smbios_get_tables_ep(MachineState *ms, Error **errp) { unsigned i, dimm_cnt, offset; + MachineClass *mc = MACHINE_GET_CLASS(ms); ERRP_GUARD(); assert(ep_type == SMBIOS_ENTRY_POINT_TYPE_32 || @@ -1123,12 +1124,12 @@ static bool smbios_get_tables_ep(MachineState *ms, smbios_build_type_9_table(errp); smbios_build_type_11_table(); -#define MAX_DIMM_SZ (16 * GiB) -#define GET_DIMM_SZ ((i < dimm_cnt - 1) ? MAX_DIMM_SZ \ - : ((current_machine->ram_size - 1) % MAX_DIMM_SZ) + 1) +#define GET_DIMM_SZ ((i < dimm_cnt - 1) ? mc->smbios_memory_device_size \ + : ((current_machine->ram_size - 1) % mc->smbios_memory_device_size) + 1) - dimm_cnt = QEMU_ALIGN_UP(current_machine->ram_size, MAX_DIMM_SZ) / - MAX_DIMM_SZ; + dimm_cnt = QEMU_ALIGN_UP(current_machine->ram_size, + mc->smbios_memory_device_size) / + mc->smbios_memory_device_size; /* * The offset determines if we need to keep additional space between From patchwork Mon Jul 22 00:18: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: 13738162 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 E4D52C3DA61 for ; Mon, 22 Jul 2024 00:23:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgkw-00006i-FR; Sun, 21 Jul 2024 20:18:23 -0400 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 1sVgks-0008Cj-A4 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:18 -0400 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 1sVgkq-0005so-1P for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607495; 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=gJr1WpFyP035ncVh4reYlb2V1cyFXZTXswtAGoUIz8s=; b=hQRQHs1E3WIHJySdgU5CE/KhIcfDGwv+/iPvKHQprQyyvBROAkkolUVS1VTCuvuTrLdxqn l4tPPITlVgm+CxEX/favgX+Fcm5VABgvALj9m30JDfQ2dDRX//Zd/YoBzuij3P578FDc+L /XFJMPiD0SiWn5/Hw7DcF/HkWJAf0IQ= 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-687-mm-JpQqPPn-mX0o2sRC4qQ-1; Sun, 21 Jul 2024 20:18:13 -0400 X-MC-Unique: mm-JpQqPPn-mX0o2sRC4qQ-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42794cb8251so27670125e9.2 for ; Sun, 21 Jul 2024 17:18:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607491; x=1722212291; 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=gJr1WpFyP035ncVh4reYlb2V1cyFXZTXswtAGoUIz8s=; b=CzyAI0imxtqXpZGhbZ3l44HIrdxDqmvTWDTmzPOy3HkgTRMtlWDZiGDPwtUnM+dbrm lNl0B0bbDrUWVPoJGRtLbNX6BAAxHggiypUpCmZvN/pvHiO0uJ5U4VUTgUC/RuWzKj82 DXZYc27py3wgKP+dzBOwImLMZ4iE6k9lRVsqe/D2VwYPIndsPfzT5VBqg01KaHHgCFHs zP74GaEo2yFrir4sz8vdlovuP7GHUPcZyE4OISGfQDOPV+cL3PHamROtmjBmakoOtnr+ n7zfAC0AOAYmwdR3dV6xjBFpzIL5HEwS6Vl1SaJL1ziJ2cqFsyknzbJc6wSCkq4EBO+G VOhA== X-Gm-Message-State: AOJu0Yw7CtVgYkyEfO9JuEV2IMHPPbRs+MhKcKPydRSOKKwG/Enec9B5 qaLieY9o9aRt2zpuKBLFsceObHelaWKNMwTJS6RWHjla9snz0QtxjMRvKpO1MGKz3iMBr6ycctf AEs32PpTI27ZSLJsDIIPi8UOVr/pIcCwele9MqTdloi5dplF1zfetjJLX6d57GncU1SGvGbbo2V 4tbG89CsaHwSsQqrM5a6jWuz8PfZIhFg== X-Received: by 2002:a05:600c:1c09:b0:426:8884:3781 with SMTP id 5b1f17b1804b1-427daa61ca9mr38652365e9.24.1721607491639; Sun, 21 Jul 2024 17:18:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFp6+9baDwsEiyEPnA7xIaxHkcyq2LXt0iMcBVbyVGBbQ+k+uHq2tc7uERjPkGcHeAVyTHa5g== X-Received: by 2002:a05:600c:1c09:b0:426:8884:3781 with SMTP id 5b1f17b1804b1-427daa61ca9mr38652065e9.24.1721607491075; Sun, 21 Jul 2024 17:18:11 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868b24csm6992468f8f.25.2024.07.21.17.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:10 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Salil Mehta , Gavin Shan , Vishnu Pajjuri , Jonathan Cameron , Xianglai Li , Miguel Luis , Shaoqin Huang , Nicholas Piggin , Zhao Liu , Harsh Prateek Bora , Igor Mammedov , Paolo Bonzini , kvm@vger.kernel.org Subject: [PULL 38/63] accel/kvm: Extract common KVM vCPU {creation,parking} code Message-ID: <5a847065050b8bef70a8819ecc057b6103798514.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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 KVM vCPU creation is done once during the vCPU realization when Qemu vCPU thread is spawned. This is common to all the architectures as of now. Hot-unplug of vCPU results in destruction of the vCPU object in QOM but the corresponding KVM vCPU object in the Host KVM is not destroyed as KVM doesn't support vCPU removal. Therefore, its representative KVM vCPU object/context in Qemu is parked. Refactor architecture common logic so that some APIs could be reused by vCPU Hotplug code of some architectures likes ARM, Loongson etc. Update new/old APIs with trace events. New APIs qemu_{create,park,unpark}_vcpu() can be externally called. No functional change is intended here. Signed-off-by: Salil Mehta Reviewed-by: Gavin Shan Tested-by: Vishnu Pajjuri Reviewed-by: Jonathan Cameron Tested-by: Xianglai Li Tested-by: Miguel Luis Reviewed-by: Shaoqin Huang Reviewed-by: Vishnu Pajjuri Reviewed-by: Nicholas Piggin Tested-by: Zhao Liu Reviewed-by: Zhao Liu Reviewed-by: Harsh Prateek Bora Reviewed-by: Igor Mammedov Message-Id: <20240716111502.202344-2-salil.mehta@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- accel/kvm/kvm-cpus.h | 1 - include/sysemu/kvm.h | 25 +++++++++++ accel/kvm/kvm-all.c | 95 ++++++++++++++++++++++++++++-------------- accel/kvm/trace-events | 5 ++- 4 files changed, 92 insertions(+), 34 deletions(-) diff --git a/accel/kvm/kvm-cpus.h b/accel/kvm/kvm-cpus.h index ca40add32c..171b22fd29 100644 --- a/accel/kvm/kvm-cpus.h +++ b/accel/kvm/kvm-cpus.h @@ -22,5 +22,4 @@ bool kvm_supports_guest_debug(void); int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len); int kvm_remove_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len); void kvm_remove_all_breakpoints(CPUState *cpu); - #endif /* KVM_CPUS_H */ diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index c31d9c7356..c4a914b3d8 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -313,6 +313,31 @@ int kvm_create_device(KVMState *s, uint64_t type, bool test); */ bool kvm_device_supported(int vmfd, uint64_t type); +/** + * kvm_create_vcpu - Gets a parked KVM vCPU or creates a KVM vCPU + * @cpu: QOM CPUState object for which KVM vCPU has to be fetched/created. + * + * @returns: 0 when success, errno (<0) when failed. + */ +int kvm_create_vcpu(CPUState *cpu); + +/** + * kvm_park_vcpu - Park QEMU KVM vCPU context + * @cpu: QOM CPUState object for which QEMU KVM vCPU context has to be parked. + * + * @returns: none + */ +void kvm_park_vcpu(CPUState *cpu); + +/** + * kvm_unpark_vcpu - unpark QEMU KVM vCPU context + * @s: KVM State + * @vcpu_id: Architecture vCPU ID of the parked vCPU + * + * @returns: KVM fd + */ +int kvm_unpark_vcpu(KVMState *s, unsigned long vcpu_id); + /* Arch specific hooks */ extern const KVMCapabilityInfo kvm_arch_required_capabilities[]; diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 64bf47a033..0f110cce3e 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -340,14 +340,71 @@ err: return ret; } +void kvm_park_vcpu(CPUState *cpu) +{ + struct KVMParkedVcpu *vcpu; + + trace_kvm_park_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu)); + + vcpu = g_malloc0(sizeof(*vcpu)); + vcpu->vcpu_id = kvm_arch_vcpu_id(cpu); + vcpu->kvm_fd = cpu->kvm_fd; + QLIST_INSERT_HEAD(&kvm_state->kvm_parked_vcpus, vcpu, node); +} + +int kvm_unpark_vcpu(KVMState *s, unsigned long vcpu_id) +{ + struct KVMParkedVcpu *cpu; + int kvm_fd = -ENOENT; + + QLIST_FOREACH(cpu, &s->kvm_parked_vcpus, node) { + if (cpu->vcpu_id == vcpu_id) { + QLIST_REMOVE(cpu, node); + kvm_fd = cpu->kvm_fd; + g_free(cpu); + } + } + + trace_kvm_unpark_vcpu(vcpu_id, kvm_fd > 0 ? "unparked" : "!found parked"); + + return kvm_fd; +} + +int kvm_create_vcpu(CPUState *cpu) +{ + unsigned long vcpu_id = kvm_arch_vcpu_id(cpu); + KVMState *s = kvm_state; + int kvm_fd; + + /* check if the KVM vCPU already exist but is parked */ + kvm_fd = kvm_unpark_vcpu(s, vcpu_id); + if (kvm_fd < 0) { + /* vCPU not parked: create a new KVM vCPU */ + kvm_fd = kvm_vm_ioctl(s, KVM_CREATE_VCPU, vcpu_id); + if (kvm_fd < 0) { + error_report("KVM_CREATE_VCPU IOCTL failed for vCPU %lu", vcpu_id); + return kvm_fd; + } + } + + cpu->kvm_fd = kvm_fd; + cpu->kvm_state = s; + cpu->vcpu_dirty = true; + cpu->dirty_pages = 0; + cpu->throttle_us_per_full = 0; + + trace_kvm_create_vcpu(cpu->cpu_index, vcpu_id, kvm_fd); + + return 0; +} + static int do_kvm_destroy_vcpu(CPUState *cpu) { KVMState *s = kvm_state; long mmap_size; - struct KVMParkedVcpu *vcpu = NULL; int ret = 0; - trace_kvm_destroy_vcpu(); + trace_kvm_destroy_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu)); ret = kvm_arch_destroy_vcpu(cpu); if (ret < 0) { @@ -373,10 +430,7 @@ static int do_kvm_destroy_vcpu(CPUState *cpu) } } - vcpu = g_malloc0(sizeof(*vcpu)); - vcpu->vcpu_id = kvm_arch_vcpu_id(cpu); - vcpu->kvm_fd = cpu->kvm_fd; - QLIST_INSERT_HEAD(&kvm_state->kvm_parked_vcpus, vcpu, node); + kvm_park_vcpu(cpu); err: return ret; } @@ -389,24 +443,6 @@ void kvm_destroy_vcpu(CPUState *cpu) } } -static int kvm_get_vcpu(KVMState *s, unsigned long vcpu_id) -{ - struct KVMParkedVcpu *cpu; - - QLIST_FOREACH(cpu, &s->kvm_parked_vcpus, node) { - if (cpu->vcpu_id == vcpu_id) { - int kvm_fd; - - QLIST_REMOVE(cpu, node); - kvm_fd = cpu->kvm_fd; - g_free(cpu); - return kvm_fd; - } - } - - return kvm_vm_ioctl(s, KVM_CREATE_VCPU, (void *)vcpu_id); -} - int kvm_init_vcpu(CPUState *cpu, Error **errp) { KVMState *s = kvm_state; @@ -415,19 +451,14 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp) trace_kvm_init_vcpu(cpu->cpu_index, kvm_arch_vcpu_id(cpu)); - ret = kvm_get_vcpu(s, kvm_arch_vcpu_id(cpu)); + ret = kvm_create_vcpu(cpu); if (ret < 0) { - error_setg_errno(errp, -ret, "kvm_init_vcpu: kvm_get_vcpu failed (%lu)", + error_setg_errno(errp, -ret, + "kvm_init_vcpu: kvm_create_vcpu failed (%lu)", kvm_arch_vcpu_id(cpu)); goto err; } - cpu->kvm_fd = ret; - cpu->kvm_state = s; - cpu->vcpu_dirty = true; - cpu->dirty_pages = 0; - cpu->throttle_us_per_full = 0; - mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0); if (mmap_size < 0) { ret = mmap_size; diff --git a/accel/kvm/trace-events b/accel/kvm/trace-events index 681ccb667d..37626c1ac5 100644 --- a/accel/kvm/trace-events +++ b/accel/kvm/trace-events @@ -9,6 +9,10 @@ kvm_device_ioctl(int fd, int type, void *arg) "dev fd %d, type 0x%x, arg %p" kvm_failed_reg_get(uint64_t id, const char *msg) "Warning: Unable to retrieve ONEREG %" PRIu64 " from KVM: %s" kvm_failed_reg_set(uint64_t id, const char *msg) "Warning: Unable to set ONEREG %" PRIu64 " to KVM: %s" kvm_init_vcpu(int cpu_index, unsigned long arch_cpu_id) "index: %d id: %lu" +kvm_create_vcpu(int cpu_index, unsigned long arch_cpu_id, int kvm_fd) "index: %d, id: %lu, kvm fd: %d" +kvm_destroy_vcpu(int cpu_index, unsigned long arch_cpu_id) "index: %d id: %lu" +kvm_park_vcpu(int cpu_index, unsigned long arch_cpu_id) "index: %d id: %lu" +kvm_unpark_vcpu(unsigned long arch_cpu_id, const char *msg) "id: %lu %s" kvm_irqchip_commit_routes(void) "" kvm_irqchip_add_msi_route(char *name, int vector, int virq) "dev %s vector %d virq %d" kvm_irqchip_update_msi_route(int virq) "Updating MSI route virq=%d" @@ -25,7 +29,6 @@ kvm_dirty_ring_reaper(const char *s) "%s" kvm_dirty_ring_reap(uint64_t count, int64_t t) "reaped %"PRIu64" pages (took %"PRIi64" us)" kvm_dirty_ring_reaper_kick(const char *reason) "%s" kvm_dirty_ring_flush(int finished) "%d" -kvm_destroy_vcpu(void) "" kvm_failed_get_vcpu_mmap_size(void) "" kvm_cpu_exec(void) "" kvm_interrupt_exit_request(void) "" From patchwork Mon Jul 22 00:18:11 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: 13738140 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 E0FCCC3DA61 for ; Mon, 22 Jul 2024 00:19:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVglH-0000l2-BD; Sun, 21 Jul 2024 20:18:45 -0400 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 1sVgkt-0008NN-Bq for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:19 -0400 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 1sVgkr-0005t3-P3 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607497; 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=glIE7906tG8xbsdQlnyVht0Qfp0CHdCdyn4JQdsY2qk=; b=Yd9GAm1v0TmHHD2KmtIDEeevzCmkrc+GRz6Ut6JBOsPjQxzWL2xP501mKa/kSvtZSawBpR jo853tAPFb+/Zaa2laXsdCURUxmgTEhy3qSwiwerjyeeNYBshEwOfkRXUzaPFrDZzrgU6Y SfataLdZTV9FERTQkME6MLpQ8QB2j2I= 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-37-MHxxYfQKPOmD-CqxkAw0-w-1; Sun, 21 Jul 2024 20:18:15 -0400 X-MC-Unique: MHxxYfQKPOmD-CqxkAw0-w-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-36865706f5eso2223908f8f.0 for ; Sun, 21 Jul 2024 17:18:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607494; x=1722212294; 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=glIE7906tG8xbsdQlnyVht0Qfp0CHdCdyn4JQdsY2qk=; b=DNDolvy2MYjlqnhb3syWYjNOlkonFJ7wYCJFH6hx5E5hFi6w8NK+or0fnU/hcWAJ6D JakX37MfMh9JG+1ZEJVda8Gg6e+o+F0PBFBrUJUu8NxJ5bzEbkkHmJeV+U5q4J8KSBNO DaAjZcMUCN2SgN/EdHV0sC8S+B8O/qw1js/TKctocucxQRpKEbyf8Ux4Pgx1X74ZmPtx fxOY8aS/keESBh0rdS2MAmok3pZVAGB4VqygnEt8HOhRCnX09PC59aeJZmknrDRk1ULU 2hpD+qhfcillrgHZpwEdDxeIYX777QhxCywo7D16EFyHeB2IsYHYoH0kus1FbBYNSOA3 DLNg== X-Gm-Message-State: AOJu0YyrgfCXambCNcV9goPjCwmPEKDC0M98rNbYm4FA766Rjj3ozC7Y 5M9Fa+sogBIshJLkAUfjyOEerJ1QJ+n+oXqfXljkT6+w+TYPicpXO4u0SX7ZVMBKTTFetzhpDBL o71/nd0WcqyFstVu64ZFp7kjrcIU+eggpIAST5meO914gwwHF4f05aY00EJ0q6M6hKzNcaRq2rJ 9Hl+aKUkVfSCa/20jRJsXkgD4pJZguhQ== X-Received: by 2002:a5d:6b0d:0:b0:368:4edc:611e with SMTP id ffacd0b85a97d-369bae3c846mr2760755f8f.14.1721607493822; Sun, 21 Jul 2024 17:18:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqsaSk4gFPaUyOndWdxQeO0NqdQGJSWQv/k9l7RrZGhO3ssqhFlMhx43tJdHhQ3oT/Bq9sWg== X-Received: by 2002:a5d:6b0d:0:b0:368:4edc:611e with SMTP id ffacd0b85a97d-369bae3c846mr2760734f8f.14.1721607493340; Sun, 21 Jul 2024 17:18:13 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787ceccasm6962687f8f.81.2024.07.21.17.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:12 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:11 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Salil Mehta , Alex =?utf-8?q?Benn=C3=A9e?= , Jonathan Cameron , Gavin Shan , David Hildenbrand , Shaoqin Huang , Vishnu Pajjuri , Xianglai Li , Miguel Luis , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 39/63] hw/acpi: Move CPU ctrl-dev MMIO region len macro to common header file Message-ID: <9b16367d9ab2ab32fbd48b4c243a33ba66eb79ce.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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 CPU ctrl-dev MMIO region length could be used in ACPI GED and various other architecture specific places. Move ACPI_CPU_HOTPLUG_REG_LEN macro to more appropriate common header file. Signed-off-by: Salil Mehta Reviewed-by: Alex Bennée Reviewed-by: Jonathan Cameron Reviewed-by: Gavin Shan Reviewed-by: David Hildenbrand Reviewed-by: Shaoqin Huang Tested-by: Vishnu Pajjuri Tested-by: Xianglai Li Tested-by: Miguel Luis Tested-by: Zhao Liu Reviewed-by: Zhao Liu Reviewed-by: Igor Mammedov Message-Id: <20240716111502.202344-3-salil.mehta@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/cpu.h | 2 ++ hw/acpi/cpu.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h index e6e1a9ef59..df87b15997 100644 --- a/include/hw/acpi/cpu.h +++ b/include/hw/acpi/cpu.h @@ -19,6 +19,8 @@ #include "hw/boards.h" #include "hw/hotplug.h" +#define ACPI_CPU_HOTPLUG_REG_LEN 12 + typedef struct AcpiCpuStatus { CPUState *cpu; uint64_t arch_id; diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index 2d81c1e790..cf5e9183e4 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -7,7 +7,6 @@ #include "trace.h" #include "sysemu/numa.h" -#define ACPI_CPU_HOTPLUG_REG_LEN 12 #define ACPI_CPU_SELECTOR_OFFSET_WR 0 #define ACPI_CPU_FLAGS_OFFSET_RW 4 #define ACPI_CPU_CMD_OFFSET_WR 5 From patchwork Mon Jul 22 00:18: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: 13738189 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 BA567C3DA63 for ; Mon, 22 Jul 2024 00:28:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgls-0004VW-U3; Sun, 21 Jul 2024 20:19:21 -0400 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 1sVgkw-0000KN-O2 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:23 -0400 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 1sVgku-0005tR-Av for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607499; 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=T+5K6DenD/BNBvf8O7CFbeMuv8YmbqeLYA/hq2CgnkY=; b=W+VYw6Kv96USRgedUTIs7PaDkfwFNKZyLsx34nWn7VJ+3h5IQg1/wNS1Yrko/c/x2u1Mup iJHsCuDrZUU6Ex+DMzcmE9MqWFMTQbTMzKfWhm2iQFVqt/dQXWv+6bLCfnA2CR7CL+6+H6 54zlRrvT727N0EeKmS27I7oQtgl78wc= 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-32-ylVITSUvOf2X8lMSS4h7vw-1; Sun, 21 Jul 2024 20:18:18 -0400 X-MC-Unique: ylVITSUvOf2X8lMSS4h7vw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-427b57e3c6fso26533545e9.1 for ; Sun, 21 Jul 2024 17:18:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607496; x=1722212296; 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=T+5K6DenD/BNBvf8O7CFbeMuv8YmbqeLYA/hq2CgnkY=; b=Z6B9tB7pZfvvqrmGiVA8ya2k4DSam9/yEJkvV8xInnmli/CQmVN4Xj+ROrPM4m7Qn4 D7TuFNZmai7CffdHF5gLzI8YcPKO0IZT7OoMC9WN5DC+YlR2LkOg80KHEPSg1T23idZS +qch4at9nRJKgO5L1H/iPSR+7pnmJaPGoKDio66WQNmr257W5/MwxVvPL6u92OfolkhW CAHcGR3jjiQ2kkq2i+svE0qf9uGwy6jbwN7vDuFrA8AZZeWfI1yEOFSpQLh5cmMhdBTk DZ3FpBodZLxzxiRlQYxVqbwuLoVCnQ5l+LTFN/EpmNnLa3i2weGDJi2eGkHqQPH6aMlW K1qw== X-Gm-Message-State: AOJu0YytQI47jM4dRxo4EURQtgmFYDDi8Tx1hSsLwO0HJWERDyJatKd4 A4DZXYHWfQTxjoZmdqsAO3F1Wa9N9Da0RDWBfKwMlgdkGF+pChl9ugz3pz68XWkMQpdYh8OIYJP 3bKXncQwJeagX72XQv8hoTwzdP5z/nMVaWp6q5qDuT9As8uUxNWHEKOlZJcPSDODlHj/+XJzb84 /Br1FTkc2hhmtxNsmtP9YYB1IosUUFcg== X-Received: by 2002:a05:600c:1ca8:b0:426:62c5:473e with SMTP id 5b1f17b1804b1-427dc58f1e8mr33501665e9.26.1721607496590; Sun, 21 Jul 2024 17:18:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMOjj2YAghyagvHCJGOVVWFYU0NVVFzXwmvliJgnMWKmCg1JgZxXvVLeKZzbNTj6m4uxnQfw== X-Received: by 2002:a05:600c:1ca8:b0:426:62c5:473e with SMTP id 5b1f17b1804b1-427dc58f1e8mr33501415e9.26.1721607496053; Sun, 21 Jul 2024 17:18:16 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a804a4sm62337845e9.1.2024.07.21.17.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:15 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Salil Mehta , Keqian Zhu , Jonathan Cameron , Gavin Shan , David Hildenbrand , Shaoqin Huang , Vishnu Pajjuri , Xianglai Li , Miguel Luis , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 40/63] hw/acpi: Update ACPI GED framework to support vCPU Hotplug Message-ID: <5ac16b45ea9924eb30664470d6b75838b628c5d3.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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 ACPI GED (as described in the ACPI 6.4 spec) uses an interrupt listed in the _CRS object of GED to intimate OSPM about an event. Later then demultiplexes the notified event by evaluating ACPI _EVT method to know the type of event. Use ACPI GED to also notify the guest kernel about any CPU hot(un)plug events. Note, GED interface is used by many hotplug events like memory hotplug, NVDIMM hotplug and non-hotplug events like system power down event. Each of these can be selected using a bit in the 32 bit GED IO interface. A bit has been reserved for the CPU hotplug event. ACPI CPU hotplug related initialization should only happen if ACPI_CPU_HOTPLUG support has been enabled for particular architecture. Add cpu_hotplug_hw_init() stub to avoid compilation break. Co-developed-by: Keqian Zhu Signed-off-by: Keqian Zhu Signed-off-by: Salil Mehta Reviewed-by: Jonathan Cameron Reviewed-by: Gavin Shan Reviewed-by: David Hildenbrand Reviewed-by: Shaoqin Huang Tested-by: Vishnu Pajjuri Tested-by: Xianglai Li Tested-by: Miguel Luis Reviewed-by: Vishnu Pajjuri Tested-by: Zhao Liu Reviewed-by: Zhao Liu Message-Id: <20240716111502.202344-4-salil.mehta@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Igor Mammedov --- include/hw/acpi/generic_event_device.h | 4 +++ hw/acpi/acpi-cpu-hotplug-stub.c | 6 ++++ hw/acpi/generic_event_device.c | 47 ++++++++++++++++++++++++++ docs/specs/acpi_hw_reduced_hotplug.rst | 3 +- 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h index ba84ce0214..e091ac2108 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -62,6 +62,7 @@ #include "hw/sysbus.h" #include "hw/acpi/memory_hotplug.h" #include "hw/acpi/ghes.h" +#include "hw/acpi/cpu.h" #include "qom/object.h" #define ACPI_POWER_BUTTON_DEVICE "PWRB" @@ -95,6 +96,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AcpiGedState, ACPI_GED) #define ACPI_GED_MEM_HOTPLUG_EVT 0x1 #define ACPI_GED_PWR_DOWN_EVT 0x2 #define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4 +#define ACPI_GED_CPU_HOTPLUG_EVT 0x8 typedef struct GEDState { MemoryRegion evt; @@ -106,6 +108,8 @@ struct AcpiGedState { SysBusDevice parent_obj; MemHotplugState memhp_state; MemoryRegion container_memhp; + CPUHotplugState cpuhp_state; + MemoryRegion container_cpuhp; GEDState ged_state; uint32_t ged_event_bitmap; qemu_irq irq; diff --git a/hw/acpi/acpi-cpu-hotplug-stub.c b/hw/acpi/acpi-cpu-hotplug-stub.c index 3fc4b14c26..c6c61bb9cd 100644 --- a/hw/acpi/acpi-cpu-hotplug-stub.c +++ b/hw/acpi/acpi-cpu-hotplug-stub.c @@ -19,6 +19,12 @@ void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, return; } +void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner, + CPUHotplugState *state, hwaddr base_addr) +{ + return; +} + void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list) { return; diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 2d6e91b124..4641933a0f 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -25,6 +25,7 @@ static const uint32_t ged_supported_events[] = { ACPI_GED_MEM_HOTPLUG_EVT, ACPI_GED_PWR_DOWN_EVT, ACPI_GED_NVDIMM_HOTPLUG_EVT, + ACPI_GED_CPU_HOTPLUG_EVT, }; /* @@ -234,6 +235,8 @@ static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev, } else { acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp); } + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + acpi_cpu_plug_cb(hotplug_dev, &s->cpuhp_state, dev, errp); } else { error_setg(errp, "virt: device plug request for unsupported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -248,6 +251,8 @@ static void acpi_ged_unplug_request_cb(HotplugHandler *hotplug_dev, if ((object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) && !(object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)))) { acpi_memory_unplug_request_cb(hotplug_dev, &s->memhp_state, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp); } else { error_setg(errp, "acpi: device unplug request for unsupported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -261,6 +266,8 @@ static void acpi_ged_unplug_cb(HotplugHandler *hotplug_dev, if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { acpi_memory_unplug_cb(&s->memhp_state, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + acpi_cpu_unplug_cb(&s->cpuhp_state, dev, errp); } else { error_setg(errp, "acpi: device unplug for unsupported device" " type: %s", object_get_typename(OBJECT(dev))); @@ -272,6 +279,7 @@ static void acpi_ged_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list) AcpiGedState *s = ACPI_GED(adev); acpi_memory_ospm_status(&s->memhp_state, list); + acpi_cpu_ospm_status(&s->cpuhp_state, list); } static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) @@ -286,6 +294,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) sel = ACPI_GED_PWR_DOWN_EVT; } else if (ev & ACPI_NVDIMM_HOTPLUG_STATUS) { sel = ACPI_GED_NVDIMM_HOTPLUG_EVT; + } else if (ev & ACPI_CPU_HOTPLUG_STATUS) { + sel = ACPI_GED_CPU_HOTPLUG_EVT; } else { /* Unknown event. Return without generating interrupt. */ warn_report("GED: Unsupported event %d. No irq injected", ev); @@ -371,6 +381,42 @@ static const VMStateDescription vmstate_acpi_ged = { } }; +static void acpi_ged_realize(DeviceState *dev, Error **errp) +{ + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); + AcpiGedState *s = ACPI_GED(dev); + uint32_t ged_events; + int i; + + ged_events = ctpop32(s->ged_event_bitmap); + + for (i = 0; i < ARRAY_SIZE(ged_supported_events) && ged_events; i++) { + uint32_t event = s->ged_event_bitmap & ged_supported_events[i]; + + if (!event) { + continue; + } + + switch (event) { + case ACPI_GED_CPU_HOTPLUG_EVT: + /* initialize CPU Hotplug related regions */ + memory_region_init(&s->container_cpuhp, OBJECT(dev), + "cpuhp container", + ACPI_CPU_HOTPLUG_REG_LEN); + sysbus_init_mmio(sbd, &s->container_cpuhp); + cpu_hotplug_hw_init(&s->container_cpuhp, OBJECT(dev), + &s->cpuhp_state, 0); + break; + } + ged_events--; + } + + if (ged_events) { + error_report("Unsupported events specified"); + abort(); + } +} + static void acpi_ged_initfn(Object *obj) { DeviceState *dev = DEVICE(obj); @@ -411,6 +457,7 @@ static void acpi_ged_class_init(ObjectClass *class, void *data) dc->desc = "ACPI Generic Event Device"; device_class_set_props(dc, acpi_ged_properties); dc->vmsd = &vmstate_acpi_ged; + dc->realize = acpi_ged_realize; hc->plug = acpi_ged_device_plug_cb; hc->unplug_request = acpi_ged_unplug_request_cb; diff --git a/docs/specs/acpi_hw_reduced_hotplug.rst b/docs/specs/acpi_hw_reduced_hotplug.rst index 0bd3f9399f..3acd6fcd8b 100644 --- a/docs/specs/acpi_hw_reduced_hotplug.rst +++ b/docs/specs/acpi_hw_reduced_hotplug.rst @@ -64,7 +64,8 @@ GED IO interface (4 byte access) 0: Memory hotplug event 1: System power down event 2: NVDIMM hotplug event - 3-31: Reserved + 3: CPU hotplug event + 4-31: Reserved **write_access:** From patchwork Mon Jul 22 00:18: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: 13738144 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 E3EE3C3DA5D for ; Mon, 22 Jul 2024 00:19:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVglv-0004em-70; Sun, 21 Jul 2024 20:19:24 -0400 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 1sVgky-0000dD-V3 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:25 -0400 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 1sVgkw-0005tZ-AX for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607501; 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=sZSgHsYIlqu62oOYqEz8U74/NNGfq5BqJa6TiXLGU28=; b=OcqIcppQgn9nNoyYnoSsa93RdS8P774FhhmOuf6LN6/UwS543VvgLL3cjdCe/RIQPTpnof j2CMUaGcdsc8wz+bK7cVR/CyIA2fmA6q1AUahaezeDXyBHOOLyBZOqsNBcUCMvYgNbV0u2 aLsgubz7/Xce7dEIE8MKvzOw2mOXxCE= 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-330-umMXAXSzMQSgGtm0IOBoUg-1; Sun, 21 Jul 2024 20:18:20 -0400 X-MC-Unique: umMXAXSzMQSgGtm0IOBoUg-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-368448dfe12so1083469f8f.1 for ; Sun, 21 Jul 2024 17:18:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607499; x=1722212299; 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=sZSgHsYIlqu62oOYqEz8U74/NNGfq5BqJa6TiXLGU28=; b=LP5L0wZ0byR0bvUmClnInZGPDUjujrPYt6Ln6zKKgOHXOZQQwNayFBhj8pGheKgoNr rd6S5AGVo5TB1t7pJDmO1gHURFgVdKcBerhHcyInrOBO2Oo4VGzJpMtIVytmktDpNWMq AGAlZJgXv+5N7U0s71dxqzDnjGprxSsggHAqxUkh3WtNYsiUzwhRFTYGmVb29+nqg8ar NtCQsuUd4GIlaFrnNXviWRKubS5pVd1tfLMOf/hBt3kRbhqLuP0erKkxcUWz+MlBPPVx 5P1VP/FEvGF2uxHHICqnWquubcgOSMgRdVsEi90hIaKqjhbL18gJULlWXIO8SOEvnohE M9Ag== X-Gm-Message-State: AOJu0YxwUPRx10+xjKb845zsE1G6bwSQGMXk4fU5kFN0wHK0ZGw+8a1j 4QxZzntIz53KlXKSc+MFxwj8NvnESjAmrvUzPf2DLhx5uSJpZ9It9R/Evj9+6l2HLAG0+K4gWKj lSocCxHDhlpyhp8Vl+L2/hJ/D1vdLN/ZtP03MknDzat1Js2NM7U6iSxOW2eO7z0V7r3g9QKElIs +rXVsFRrU+TSebppFlH97SkW9QYU7paA== X-Received: by 2002:a5d:64e6:0:b0:367:8fee:4434 with SMTP id ffacd0b85a97d-369c6cbc6demr2625268f8f.16.1721607498865; Sun, 21 Jul 2024 17:18:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGK+6zlxyCwXaMhJ56jglivt3PF1+NKzmfKZuVzKMpYafUXEDe0ATnhcD1Ak/Im0bxZDROBow== X-Received: by 2002:a5d:64e6:0:b0:367:8fee:4434 with SMTP id ffacd0b85a97d-369c6cbc6demr2625249f8f.16.1721607498350; Sun, 21 Jul 2024 17:18:18 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787eb6b0sm7011291f8f.90.2024.07.21.17.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:17 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Salil Mehta , Keqian Zhu , Jonathan Cameron , Gavin Shan , Vishnu Pajjuri , Xianglai Li , Miguel Luis , Shaoqin Huang , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 41/63] hw/acpi: Update GED _EVT method AML with CPU scan 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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 OSPM evaluates _EVT method to map the event. The CPU hotplug event eventually results in start of the CPU scan. Scan figures out the CPU and the kind of event(plug/unplug) and notifies it back to the guest. Update the GED AML _EVT method with the call to method \\_SB.CPUS.CSCN (via \\_SB.GED.CSCN) Architecture specific code [1] might initialize its CPUs AML code by calling common function build_cpus_aml() like below for ARM: build_cpus_aml(scope, ms, opts, xx_madt_cpu_entry, memmap[VIRT_CPUHP_ACPI].base, "\\_SB", "\\_SB.GED.CSCN", AML_SYSTEM_MEMORY); [1] https://lore.kernel.org/qemu-devel/20240613233639.202896-13-salil.mehta@huawei.com/ Co-developed-by: Keqian Zhu Signed-off-by: Keqian Zhu Signed-off-by: Salil Mehta Reviewed-by: Jonathan Cameron Reviewed-by: Gavin Shan Tested-by: Vishnu Pajjuri Tested-by: Xianglai Li Tested-by: Miguel Luis Reviewed-by: Shaoqin Huang Tested-by: Zhao Liu Reviewed-by: Igor Mammedov Message-Id: <20240716111502.202344-5-salil.mehta@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/generic_event_device.h | 1 + hw/acpi/generic_event_device.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h index e091ac2108..40af3550b5 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -87,6 +87,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AcpiGedState, ACPI_GED) #define GED_DEVICE "GED" #define AML_GED_EVT_REG "EREG" #define AML_GED_EVT_SEL "ESEL" +#define AML_GED_EVT_CPU_SCAN_METHOD "\\_SB.GED.CSCN" /* * Platforms need to specify the GED event bitmap diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 4641933a0f..15b4c3ebbf 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -108,6 +108,9 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev, aml_append(if_ctx, aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD)); break; + case ACPI_GED_CPU_HOTPLUG_EVT: + aml_append(if_ctx, aml_call0(AML_GED_EVT_CPU_SCAN_METHOD)); + break; case ACPI_GED_PWR_DOWN_EVT: aml_append(if_ctx, aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE), From patchwork Mon Jul 22 00:18:18 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: 13738170 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 56FB9C3DA5D for ; Mon, 22 Jul 2024 00:24:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmQ-0007iv-4P; Sun, 21 Jul 2024 20:19:54 -0400 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 1sVgl1-0000ob-0l for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:38 -0400 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 1sVgky-0005tw-QL for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607504; 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=QIRNn3AfY79eXuLLx4aGJnafHez/N0jAHeOHCZXedWo=; b=RL2Kt1TahAXy/goT7uaIRMpBnIz8ke2xye31L79YWGRLHK267KMlXiSk0aj6ojGCuLvY62 gub2sLgIFPG3Oxhu1+SSPnPQDiC7p0LvrWc1VSpCQ/deChHzuLf/7orxW3tfnS4qAAsgEV oUNuZ7Sc11xkW7IaJ+s6QicqL3O2G54= 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-203-GkL5EU5nPWaFT0OuzKC20w-1; Sun, 21 Jul 2024 20:18:22 -0400 X-MC-Unique: GkL5EU5nPWaFT0OuzKC20w-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-369bf135b49so665282f8f.0 for ; Sun, 21 Jul 2024 17:18:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607501; x=1722212301; 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=QIRNn3AfY79eXuLLx4aGJnafHez/N0jAHeOHCZXedWo=; b=gLCiOcofKWTIvQtjws1ChdKErzEx7tvnbS+FPcGxE2FXZaqFwAq4qrtUNwX5G6j2mc gmF5xOCTzwM5xp/nxk0zW+g9ePHLKrhU7vOPPbaG+pc/8SGrZT81guatuHIxjwszHCJa 3Y/JREp+bwmDJpqs8syCeD2jmuHg5DeriHoZ/tcY3uAjExltR3Bgga8cvqJF6h2H3d9h RonGP/THtIvadxwUUD9524ki6xZesHHw05Tr3wNuDWYBlNtUucWeGrz7U2GnHk+XDBog dedK2vRUYAxzK3NFa1cSFZCKPpUYpaRsUhJ4gBRHSQZKOCv67Znm0dCwJraKxgKff2dH VZgw== X-Gm-Message-State: AOJu0Yxm1V19a+eyl3BnL8Fv6uNvug3BoiyNfWpqYVEO8WSXyt2RIzZk EY/+//2R0wPqQRskOTrlb6iqEZ8qJG7GHRSE/FXDL+IH4DfccjII2EljCFEYihARIKRkDybKVeA kA8dGv9uPBgeeRfLpsKTKuIx64kTeiCdiR6/DbG9v1HhmKgEhDUr6u9zNyqRv+ff6S9CNXdGg1r FTIBIbYxYwqDuDJ/Z0Ws7nyNPhfl2qag== X-Received: by 2002:a5d:64a7:0:b0:365:aec0:e191 with SMTP id ffacd0b85a97d-36873f1810fmr7463335f8f.21.1721607501566; Sun, 21 Jul 2024 17:18:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvMOeXjUqX5WYh/2pce1U2w5d5bvMA+eIIyvc8mTyL7bz5RqIByPLKN2pqLTwLK+5RhzYWcQ== X-Received: by 2002:a5d:64a7:0:b0:365:aec0:e191 with SMTP id ffacd0b85a97d-36873f1810fmr7463303f8f.21.1721607500951; Sun, 21 Jul 2024 17:18:20 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8d930sm133915165e9.32.2024.07.21.17.18.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:20 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:18 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Salil Mehta , Keqian Zhu , Gavin Shan , Vishnu Pajjuri , Jonathan Cameron , Xianglai Li , Miguel Luis , Shaoqin Huang , Zhao Liu , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 42/63] hw/acpi: Update CPUs AML with cpu-(ctrl)dev change Message-ID: <94542f1464e8246fcb9455a19fdea69d86c698b4.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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 CPUs Control device(\\_SB.PCI0) register interface for the x86 arch is IO port based and existing CPUs AML code assumes _CRS objects would evaluate to a system resource which describes IO Port address. But on ARM arch CPUs control device(\\_SB.PRES) register interface is memory-mapped hence _CRS object should evaluate to system resource which describes memory-mapped base address. Update build CPUs AML function to accept both IO/MEMORY region spaces and accordingly update the _CRS object. Co-developed-by: Keqian Zhu Signed-off-by: Keqian Zhu Signed-off-by: Salil Mehta Reviewed-by: Gavin Shan Tested-by: Vishnu Pajjuri Reviewed-by: Jonathan Cameron Tested-by: Xianglai Li Tested-by: Miguel Luis Reviewed-by: Shaoqin Huang Tested-by: Zhao Liu Reviewed-by: Igor Mammedov Message-Id: <20240716111502.202344-6-salil.mehta@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/cpu.h | 5 +++-- hw/acpi/cpu.c | 17 +++++++++++++---- hw/i386/acpi-build.c | 3 ++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h index df87b15997..32654dc274 100644 --- a/include/hw/acpi/cpu.h +++ b/include/hw/acpi/cpu.h @@ -63,9 +63,10 @@ typedef void (*build_madt_cpu_fn)(int uid, const CPUArchIdList *apic_ids, GArray *entry, bool force_enabled); void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, - build_madt_cpu_fn build_madt_cpu, hwaddr io_base, + build_madt_cpu_fn build_madt_cpu, hwaddr base_addr, const char *res_root, - const char *event_handler_method); + const char *event_handler_method, + AmlRegionSpace rs); void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list); diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index cf5e9183e4..5cb60ca8bc 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -338,9 +338,10 @@ const VMStateDescription vmstate_cpu_hotplug = { #define CPU_FW_EJECT_EVENT "CEJF" void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, - build_madt_cpu_fn build_madt_cpu, hwaddr io_base, + build_madt_cpu_fn build_madt_cpu, hwaddr base_addr, const char *res_root, - const char *event_handler_method) + const char *event_handler_method, + AmlRegionSpace rs) { Aml *ifctx; Aml *field; @@ -364,14 +365,22 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, aml_name_decl("_UID", aml_string("CPU Hotplug resources"))); aml_append(cpu_ctrl_dev, aml_mutex(CPU_LOCK, 0)); + assert((rs == AML_SYSTEM_IO) || (rs == AML_SYSTEM_MEMORY)); + crs = aml_resource_template(); - aml_append(crs, aml_io(AML_DECODE16, io_base, io_base, 1, + if (rs == AML_SYSTEM_IO) { + aml_append(crs, aml_io(AML_DECODE16, base_addr, base_addr, 1, ACPI_CPU_HOTPLUG_REG_LEN)); + } else if (rs == AML_SYSTEM_MEMORY) { + aml_append(crs, aml_memory32_fixed(base_addr, + ACPI_CPU_HOTPLUG_REG_LEN, AML_READ_WRITE)); + } + aml_append(cpu_ctrl_dev, aml_name_decl("_CRS", crs)); /* declare CPU hotplug MMIO region with related access fields */ aml_append(cpu_ctrl_dev, - aml_operation_region("PRST", AML_SYSTEM_IO, aml_int(io_base), + aml_operation_region("PRST", rs, aml_int(base_addr), ACPI_CPU_HOTPLUG_REG_LEN)); field = aml_field("PRST", AML_BYTE_ACC, AML_NOLOCK, diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index f4e366f64f..5d4bd2b710 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1536,7 +1536,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, .fw_unplugs_cpu = pm->smi_on_cpu_unplug, }; build_cpus_aml(dsdt, machine, opts, pc_madt_cpu_entry, - pm->cpu_hp_io_base, "\\_SB.PCI0", "\\_GPE._E02"); + pm->cpu_hp_io_base, "\\_SB.PCI0", "\\_GPE._E02", + AML_SYSTEM_IO); } if (pcms->memhp_io_base && nr_mem) { From patchwork Mon Jul 22 00:18: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: 13738151 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 954E4C3DA5D for ; Mon, 22 Jul 2024 00:21:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmO-0007bM-Sw; Sun, 21 Jul 2024 20:19:52 -0400 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 1sVgl7-0001RD-QJ for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:40 -0400 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 1sVgl5-0005uT-R9 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607509; 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=DSrvGWDM8WQlkDQ1QptgcjyZ8pct3cQ7nSxPz3zLafI=; b=Lnx97+XjxefFQ0CYeeleujw+I9Vcyam9zmf4IQCGeC2a7SHH8ZwRFmHE6cZJE/LWP1OnDJ 8s3DGb6T2CuL0os0XsPuW3ZCzU3s5hNlE5RuW5H7BcZzW9M32w5QGHnhRb9dVkJh4ELSWF zrocGQ1c32+37+gwIQz3Ym/Apngc3h4= 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-488-RioShQkKOOeOhjGgtZiTBQ-1; Sun, 21 Jul 2024 20:18:26 -0400 X-MC-Unique: RioShQkKOOeOhjGgtZiTBQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42725d3ae3eso27672475e9.3 for ; Sun, 21 Jul 2024 17:18:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607504; x=1722212304; 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=DSrvGWDM8WQlkDQ1QptgcjyZ8pct3cQ7nSxPz3zLafI=; b=Nb0d82m3nUqjWGeXwVW044af1v/MXUbl6arC/J9jbzbyFM15FXBFi1v9SO9rp8n5mG Ws0np+Wyu8V+Gw+iqcFHETLFFPfpulqOHm8ZlzwAWyiZ6q15xYxIbr5VoAli2ioo7tDL DeRaDjHR4g3H74WUKEQfYoASG1pSge9y1fVb1Ram8NzypTFCgxmn1FoIon7DL7STXRR3 oZ4U2KPf2hWPsMS/dBs9BlS/JYSwsUEZqzYN/O+41OHMNW02ihj2mpRJIRhnL5O/09D6 z77TrZBortXof8CDW0JAs9UOiBjhSvWYNCqQLfsA7fWHK8rLTTPd27AWE8DvXFlW9uNl ghLQ== X-Gm-Message-State: AOJu0Yx3+rA1JGfpdEpy3Zm/b0T0twFeo+55QRJdwHleyFH/FdoyLxp9 lYaSvZ8VzC3yxPNKd+PSDFUtm9xRV7x+Sw1utGHwlNjYNNGW4MaNe2MUq72uZmbpZEac/L85hYV USTchQtnYYvH9Sq8ajaJ4F3lJbORHRP3dH5/D4HmcQGfwVG4YlF1cx0kMJUcBTR0nGzaBBuX/t2 IISame7y18JiaZQb0ElGp5ZW59lDtR+Q== X-Received: by 2002:a05:600c:1f10:b0:426:5e8e:aa47 with SMTP id 5b1f17b1804b1-427dcf69b05mr32388475e9.4.1721607504319; Sun, 21 Jul 2024 17:18:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVAs5BgjvLYEh0pd5ccwHoeJwA+QVq/mi0TrjT3zQzDHFtsVJSvrjJQivRAc7qy/gvL18oVw== X-Received: by 2002:a05:600c:1f10:b0:426:5e8e:aa47 with SMTP id 5b1f17b1804b1-427dcf69b05mr32388205e9.4.1721607503800; Sun, 21 Jul 2024 17:18:23 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d68fa9b1sm107760615e9.8.2024.07.21.17.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:23 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Salil Mehta , Vishnu Pajjuri , Gavin Shan , Xianglai Li , Miguel Luis , Shaoqin Huang , Zhao Liu , Igor Mammedov , Richard Henderson , Paolo Bonzini , Eduardo Habkost , Marcel Apfelbaum , Philippe =?utf-8?q?Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Peter Xu , David Hildenbrand Subject: [PULL 43/63] physmem: Add helper function to destroy CPU AddressSpace Message-ID: <3ef94482c9e3e996eb5ed1ab3ec829885dc50d7f.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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 Virtual CPU Hot-unplug leads to unrealization of a CPU object. This also involves destruction of the CPU AddressSpace. Add common function to help destroy the CPU AddressSpace. Signed-off-by: Salil Mehta Tested-by: Vishnu Pajjuri Reviewed-by: Gavin Shan Tested-by: Xianglai Li Tested-by: Miguel Luis Reviewed-by: Shaoqin Huang Tested-by: Zhao Liu Acked-by: Igor Mammedov Message-Id: <20240716111502.202344-7-salil.mehta@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/exec/cpu-common.h | 8 ++++++++ include/hw/core/cpu.h | 1 + system/physmem.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 815342d043..240ee04369 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -129,6 +129,14 @@ size_t qemu_ram_pagesize_largest(void); */ void cpu_address_space_init(CPUState *cpu, int asidx, const char *prefix, MemoryRegion *mr); +/** + * cpu_address_space_destroy: + * @cpu: CPU for which address space needs to be destroyed + * @asidx: integer index of this address space + * + * Note that with KVM only one address space is supported. + */ +void cpu_address_space_destroy(CPUState *cpu, int asidx); void cpu_physical_memory_rw(hwaddr addr, void *buf, hwaddr len, bool is_write); diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index d946161717..1c9c775df6 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -496,6 +496,7 @@ struct CPUState { QSIMPLEQ_HEAD(, qemu_work_item) work_list; struct CPUAddressSpace *cpu_ases; + int cpu_ases_count; int num_ases; AddressSpace *as; MemoryRegion *memory; diff --git a/system/physmem.c b/system/physmem.c index 9a3b3a7636..0e19186e1b 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -763,6 +763,7 @@ void cpu_address_space_init(CPUState *cpu, int asidx, if (!cpu->cpu_ases) { cpu->cpu_ases = g_new0(CPUAddressSpace, cpu->num_ases); + cpu->cpu_ases_count = cpu->num_ases; } newas = &cpu->cpu_ases[asidx]; @@ -776,6 +777,34 @@ void cpu_address_space_init(CPUState *cpu, int asidx, } } +void cpu_address_space_destroy(CPUState *cpu, int asidx) +{ + CPUAddressSpace *cpuas; + + assert(cpu->cpu_ases); + assert(asidx >= 0 && asidx < cpu->num_ases); + /* KVM cannot currently support multiple address spaces. */ + assert(asidx == 0 || !kvm_enabled()); + + cpuas = &cpu->cpu_ases[asidx]; + if (tcg_enabled()) { + memory_listener_unregister(&cpuas->tcg_as_listener); + } + + address_space_destroy(cpuas->as); + g_free_rcu(cpuas->as, rcu); + + if (asidx == 0) { + /* reset the convenience alias for address space 0 */ + cpu->as = NULL; + } + + if (--cpu->cpu_ases_count == 0) { + g_free(cpu->cpu_ases); + cpu->cpu_ases = NULL; + } +} + AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx) { /* Return the AddressSpace corresponding to the specified index */ From patchwork Mon Jul 22 00:18:24 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: 13738176 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 9CF9CC3DA63 for ; Mon, 22 Jul 2024 00:26:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmR-0007pi-0j; Sun, 21 Jul 2024 20:19:55 -0400 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 1sVglC-0001j3-Ab for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:43 -0400 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 1sVgl9-0005uy-EE for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607514; 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=PcyBRXkTTTsoCZ0FToTwoi2W+WoWKXejjiio+24ADX4=; b=D5ko1VLSyrXHqLQHPKj/Pa6u9VC3gXupl2mZBw3by7nz1I33k3hEGKEFKrcDK9xE/YtW0d EvuETaTltG8FQffAGov+1KR0ieoQ9QBmQ3jDHoG54xheiiEfxCGa1mQEZakL4hZpAJH4tI 9yRou/6GnWmBlo8H+ig1oubXYWxzmko= 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-332-gDCpH2F3NaKIhYCG9HD-Qg-1; Sun, 21 Jul 2024 20:18:28 -0400 X-MC-Unique: gDCpH2F3NaKIhYCG9HD-Qg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-42668699453so37768895e9.3 for ; Sun, 21 Jul 2024 17:18:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607507; x=1722212307; 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=PcyBRXkTTTsoCZ0FToTwoi2W+WoWKXejjiio+24ADX4=; b=MXLynDPsa17xgrrHkBygb3wo5tL039IulxbTKFcY7X7DXn+kkokQaQx/xIOeMelFFA VBfrPFFM3XKdQCmU4lDHZssIEEQHM8/tGlxZWJerOh0Acw+0icfpPswGF/JzO+knByXC AYwGyNHmMwoRB65UmNCXezE/SR/DsbXqd3ku3UxO//CeuU/KZ++8v2n3q/MjjSz76MEC EWmLHuAhhDDJkwGlvbs/vtnVipSamYlTsuX3MGIgh2+qpSQu1PCAVP0M/lJ1Fj1IW7FK Xhg8Rbx62diFCDoAKg7+TF7t1ojAG6ZJJzy6GECqk2K+Sjrjpc4XEIztRpRvieu/T6iL pTgQ== X-Gm-Message-State: AOJu0Yy4C6XRRvf04z4shxFmghwiAn188XUblQjvbiHKt7ax+yJilg3B eSqBsEQRFoF3rtrevMC/N/DR0+oh5mOT6CIf8htSQxxS6XaSqFqiKzwqF44Ycv92zjCZgFPmzp8 vWN4vbkJ43gVwrO6yX3JuSIh2O9pJ1M0cb6HxppIZz/3HoBbBAwSA6a6oIA02G5UMs+5tUFBHPz QWO0G2H02/AfzXIBXwjWAe1+C/OgJXpA== X-Received: by 2002:a05:600c:4ed3:b0:426:690d:d5b7 with SMTP id 5b1f17b1804b1-427dc55bb09mr37066355e9.25.1721607507015; Sun, 21 Jul 2024 17:18:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsouKXDGxkIdMyPaPINBJmjiQT+Suo0Ny91y8xgXjnhkmksE7uwx7aHFzR8O8q72lm/20CfA== X-Received: by 2002:a05:600c:4ed3:b0:426:690d:d5b7 with SMTP id 5b1f17b1804b1-427dc55bb09mr37066145e9.25.1721607506421; Sun, 21 Jul 2024 17:18:26 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a804a4sm62340195e9.1.2024.07.21.17.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:25 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Salil Mehta , Vishnu Pajjuri , Gavin Shan , Xianglai Li , Miguel Luis , Shaoqin Huang , Zhao Liu , Igor Mammedov , Alex =?utf-8?q?Benn=C3=A9e?= , Philippe =?utf-8?q?Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Eduardo Habkost , Marcel Apfelbaum , Yanan Wang Subject: [PULL 44/63] gdbstub: Add helper function to unregister GDB register space Message-ID: <1f08da5cf90c3e0d60487ac13ed7079ff3735637.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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 Add common function to help unregister the GDB register space. This shall be done in context to the CPU unrealization. Note: These are common functions exported to arch specific code. For example, for ARM this code is being referred in associated arch specific patch-set: Link: https://lore.kernel.org/qemu-devel/20230926103654.34424-1-salil.mehta@huawei.com/ Signed-off-by: Salil Mehta Tested-by: Vishnu Pajjuri Reviewed-by: Gavin Shan Tested-by: Xianglai Li Tested-by: Miguel Luis Reviewed-by: Shaoqin Huang Reviewed-by: Vishnu Pajjuri Tested-by: Zhao Liu Acked-by: Igor Mammedov Message-Id: <20240716111502.202344-8-salil.mehta@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/exec/gdbstub.h | 6 ++++++ gdbstub/gdbstub.c | 13 +++++++++++++ hw/core/cpu-common.c | 5 ++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 1bd2c4ec2a..d73f424f56 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -40,6 +40,12 @@ void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, const GDBFeature *feature, int g_pos); +/** + * gdb_unregister_coprocessor_all() - unregisters supplemental set of registers + * @cpu - the CPU associated with registers + */ +void gdb_unregister_coprocessor_all(CPUState *cpu); + /** * gdbserver_start: start the gdb server * @port_or_device: connection spec for gdb diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index b9ad0a063e..5da17d6530 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -618,6 +618,19 @@ void gdb_register_coprocessor(CPUState *cpu, } } +void gdb_unregister_coprocessor_all(CPUState *cpu) +{ + /* + * Safe to nuke everything. GDBRegisterState::xml is static const char so + * it won't be freed + */ + g_array_free(cpu->gdb_regs, true); + + cpu->gdb_regs = NULL; + cpu->gdb_num_regs = 0; + cpu->gdb_num_g_regs = 0; +} + static void gdb_process_breakpoint_remove_all(GDBProcess *p) { CPUState *cpu = gdb_get_first_cpu_in_process(p); diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index d2e3e4570a..7982ecd39a 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -282,7 +282,10 @@ static void cpu_common_finalize(Object *obj) } #endif free_queued_cpu_work(cpu); - g_array_free(cpu->gdb_regs, TRUE); + /* If cleanup didn't happen in context to gdb_unregister_coprocessor_all */ + if (cpu->gdb_regs) { + g_array_free(cpu->gdb_regs, TRUE); + } qemu_lockcnt_destroy(&cpu->in_ioctl_lock); qemu_mutex_destroy(&cpu->work_mutex); qemu_cond_destroy(cpu->halt_cond); From patchwork Mon Jul 22 00:18:26 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: 13738145 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 C422FC3DA63 for ; Mon, 22 Jul 2024 00:19:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmM-0006eQ-9o; Sun, 21 Jul 2024 20:19:52 -0400 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 1sVgl9-0001XI-Ki for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:40 -0400 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 1sVgl7-0005ui-Ij for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607512; 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=i33/3Qja9OS3einDB0z9RqroZS7tFHAamIIdFj14KsM=; b=d0nV8Wlc0OUj3yQhDqMallwbjzC4qO96TRsZOuCTEafOD1mzCrDGzyNa6rFx/zrdLoi6qj 4cwjIJ3zVyWMBnXkZiHY3ORDtGTFOe8jwcgnZYJZgnMImHBIrFLJlfgBmg5SWegUB/KW0k 5XLNPwwxMps+G0y+UTHNYYDxazgkV5M= 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-228-lY0ZXDZPPsGhfpG9ve1Thw-1; Sun, 21 Jul 2024 20:18:30 -0400 X-MC-Unique: lY0ZXDZPPsGhfpG9ve1Thw-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-36848f30d39so2010723f8f.3 for ; Sun, 21 Jul 2024 17:18:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607509; x=1722212309; 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=i33/3Qja9OS3einDB0z9RqroZS7tFHAamIIdFj14KsM=; b=b8LDZqN3PxzCcstYb+JwuaEcKr+c0A2T+ILsCHbPORmaiY+Jxc/Kv/HOiQaThNnj5d fQ+CwiwDclY3sP6biXTm/VvcNdH4fl06Kob9nQYZx//SbOk4yNc0jwtRDD5ULeGJrh8m zYB1tOXIUD6n0Kzp/omdPy7C+Y/Tp4QzrSv0RTTKgU04L2/Zh2SSA4WlwgbaoLkAvLTv Jgm4dKyc0qmRJxd/KBx7+nVVqhl/NAgc6hSOh8sQzAGmr+q+3UvMlFUEU6x5oNhIKBiN NcFluJ4RxOmqa69rEp7G8EAKp2eVYhw3KPOMCLeRul95XXNEm1HuXX/Cw14Nb2SSnlyp UBUg== X-Gm-Message-State: AOJu0Ywupw2nq58MOsdoRRDop6Sq1KWrH2KpX92I4TCBdzF3ozGVaavk Ns47/0ozZevK+Jjcw2N1BuVaYcNIkZ/LOLyZ6fWq6RfFk2/PBT3CQLG3+Kd/VYZIluMtn+a+Jq6 NWTuNlQbJuYXsVy7wuI92eb4rLMPUdE1VYslTTRvh4kbklzLg0wlnE+jnwdc9cDGjxVtghvF6P1 wOViojFQVZOUtOKEufggMhZtUojB9BOQ== X-Received: by 2002:a5d:64ca:0:b0:362:5816:f134 with SMTP id ffacd0b85a97d-369bbbb300cmr3923863f8f.13.1721607509022; Sun, 21 Jul 2024 17:18:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHK22AR+7mZMrfsh53tjz4BVVg7AMhBn1TC2xLGdIkNhQvuRomZWJOGRQSGkGxDSVHhpmBb/g== X-Received: by 2002:a5d:64ca:0:b0:362:5816:f134 with SMTP id ffacd0b85a97d-369bbbb300cmr3923850f8f.13.1721607508443; Sun, 21 Jul 2024 17:18:28 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868bc21sm6983773f8f.39.2024.07.21.17.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:27 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Eric Auger , =?utf-8?q?C=C3=A9dric?= Le Goater Subject: [PULL 45/63] Revert "virtio-iommu: Clear IOMMUDevice when VFIO device is unplugged" 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Eric Auger This reverts commit 1b889d6e39c32d709f1114699a014b381bcf1cb1. There are different problems with that tentative fix: - Some resources are left dangling (resv_regions, host_resv_ranges) and memory subregions are left attached to the root MR although freed as embedded in the sdev IOMMUDevice. Finally the sdev->as is not destroyed and associated listeners are left. - Even when fixing the above we observe a memory corruption associated with the deallocation of the IOMMUDevice. This can be observed when a VFIO device is hotplugged, hot-unplugged and a system reset is issued. At this stage we have not been able to identify the root cause (IOMMU MR or as structs beeing overwritten and used later on?). - Another issue is HostIOMMUDevice are indexed by non aliased BDF whereas the IOMMUDevice is indexed by aliased BDF - yes the current naming is really misleading -. Given the state of the code I don't think the virtio-iommu device works in non singleton group case though. So let's revert the patch for now. This means the IOMMU MR/as survive the hotunplug. This is what is done in the intel_iommu for instance. It does not sound very logical to keep those but currently there is no symetric function to pci_device_iommu_address_space(). probe_done issue will be handled in a subsequent patch. Also resv_regions and host_resv_regions will be deallocated separately. Signed-off-by: Eric Auger Message-Id: <20240716094619.1713905-2-eric.auger@redhat.com> Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 33ae61c4a6..4e34dacd6e 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -467,26 +467,6 @@ static AddressSpace *virtio_iommu_find_add_as(PCIBus *bus, void *opaque, return &sdev->as; } -static void virtio_iommu_device_clear(VirtIOIOMMU *s, PCIBus *bus, int devfn) -{ - IOMMUPciBus *sbus = g_hash_table_lookup(s->as_by_busptr, bus); - IOMMUDevice *sdev; - - if (!sbus) { - return; - } - - sdev = sbus->pbdev[devfn]; - if (!sdev) { - return; - } - - g_list_free_full(sdev->resv_regions, g_free); - sdev->resv_regions = NULL; - g_free(sdev); - sbus->pbdev[devfn] = NULL; -} - static gboolean hiod_equal(gconstpointer v1, gconstpointer v2) { const struct hiod_key *key1 = v1; @@ -728,7 +708,6 @@ virtio_iommu_unset_iommu_device(PCIBus *bus, void *opaque, int devfn) } g_hash_table_remove(viommu->host_iommu_devices, &key); - virtio_iommu_device_clear(viommu, bus, devfn); } static const PCIIOMMUOps virtio_iommu_ops = { From patchwork Mon Jul 22 00:18:28 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: 13738161 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 EACDFC3DA5D for ; Mon, 22 Jul 2024 00:23:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgm0-0005VY-AR; Sun, 21 Jul 2024 20:19:28 -0400 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 1sVglC-0001j2-AQ for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:43 -0400 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 1sVgl9-0005v0-EW for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607514; 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=69G17GN4Uq3+tY5aOWicSxywkAKy5R3rr33OsIJt9PA=; b=Vd5ZhJtZXfsuRIUE5FopWGRCGwo3TT5mXWrTj9V1+rq8wp1ZjDpM2/0k3k6jupE82Yk826 1t6Kk2eopl+pPjQwPHgai3IE7rJrxT+RiigqgDe8l82Ve1ozCU4rrUqMnM18z3UoO2P3S8 ou3MsxSPVsejNsrGwGE/rBhwmQmumZ8= 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-275-2RU-yBHBMEWqrAr0GUvn2w-1; Sun, 21 Jul 2024 20:18:32 -0400 X-MC-Unique: 2RU-yBHBMEWqrAr0GUvn2w-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-427b7a2052bso37781595e9.2 for ; Sun, 21 Jul 2024 17:18:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607511; x=1722212311; 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=69G17GN4Uq3+tY5aOWicSxywkAKy5R3rr33OsIJt9PA=; b=SpA7XgfdEI73tyLJmTTHgL/n1JF8IC0hGs4tiCqF/tp7D/2GLsavtGNY43dhowqoFa m8115dKVwxPxSzFnqPX62ZiOgo1BbLAH5np0+p2fuQKdl3Ad1Dj1fMvbDGv2bI4xEHA6 mEp2sXfCvsqnrs7h+bgnP98jhv5BNt1/Zwu6IjEt4x8w0TCcFlNvJ6RCyWKFThef65ae v+bL1c0HrstfDn6/k5Td0cN7Pm/yHUwPVRH09VwZZvABkYheH6rnUV0jcVSbhOsryqMF f/yZrmuUfRwtiO8g1OTulD0L7jpyeKnLm52X0kUhO6AEteOKmLNYoxI85XoK5/GQ5BZk OIsw== X-Gm-Message-State: AOJu0YxXWp2dtMCHgCCAP7CRafp0eOKS0fJolbFp3mPReOmUyMzEFzW+ brMvzkD02E2bo87CDurqUAuy3TzDqlksEUtL/tXKHFzgaAyTtctezPZSkOXPMCRqvQYQwRM83wg kSZTGNeyRnv9U8/fZYwWlhpKUBw7TBjKX+2wgwVGJsRtikdShF06Ls3ZfNRGjD9IgPhYKgEprs4 ntm//Abpwj6rDkAp8cG8p6lOfFRFVqwA== X-Received: by 2002:a05:600c:1c2a:b0:426:6ed5:fcb with SMTP id 5b1f17b1804b1-427dc515beemr42567885e9.4.1721607511022; Sun, 21 Jul 2024 17:18:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAQaOVzbbduw1T5NliFk1+46Rn/a2bF5urrIUlnBbkMdCQWOyPCx6DN2WFQABVTpb5nUm1SQ== X-Received: by 2002:a05:600c:1c2a:b0:426:6ed5:fcb with SMTP id 5b1f17b1804b1-427dc515beemr42567755e9.4.1721607510416; Sun, 21 Jul 2024 17:18:30 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8d8f9sm133844425e9.37.2024.07.21.17.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:29 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Eric Auger , =?utf-8?q?C=C3=A9dric?= Le Goater Subject: [PULL 46/63] virtio-iommu: Remove probe_done 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Eric Auger Now we have switched to PCIIOMMUOps to convey host IOMMU information, the host reserved regions are transmitted when the PCIe topology is built. This happens way before the virtio-iommu driver calls the probe request. So let's remove the probe_done flag that allowed to check the probe was not done before the IOMMU MR got enabled. Besides this probe_done flag had a flaw wrt migration since it was not saved/restored. The only case at risk is if 2 devices were plugged to a PCIe to PCI bridge and thus aliased. First of all we discovered in the past this case was not properly supported for neither SMMU nor virtio-iommu on guest kernel side: see [RFC] virtio-iommu: Take into account possible aliasing in virtio_iommu_mr() https://lore.kernel.org/all/20230116124709.793084-1-eric.auger@redhat.com/ If this were supported by the guest kernel, it is unclear what the call sequence would be from a virtio-iommu driver point of view. Signed-off-by: Eric Auger Message-Id: <20240716094619.1713905-3-eric.auger@redhat.com> Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-iommu.h | 1 - hw/virtio/virtio-iommu.c | 3 --- 2 files changed, 4 deletions(-) diff --git a/include/hw/virtio/virtio-iommu.h b/include/hw/virtio/virtio-iommu.h index bdb3da72d0..7db4210b16 100644 --- a/include/hw/virtio/virtio-iommu.h +++ b/include/hw/virtio/virtio-iommu.h @@ -43,7 +43,6 @@ typedef struct IOMMUDevice { MemoryRegion bypass_mr; /* The alias of shared memory MR */ GList *resv_regions; GList *host_resv_ranges; - bool probe_done; } IOMMUDevice; typedef struct IOMMUPciBus { diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 4e34dacd6e..2c54c0d976 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -555,8 +555,6 @@ static int virtio_iommu_set_host_iova_ranges(VirtIOIOMMU *s, PCIBus *bus, current_ranges = sdev->host_resv_ranges; - g_assert(!sdev->probe_done); - /* check that each new resv region is included in an existing one */ if (sdev->host_resv_ranges) { range_inverse_array(iova_ranges, @@ -956,7 +954,6 @@ static int virtio_iommu_probe(VirtIOIOMMU *s, } buf += count; free -= count; - sdev->probe_done = true; return VIRTIO_IOMMU_S_OK; } From patchwork Mon Jul 22 00:18:30 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: 13738160 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 04CB0C3DA63 for ; Mon, 22 Jul 2024 00:23:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVglS-0002IK-6c; Sun, 21 Jul 2024 20:18:54 -0400 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 1sVglD-0001lb-46 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:43 -0400 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 1sVglA-0005vB-Cj for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607515; 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=RRfxJi15v0LjYUfndDtOwJPZVyigXXbxUoHPnTtDziA=; b=EZYJ2TpiUguVFYsRkAZOEDiAgL/Z1w5Cut5KlkylSR3Jxq95ZiFrl9A3HWpralOsdGC8Ot RPUvebbD0wq0eLsAyTm7kUYsltXEAonbZfWCcxzXvyXD+NQ369UcEWj26Q6WgO0Sb3scc6 fsSvAhoyN/nXpJnIhPxMRA8ZQvf9G0k= 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-587-2FWS31f5Ot213MPUTzXxfQ-1; Sun, 21 Jul 2024 20:18:34 -0400 X-MC-Unique: 2FWS31f5Ot213MPUTzXxfQ-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-36863648335so2230303f8f.0 for ; Sun, 21 Jul 2024 17:18:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607513; x=1722212313; 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=RRfxJi15v0LjYUfndDtOwJPZVyigXXbxUoHPnTtDziA=; b=aP38nqW/FZcKBsUIP2NZveWuve/yi0n25UMT22Wp8NeG8J06RZmwxCGA9VYFkTbq6w EQSQEgn9wboOOxE68hpDFbBsMH7bTTh0hPJksd0Ag6S6A0EUGbC/GjqQMDjnYOD26jjW 7TEes/2ckRZIw/yCbjqFGwI87GGnGw7rLCjAsJCAPnTqU918MqgCdmc7Gwfbo/lPNPWn snKMjcX64+jboO8CaQfecK8/QcZ6nmzlX24pxoXMrfgyNCWJbbIKIaC0n83l9Tapxdi2 1nd1gQJNxYQtPHRSGF9D6cF0PN2k63tQd4bFnYXYVBsE20b8d7IOJ3Rx5iIxjeZgzBkP PGOg== X-Gm-Message-State: AOJu0YwYdOCzdwXQrKvj0ENNbDQR9z42jUYb1VzW/tLnJNhj8bPGrFuP VfAb7mKmwksqtiYC0K3G2BTPEvx1+PGoliz/5lNwny05eiOWHyrUf3r8Zjc7BLmF1XdSnV99gw+ nt5bhqMItu+jPCvW+hyRiyDdmZgZ5Uxhok6NZSfFv/SbRXh/anp9s26xYzN5PUu894k1gyp8p5d vy8DUA8qFYdwMxwZOrupcEli5K0+4Vmw== X-Received: by 2002:a5d:4e42:0:b0:368:4c56:2bd0 with SMTP id ffacd0b85a97d-369bae2508bmr2813395f8f.33.1721607512906; Sun, 21 Jul 2024 17:18:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7+3eNKTyYnhFU6enTq9Eiho1wRamJ+moS5+J+c/M1I6N45PudRahq3fnaA9q7j1xF5wKreQ== X-Received: by 2002:a5d:4e42:0:b0:368:4c56:2bd0 with SMTP id ffacd0b85a97d-369bae2508bmr2813382f8f.33.1721607512384; Sun, 21 Jul 2024 17:18:32 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868490fsm7050188f8f.6.2024.07.21.17.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:31 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Eric Auger , =?utf-8?q?C=C3=A9dric?= Le Goater Subject: [PULL 47/63] virtio-iommu: Free [host_]resv_ranges on unset_iommu_devices Message-ID: <7d2d4621f8af47bafdc5a11b75b6fed06b171084.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Eric Auger We are currently missing the deallocation of the [host_]resv_regions in case of hot unplug. Also to make things more simple let's rule out the case where multiple HostIOMMUDevices would be aliased and attached to the same IOMMUDevice. This allows to remove the handling of conflicting Host reserved regions. Anyway this is not properly supported at guest kernel level. On hotunplug the reserved regions are reset to the ones set by virtio-iommu property. Signed-off-by: Eric Auger Message-Id: <20240716094619.1713905-4-eric.auger@redhat.com> Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 62 ++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 2c54c0d976..2de41ab412 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -538,8 +538,6 @@ static int virtio_iommu_set_host_iova_ranges(VirtIOIOMMU *s, PCIBus *bus, { IOMMUPciBus *sbus = g_hash_table_lookup(s->as_by_busptr, bus); IOMMUDevice *sdev; - GList *current_ranges; - GList *l, *tmp, *new_ranges = NULL; int ret = -EINVAL; if (!sbus) { @@ -553,33 +551,10 @@ static int virtio_iommu_set_host_iova_ranges(VirtIOIOMMU *s, PCIBus *bus, return ret; } - current_ranges = sdev->host_resv_ranges; - - /* check that each new resv region is included in an existing one */ if (sdev->host_resv_ranges) { - range_inverse_array(iova_ranges, - &new_ranges, - 0, UINT64_MAX); - - for (tmp = new_ranges; tmp; tmp = tmp->next) { - Range *newr = (Range *)tmp->data; - bool included = false; - - for (l = current_ranges; l; l = l->next) { - Range * r = (Range *)l->data; - - if (range_contains_range(r, newr)) { - included = true; - break; - } - } - if (!included) { - goto error; - } - } - /* all new reserved ranges are included in existing ones */ - ret = 0; - goto out; + error_setg(errp, "%s virtio-iommu does not support aliased BDF", + __func__); + return ret; } range_inverse_array(iova_ranges, @@ -588,14 +563,31 @@ static int virtio_iommu_set_host_iova_ranges(VirtIOIOMMU *s, PCIBus *bus, rebuild_resv_regions(sdev); return 0; -error: - error_setg(errp, "%s Conflicting host reserved ranges set!", - __func__); -out: - g_list_free_full(new_ranges, g_free); - return ret; } +static void virtio_iommu_unset_host_iova_ranges(VirtIOIOMMU *s, PCIBus *bus, + int devfn) +{ + IOMMUPciBus *sbus = g_hash_table_lookup(s->as_by_busptr, bus); + IOMMUDevice *sdev; + + if (!sbus) { + return; + } + + sdev = sbus->pbdev[devfn]; + if (!sdev) { + return; + } + + g_list_free_full(g_steal_pointer(&sdev->host_resv_ranges), g_free); + g_list_free_full(sdev->resv_regions, g_free); + sdev->host_resv_ranges = NULL; + sdev->resv_regions = NULL; + add_prop_resv_regions(sdev); +} + + static bool check_page_size_mask(VirtIOIOMMU *viommu, uint64_t new_mask, Error **errp) { @@ -704,6 +696,8 @@ virtio_iommu_unset_iommu_device(PCIBus *bus, void *opaque, int devfn) if (!hiod) { return; } + virtio_iommu_unset_host_iova_ranges(viommu, hiod->aliased_bus, + hiod->aliased_devfn); g_hash_table_remove(viommu->host_iommu_devices, &key); } From patchwork Mon Jul 22 00:18:32 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: 13738164 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 5C076C3DA61 for ; Mon, 22 Jul 2024 00:23:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmS-00086E-Gb; Sun, 21 Jul 2024 20:19:56 -0400 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 1sVglH-0001wB-AO for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:45 -0400 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 1sVglD-0005vV-1l for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607518; 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=+taPMy5Q8060TvpZgWRsF1ltpcOrUHjqjPNdMJkSVmk=; b=gFpd/CdEWpUd9ZnTkA11bE7FQ6IVDPgUL4LS+Va2QQyDlVFCxyQdN/gdltnVpQIC2i6S9K 88sX1e4C00pxy6Y4QjPkNNlwXsSkFW4h8+oM1wKF0z8Z8c4RAYywzpY1J7ua31pbe914Ko nt0ETxhuGHxjyRG0ZfDT+GT8c46nuEo= 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-412-O57d3f1rP2CAAYU1ceKrFQ-1; Sun, 21 Jul 2024 20:18:36 -0400 X-MC-Unique: O57d3f1rP2CAAYU1ceKrFQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4265464ddc9so15455105e9.1 for ; Sun, 21 Jul 2024 17:18:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607515; x=1722212315; 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=+taPMy5Q8060TvpZgWRsF1ltpcOrUHjqjPNdMJkSVmk=; b=BanaRycDWQVRWakkRBnh/dK3TVDqvy2XzAwQ4rUh+YOOzP7RO/HVq6Gt4VuwJY3qfl JwX+1OOZ/gr3kqmgFqmb2BgB0PaHQ/YqSGeE9xgvFJ+1wdevtX9UP0bXgnRgK5QZtyDw sjcWhRz8tNkHmo5LXJVrrsUU1TsAPa6C/ViLT3Bu2r+2t+5+j5zYX3+iokF8IwUL/fIt 72Hj8dUT6e/rDzt2cJYrPDXLE6lmrnCt9JR4KTpOke3DAZDyaJB4iiWjRQFo2ANpJYp5 R9waE5NNeFYqD33Eh5JTVXMtip9+GbqGvFX2sQxtGR+7RaenRyr2w+gl2ZRec8o72snu V6Hg== X-Gm-Message-State: AOJu0Yzuhv/Ls+bEpZtXJrGf4yCHb8KnT4v+qqJ35w/OPewRyXMQMMsw tGyht1keJTqoyzP+s2YvyickCAJFmVXx6KI/u3O9n1KwwzWVlkVLVVpMahbs1PzRHs0zZ6rots+ 0+GDMX4jDO8sjOf4zM6wFrQu2sjV1e3SGgzI9GxGm4qaz2g+YImRPq+7Imwc+3Rm4QPR+bOFfo1 SSwGpXteWFd7UHKq7oSaa7YHqVlv1PYw== X-Received: by 2002:a05:600c:46ce:b0:426:686f:7ad with SMTP id 5b1f17b1804b1-427da805e46mr39659245e9.10.1721607514825; Sun, 21 Jul 2024 17:18:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGG7QDE/bNhHpHK6AcOFPRi1M4tg3TKYoiAu3jzyNrFF935IgyTnkTQoC5GBKu0yx+sdRc56w== X-Received: by 2002:a05:600c:46ce:b0:426:686f:7ad with SMTP id 5b1f17b1804b1-427da805e46mr39659125e9.10.1721607514320; Sun, 21 Jul 2024 17:18:34 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d68fa493sm107416355e9.10.2024.07.21.17.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:33 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Eric Auger , =?utf-8?q?C=C3=A9dric?= Le Goater Subject: [PULL 48/63] virtio-iommu: Remove the end point on detach Message-ID: <4dc8ff564fbefd6f8542ef3367b839d1319a5de6.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Eric Auger We currently miss the removal of the endpoint in case of detach. Signed-off-by: Eric Auger Message-Id: <20240716094619.1713905-5-eric.auger@redhat.com> Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 2de41ab412..440dfa6e92 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -786,6 +786,7 @@ static int virtio_iommu_detach(VirtIOIOMMU *s, if (QLIST_EMPTY(&domain->endpoint_list)) { g_tree_remove(s->domains, GUINT_TO_POINTER(domain->id)); } + g_tree_remove(s->endpoints, GUINT_TO_POINTER(ep_id)); return VIRTIO_IOMMU_S_OK; } From patchwork Mon Jul 22 00:18:34 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: 13738179 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 B9154C3DA5D for ; Mon, 22 Jul 2024 00:27:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmR-0007yZ-T4; Sun, 21 Jul 2024 20:19:55 -0400 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 1sVglJ-00024d-Jo for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:46 -0400 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 1sVglG-0005vo-FP for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607521; 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=qrDoyOU8aLoqXDosKSDaANOTDQMMjAFfwW6ZQlvyVxk=; b=ZJOPUbI+drLGKe1cL/rmFS01zhQon5KKovKfmTQasewl07kG2M/rpnftvU8G8VOrC+iN7Q oo3RW7y6Ud6Wdb7HnXDZBswv2DtscrAonCZj2rzzXB9R2C650qAfKWxl2yxGwUr+VL2bBg fqTmQns615FfJoCPyWm9LvAquMWT4Sc= 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-463-DOjRHeDHMGGq2GkFQDRyvg-1; Sun, 21 Jul 2024 20:18:38 -0400 X-MC-Unique: DOjRHeDHMGGq2GkFQDRyvg-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-369bf135b49so665350f8f.0 for ; Sun, 21 Jul 2024 17:18:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607517; x=1722212317; 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=qrDoyOU8aLoqXDosKSDaANOTDQMMjAFfwW6ZQlvyVxk=; b=UuBZUH3BbKmqDdd8g9QD/toeFje772BEZ/lg6vux4d4hJvrRbasa6VlBae2xucNewg DYPoWr0yJhGYih6M9tMAFN/ZP9XZPuEPz5t/6/6P5iAzMixU5Iia6/KP90X+qcT/V2sX DjzsdgkHgS2HxJJ8zmmfUq3WMYQHGJr3/c0Q0kSfJoSbPnAfZhjvSGJCIHo65k1JZSb8 NqZ5zJk0pJA5xh+Fyxj5souCIrtUJtOP2ubEs5r1YabtqGrotLv1D6fKqKfLnlrf+QQX d6ZAeJrDPpjcOScXbiPaEJ4ZcrP3C0s4hwn+OI8qpkvnmswmgSANg4Vo4aoQ6iW9KIyZ 8vqA== X-Gm-Message-State: AOJu0Yy61pVvv8m+618ebjeufsT30TZve5Q5wfm2cQrYkGZqiAt187Rz nwErf0g4qp8nzSJiSXrufAMMuRJUa8sVCKpYHpW3BenI3HDEuDfaCK1EgZPePCSoORRYTi5SMxz DTGJuccnWJLyKRpUjBvqd8lZ8mtxr4zNg6b2mEsNNbBvq24vLQ3T890M0yabN8STTvCoXzjWOLQ m8Xp1OA4FuGpBDo79FWss6q49KaMyaKg== X-Received: by 2002:a5d:53d0:0:b0:360:728d:8439 with SMTP id ffacd0b85a97d-369b66a18camr3956902f8f.2.1721607516836; Sun, 21 Jul 2024 17:18:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoLrhS4w9mdOYGKXhYPKqbrEl4aoz0iTh0xJskX67EREMMdJq5Ff9axOlDY/5bJXnKCUa4Fg== X-Received: by 2002:a5d:53d0:0:b0:360:728d:8439 with SMTP id ffacd0b85a97d-369b66a18camr3956892f8f.2.1721607516303; Sun, 21 Jul 2024 17:18:36 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787ced33sm7053287f8f.86.2024.07.21.17.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:35 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Eric Auger , =?utf-8?q?C=C3=A9dric?= Le Goater , Alex Williamson Subject: [PULL 49/63] hw/vfio/common: Add vfio_listener_region_del_iommu trace event Message-ID: <82679f515adbd6ebca1908042d873be31989764d.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Eric Auger Trace when VFIO gets notified about the deletion of an IOMMU MR. Also trace the name of the region in the add_iommu trace message. Signed-off-by: Eric Auger Message-Id: <20240716094619.1713905-6-eric.auger@redhat.com> Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/vfio/common.c | 3 ++- hw/vfio/trace-events | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 6d15b36e0b..cfc44a4569 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -599,7 +599,7 @@ static void vfio_listener_region_add(MemoryListener *listener, IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr); int iommu_idx; - trace_vfio_listener_region_add_iommu(iova, end); + trace_vfio_listener_region_add_iommu(section->mr->name, iova, end); /* * FIXME: For VFIO iommu types which have KVM acceleration to * avoid bouncing all map/unmaps through qemu this way, this @@ -725,6 +725,7 @@ static void vfio_listener_region_del(MemoryListener *listener, if (memory_region_is_iommu(section->mr)) { VFIOGuestIOMMU *giommu; + trace_vfio_listener_region_del_iommu(section->mr->name); QLIST_FOREACH(giommu, &bcontainer->giommu_list, giommu_next) { if (MEMORY_REGION(giommu->iommu_mr) == section->mr && giommu->n.start == section->offset_within_region) { diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index e16179b507..98bd4dccea 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -95,7 +95,8 @@ vfio_region_read(char *name, int index, uint64_t addr, unsigned size, uint64_t d vfio_iommu_map_notify(const char *op, uint64_t iova_start, uint64_t iova_end) "iommu %s @ 0x%"PRIx64" - 0x%"PRIx64 vfio_listener_region_skip(const char *name, uint64_t start, uint64_t end) "SKIPPING %s 0x%"PRIx64" - 0x%"PRIx64 vfio_spapr_group_attach(int groupfd, int tablefd) "Attached groupfd %d to liobn fd %d" -vfio_listener_region_add_iommu(uint64_t start, uint64_t end) "region_add [iommu] 0x%"PRIx64" - 0x%"PRIx64 +vfio_listener_region_add_iommu(const char* name, uint64_t start, uint64_t end) "region_add [iommu] %s 0x%"PRIx64" - 0x%"PRIx64 +vfio_listener_region_del_iommu(const char *name) "region_del [iommu] %s" vfio_listener_region_add_ram(uint64_t iova_start, uint64_t iova_end, void *vaddr) "region_add [ram] 0x%"PRIx64" - 0x%"PRIx64" [%p]" vfio_known_safe_misalignment(const char *name, uint64_t iova, uint64_t offset_within_region, uintptr_t page_size) "Region \"%s\" iova=0x%"PRIx64" offset_within_region=0x%"PRIx64" qemu_real_host_page_size=0x%"PRIxPTR vfio_listener_region_add_no_dma_map(const char *name, uint64_t iova, uint64_t size, uint64_t page_size) "Region \"%s\" 0x%"PRIx64" size=0x%"PRIx64" is not aligned to 0x%"PRIx64" and cannot be mapped for DMA" From patchwork Mon Jul 22 00:18:36 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: 13738167 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 9892EC3DA7E for ; Mon, 22 Jul 2024 00:24:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmO-0007ZR-QJ; Sun, 21 Jul 2024 20:19:52 -0400 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 1sVglJ-00024r-Kd for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:46 -0400 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 1sVglH-0005vt-6V for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607521; 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=lNaBRV7Yd2JZRWzu6CicjU/g67eykdpgIsM3nElPwyU=; b=bmIYgsu370XOBbenOKyUN6VlcOWm6pF0nRxiw6DvYpEt7F58ESmjFKmz9S9HxC+9aqByYN yD3loQJf2MLYfWtyvS04cxGdQgxRaZ+rxvmiVtys9PiEFIoCrq01daD4uWGlPiG+Uby81z pm3X4ce6EhtFvtGUWH1xSVGLPH9wHp8= 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-370-GJe62vGLO6-Pvt_Al_vmqA-1; Sun, 21 Jul 2024 20:18:40 -0400 X-MC-Unique: GJe62vGLO6-Pvt_Al_vmqA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4266d0183feso27814285e9.0 for ; Sun, 21 Jul 2024 17:18:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607519; x=1722212319; 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=lNaBRV7Yd2JZRWzu6CicjU/g67eykdpgIsM3nElPwyU=; b=tY+U/InWqtLLQb5oz6WnOTtWiiidTwosFVZAH6UYT/FwUG7/GyjGHrS7q3OdDfjMd9 EJY2Kaoqx2CyuF5ybRIMDbG3Myjpf0xJGgNq/v2+sHYVkVxk6h5oAX8eN7gmtvlSydFQ Dtu2isxUuMw7i7+wV8kaHpcRqwnHOR9ihoApqKSE81FiOQwW368aDVaVLgv1scVIKevy AeEOiNDDtP9R5SR9Xa0Lj9BBLPiq/omRdOJP+FA/y5n8NdH2GZKFPHUSW4bViIWqF3nM u74z0lmrdpP88X/fbEThIDUZHZkAugEib6vdu0efmezSHARI+UBH7W7Qn9oufD8/g16U 3NIw== X-Gm-Message-State: AOJu0Yy21my/JlsIiqj0LptVeNaUFP1ywWfdxxu1ms9TVbcmnXDhjM5a 7E0qHNBQ9Or9KefYz741pa2wCTBLKhIA3WZ7iSS4ybYVkGlQ/OZADoUDWxfKM9yxKQci0VtSyBt +wdkU0Ai2Ci59T3OkZCxOfuBxv3vORYuXkuI5AgUe2WON7n3M5a8D6lblwnmZuSla/R+A521sMg kfRB3ZpKrCeXmzxth2CUuOGXYaPNcG8A== X-Received: by 2002:a05:600c:5012:b0:426:5dd0:a1fc with SMTP id 5b1f17b1804b1-427daa67bdbmr40789025e9.34.1721607518935; Sun, 21 Jul 2024 17:18:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTQARRO7aYw9Gw8nLhPCkPXDku1VDsP8XeRloC7Xv2YVG1qPuIWV0VDrehO6FRmjGukvNiTQ== X-Received: by 2002:a05:600c:5012:b0:426:5dd0:a1fc with SMTP id 5b1f17b1804b1-427daa67bdbmr40788925e9.34.1721607518402; Sun, 21 Jul 2024 17:18:38 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d8e68ba0sm96986755e9.21.2024.07.21.17.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:37 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:36 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Eric Auger , =?utf-8?q?C=C3=A9dric?= Le Goater Subject: [PULL 50/63] virtio-iommu: Add trace point on virtio_iommu_detach_endpoint_from_domain Message-ID: <40885f26a8c3d93b3e85ebc4f713ace016ac68b4.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Eric Auger Add a trace point on virtio_iommu_detach_endpoint_from_domain(). Signed-off-by: Eric Auger Message-Id: <20240716094619.1713905-7-eric.auger@redhat.com> Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 1 + hw/virtio/trace-events | 1 + 2 files changed, 2 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 440dfa6e92..59ef4fb217 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -308,6 +308,7 @@ static void virtio_iommu_detach_endpoint_from_domain(VirtIOIOMMUEndpoint *ep) if (!ep->domain) { return; } + trace_virtio_iommu_detach_endpoint_from_domain(domain->id, ep->id); g_tree_foreach(domain->mappings, virtio_iommu_notify_unmap_cb, ep->iommu_mr); QLIST_REMOVE(ep, next); diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index b7c04f0856..04e36ae047 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -116,6 +116,7 @@ virtio_iommu_get_config(uint64_t page_size_mask, uint64_t start, uint64_t end, u virtio_iommu_set_config(uint8_t bypass) "bypass=0x%x" virtio_iommu_attach(uint32_t domain_id, uint32_t ep_id) "domain=%d endpoint=%d" virtio_iommu_detach(uint32_t domain_id, uint32_t ep_id) "domain=%d endpoint=%d" +virtio_iommu_detach_endpoint_from_domain(uint32_t domain_id, uint32_t ep_id) "domain=%d endpoint=%d" virtio_iommu_map(uint32_t domain_id, uint64_t virt_start, uint64_t virt_end, uint64_t phys_start, uint32_t flags) "domain=%d virt_start=0x%"PRIx64" virt_end=0x%"PRIx64 " phys_start=0x%"PRIx64" flags=%d" virtio_iommu_unmap(uint32_t domain_id, uint64_t virt_start, uint64_t virt_end) "domain=%d virt_start=0x%"PRIx64" virt_end=0x%"PRIx64 virtio_iommu_unmap_done(uint32_t domain_id, uint64_t virt_start, uint64_t virt_end) "domain=%d virt_start=0x%"PRIx64" virt_end=0x%"PRIx64 From patchwork Mon Jul 22 00:18:38 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: 13738142 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 B215AC3DA61 for ; Mon, 22 Jul 2024 00:19:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVglc-0002sW-GM; Sun, 21 Jul 2024 20:19:07 -0400 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 1sVglL-0002Au-P3 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:48 -0400 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 1sVglJ-0005wC-Fj for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607524; 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=2MFU5YluLJy3dMwMtCRKC5eZxelIcmwO+t8tRGjROFc=; b=fyU7JAlDE6XfI9DXhzVO5DF2SaHhnemXSMGGVvWNiRhLsqPwaegrs18xRCfrPSwUik5JNs jSFsVEALuMZckp6R5xPiCkZ48sjD1Op3f+vbmyd4SIO1STkrql7g9CeXZ1ZzDY/tT03Upi Wpg2Hqdx+1JLHkOOn8fUXx8O4FqXOjg= 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-127-NWlMjow5Np-UUeG9blZMqw-1; Sun, 21 Jul 2024 20:18:42 -0400 X-MC-Unique: NWlMjow5Np-UUeG9blZMqw-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-36835daf8b7so2715769f8f.2 for ; Sun, 21 Jul 2024 17:18:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607521; x=1722212321; 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=2MFU5YluLJy3dMwMtCRKC5eZxelIcmwO+t8tRGjROFc=; b=Tf6exIy3f9LWp0+eeufqXc+STC6xkQETmjFMnU00mp4til+7X/xKxFwShp7ZStVPgj uMCit2DVvQYhVMSAT3NaEf/opKvADgNJCkIpJyPIeH7qfG847iQ0Nd3NWVLuOe4ywVuA OEYETLgX1RZ2tFi6D3V6e9NApU5SuG0uJ2MUAhUHGdEFAGn+e8WXKHbc83Q7pH0/dXla /mPdMCe7b2jYZOMzB205Dk1Go/ybxJnQ4QguckX7mLgSRU/8g38KzBazXFEjsZo+dP3A 1e2Gt0Qp9daewn2u7ZIGyPufzwiLSdxcr7Js0qWAqAHFnlLzVMVrTb+5ThsV/mhVCnj7 iJQA== X-Gm-Message-State: AOJu0YxGgAWM2m0b3cfbPrK8eIr3MiRRhwgyEfyqmGzioYVmQ2nTCM6S T+CjlWszXhV19d057JBw91tfHWiEEMel+4y5YC/QlUnfoWbBInWwc3lJnvSZ79D3TsJRaJ/Q23b qQ5o0IUtOl57oPTyiEqAkDDZTCFoFjTWSFodsTcqIenGYg7WvpbIR3QtvF54jYFUejTfu8Ybk/q AunzT8czzCwVVI2dUd6xNxxaWMEAVvAQ== X-Received: by 2002:a5d:4604:0:b0:368:7282:51d6 with SMTP id ffacd0b85a97d-369bae4d54dmr4227556f8f.21.1721607521257; Sun, 21 Jul 2024 17:18:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWzKtRRYHll+mm01uoqHoCxQ2/pCyfQk0/jmxFlqOHMnxJDo0jZlLMmPQiMvL27rYFpYlwMQ== X-Received: by 2002:a5d:4604:0:b0:368:7282:51d6 with SMTP id ffacd0b85a97d-369bae4d54dmr4227530f8f.21.1721607520599; Sun, 21 Jul 2024 17:18:40 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36878684204sm7029703f8f.2.2024.07.21.17.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:40 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Alistair Francis , Igor Mammedov , Palmer Dabbelt , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , qemu-riscv@nongnu.org Subject: [PULL 51/63] hw/riscv/virt-acpi-build.c: Add namespace devices for PLIC and APLIC 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Sunil V L As per the requirement ACPI_080 in the RISC-V Boot and Runtime Services (BRS) specification [1], PLIC and APLIC should be in namespace as well. So, add them using the defined HID. [1] - https://github.com/riscv-non-isa/riscv-brs/releases/download/v0.0.2/riscv-brs-spec.pdf (Chapter 6) Signed-off-by: Sunil V L Acked-by: Alistair Francis Acked-by: Igor Mammedov Message-Id: <20240716144306.2432257-2-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/riscv/virt-acpi-build.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 0925528160..5f5082a35b 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -141,6 +141,30 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtState *s) } } +static void acpi_dsdt_add_plic_aplic(Aml *scope, uint8_t socket_count, + uint64_t mmio_base, uint64_t mmio_size, + const char *hid) +{ + uint64_t plic_aplic_addr; + uint32_t gsi_base; + uint8_t socket; + + for (socket = 0; socket < socket_count; socket++) { + plic_aplic_addr = mmio_base + mmio_size * socket; + gsi_base = VIRT_IRQCHIP_NUM_SOURCES * socket; + Aml *dev = aml_device("IC%.02X", socket); + aml_append(dev, aml_name_decl("_HID", aml_string("%s", hid))); + aml_append(dev, aml_name_decl("_UID", aml_int(socket))); + aml_append(dev, aml_name_decl("_GSB", aml_int(gsi_base))); + + Aml *crs = aml_resource_template(); + aml_append(crs, aml_memory32_fixed(plic_aplic_addr, mmio_size, + AML_READ_WRITE)); + aml_append(dev, aml_name_decl("_CRS", crs)); + aml_append(scope, dev); + } +} + static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, uint32_t uart_irq) @@ -411,6 +435,14 @@ static void build_dsdt(GArray *table_data, socket_count = riscv_socket_count(ms); + if (s->aia_type == VIRT_AIA_TYPE_NONE) { + acpi_dsdt_add_plic_aplic(scope, socket_count, memmap[VIRT_PLIC].base, + memmap[VIRT_PLIC].size, "RSCV0001"); + } else { + acpi_dsdt_add_plic_aplic(scope, socket_count, memmap[VIRT_APLIC_S].base, + memmap[VIRT_APLIC_S].size, "RSCV0002"); + } + acpi_dsdt_add_uart(scope, &memmap[VIRT_UART0], UART0_IRQ); if (socket_count == 1) { From patchwork Mon Jul 22 00:18: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: 13738191 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 0618DC3DA63 for ; Mon, 22 Jul 2024 00:29:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmT-0008Eg-4w; Sun, 21 Jul 2024 20:19:57 -0400 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 1sVglM-0002Hw-VD for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:51 -0400 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 1sVglL-0005wi-B7 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607526; 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=uKdtFU2bD5M7BU4ChiAF5yuLXt6KWMO049/Tq7aTIq8=; b=FRZoEOCMMK2NA9QbgA0bUYGEo1ALdZuWKk4DDXLGOXMA/62yeyQed5pl4my8mol4n/4ukH 4dYb9WcGmnWbAVEmjEb9IFLMX2tTr4cBHCVLJIZqGGdq1ex4GZFhhsrrsYNFX9Mess2ozB lCNZUsT2JfXaWSNpgAYQ7mOCvBKWeJo= 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-504-eOdMfpSjPbSPPB7r_bVXVA-1; Sun, 21 Jul 2024 20:18:45 -0400 X-MC-Unique: eOdMfpSjPbSPPB7r_bVXVA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-427d9e61ba8so15911735e9.3 for ; Sun, 21 Jul 2024 17:18:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607523; x=1722212323; 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=uKdtFU2bD5M7BU4ChiAF5yuLXt6KWMO049/Tq7aTIq8=; b=HiaSRISxNQxpxGxJK6OCm/jiaSlAw3IfW+mlhlGT8ou7cmwPWp47VRKCFVjkEgGf85 E37iwwkZq/1Rbf/WP+yUWsscTYRP8Hc+KXxDsL81VE63cOWFYtU9lxBtDa9aZMWrDORQ vqNHdnpIYD4I/pxjBpjM1CUWalVLhPHj2x3PWQ0+CjErHVeMpw4g0TBSH089H/C711Y+ CnpfjP7ljebua3EZbBFZBV35oSJSJbhwHXdCa3gZguRj30K3jhtjx7s4HmtKRL1zP4lc vI4mj3C6Ap9UoeRU25ntGrjQh5q4isSTWjJurLH75uKbSMCBcJ6M5L/AWqXpCWKUYt5j VF+Q== X-Gm-Message-State: AOJu0YwsxpUoIkWWwuQE9iXm9pkylLGbiBrtLMwjMGqNJthlP7xI9WHl yhdsHisLGhC7vG5hCkSVOnkT5VPX1VLcoJ2DyAB7oguq0bcrNRmk4zo2o2KMkVWDOi1HBSQnfyw WMJvfViaxQhWfky2OlUm81K0oQRTJxx8kQ494dVJfrsmeryTMXd3jsKksak6iFObah60HzRN5IC hhZ9uq5mYxFJ4Cwa0UMlnY7wr72MKhPg== X-Received: by 2002:a05:600c:4fd2:b0:426:60e4:c691 with SMTP id 5b1f17b1804b1-427dc5284b5mr27693435e9.11.1721607523425; Sun, 21 Jul 2024 17:18:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHMnXBjyyY8iAqGyY/a6I9yp2jzeE/A9BI06NkJ8AOmviyvA4hs0Psc7HSzJ/Wr0FRuwpFFg== X-Received: by 2002:a05:600c:4fd2:b0:426:60e4:c691 with SMTP id 5b1f17b1804b1-427dc5284b5mr27693275e9.11.1721607522905; Sun, 21 Jul 2024 17:18:42 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a635cdsm133630885e9.13.2024.07.21.17.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:42 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:40 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Alistair Francis , Igor Mammedov , Palmer Dabbelt , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , qemu-riscv@nongnu.org Subject: [PULL 52/63] hw/riscv/virt-acpi-build.c: Update the HID of RISC-V UART 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Sunil V L The requirement ACPI_060 in the RISC-V BRS specification [1], requires NS16550 compatible UART to have the HID RSCV0003. So, update the HID for the UART. [1] - https://github.com/riscv-non-isa/riscv-brs/releases/download/v0.0.2/riscv-brs-spec.pdf (Chapter 6) Signed-off-by: Sunil V L Acked-by: Alistair Francis Reviewed-by: Igor Mammedov Message-Id: <20240716144306.2432257-3-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/riscv/virt-acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 5f5082a35b..36d6a3a412 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -170,7 +170,7 @@ acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, uint32_t uart_irq) { Aml *dev = aml_device("COM0"); - aml_append(dev, aml_name_decl("_HID", aml_string("PNP0501"))); + aml_append(dev, aml_name_decl("_HID", aml_string("RSCV0003"))); aml_append(dev, aml_name_decl("_UID", aml_int(0))); Aml *crs = aml_resource_template(); From patchwork Mon Jul 22 00:18: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: 13738192 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 3D3D9C3DA5D for ; Mon, 22 Jul 2024 00:30:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmT-0008Jz-GM; Sun, 21 Jul 2024 20:19:57 -0400 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 1sVglQ-0002Yw-K0 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:54 -0400 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 1sVglO-0005xL-DD for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607529; 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=0mtOB+kdXXWYOHCvpvehEzKr387KURYV1YXTFOFkqBM=; b=MmsLm4XwWGuY5lGHldHayci3aCCVVV0Pbv0k+JWECaYNSQi8UpW+HEz3lrPMNDaMTzKjX4 Hbuw6MOGV06/ji6qV3DiYl52oBL2yp1mmb2sRJa4jsoiQQCglDm19ZTMr+ZIM80m9h/LW7 XAeH/GtTxZ3PAVd/1ow0h29L4fRPx9g= 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-44-ZYno_MHqO8WgTp5rNYwDrA-1; Sun, 21 Jul 2024 20:18:47 -0400 X-MC-Unique: ZYno_MHqO8WgTp5rNYwDrA-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-36832c7023bso1998783f8f.2 for ; Sun, 21 Jul 2024 17:18:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607525; x=1722212325; 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=0mtOB+kdXXWYOHCvpvehEzKr387KURYV1YXTFOFkqBM=; b=twYLNhRH6AyWQ8rhJbn5M4mMFhcgbRhICRUN+UFirWSJgVw4n37cEK9gPiIyft1KBE 92WUmyACtnxA6Rc86kVGz7x6uBAzKBjVUeRQrfe1AMZA0oXQx0s1SAzrm6L0GICidQ0/ juCgvw5Cvjf7CRAngVv/KXgDI0AeGaQIB/YM4RYnsW54TXiPDCLg36h8dOYvWXTiAunH G7fNO3h3+2DqqaPOZ34/l77FMv2P4mrlHl+cenMBEDNA0uqddgPLvwo5APm1QcUi72ro suaEHzIZ3XZ+aEhUvSdeC9lXF38zl58evqxw51XEhW+U1NBzSyPsor2i/Cp//mmNItAN tl2Q== X-Gm-Message-State: AOJu0Yxpn4YTTmeMVKrVtHxHT/Mf2iO8yOMrCCXKVVAMlwK2btzvdqAF AINsaoAlrSbhjAcFYQT6Am2WZxdfDqsseFKmvNp4YYjUylv7RnTNWSf0NSFvONu+dUYSV5tR/3I kgQES7pUTKCZhYgGnt9WRZyh59ydu7ch+8h+IQBGzSKP35EluIH/hbhJYs8o1ot7LfR+N+Gv4/D W5G9mLsb8VuHj7178e41aDargzaBGIWg== X-Received: by 2002:adf:ed8d:0:b0:368:664a:d4f9 with SMTP id ffacd0b85a97d-369bae3654fmr3626642f8f.28.1721607525417; Sun, 21 Jul 2024 17:18:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGq4aisgZ8WlyYTytcvABA33osNBxKn0f+Wl26HpwGQNZUowaQ7sTphc2MToHO5QAEZNQG6QQ== X-Received: by 2002:adf:ed8d:0:b0:368:664a:d4f9 with SMTP id ffacd0b85a97d-369bae3654fmr3626629f8f.28.1721607524921; Sun, 21 Jul 2024 17:18:44 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36878684757sm7058218f8f.10.2024.07.21.17.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:44 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Igor Mammedov , Ani Sinha Subject: [PULL 53/63] tests/acpi: Allow DSDT acpi table changes for aarch64 Message-ID: <04fccb2e79edf00f0521efe364243a4f495df3b5.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Sunil V L so that CI tests don't fail when those ACPI tables are updated in the next patch. This is as per the documentation in bios-tables-tests.c. Signed-off-by: Sunil V L Reviewed-by: Igor Mammedov Message-Id: <20240716144306.2432257-4-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index dfb8523c8b..9282ea0fb2 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,7 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/aarch64/virt/DSDT", +"tests/data/acpi/aarch64/virt/DSDT.memhp", +"tests/data/acpi/aarch64/virt/DSDT.topology", +"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt", +"tests/data/acpi/aarch64/virt/DSDT.pxb", +"tests/data/acpi/x86/microvm/DSDT.pcie", From patchwork Mon Jul 22 00:18: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: 13738155 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 CFCA2C3DA61 for ; Mon, 22 Jul 2024 00:22:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgly-0005Cw-Al; Sun, 21 Jul 2024 20:19:26 -0400 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 1sVglR-0002aw-64 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:54 -0400 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 1sVglP-0005xW-DF for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607530; 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=WUYDk8FUt/O+FXoIUIkb4reQo415JT0gLF3CIIPrYls=; b=VmTpe/biTdDPcmQYRvhipjj+Eta1YD5XGg96KLs7F21vQXD7T45lzPQDaMDfsYISeVs0UM OT6IrOr34Zu6CQRES7WlR4eolweVhXEQvByuIR9yl1gIHz27xU4t1RiO9DnWqZYooR/oZM a0V7tC7SY7+1DiQt2eqKtQHiGKQ9zYo= 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-617-K80vAoScPzCy9VhLksNZLw-1; Sun, 21 Jul 2024 20:18:49 -0400 X-MC-Unique: K80vAoScPzCy9VhLksNZLw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42671a6fb9dso25239965e9.3 for ; Sun, 21 Jul 2024 17:18:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607528; x=1722212328; 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=WUYDk8FUt/O+FXoIUIkb4reQo415JT0gLF3CIIPrYls=; b=TSLRYyiYbgkLnnHr3tGmk02m7UDwzaDUHOkFpUqU55DvtfeYv3RyNdb/4WkmIM/el/ f6GPzH+pwejZieb9d0U4ToTV7+u26E73k5og2AryRgr9jOLTat1TzXH7xJacrcaRXSvB 5LX1DimhfDtQ/UsarPCbJn968+gd4OAb4p5yUb/0ylMb4PaUBZIVIHLm/qrqnXgOsbBa X84jWrjlD1l05gssj6mdqzUDD359Zq1bV7y1Hfu5D4jLcUAn1R8w9SRa5QezTkzNO9ZH imV09+EEvVl/pblwvsXSAv8AP3lwONrtM110Ay3LrPsS7k2me29KjKTtoH4h3gEs9Ht2 3Z1w== X-Gm-Message-State: AOJu0Yxc7AoFEEZP15efFLv9FkXWS7bOeXjEmWij7ow8KV2TvfM4RxoW B8FAoW5A8gqhW+VIObwPGtNi6aC87hlQx3mXs5pqqD56J46kX0n+jzqkWOXtYXI3sgiFIBVYfrX cy+AGpi9ZEwBb8tncgFZXZB8NqhbdMrk7SDdv/SJpJ3hkx28bYYSKxRd/S6Ut5xpvaf1O8Q+9iw 3HfwRAgFbNy8TaItzEKbMlKIqXUSjEAA== X-Received: by 2002:a05:600c:3ba3:b0:426:5de3:2ae5 with SMTP id 5b1f17b1804b1-427dc520291mr38634635e9.10.1721607528007; Sun, 21 Jul 2024 17:18:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEm0kI/w09KN27i6SCc7Nyn2TmcReM1GKo5eFcICdIBK5s45Gj3934GA+ivd2ww5odWpowjew== X-Received: by 2002:a05:600c:3ba3:b0:426:5de3:2ae5 with SMTP id 5b1f17b1804b1-427dc520291mr38634425e9.10.1721607527081; Sun, 21 Jul 2024 17:18:47 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e2a1sm132413165e9.31.2024.07.21.17.18.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:46 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Igor Mammedov , Alistair Francis , Daniel Henrique Barboza , Michael Tokarev Subject: [PULL 54/63] acpi/gpex: Create PCI link devices outside PCI root bridge 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Sunil V L Currently, PCI link devices (PNP0C0F) are always created within the scope of the PCI root bridge. However, RISC-V needs these link devices to be created outside to ensure the probing order in the OS. This matches the example given in the ACPI specification [1] as well. Hence, create these link devices directly under _SB instead of under the PCI root bridge. To keep these link device names unique for multiple PCI bridges, change the device name from GSIx to LXXY format where XX is the PCI bus number and Y is the INTx. GPEX is currently used by riscv, aarch64/virt and x86/microvm machines. So, this change will alter the DSDT for those systems. [1] - ACPI 5.1: 6.2.13.1 Example: Using _PRT to Describe PCI IRQ Routing Signed-off-by: Sunil V L Acked-by: Igor Mammedov Message-Id: <20240716144306.2432257-5-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-host/gpex-acpi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hw/pci-host/gpex-acpi.c b/hw/pci-host/gpex-acpi.c index f69413ea2c..391fabb8a8 100644 --- a/hw/pci-host/gpex-acpi.c +++ b/hw/pci-host/gpex-acpi.c @@ -7,7 +7,8 @@ #include "hw/pci/pcie_host.h" #include "hw/acpi/cxl.h" -static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq) +static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq, + Aml *scope, uint8_t bus_num) { Aml *method, *crs; int i, slot_no; @@ -20,7 +21,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq) Aml *pkg = aml_package(4); aml_append(pkg, aml_int((slot_no << 16) | 0xFFFF)); aml_append(pkg, aml_int(i)); - aml_append(pkg, aml_name("GSI%d", gsi)); + aml_append(pkg, aml_name("L%.02X%X", bus_num, gsi)); aml_append(pkg, aml_int(0)); aml_append(rt_pkg, pkg); } @@ -30,7 +31,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq) /* Create GSI link device */ for (i = 0; i < PCI_NUM_PINS; i++) { uint32_t irqs = irq + i; - Aml *dev_gsi = aml_device("GSI%d", i); + Aml *dev_gsi = aml_device("L%.02X%X", bus_num, i); aml_append(dev_gsi, aml_name_decl("_HID", aml_string("PNP0C0F"))); aml_append(dev_gsi, aml_name_decl("_UID", aml_int(i))); crs = aml_resource_template(); @@ -45,7 +46,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq) aml_append(dev_gsi, aml_name_decl("_CRS", crs)); method = aml_method("_SRS", 1, AML_NOTSERIALIZED); aml_append(dev_gsi, method); - aml_append(dev, dev_gsi); + aml_append(scope, dev_gsi); } } @@ -174,7 +175,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) aml_append(dev, aml_name_decl("_PXM", aml_int(numa_node))); } - acpi_dsdt_add_pci_route_table(dev, cfg->irq); + acpi_dsdt_add_pci_route_table(dev, cfg->irq, scope, bus_num); /* * Resources defined for PXBs are composed of the following parts: @@ -205,7 +206,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) aml_append(dev, aml_name_decl("_STR", aml_unicode("PCIe 0 Device"))); aml_append(dev, aml_name_decl("_CCA", aml_int(1))); - acpi_dsdt_add_pci_route_table(dev, cfg->irq); + acpi_dsdt_add_pci_route_table(dev, cfg->irq, scope, 0); method = aml_method("_CBA", 0, AML_NOTSERIALIZED); aml_append(method, aml_return(aml_int(cfg->ecam.base))); From patchwork Mon Jul 22 00:18: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: 13738168 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 CF968C3DA7F for ; Mon, 22 Jul 2024 00:24:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmU-0008SP-7U; Sun, 21 Jul 2024 20:19:58 -0400 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 1sVglc-0003Pk-M0 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:07 -0400 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 1sVglU-0005yH-ME for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607536; 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=aqD0Di/u5jqVGrexXisvKd7DLh+zSri/mjbojl6aQqw=; b=J98svhRTGc0HaTgkp97BW9C9jtGdtCS5G6+GuZcleXkaDZOjtX9Or1YxGpMzEUqUYJ0fkC Tu6xlYtqzVfAjKUsxhzhWZ1FU4+lVxpOFKgV2/egwPEkurnjgYFyp7ZKCgPje9el6X9uq9 S5wtik3IpfNDNXjuapTJgTDsZ58rIuw= 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-517-4ZZPtGx0OWCjXzdwdBC-iA-1; Sun, 21 Jul 2024 20:18:52 -0400 X-MC-Unique: 4ZZPtGx0OWCjXzdwdBC-iA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4266edc9c85so25285605e9.2 for ; Sun, 21 Jul 2024 17:18:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607530; x=1722212330; 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=aqD0Di/u5jqVGrexXisvKd7DLh+zSri/mjbojl6aQqw=; b=ZFi1z1X8Gk/whxKHGCxs7RVqTUyN5SwO/Id374GLJC1mp3E3NUw1W765RWs5qya9TM QfE7OeqzKv77NkJYItpoIQHXUMRb3xor81rcFN72+xnA2fd+Ra0Mr2Z+Upq1YomDbm6G uXI2SwTapuLJnhBupK8X2W00Nz6sWWYsYcpMmOJy6o0dJnk+JhgBDKAwomULvC1DqYcO fJ438IbxNPsLL92blY4fkBAVBXR8wmeUoZCHKYgu5OgXEMHKfmKF9we03JEknbKGFW3u 3+IQujII+cJftZKwbCfJ4zYhtmx52V+WjZlboW/4TN2xEIdEEXG1eTHGebImkNsFppyV zRiA== X-Gm-Message-State: AOJu0YxtgmHJIbRnOF0+ozLlh8to0K8moVUd4DAKkRDAcja5k+soJF3+ El1UX6xbAyK9VqHpuOagJlTJcnimH7nt3IDNEktmJ+4xQ5++JMkHo4l4BmnSh8/cF28jlF5hhQs ipnimKDrAlZr+pP7Ph8LJmlNSg9fkVCfhBS2MaJC64MBejaxly60efW+zpjBYuQNZP87oG8Ia89 SKY60frHxg9wqaFKeVFRyPr7AW5Ls6KQ== X-Received: by 2002:a05:600c:4fd0:b0:426:6138:34b3 with SMTP id 5b1f17b1804b1-427dc512feemr32224765e9.5.1721607530257; Sun, 21 Jul 2024 17:18:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHeb6wVjL1v0d1tDXK4ktKdDO5Uf82MokGVkhomKhjot+sIPIw2glATgu5E2bl6VEG94gGYKw== X-Received: by 2002:a05:600c:4fd0:b0:426:6138:34b3 with SMTP id 5b1f17b1804b1-427dc512feemr32224535e9.5.1721607529286; Sun, 21 Jul 2024 17:18:49 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a3c159sm134924855e9.8.2024.07.21.17.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:48 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Igor Mammedov , Ani Sinha Subject: [PULL 55/63] tests/acpi: update expected DSDT blob for aarch64 and microvm 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Sunil V L After PCI link devices are moved out of the scope of PCI root complex, the DSDT files of machines which use GPEX, will change. So, update the expected AML files with these changes for these machines. Mainly, there are 2 changes. 1) Since the link devices are created now directly under _SB for all PCI root bridges in the system, they should have unique names. So, instead of GSIx, named those devices as LXXY where L means link, XX will have PCI bus number and Y will have the INTx number (ex: L000 or L001). The _PRT entries will also be updated to reflect this name change. 2) PCI link devices are moved from the scope of each PCI root bridge to directly under _SB. Below is the sample iASL difference for one such link device. Scope (\_SB) { Name (_HID, "LNRO0005") // _HID: Hardware ID Name (_UID, 0x1F) // _UID: Unique ID Name (_CCA, One) // _CCA: Cache Coherency Attribute Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings { Memory32Fixed (ReadWrite, 0x0A003E00, // Address Base 0x00000200, // Address Length ) Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, ) { 0x0000004F, } }) + Device (L000) + { + Name (_HID, "PNP0C0F" /* PCI Interrupt Link Device */) + Name (_UID, Zero) // _UID: Unique ID + Name (_PRS, ResourceTemplate () + { + Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, ) + { + 0x00000023, + } + }) + Name (_CRS, ResourceTemplate () + { + Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, ) + { + 0x00000023, + } + }) + Method (_SRS, 1, NotSerialized) // _SRS: Set Resource Settings + { + } + } + Device (PCI0) { Name (_HID, "PNP0A08" /* PCI Express Bus */) // _HID: Hardware ID Name (_CID, "PNP0A03" /* PCI Bus */) // _CID: Compatible ID Name (_SEG, Zero) // _SEG: PCI Segment Name (_BBN, Zero) // _BBN: BIOS Bus Number Name (_UID, Zero) // _UID: Unique ID Name (_STR, Unicode ("PCIe 0 Device")) // _STR: Description String Name (_CCA, One) // _CCA: Cache Coherency Attribute Name (_PRT, Package (0x80) // _PRT: PCI Routing Table { Package (0x04) { 0xFFFF, Zero, - GSI0, + L000, Zero }, ..... }) Device (GSI0) { Name (_HID, "PNP0C0F" /* PCI Interrupt Link Device */) Name (_UID, Zero) // _UID: Unique ID Name (_PRS, ResourceTemplate () { Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, ) { 0x00000023, } }) Name (_CRS, ResourceTemplate () { Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, ) { 0x00000023, } }) Method (_SRS, 1, NotSerialized) // _SRS: Set Resource Settings { } } } } Signed-off-by: Sunil V L Message-Id: <20240716144306.2432257-6-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 6 ------ tests/data/acpi/aarch64/virt/DSDT | Bin 5196 -> 5196 bytes .../data/acpi/aarch64/virt/DSDT.acpihmatvirt | Bin 5282 -> 5282 bytes tests/data/acpi/aarch64/virt/DSDT.memhp | Bin 6557 -> 6557 bytes tests/data/acpi/aarch64/virt/DSDT.pxb | Bin 7679 -> 7679 bytes tests/data/acpi/aarch64/virt/DSDT.topology | Bin 5398 -> 5398 bytes tests/data/acpi/x86/microvm/DSDT.pcie | Bin 3023 -> 3023 bytes 7 files changed, 6 deletions(-) diff --git a/tests/data/acpi/aarch64/virt/DSDT b/tests/data/acpi/aarch64/virt/DSDT index c47503990715d389914fdf9c8bccb510761741ac..36d3e5d5a5e47359b6dcb3706f98b4f225677591 100644 GIT binary patch literal 5196 zcmZvgO>Y}j6o${(6MH=V$k=i0*l}VPO2ub2wwop`ZK*wW5*Ir$o}@u?C09a4lx!+d zA(aX#WYI!)G=g=I@i_JB;ppIOkQ*EXH&1-1FS~%$$*qZ^!NI_47oL z<@T<#?bh0#4xL)9R?~<`U8`T~Wm|hNaodyeaoMqL+n8+kI_Z`(?Af-xPR3-v*P-$8 zO=ouy-Wv_JZM$9%?imwj8iTOGNaH#>X3*2hOI?{iHkCw{5#Y z#>CxgnMq^fI4#XbWX+6^h$NPR$d-P86fUX1GupLnd+lP{S>(m!CPjkDZH}n>vm-)H z`x+v`5cL4jR;y@82s0uvbjE0KMpI-&B}R-fnw)V>WatvZV2o>=u_iL+B!^#TXl$aYJMzBu0)gZZJkY_&6}dOjBay8RI5r zh-r!+Nto&d#`usksVrpTbv>1X65}Rg3>c#+=jp1%xWyPdoFV6FRbt#> zjNO3I)BCf6Xt*=99eZe)S*Z8H9e-!=n;{EcxBpfw71az$~?*?_2hI) z>fMlkt@UlYPPvroHzVrtgpFw5wwsho>#6BfBNbDhwNzAtavA@g7uURKsz^H+8}T9= zvzCesherHJJBW;s7a7hH^&-O+M7_vxXw;9a2a!=fGMq*CBEuEvUSv2__ano_>waW7 z%N%&lf#)20&iRqyEHUtmfoBXoW9S(N&p3F-(KC*o26!6aX`rWpo(b?wfM)_d6Xfz=*&FpKznPfqx{iKwNKWUVezqMy z{UWY}j6o${(6MH=V$oM0+<2bPkrQ)+1+f9>}w$vUwj!T>vPtqW{k}IJiN;Z|K zkV=IVvS=YY8i_4Iip1YQV#SVK7p&Rv2iReB=OaC@dS>Cwy>riV@8i6duW#4w?rs%` zB0qO_oK3gh`E=ye>-D-uMCxAswVrphdsDYFog7sh+qRAA=AfHyJEMVZ+iPS@_Xb^> z99?&IhT*gEaMQLMjo_Ivb;fSCVwRpINC6XM5&aM&O}juuPiS(qzOnCY_}ou=!#&%! zn`BJg-L{!DrjFCrd_>mF_=rfN98|XTyW?<4TifFu+qPFKFk+@DF$#=v zoioIk;)f)RdXX_cGDeRx-a(-nzvgE6)_L(XYUV%%bk zoq)0Z>&O`d>lkg1?6$qGb~}S^&}yk&Os`MIwA0x>-w?_J)k<-RHrUI zps(p6eMS$66vW$jjK;h9t*^|(TvAWYX4H2FHu?8j-yJk4ms0&^r0))zVI$gi2QA8_ z_0(*pk*aB&w^UV=avA@bSJ!&gRF!rxHsVz_&s(Z892)T}?VvJ3US&8-)T<0v5cMj< zp;5oG5mZL~%5WCls|;75dzIl(-LDK6ultqZEOX#F2cC22Ip7 zJmcUQN6$EV8sKSwr-7aZdM3a#0iFr;OrWO;o+fyj=xL&75XAwM$;8{e^B6^mf#(u>E}>@?JgeYYMb9dF zE`#SXcrK&oGJ39n=L&ePpyvvD*1)p{o;CEWg`Sh6fv&#P{GV^?E84L)&cBF9V>g>I zlipFpo8DKtf6jn?h1k>`yIOz>b_{^h3_x8JP=4Pz>W*4fu)zhCIxpbMdP`vWeaH$n zy2y$m>yp6o`vO+MnmU~}on_RikNSP%za5)#^YQm-ilj(gGxef9FA=5GVUD`2+3Y{{ zvrIj`{Jcb3D(bh0X5R4GEh3GM-(xl2b?A+l`GeS{`k#>D?u|xdIJ@I5Dr_XCJFcT2 zACS}CZ=7z%Prk_JO=~jztMzZKdi$sS$L-&4zWn_7z|@`Ye)IUiG@R~!>yc_Gj=E_n z)Km3h*3|2%_2T5A_N@YXqZ_Bi7boF3zuQs|AF08r|LowGjNh*&X`CGtKA3jhp?-S7 zU(KIufBfyPelz^B^v`hdcV~E-IQf#!vQbS_FElwC>f@dZX;cSY>UgYW+ONGo-v3}W zo7L3+f?bxnSLbG(_`S>OWUk-qPW_1c$8rs|@!T79)BRo-G9A_4@k2yJpB)c*AqPe diff --git a/tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt b/tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt index aee6ba017cd730948bfa93e91551eb10a6809293..e6154d0355f84fdcc51387b4db8f9ee63acae4e9 100644 GIT binary patch literal 5282 zcmZvgO>Y}j6o${(jy)cKWb8O`;yAGjrQ)+1+f9>}QfiN##KlgGCuxve$(2wMC7ViA zNToswS+o#|1&v@GP=5##D|YNaV$Fs>zz(B3cg8($duB17`*EIopF3xy>)ZC)dp{S5 zB7e4a-EFVh`e@)*tJSJOMCw`n+TU#%x5r*an{Kk?|0jz z+iFsqF*;s$9j7j}SrOgX5F4YT zah$d1!%icg4{lK;7~J8AU_B6_hJ6VUVTf9QXsKBQ%Z3OmA~9l&QRj?cbzfjaB}SYv z8k})SFXRi1n8Yv{;}U1AiHsSEVKK%UXIvH;afy*;jLV#{E;14lBg+`;oUtJ?Oo?GL z#s+6x5gAE|k!Or6j8O|dju+mGB{2$&ag{T~G{ui3O!WoEc$YKeJWWgUSY(WAoFV6F zMq-p0<2}xh^E4|l%8YTHGvqv-l^Cmx@jhqBd1_0HDr4N>3^`A865|!dXmW;}r+JBS zo-taSA?N9w#JIp1E@RZ?JS|9!*BPVD8FHS^ON=)eqr(|;o-Rm?w;5xTGvquiN{ow) zvBep3o-RrZhcUJ}L(bDBiBV^aE@#MjT9O!-7~>{q$a%UfF)lO42b>}2X<1@yFh-9v z;{Z(tT)|e4R!{O>ugRpAA_Nn%UUUa zpYy8UUvFZtt`Hx4L(dp#R4^St878343n*PTMcq`h3cemdsm%zV)@uSw*C8wTijWmW z)&+s3>!z$5KMdS%@YWQo>1?Pq>9&JXL+$xGTV#$~t)1yQdV9lM#VQZTr7qp2Dmhf8 zHr=H!=pKDccZn3l-=+h#y&>mQ-ZeHKHS(ATmOJWH?IHj|^uJ^&`Ws zQ5{(eBBMGo93|#QhBJuykzv=EjtnOs(~;pQGvGM`o-^n{8Su=YX9hj9;F$%_EP7_qa~3>j!E+WpXVKFJPa8aK^t9142c9|b%%NuvJ@eq1 z2hTiu=FxKwJm7r=7?JQvV&0X>W0Sp?4_ zdKS@h5j+>ca}hlk(Q^qrm%wugJ(tk41fC`EETLx!J(t0A89bNKa~VC$;8_OGGJ2NL za|JwCz;gvXSI~16JXgVU6+KtcvjUzK@T{O`CG;%VW4G0$XIXWYr2gON9m{sYdhkt# zB56|BMBR)hMWVDi%u$y;nf#~zmZ{c@Pl{xuqq;;i@w-p16B%^!7K`z(BfrN)cVd^S ze@LdcKNyhd?hSiX*i4RhJvVl8NN)R}cD9{3{WLdc*`xknjejfU8$TXAX#VovAD^5Y zS~0hMP(L}eOt*c|xUUL|qaGRx^+?^Uin^cKPfza|Un!v9yLPtl^fc_Jt8LYIUv*aX z&klde>UuRu?b%`BopIai$Ii~_+5Eo#+uz>Wm;LXH|MZuBb^B+@)6eKxE@~L+Mx*0? zY}oPG7RdDvy43Ml!*X6)AO9UpCXqxMd&&E%aOccEeRRiCJDA6V VgJH`$8XYgG2R)eH5W2xu?SCHZ3OxV- literal 5282 zcmZvg%WoT16o=2)6MH;sd!dnyJ^zWmfB;-afuV-Ng5Sg>ZpKfn&7JCEf2+B1vs+{gLu{l;fBcW%e+?EIW3 ziri~&I~#7T{qfML)oL}3h}5Qc7u$GyVEk0#>8=2nvcku86Ocz6obf?es>g#Zf=dX zZQEWsANDNrd~lN@!QeJW1os0GYS>p05r(J-h_;$VaN7`JMkI#L7!A${?(R#BsKkgd zMw2tH_&4$;hAuG-#<;>6DX<1@iVT?PRA?N9$#JI{BA99AArxl5@#u%HN zA?N9m#JJ8F1IB2|dAckyZZO6cXUKV4l^C}eV>@7M{W5g=!90drL%U_Ksnt%u6O@{2 z71QmJF=@BA&Xy(a&L~?oD?@UqPYdYj+~ybNK`yB$ zr&H>=eVhDit>^aZluN04GtzVWjj#~yx&0>P(t2t-)kwwE&q^w)LAi|I=EXJ7iz?C% z`bNCS##u>4hFv3mq#Z;?$cqd|iF%RY45D6S*fr`$)`Q5X9~q9Kdy(M`bT2aOs{4`Q zroc0Wo+PYXRQ^vr^17Cf`)nMKbWc;>(}hn_j~oCD7}@SH=>IrPkfXC6HB z=$S{)dGMSE&w2EmN6!WDTma7n^jtvC0(cg{vw)rj^elpB5j>0NSwzngc$UDkgq|hz zEQ4nmJj>`=M$bj?Tm;WW^jt*G3V2q)vx1%#^jreZCGcEA&n5I+2G3>iTt?4j^sIts z6+ElxSq(kMhkaeW)cnsk^@?`v^|Kf8aO7q)X42b=c-?!Y`}+)7myb={k*fu$V8s9^ z%>dLz0p-`7q3)>ztv3XgUx%z8QC8_Tl z|8{J|&Bx!SDUu>}Ow~zyULZ=T%^Y=D)9HWevrM&KeqJCg74=I*Q?L8<7Li6r@30u} zIPiK*{Z8yq^-sufcZWkVoSo4o<<}FFZP(F{_Q~n&)lW9!$Dd{AOlv&&tNCxWa{I@< z$E{y){`u+AzNtH%y~feLX*iv|<|9>59CguDsHf^=R@M2$dU5f4cuu#;;d{)KB;G?@c=HKtH+Q&*qQS-~V=3z8d^c_-9c1%^92|jz6c< zY*f?KiN=QmebjX!8`Vaa+8%3~_AB?t`wynmX;u9f?6B0e+Ba**?_E~=eZ6jH;-|R3 z*;iK!&)t3}-RpKBr=!|ie&|7W)a_A<$Viy__?x6EI$gKBS<5d?x_5UHk5u9QiFN$+ ZzNyxG&xU)Wws|lmOEx4_iApz1w;!2&tj6JXeWQh$hxMJ8vAXdRjSVoZT z{LMY1)T)o{FHUm5-mmG?=ch0CR;lsZ-|3qqdJb<|zx=B{1@?NW{q=kO?8blVkKxxJ z?|;2~NWPhy)><`Ln04LgruA7hx&57vZ(3huV6&@giZJiGky3tMKeE+DHKqU0b=P5N zOWl`aS6&_?TN;@=_NngEv2y9TpB%VUwh*{frUt$|_hsNqStfL)Y$0@|Obu0PdZ*id z=u=rHf;56OqBQcQEHi<0;!1%|05x`OZ<0u3NMlH2N@Gf=kWL|;`clqm`hXgDiV36% zqzR=7r75H-q$#9!_!^qI(w@KDLI!C@X+~)dX%1;lY5tJ9RSG~0HL}mY+?9gTg3=Pw z64H{=lG2$g1v&%N%qX2vT0vStT2We2T0>g9QlRw!HTJcwDQzHaAZ;jZD4jz(hjdQp z+?Ph)(*>jpNEehYC|yFjgmgJbEp$ofN~!+*-NUhhbVcck(lw-ONY|9EeJRilpk@Q< zhSCkCEu<}^Eu}4`TUW{!wgc4UUALulOX&{M9i%%-ca-iS-2=Msp{D<8?4DNCq{l&;cioZDqe_E!uRgseNKcTSC_RbvPucv8{{w0Ur_ulb delta 1922 zcmY+^IkKBD0Dxf`urXq>jrYBKwU@~aoX4X{L%Q4{If7<#fmgV8ojQ{Xs;SSS%=CX5R84*H zgRpAqt0?m*Yula>cAgvQ>LSX*UNhab8|w1p%D|MD=SY{z&kbyPa%mt;dUlgTllm=$ zCiPQ8Tb^AR+R`r*nbL0|GNqpy38|dZY(KK8U#1UfAJRUheOvlv29OR+>7fHal^*Mx zCb8Sger5238V?638e|85>g4Ngj5edLQ_-f^EX>aAx$Yw zDa|0wAk8Svo>H?)4rnfV`uX>FC8so}w1BjLw4k)0bYw~o9RaFFl#VDJLpp|ZOzD`? z38WKKdg!EsD*f6{C@mo^AuTB_DV;((g>*{j)RxM>r!z=rkj^NbQ96fo4(Ys;YUrHM zg%Ixi&BL*PbV2EY(j}xzNSBl@ZRw#aK-CJ;6{Ram*O0CuT~oTIbYn`tg-r)lS=(+X z-B7xPbPMU0(k-PsNOyql98|fl_Kwm$qe-+tCn)ztS}@}@s-_jmXEFR9J=MSlKMl<)C>L_)+@ diff --git a/tests/data/acpi/aarch64/virt/DSDT.pxb b/tests/data/acpi/aarch64/virt/DSDT.pxb index fbd78f44c4785d19759daea909fe6d6f9a6e6b01..c0fdc6e9c1396cc2259dc4bc665ba023adcf4c9b 100644 GIT binary patch literal 7679 zcmds+&2JlJ5Qk@NCtj~VVmnTpZ@W+`KC5-yG;S%S@!CmT;>6fVgOp0HKt+^XB2ghq zg$OycB{v$uIY{|KkT`MU#sP8U!au+bqnX|H%&4zK4?W>S;@!+VGe76G^vG`X8ry?; zfXI{jmbcz3*FWfZ<#M@f0RTS7-`V3otlRxwy}x%f_$UDgOh6Xk+flHra{%xF_Ks?+yWXnLeZSe> zab0&2?0#>1#Yx(I&s(v4M9#_hh)7~8=v;~2>V_+AY<9O?*InYV!%iOVKqMIMN<_t< zt`Ru)8AL=NDgmO7TP&IoPQ=8B3C5yiRE>=ffRDw5$K4Okz zViW}9s$>|CseY4$M}1N--j)pWIZc`Nm=cU@l3_llX%k~cFy4_2^Eu6!7;}PgT{6t) zbj-w95R7*v!+cJ&CPrB>Zb*jtoaRi7mjq))GR)^RZ(^JmjJjl)&*`{{aX~OV!B{k( z(}Icds$euE!+cIBOpMnBqbV8Yb2@2ayeSx~l3_llMHAzqV5~`o`J7If7_MNfONRNJ zPMa8ug3*!;^EsU{F)j(lP028y(^(VavS7R?8Rm03XJXU@V?#2`=XBo0xGETJ!Kj+g z>4J%IO)xek!+cIlCdPHa*a{e}*hVe1kIrVt_1x8=d~~|KT*gU~=e$hyzQpKzh0%Vm z+q3q3RIrXhS++u*H=z7`L)1;&DtPxO6v~KP>lFjbzo%KjyGXO5nsvdz^6w2<-jj}3 z3;t`!T5)UmnzS0hRTb=hy}s!jl2YQY-gY-P?MxoP7w{pJp#gW{bGQc|!Ce4sB{}PK zx5qa=a}M*#SaL7`{EvYD+}fzQ709RXz7xS0CA^4k)Z8lM)3MZGU;*}2hF93N2>Fcv zH|neMC3d<&ZG<`(hgaAcmPY(eH|UH2b%s--)ERCNrOvQ4>UUOx&ZyrRPKi-xxIv6M z!_t`F87?35JHsg>D(8sGIihop_?_XDQI&I4hPQs+#moGFzvrE{iq&a}#zRyor; zXIkgXsGJ#cd<&aBFrRXMXdXIAITshl~LGpBRrbk4lWnO8aU zI%i(z99KEVRnBppb6n>vsGJ3rv!HVpbj}Htb3)~u&^ae`&PkPXQstb~IVW|_qRLrR zIg2`HQRkdeIj2<4DV=jl=bTnKr&Z2ropV~}oKZPvRL&Wlb4KT!RXJx>&RLyvR_B~k zIp1{78k{jHuCJKhJcv0FJ^kDq*!8+WpM?cb|^m*#H#uzP>y zr+0q)_;}xmd5zu0<9)~W8oSj4yg&{f6VyzaY*HCzwlPS(QC&}&-vT@y8O$Zy`?YP-xdFAPyg(-PZKAf!dWhA zS@;9Uvxc8xDWL)FGtZ}N?u%14_XR4O`=XTX#`hhs^&iUCYp(g?HdJ5Kwvsc~0S{Vm z7s}v1x4gM19VBuVzPO>UMeyYbFQS-lsB7TY1uBPKq5oKT;HflpIqVFj2IY-vsWU>I zO5UiHI!WGW8>&Tl;|);WxRm6LN~x3Nji;cz@dhYwTuSoB%agqE6qGmK0OgHKN!~ao z$s12WdE*UG-nf+Hjh82R<0&X_yaCD^my*2k@+5CO1?7!5KzZX*k~dzSu|OG(~%d6GAtg7U^2puBM@$r~?E^2Sq8-gpC)H!dZ4JjokRL3!g1P~Nzd z#v7o#aVg0gFHiEuQ&8S`1C%!|C3)lJN#1x0${TNh^2VhkZ@fIo8&5%b;|);WxRm6L zmnV7SDJXBe0m>VflDzTqByTvSknMZ*6*$Y_7j^iNv~P3kap!)ha{ynH)IBZ&r11MU zd}IfMfAEuZ02o|+Tm&l>^{)U11G;-174Y~C(L)bZ!vQ|R^5B8@|Chqpj&++op+Fve zH;Lb9Rvq`5*N6TGgTbJL{|oWR;&c3}vmU>F5x-1bYc~4+mrDLOsTKV6Yp2ynuQgFc zk?(&}7`0yWTMwJv<{G2`?1U5B`zDE(UbENSC>Q4Y&0E`v1H8C%nmu`V$H9-E9(8uR Tb?0#JXd0jR!+hoS0#*ALFGd+# literal 7679 zcmeI1%WoT16o-!=vB%>_Y{#)<$Btbn70+sHH%(gFQhV$;E^%T!NrU7{u0TbUY$8!1 zN`(knw2&Q*#D-0fBJpQ{#EKm|7KkMq{sDFjy7NfSPd!^U$g{BL-nr+y_p^`XGj}>x zXWOn21%GUBnd?@q{qE4L)oQf>5vgez3yGpCg#Y>l=Q;m7%5KIL{bu&XDtTPGVeO43jY$a-QZS z#>$#Xhepd-Rn< zQH?ruk3OOM^gi7qQlU<{F&u5rZG5aBWaHtuZBx(c8|0n`dRD(q*@WuXgFUO?@Ef6? z)o)TZ8BW-CfK*KVtfitFlufzUoVez*riwJYu|X%Yan@3i{?MQsX?T%Aaw7d%LQbT= zf{+vG4-L7IbuTjHM*6daok)KLVJFfb8g?W7#fRNUf0h~WoB_`n^qg@c{aGU583E4- zdPdMQ3Z7B$jG|{0JvH#uz*9p{4LxJv83WH4ddARG2TvV5b@bHHGY+0{@QkBp96b}@ znE=lOdM3~_37$#tOrmEJJyYPB0?!nBrqFX1JZHgk7CmRtGYy_;@Jyp;8a*@MnE}rX zdS=iw3!Yi<%%W!&J?Fr44m{`3a}GUo;F$x@9D3%^a~?eB!E+ux=g~6{o_X-hqh}sH z3*cD*&jNZD&~pJi7r=7?Jr~fk2%bgoETU%-JxkzO0?!h9me6w%JQu-p5j_{tvkabP z@GPTe89giDSpm-qdREYL2|Sm;a|u0{(6b7jRq(8$XVv!{ANIrQPtCn)Q-92+v39mA zFdSK#lpc3BAYOF-$lcuq?8`+a*2oHYD6dWcR6qmNc>(42ouO{2Re5DCpwun_U)DGA!*=L+bIuAk(e9{c0m?zFnNuLi6B)4lIgZoitOe!7=?W74q(;gfUj zYJOe$qup#B8_d zG^HNYsV!-@np=q3u$N3Iy+penbf*omft{!!^ zqjxT6vyAf8kXgU0b{T+Hl$6X{)`rgV<%10z=Ca3uqoJaB_a{2O4ZbtNR29` zQ6}qobnhIF2>m>a>y#x8HFbXN|1!UZ+Jm zR+VDL=xE7xoSGD~LpoR&gJB)KA_h$zTor>eI(StKMs#pZ3`R#s*WI07U^(b*IZn0e zTUujxFw7L~!t)rZM-!to(T@=_j0;5cghof}8~g5t27lJ>?KzH9BWpa|ZP;;Z?79s@ zBQkbMBSNtSKeJ)p9Rv@zyFJ)(9B1|QwA0MjliL*XCwDl)-vdObY2QGE7^3PUnrapP zRw2R;Neq)QYMkNk=s8AMVni6D&Kds3pJSL3!(xmpoZ;8UImV2{uo+{OGyF0-$B0Ob z1Y=y~48PjWF`^P9#TaXxv91g29K(_rX~tORjB6qzCNZ*%ag8ym{>yQ09k#^CF~)Vy z5X%%_lAzS{jPWsN$aR{K*0I1CH#kGC)1<^GGR95Lkn1!hF-nYai!xlXeZ<04};IYX|~If-$JFkj1FhWby}1d zR~X|CXUKKBBr&cs#;2Si*J(*&tTRTJGvqp5mKfI=qsJI^xlUIk#tp{U<_x(`%M#-j zW9;~hj@g|a?fTn&$8|QQhmZbXm`T}j@0|0tH(noNurC)G4+leIq*4BI0A*N!x+tJ@ z-xPI6t;&CU0HqEid|B@ZEZv7J|1CmR7+IGDmhPLfZvWhOJN~XIR>N6W&!p4xTXl8j zYj2V@ZZ@~4&vCdr$dv6;pIqwD1FDci6>8A~`j#Hj7xaKgLA+yHf3Q2({l-4b#?AO- zLTYbF-y2=WsZutf`t6WSu;^W-yECWd!sWXGcn>sU? zWd=NFz;gyYXLM#TO9VV4;2A;B2zo}rGYXzj^o*jX1)dgoTIgw^XAC@J;2A^D7<$^^ zX@jSYo;G^M!7~n?arBI%X97GE;F&3OrNbnL^JLdd`C9EO^eM z=PY`r!7~k>Y4l8^X9heo;F&?s40>k4GYg(s^vt5?9C*%w=Nx*@p=S;}bKsdn&m4Nr zgXcVW&ZFl%dgj4151x7S%%f)kJPY7iK+ghtE`a9(crKvl0(vfj=OTD6qUR!d7QwR! zo<;O5qURELE`jF~dM=@72|P>SSwhbedM<OVX9HKqI2B-OKn+(+ZquxFlL(5v}#?T^2Q ztKap0D*V%1{N3%H#!kMbvrO19)DMl0dgh=#WJe&^`_QF6kJWAGjpyU-!DKQitG!@X zTHUMfX3glm%jz5BX1g`!-{q?6D7DvVB{$nGICh4O_jKxEd(hsb1d$c9&C#>CYP#)V tyIaXEkK1>5V~3v(BV4nB)2Tl8MbhM~$^kn)#==w*s{{hx=B0T^A literal 5398 zcmZvgO>Y}j6o${(6MH=V$k=i0#BpL5O2ub2wwop`ZNVNpj!T>vPtqW{k}IJiN;Z|K zkV=J=X3;`+G!p9|RpM_Tv0}%L1#33^0d^Q&-6yiN?#FrVeP+&Ru5a6K?-u5X zA}6gKZ_}@~J{x$|YPD(*k-ApD&eI*^?$~dQM@J>kbzN(`*=whp-k|5Y?iyL+y(-?^ z8XA$cGa3;|ECi8F^Ug55xm(-A9oKbNUk!T}`D$>RBEjG;M+DCR5o*}i5D|u`1&EfK zMewK)VMio}$ryFc2%hLUMpR^Ve zlNc$+xXKwpww+_dB}RrZ);MEbC)PQJB{3YvSm%suA|oL&a*T0}F>1lfac&;A#K<$o zbWnv&+Rz!*0;L(bE*#3(VwP0o<>G$S#}jB$%IPU<#V|>gRa-L=-#v6>$L!?X=K>d)RE!jO&uAIG6SA7;5mbyGdeOHB?g``@Qk5n z3_auE83)feddAVy0#6G(E%da|GXb6n@Jyg*0zGZ;w87IxPa8dx;F$!^Bzh*%GXW0 zSp?4_dKS@h0X!GLa{)aU&~p(y7r}E8Jr~il1fC`EETLx!J(s|92|Sn3a|u1m;8_OG zGJ2NLa~V9B!E+fsm(g~K)cp14pI;mw*rwOsuOA=Sme<~IJX8h6 zQ5Ow`dZJEtMV(Kb7bg#l?-X#_yLMW5aT4~^)sAX>s5-0qmj^#*biEp+_VOVA!MN@B z&C?5dHh--B{q${V@)kQ_j>Jgx6_84jvDXi(8JEK)1?%V zm9Wjx)1)eT9lx_x%`cBTcXksGRpH*LbMoY#t=4=# zNXH2&xH!0UoF!@_nJF=hK7cct8UTkcysycvc-CSz4zub-eR1o%pb7x`Jy2ks+f1^alwVEMf1f#zw7f`YHob!A92q2)g;Rqp%8sd z?PZ(QALU7-;?FNBMf5mJnpRi)T8#8D=lpv9gLQr*^!#A$&@?k%f8Cah)v{sW2iiK7 zI?VM}*Qqp2W!;cUja{XBU+$`V!>(8ga}{sMrN%H<@1|U7%vHJ}mm0guHCTFLbnUeI z{9Sn_BL(hr`5grAkc@CJIJ`Q?VCt7!tm%=U5uH$*IJL>46Z(qo(1GsZBx5>PJsH)dN>Rmq3t*?HBKHIpiO9GUDuk0X<% zx{6FTudA9#l?*sD;LM;iqau?kS#V~-nMG$7ojGvkz?nm5PDLh81Dpmp4Rjjl%!4xz z&OAEv=w#qz;AH4z=q!M<0L}tB3+Ob#X@b*4r-@DroEA7ObXw>vg0l$DB07ucEP=BG z&JsFH=(NFUgVRQ*jm|PS%it`dvy9FPI4j_+ptFL`Dmbg)tfI4u&Kfvt;H;suhRzLe zZh&(Gog3)f1m`9=H_^F?&N?{j;H;ywj?OJ`Zh>`1IJeQc zjm{l#?tpU#ojd4kg0l(ECOVtw+y&<@ICs&xi_Sf8?tya;oqOnPfwKk97CKvrvu1{3 z(5FjzU3so#XkNmYq( zx)-O+5YDW3COa~ZZ1iNRhw{Z*^1ZU3EbnXI$b|9g&T8|?GFhjFZ8>=+7t8U>)1QiJ zTo&nEp4Q$DonWG`-cY-FcI&slgZ-~3Kh*!3G=3G6Ret$7U6#|DCSNpPOmyE3u3d6O qe212o=N{v)ozHW59#Itio1Dw~vE}arvh9!MooGL-`(WCO*XzTlIYkSPTt|@s6&YX(W1>9IKF^Z&x=9?fm!FKC zP!<{5o@-gX0mYHVWbBX(D~r;jJY|(45eJ=({qcl!qU8&r&c7~k*B%Gsy>4SO9N#%C zo^t2z(!6+ZS7bB+llG7B^%uZ{M?Q%a*lhz8I-@eCw8++uQdKEX&%KlcJ!7 zwmnqjUe-nPVUZLn|MY?~M33^MC{4Mq#mt&)u+(;Z~vNGmClm65&cF4s(}sBvVv12v9Jm#Q){-MlJmrd4v_%z-n9&YX-) ztK`9%2WK9gd2|-QSpa7Nodp@0IyG==;MCBmp|c3iA~=iaETU6@Q-D*TQ=qd1&Js9F z=q#aA2d55B9i2Kl4R9LZG|*|FvkcBMILqiPqq73e3OFn1tf12brwL9IohCY~;H-kP ziq0xJYv8Pbvxd$ZI_u!9gR_p#IyxKRY=E6?Cqka}}Jc;9N!LDmt6s zY=X0i&L%q7z_|v_HFU0_vjxr;I9up!p>rLa>)>2R=Q=t!z_|g=4RmgxvklHRINRuK zqjM9So8a6;=O#M0z_|s^Ep%?7vjff!I6LU?+l}ysQ2VyAm19RlXsY9K&3Ln{s6_ zSLKFWaxBT!&_jDPq)R@FXYwfabK-+<4a)EkQN%ChniG%T&aAh*UAXw9S{LSg`sd)kPJ8G3+2_M2 z@BIGp`H4_%XVyPI5t{AH2B+NNJlq&?st5cM9eyv(#~1gMuQ*}6y0=_?e37n`!zNFj z@?svpJo%w4$GJ%F@}%)*=mb-B`I_9#(_6p(9c+I&{jT}XwDpTUT^27srORqoQTRpk w#Z>jj0sPOV diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index 9282ea0fb2..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,7 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/aarch64/virt/DSDT", -"tests/data/acpi/aarch64/virt/DSDT.memhp", -"tests/data/acpi/aarch64/virt/DSDT.topology", -"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt", -"tests/data/acpi/aarch64/virt/DSDT.pxb", -"tests/data/acpi/x86/microvm/DSDT.pcie", From patchwork Mon Jul 22 00:18: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: 13738169 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 5D2BFC3DA5D for ; Mon, 22 Jul 2024 00:24:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmv-0003Kv-6p; Sun, 21 Jul 2024 20:20:25 -0400 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 1sVglc-0003Pn-MQ for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:08 -0400 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 1sVglW-0005yj-Q1 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607538; 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=23tk34UMbS5KN8DzcPjFZwgbF2YmEX25+n6MkYYLPTM=; b=hBi9AZENJAMcmdPuLzbiiVd6vBvOSOuofQAaYd76HI2SvMWoOE0Z6K+33pfBqRulc4QQb5 jDnlY0PSNQJdv/UHh0FMwggfu8/7bucgM7YHP2Uhzlze6yW651PskTLmm5anJj7MnDBCWf gT8Fk/J005XDXG/38RnjIj+EB1b/Nog= 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-398-LwRAtUqlPtKCY-XgeeIgZw-1; Sun, 21 Jul 2024 20:18:53 -0400 X-MC-Unique: LwRAtUqlPtKCY-XgeeIgZw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4279837c024so26479955e9.2 for ; Sun, 21 Jul 2024 17:18:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607532; x=1722212332; 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=23tk34UMbS5KN8DzcPjFZwgbF2YmEX25+n6MkYYLPTM=; b=EJmlANi/QB2oo0tpo5qONUL73eVmuwTXT6Km8w6yLH0KYxUDzUWzBo67hYPj3beocz FfMR9ekQuzswkNik+x722R3hC8DCSsiTjIr70XLWsbKfSASDbWp7FvZ7PPED6tNiu/WL tSbemnKAZC1RrPwtzi9EuBlnEiFQNvqLGATp2EVEiggsbzObrYyAsx27vIUSv+dFs8S4 grkLgy/M/5WwtSfGwTs7NF5362Cso93pLV7ETzhpF+EmHO82GTxygdiYa0s9HiOyiTDh lCh6MJuCYBZwC3tDyS7ZIRZc8GCh+5nZDkQWNfxZgQySZ2+4V0MjpcILxjHWwDCNib0q DTog== X-Gm-Message-State: AOJu0Yy5mF7EvWcQz0SH9R18wkGBwQxppU8urPmmWQZnc4ncJWDhUxLO 4nahUbqQIJRDL32LSc7M22/u2Lwkn2HrANx+Prd9ykvxQfmXsmBl6CrxpJrq9eSTGPHQsNbuIPg 8h3Zz6TIyFwj+HZqz54W3rktalLTTnymaK6W1Tg9sRWh0VLsvkx6QCGi6FUxwpwCfh1J3Uo1gE5 Z72trJO0qVMmpJIJl5GvtO5yCVj8Ib6Q== X-Received: by 2002:a05:600c:4589:b0:426:602d:a246 with SMTP id 5b1f17b1804b1-427dc59e752mr39667785e9.32.1721607532178; Sun, 21 Jul 2024 17:18:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKDuDlo79LxifLkTRki1rRKQt1Y8nLJhLUbuYMWhv2a7QyUSI2zWK/nIhXjtq/CJhYUAh2yQ== X-Received: by 2002:a05:600c:4589:b0:426:602d:a246 with SMTP id 5b1f17b1804b1-427dc59e752mr39667645e9.32.1721607531571; Sun, 21 Jul 2024 17:18:51 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a3c159sm134925665e9.8.2024.07.21.17.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:51 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:49 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Igor Mammedov , Alistair Francis , Ani Sinha Subject: [PULL 56/63] tests/qtest/bios-tables-test.c: Remove the fall back path Message-ID: <1ad2fe8d4792da37fefe6791050efc46016f9645.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Sunil V L The expected ACPI AML files are moved now under ${arch}/{machine} path. Hence, there is no need to search in old path which didn't have ${arch}. Remove the code which searches for the expected AML files under old path as well. Suggested-by: Igor Mammedov Signed-off-by: Sunil V L Acked-by: Alistair Francis Reviewed-by: Igor Mammedov Message-Id: <20240716144306.2432257-7-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index f4c4704bab..498e0e35d9 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -267,15 +267,6 @@ static void dump_aml_files(test_data *data, bool rebuild) data->arch, data->machine, sdt->aml, ext); - /* - * To keep test cases not failing before the DATA files are moved to - * ${arch}/${machine} folder, add this check as well. - */ - if (!g_file_test(aml_file, G_FILE_TEST_EXISTS)) { - aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, - data->machine, sdt->aml, ext); - } - if (!g_file_test(aml_file, G_FILE_TEST_EXISTS) && sdt->aml_len == exp_sdt->aml_len && !memcmp(sdt->aml, exp_sdt->aml, sdt->aml_len)) { @@ -412,11 +403,6 @@ static GArray *load_expected_aml(test_data *data) try_again: aml_file = g_strdup_printf("%s/%s/%s/%.4s%s", data_dir, data->arch, data->machine, sdt->aml, ext); - if (!g_file_test(aml_file, G_FILE_TEST_EXISTS)) { - aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine, - sdt->aml, ext); - } - if (verbosity_level >= 2) { fprintf(stderr, "Looking for expected file '%s'\n", aml_file); } From patchwork Mon Jul 22 00:18: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: 13738186 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 34F4FC3DA63 for ; Mon, 22 Jul 2024 00:28:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmW-0000fW-Sy; Sun, 21 Jul 2024 20:20:00 -0400 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 1sVglc-0003Pj-MG for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:07 -0400 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 1sVglW-0005yS-3M for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:18:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607537; 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=dzt8G/PRNnMChFMEQ4aarEs6+i24lgZhcl5D6q7vGuM=; b=B//3CDP8iUE9kLts7+p5UfQghhNDJuqXAZeNMs5TO5f+67C5VX6ylsgSwH9Q7ahW+X+kD6 HmBaGXUb0ZaL6uBQOBTWhbM4YGa4PhJ9nyTX09vXuuTlgrWCYQ1rIsT9YJm4dDexPX/EQ3 gh8uLmXfxCd3GNJdmLBvHhNpiDg0OyI= 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-218-sGhs1ftxM9yN6lJMEDkz8Q-1; Sun, 21 Jul 2024 20:18:55 -0400 X-MC-Unique: sGhs1ftxM9yN6lJMEDkz8Q-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-427b7a2052bso37783415e9.2 for ; Sun, 21 Jul 2024 17:18:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607534; x=1722212334; 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=dzt8G/PRNnMChFMEQ4aarEs6+i24lgZhcl5D6q7vGuM=; b=mGC1qpTK/SQHSwoVRrBNO6VyXiVGhpMdfRCQ5IzPV3PBuQRRgoOZiRIMAptW7JZ0TU 8Q7kuS7ymDtCvzhbJZOKW3WFegc7K6WR9I5eO0lGXFEawLCY55wFJ7BUwKCJHnoXIHTD +BpS43vgp4Pg82kNG8MDqJsOEaEZSJKFWppgS4KOLw0kG6qEHyRZ5+OWDUCU0yPOX81M 648or4HukpkPJx5P15msdaxO47Hz1A2PYq0jnqradx/QkNvhn+qQNMhJMegekP8LrXwd htj0qZ+4qr0klq1mYMVu+zCgoe+6P9ZuS160xbOnU1R3AiO+4zuIfgkWO72P48gFQn9e M72Q== X-Gm-Message-State: AOJu0YzdXNV3iZ8raqgA+OCq9uBHrYuvBo9ACjnp8ccBSJ7zxkhlYGmE 8Q+dg6W6NC2nxesUZm3vHyFfYobdZo7ax3YoAfovx9VoIFer4levHlrGiQTl8BRcf7CmITStfzs pDWTwqoLOzmABJmnx/K2K5IzpF6DmI4aQZwYn5jashv9nqdp7sJd0FY/nSifJ937t+lpL0c3sm+ OSl0Kwbd4xA+fwADrTW7W0pWPhAMD1Jg== X-Received: by 2002:a05:600c:4f47:b0:426:61fc:fc1a with SMTP id 5b1f17b1804b1-427dc515d17mr39079015e9.3.1721607534331; Sun, 21 Jul 2024 17:18:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8YZfFWpbcRoIDZgme7S2NZqWIXHvsojUm7n30zBxqgzXwin+UhnslKPiLHokD4BBbvolMag== X-Received: by 2002:a05:600c:4f47:b0:426:61fc:fc1a with SMTP id 5b1f17b1804b1-427dc515d17mr39078835e9.3.1721607533662; Sun, 21 Jul 2024 17:18:53 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2927e21sm83115235e9.0.2024.07.21.17.18.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:53 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Alistair Francis , Igor Mammedov , Ani Sinha Subject: [PULL 57/63] tests/acpi: Add empty ACPI data files for RISC-V 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Sunil V L As per process documented (steps 1-3) in bios-tables-test.c, add empty AML data files for RISC-V ACPI tables and add the entries in bios-tables-test-allowed-diff.h. Signed-off-by: Sunil V L Acked-by: Alistair Francis Reviewed-by: Igor Mammedov Message-Id: <20240716144306.2432257-8-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 6 ++++++ tests/data/acpi/riscv64/virt/APIC | 0 tests/data/acpi/riscv64/virt/DSDT | 0 tests/data/acpi/riscv64/virt/FACP | 0 tests/data/acpi/riscv64/virt/MCFG | 0 tests/data/acpi/riscv64/virt/RHCT | 0 tests/data/acpi/riscv64/virt/SPCR | 0 7 files changed, 6 insertions(+) create mode 100644 tests/data/acpi/riscv64/virt/APIC create mode 100644 tests/data/acpi/riscv64/virt/DSDT create mode 100644 tests/data/acpi/riscv64/virt/FACP create mode 100644 tests/data/acpi/riscv64/virt/MCFG create mode 100644 tests/data/acpi/riscv64/virt/RHCT create mode 100644 tests/data/acpi/riscv64/virt/SPCR diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index dfb8523c8b..70474a097f 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,7 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/riscv64/virt/APIC", +"tests/data/acpi/riscv64/virt/DSDT", +"tests/data/acpi/riscv64/virt/FACP", +"tests/data/acpi/riscv64/virt/MCFG", +"tests/data/acpi/riscv64/virt/RHCT", +"tests/data/acpi/riscv64/virt/SPCR", diff --git a/tests/data/acpi/riscv64/virt/APIC b/tests/data/acpi/riscv64/virt/APIC new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/riscv64/virt/DSDT b/tests/data/acpi/riscv64/virt/DSDT new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/riscv64/virt/FACP b/tests/data/acpi/riscv64/virt/FACP new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/riscv64/virt/MCFG b/tests/data/acpi/riscv64/virt/MCFG new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/riscv64/virt/RHCT b/tests/data/acpi/riscv64/virt/RHCT new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/riscv64/virt/SPCR b/tests/data/acpi/riscv64/virt/SPCR new file mode 100644 index 0000000000..e69de29bb2 From patchwork Mon Jul 22 00:18: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: 13738185 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 7DB3AC3DA5D for ; Mon, 22 Jul 2024 00:28:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmR-0007yX-Sd; Sun, 21 Jul 2024 20:19:55 -0400 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 1sVglf-0003ak-55 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:12 -0400 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 1sVglc-0005z8-Fl for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607542; 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=gfiaAZu1KXFxLDbrHFmgg4NXXcuygsvbvDqpALcUfu8=; b=QSCgA/4jUP4TnVSAY4LBUGYy89Mk3c1c6DDza0mU/DgNnyIJxnvz5yK9V5Ryrt4MD5PTeZ BLN59U25wrY+Fl546szTBYmXGaSMI/LuoQ2KfF32WEY4R0X19V8GF6J8Svpgc3kTAcOqvD +PIh2Zv8Up7MCRylFL2mrtC7Uj9HTCE= 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-33-rFGAARffOkWBiAGMMCeQ1g-1; Sun, 21 Jul 2024 20:18:57 -0400 X-MC-Unique: rFGAARffOkWBiAGMMCeQ1g-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-427d92bec90so19344575e9.1 for ; Sun, 21 Jul 2024 17:18:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607536; x=1722212336; 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=gfiaAZu1KXFxLDbrHFmgg4NXXcuygsvbvDqpALcUfu8=; b=REk52AIAdJMXHVhWze92RDjWVhRs8rLXKBWgSVcLpu6YGgWEKZTU1AZjJoCgInTc/y zsKwQgO0qrgvPujN1RU2/dQeiDQvsckevcx6RRbUmE2YRpFljxiwIe6pusSoYP9/hvgU O3pt5ooi5gvKRgiO+Gb0mNkv+ygjZGUSUjw62xeDGroO2OeFh0pilPsP2DHAlyIrUBg6 fiAx2f2S0n+k30I5Bntn8coKee+/wmncUZZyIB88FKJaEtDG4cKzF5VXpNLShThk9MqC CDjwmSY58YQBopoeofTXdNEV9GZ5CTn0gOBDvodCYOjuEGTbpVmzmrvKhmWw5sjP9fdV Vs1A== X-Gm-Message-State: AOJu0YyYwpJyfKze7yAq5KOOoMDOhj10C+tcDsmeLw4PP3uxSgHAszhU 4OLOgd4gyL+KBfxqMyQKdhG5peDnsK9C+O6TPmqu4ebYKhnHkl7jDoUlY7sd8N3CXnU/GmOXl1L IZzTghXch1fUsaztQNII2JG6iRg/9aMSAj75pgd0nnTagzqCatZY4RMi8zHwKsHjOw77+JxINdS x5Gg7uro7zT7f3/H+cMAl5Hv9m/vvUSg== X-Received: by 2002:a05:600c:1914:b0:426:629f:154e with SMTP id 5b1f17b1804b1-427daa60cf1mr33516255e9.30.1721607536327; Sun, 21 Jul 2024 17:18:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMl2knGwqTLEFt9fOxumTjkU6ednkgB2W3F/vBNtIj9wtsttrx7XOVbxPHeJZWdQAITxFpxQ== X-Received: by 2002:a05:600c:1914:b0:426:629f:154e with SMTP id 5b1f17b1804b1-427daa60cf1mr33516135e9.30.1721607535805; Sun, 21 Jul 2024 17:18:55 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a9466bsm133707985e9.41.2024.07.21.17.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:55 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:53 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Alistair Francis , Igor Mammedov , Ani Sinha Subject: [PULL 58/63] tests/qtest/bios-tables-test.c: Enable basic testing for RISC-V Message-ID: <1056008c0bd9dde86f159d7259138d641408e7a4.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Sunil V L Add basic ACPI table test case for RISC-V. Signed-off-by: Sunil V L Reviewed-by: Alistair Francis Reviewed-by: Igor Mammedov Message-Id: <20240716144306.2432257-9-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index 498e0e35d9..36e5c0adde 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -1963,6 +1963,28 @@ static void test_acpi_microvm_acpi_erst(void) } #endif /* CONFIG_POSIX */ +static void test_acpi_riscv64_virt_tcg(void) +{ + test_data data = { + .machine = "virt", + .arch = "riscv64", + .tcg_only = true, + .uefi_fl1 = "pc-bios/edk2-riscv-code.fd", + .uefi_fl2 = "pc-bios/edk2-riscv-vars.fd", + .cd = "tests/data/uefi-boot-images/bios-tables-test.riscv64.iso.qcow2", + .ram_start = 0x80000000ULL, + .scan_len = 128ULL * 1024 * 1024, + }; + + /* + * RHCT will have ISA string encoded. To reduce the effort + * of updating expected AML file for any new default ISA extension, + * use the profile rva22s64. + */ + test_acpi_one("-cpu rva22s64 ", &data); + free_test_data(&data); +} + static void test_acpi_aarch64_virt_tcg(void) { test_data data = { @@ -2441,6 +2463,10 @@ int main(int argc, char *argv[]) qtest_add_func("acpi/virt/viot", test_acpi_aarch64_virt_viot); } } + } else if (strcmp(arch, "riscv64") == 0) { + if (has_tcg && qtest_has_device("virtio-blk-pci")) { + qtest_add_func("acpi/virt", test_acpi_riscv64_virt_tcg); + } } ret = g_test_run(); boot_sector_cleanup(disk); From patchwork Mon Jul 22 00:18:55 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: 13738183 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 AA47CC3DA61 for ; Mon, 22 Jul 2024 00:28:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmW-0000aX-JC; Sun, 21 Jul 2024 20:20:00 -0400 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 1sVgle-0003VX-8U for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:08 -0400 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 1sVglc-0005z1-Fu for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607542; 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=MeXmlkXUO1c12DbabmZ2BwxdEJDDqafMQQCrC5Sf5B0=; b=LxIodMakSr3W+4vcYDMODrdyrUEMHtSUmeiteCv9pVSz9ZUZgA1EBSNuIOGl4Uuk3QmmL8 31VldqHq27k9Imf6XemxthNpWo8wt8BxjoHK2EprblFESOehS0DsBB3eJ2wyV9gCipfrz/ z7Vih9p1swQqu3qget2vss7+xdxfLcM= 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-74-mI3AK4OmOByK3xvdwfHEaw-1; Sun, 21 Jul 2024 20:19:00 -0400 X-MC-Unique: mI3AK4OmOByK3xvdwfHEaw-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-369bf135b49so665407f8f.0 for ; Sun, 21 Jul 2024 17:19:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607539; x=1722212339; 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=MeXmlkXUO1c12DbabmZ2BwxdEJDDqafMQQCrC5Sf5B0=; b=s0xvFkdI6RnH/yrC9pynPWsCdLf/l625pWulRlpAz4BaQW5tLyEtR5CYf0+cffIfvx vINrj34yuq831CULaqsCDOUS6bfTjRsS8lfypY5JNmhVp7yIWx+2z+EWUEBgudoEdmRj BdPOMWP7ZePXS0xYQT8JL6Fwut0IyWSEiwYTJOHbQdfGKLfpBnSoaRQnhDNZ0hzlayQ5 NQa0HS4qMOQbI7FsL10hqczd3hFrIR2JHh3gC437jPTJgdc7xEUislXPVKlCG33dRwAD /XjOlS5IyK3hdC1Uzo4n/eFG+/ppr4gI2MX1ARjXr/d+rPd8/APdkCsC/Tz9hi4qtovj kCCw== X-Gm-Message-State: AOJu0YxCOjknUwajaEsnSySPAdcI/t3Ocd5eUhTjQu1TPKXHNgCTFQj0 qL5ZEV1na5d8MsR4hMCj6kHBBj4A1W5RHafd1+ucONxuOcBglwmzU0ENPnGmLgGpEV7mKV9iak3 aW6VzH9M1O4SOKanKIua3j1X6cWh9Dx/uSYcGIE775W3eMOhOJTzfq2P2CaEgVOUhzSDOIRF1pL m+nGjD59i9dIWt1nhwUyyNP57mdQAEIw== X-Received: by 2002:a5d:6e06:0:b0:366:dee6:a9ea with SMTP id ffacd0b85a97d-368740244d5mr5158849f8f.26.1721607538727; Sun, 21 Jul 2024 17:18:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFK4RM+QFGyLG5C1KGTK/gxitW6L130y3xBcxwJs2s7cA7UZeBkcqghNyypqVCn4UqfRX+4XQ== X-Received: by 2002:a5d:6e06:0:b0:366:dee6:a9ea with SMTP id ffacd0b85a97d-368740244d5mr5158834f8f.26.1721607537941; Sun, 21 Jul 2024 17:18:57 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868480csm7009779f8f.13.2024.07.21.17.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:57 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:55 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Alistair Francis , Igor Mammedov , Ani Sinha Subject: [PULL 59/63] tests/acpi: Add expected ACPI AML files for RISC-V 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Sunil V L As per the step 5 in the process documented in bios-tables-test.c, generate the expected ACPI AML data files for RISC-V using the rebuild-expected-aml.sh script and update the bios-tables-test-allowed-diff.h. These are all new files being added for the first time. Hence, iASL diff output is not added. Signed-off-by: Sunil V L Acked-by: Alistair Francis Acked-by: Igor Mammedov Message-Id: <20240716144306.2432257-10-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 6 ------ tests/data/acpi/riscv64/virt/APIC | Bin 0 -> 116 bytes tests/data/acpi/riscv64/virt/DSDT | Bin 0 -> 3576 bytes tests/data/acpi/riscv64/virt/FACP | Bin 0 -> 276 bytes tests/data/acpi/riscv64/virt/MCFG | Bin 0 -> 60 bytes tests/data/acpi/riscv64/virt/RHCT | Bin 0 -> 332 bytes tests/data/acpi/riscv64/virt/SPCR | Bin 0 -> 80 bytes 7 files changed, 6 deletions(-) diff --git a/tests/data/acpi/riscv64/virt/APIC b/tests/data/acpi/riscv64/virt/APIC index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..66a25dfd2d6ea2b607c024722b2eab95873a01e9 100644 GIT binary patch literal 116 zcmZ<^@N_O=U|?X|;^gn_5v<@85#X$#prF9Wz`y`vgJ>9#P+??1=7Rt_Us?qr5)aeJ KkN{%wz_^&7o{G8V!Yr_%nYu-r@Aht-D9> ze|U7~@ID!|wMmncj(TGhPPe}|+808sKOJ=D42L$oFMnuWGzNPSO@FO0f*0wzh(;tL z5kz!(7Ol7lJrS27A{ohOMmshm8JDpY$xx#iuf%4kaT&u%##}UGJvL)5F5_k-BNfef zH8vv^mvJ1)NJld^Vl&cl84n^ET9DCG`?Ke1xHlA1?96VC;m9uJ^{jUnHoX4+osDhf zlw*%$=3h8}dIZef~33G`L+)@bZKg$-WS6D&|zfbrs^8=In~A zT2##YKlAF^PcOMr1bq`;WovfDm0{O}Unzph1bLO=C`qp}oI%p747(=%%4SfR^ee+r zRIf6ef$CL;T~)s_oV@B+hNH}Za}Jzy=$!K_!%8@4o)4NIy$r9%z`tE&MZ0&a2nt=&}pDE2hJQgbLh;WGY`%@ zIP>VtqjMgd^WdCE=R7)1aGKyW(P^Ty0L}t93+ODMvk1;2IE&~kqO%0f5;#lfETOXu z&N4X5=q#gi0h|lqTtMdnIv2sY2+l=xE~2vn&I&jy=&Yc#3eGAxtLUtva|xVF;9NrI z5;~W`xeU%_bS|TF1)MA3TtVjwI&0vpfwP9r8ah|OxeCrzbgrUv4V-J>Ttnv?I_u!9 zgR_p#dgv@0j_h{m!XP5y?^brx`n@l5l;9>Jmru&W3Xu`M5^TAy`&sa=u=TJ)ioqLB z?{K~Dlq6E<^yNs6ckrIlbzT0)0EfTV)a>iSA!%|v>Qi|q9eFe`s^mCw$WDd_FfHpWRkI z9##Gs zEd3$}=b5v2=%SER6h6`9WT1|=?a1~=daq3U;?mZ|bL%5`QC!!39TtaQZM==v|D}}K A9{>OV literal 0 HcmV?d00001 diff --git a/tests/data/acpi/riscv64/virt/FACP b/tests/data/acpi/riscv64/virt/FACP index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a5276b65ea8ce46cc9b40d96d98f0669c9089ed4 100644 GIT binary patch literal 276 zcmZ>BbPf<&SuVKAE}7g4Q~4C)^I7^5Cy7(c z_YX|7?Tl$5;5Aw2EhsZYq`X;YA!Uve zDUVqk>2Qc4kvb-IJ*j0I|1P;dHuz!Fg+;c5!QfI|KXypVnys literal 0 HcmV?d00001 diff --git a/tests/data/acpi/riscv64/virt/SPCR b/tests/data/acpi/riscv64/virt/SPCR index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..4da9daf65f71a13ac2b488d4e9728f194b569a43 100644 GIT binary patch literal 80 zcmWFza1IJ!U|?X{>E!S15v<@85#X$#prF9Wz`y`vgJ>{NU;r@%Kx_d9E(Qh$c8~z` M|NsC0LsftQ0Q@}*0RR91 literal 0 HcmV?d00001 diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index 70474a097f..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,7 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/riscv64/virt/APIC", -"tests/data/acpi/riscv64/virt/DSDT", -"tests/data/acpi/riscv64/virt/FACP", -"tests/data/acpi/riscv64/virt/MCFG", -"tests/data/acpi/riscv64/virt/RHCT", -"tests/data/acpi/riscv64/virt/SPCR", From patchwork Mon Jul 22 00:18:58 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: 13738163 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 C8DF7C3DA61 for ; Mon, 22 Jul 2024 00:23:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmT-0008Ls-Rt; Sun, 21 Jul 2024 20:19:57 -0400 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 1sVglf-0003aj-53 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:12 -0400 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 1sVglc-0005zF-GK for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607543; 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=sKWGQeqJTV62O0PjhVO4qR0DAdvYkDIxQ36H6bU2Erc=; b=hzlq5miZHmmtePkFYx6s5JdD9VcyshdLwZpdzxkxJMOfztrxYeSNcwlo+X8TLsFWt2u+jI sIrghdIvXuV2/0Q6sMeEPTEnp6CUn+0GP/nCtAMmYUswVX66+sdpCFIYHHXckVLotH7q3I r2PSOqYNPntM9VpYF+nFhaZGpUqRQgE= 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-246-FUkQ8cBaOGiXJ0jY13f8fg-1; Sun, 21 Jul 2024 20:19:02 -0400 X-MC-Unique: FUkQ8cBaOGiXJ0jY13f8fg-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3687eca5980so1730166f8f.0 for ; Sun, 21 Jul 2024 17:19:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607540; x=1722212340; 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=sKWGQeqJTV62O0PjhVO4qR0DAdvYkDIxQ36H6bU2Erc=; b=lMjG2gmzoX/vjezznCduLeF/lhSKZJzMoKilYOFmKkaoZumsUwywAFUzWps9LKz28k 2fXGzG5JM1mqpB/yzUk7przOUH+3qFYSam6pBuzovMjC3vBs/nGsptQNBh9Jw8T0vOjA +PllrQUCm3CZxiFbqmLjTXFhz/4qBgVv6xIyyI9bjX5AN62TZ4Dz6W4ELC8VRXKPVm6N dmyJoa6MYirGMmT6LNfLyKpFEK3GlbaRJJhQSS8l7UA3AfMmhBok355ijcwVFEB9LeQc T6xJpjbgR3ZMPwSUrlpU8RzHsrWvnfl98XHa3NKFgDrKbn5q3tfMCE6I5yhxLafGHn/E f0QQ== X-Gm-Message-State: AOJu0YzCNZsQ9yJCT6+ifJSkl36BKR4zG5Y1AwDxb+5OR0PvZHVtBnwF TDI+rCHaUBwQQWHVFP51tXA+5MrUduWDVD2QoPYluhYH9fB1W0TpBhQe0I+0ZmC2U+LzQqtkSrx ppyN5/cH3zga8ISFfl8NFAo4bwOyRzcx44h3PziHjekyuuwc6sinSwsxnhnrB6+Pxn9ouUWT3Rb 2x3Xe0RZReULg6vC7Ta19C3f8UzVD/KQ== X-Received: by 2002:a5d:4b0a:0:b0:35f:1cc9:1d1d with SMTP id ffacd0b85a97d-369bae89634mr2784119f8f.38.1721607540591; Sun, 21 Jul 2024 17:19:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCRZ4W+Hm++PaECUygA8QJPpMhESbb0eP8SqZNfF7e+5rzoq/6O92JYWKj02ORghTFvWzl8Q== X-Received: by 2002:a5d:4b0a:0:b0:35f:1cc9:1d1d with SMTP id ffacd0b85a97d-369bae89634mr2784100f8f.38.1721607540027; Sun, 21 Jul 2024 17:19:00 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787ceda0sm7008237f8f.87.2024.07.21.17.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:18:59 -0700 (PDT) Date: Sun, 21 Jul 2024 20:18:58 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alistair Francis , Alistair Francis , Jonathan Cameron , Wilfred Mallawa , Huai-Cheng Kuo , Chris Browy , Marcel Apfelbaum Subject: [PULL 60/63] hw/pci: Add all Data Object Types defined in PCIe r6.0 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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Alistair Francis Add all of the defined protocols/features from the PCIe-SIG r6.0 "Table 6-32 PCI-SIG defined Data Object Types (Vendor ID = 0001h)" table. Signed-off-by: Alistair Francis Reviewed-by: Jonathan Cameron Reviewed-by: Wilfred Mallawa Message-Id: <20240703092027.644758-2-alistair.francis@wdc.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pcie_doe.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/hw/pci/pcie_doe.h b/include/hw/pci/pcie_doe.h index 87dc17dcef..15d94661f9 100644 --- a/include/hw/pci/pcie_doe.h +++ b/include/hw/pci/pcie_doe.h @@ -46,6 +46,8 @@ REG32(PCI_DOE_CAP_STATUS, 0) /* PCI-SIG defined Data Object Types - r6.0 Table 6-32 */ #define PCI_SIG_DOE_DISCOVERY 0x00 +#define PCI_SIG_DOE_CMA 0x01 +#define PCI_SIG_DOE_SECURED_CMA 0x02 #define PCI_DOE_DW_SIZE_MAX (1 << 18) #define PCI_DOE_PROTOCOL_NUM_MAX 256 From patchwork Mon Jul 22 00:19: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: 13738156 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 8CBE9C3DA5D for ; Mon, 22 Jul 2024 00:22:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmS-0008AS-LM; Sun, 21 Jul 2024 20:19:56 -0400 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 1sVgli-0003m5-0D for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:14 -0400 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 1sVgle-000611-Eh for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607545; 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=xoblqguLfh4EB1uVC6tsmSJ2cJoOHPB82jdCECZzwFY=; b=Vc1Wc5KP+kz4Uquy33cGUjPQzplaZ/gdEZAEMxEevGrTV5M33x65PSGH0GSuxYVC+m7KTj 9xrSMyB5Xx3rOakcmWyQ7sEm/bWPMiMvQp/irBfW1wE5hF4OArpdS/mWr08y9rtOa/sy00 wdOuxkCfZWYVv2tz6TulkJaRIOuFxaY= 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-607-01EGJeJrMO6UmloePV5rkQ-1; Sun, 21 Jul 2024 20:19:04 -0400 X-MC-Unique: 01EGJeJrMO6UmloePV5rkQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-36832c7023bso1998890f8f.2 for ; Sun, 21 Jul 2024 17:19:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607543; x=1722212343; 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=xoblqguLfh4EB1uVC6tsmSJ2cJoOHPB82jdCECZzwFY=; b=UfQ+PYagetyKkTvJj+jWJ2BmZz9LcTe72vT8suktNXnbJADKsdDMSN0xO2cKdKvIpW 4a2DgLmcn5NpmewhT5t7CGnUef6W725nkxFDLRAeVa6yA+F+YdTTbmxjd6rGB9+/M5PC iGsv+HjV9I26KquiZ7g/JxkQJMp5XWLCZT4RYbT3qzHe7drLGBVLB21NefyYRssxOUdk mXoQzhh4Z6KelWpQPVkvLOrfgifSH6GfoSr0ogyoZlMdL6mab6LcldRuAXSnuZsZcNIC ejEk6qYlaB/zBajVdznkwSQpje3guF7+GYhfqoxJwnPxyfgRe37mLQ7ck94zxUh7BQHt HY0w== X-Gm-Message-State: AOJu0YwpeCrKvdexXPGOEtgZDMShzMCsO8u13970yNRDzIp3qdgHYLXP +nACFSNDN5wEJ7BK6vx0xksI3fBTVViHmy5zzn9c24Ernl18C+KfxAVtpg+cBHd2gN+3B7oTIkF V/icjDdWTGFyr6yd3ldYGrfdZk3tkUqlnCHDZ/dY7TkPirLrZEYlOPTAJr/ppHj4PbEumI2/aZt vq9vFKlWiXPq7SAcAZ014G6MCYCN8FPw== X-Received: by 2002:adf:fe8a:0:b0:368:48b2:95ec with SMTP id ffacd0b85a97d-369bae23887mr3409469f8f.1.1721607542826; Sun, 21 Jul 2024 17:19:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGnzoJ1DHoMfu5poDT9XutaBPNxillkhGLK65VisBeF6u5bvbzb5bdhWGg/gWyW8ooziszCxA== X-Received: by 2002:adf:fe8a:0:b0:368:48b2:95ec with SMTP id ffacd0b85a97d-369bae23887mr3409447f8f.1.1721607542202; Sun, 21 Jul 2024 17:19:02 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868490fsm7050853f8f.6.2024.07.21.17.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:19:01 -0700 (PDT) Date: Sun, 21 Jul 2024 20:19:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Huai-Cheng Kuo , Chris Browy , Jonathan Cameron , Wilfred Mallawa , Alistair Francis , Paolo Bonzini Subject: [PULL 61/63] backends: Initial support for SPDM socket 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.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Huai-Cheng Kuo SPDM enables authentication, attestation and key exchange to assist in providing infrastructure security enablement. It's a standard published by the DMTF [1]. SPDM supports multiple transports, including PCIe DOE and MCTP. This patch adds support to QEMU to connect to an external SPDM instance. SPDM support can be added to any QEMU device by exposing a TCP socket to a SPDM server. The server can then implement the SPDM decoding/encoding support, generally using libspdm [2]. This is similar to how the current TPM implementation works and means that the heavy lifting of setting up certificate chains, capabilities, measurements and complex crypto can be done outside QEMU by a well supported and tested library. 1: https://www.dmtf.org/standards/SPDM 2: https://github.com/DMTF/libspdm Signed-off-by: Huai-Cheng Kuo Signed-off-by: Chris Browy Co-developed-by: Jonathan Cameron Signed-off-by: Jonathan Cameron [ Changes by WM - Bug fixes from testing ] Signed-off-by: Wilfred Mallawa [ Changes by AF: - Convert to be more QEMU-ified - Move to backends as it isn't PCIe specific ] Signed-off-by: Alistair Francis Message-Id: <20240703092027.644758-3-alistair.francis@wdc.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/sysemu/spdm-socket.h | 74 ++++++++++++ backends/spdm-socket.c | 216 +++++++++++++++++++++++++++++++++++ MAINTAINERS | 6 + backends/Kconfig | 4 + backends/meson.build | 2 + 5 files changed, 302 insertions(+) create mode 100644 include/sysemu/spdm-socket.h create mode 100644 backends/spdm-socket.c diff --git a/include/sysemu/spdm-socket.h b/include/sysemu/spdm-socket.h new file mode 100644 index 0000000000..5d8bd9aa4e --- /dev/null +++ b/include/sysemu/spdm-socket.h @@ -0,0 +1,74 @@ +/* + * QEMU SPDM socket support + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef SPDM_REQUESTER_H +#define SPDM_REQUESTER_H + +/** + * spdm_socket_connect: connect to an external SPDM socket + * @port: port to connect to + * @errp: error object handle + * + * This will connect to an external SPDM socket server. On error + * it will return -1 and errp will be set. On success this function + * will return the socket number. + */ +int spdm_socket_connect(uint16_t port, Error **errp); + +/** + * spdm_socket_rsp: send and receive a message to a SPDM server + * @socket: socket returned from spdm_socket_connect() + * @transport_type: SPDM_SOCKET_TRANSPORT_TYPE_* macro + * @req: request buffer + * @req_len: request buffer length + * @rsp: response buffer + * @rsp_len: response buffer length + * + * Send platform data to a SPDM server on socket and then receive + * a response. + */ +uint32_t spdm_socket_rsp(const int socket, uint32_t transport_type, + void *req, uint32_t req_len, + void *rsp, uint32_t rsp_len); + +/** + * spdm_socket_close: send a shutdown command to the server + * @socket: socket returned from spdm_socket_connect() + * @transport_type: SPDM_SOCKET_TRANSPORT_TYPE_* macro + * + * This will issue a shutdown command to the server. + */ +void spdm_socket_close(const int socket, uint32_t transport_type); + +#define SPDM_SOCKET_COMMAND_NORMAL 0x0001 +#define SPDM_SOCKET_COMMAND_OOB_ENCAP_KEY_UPDATE 0x8001 +#define SPDM_SOCKET_COMMAND_CONTINUE 0xFFFD +#define SPDM_SOCKET_COMMAND_SHUTDOWN 0xFFFE +#define SPDM_SOCKET_COMMAND_UNKOWN 0xFFFF +#define SPDM_SOCKET_COMMAND_TEST 0xDEAD + +#define SPDM_SOCKET_TRANSPORT_TYPE_MCTP 0x01 +#define SPDM_SOCKET_TRANSPORT_TYPE_PCI_DOE 0x02 + +#define SPDM_SOCKET_MAX_MESSAGE_BUFFER_SIZE 0x1200 + +#endif diff --git a/backends/spdm-socket.c b/backends/spdm-socket.c new file mode 100644 index 0000000000..d0663d696c --- /dev/null +++ b/backends/spdm-socket.c @@ -0,0 +1,216 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * QEMU SPDM socket support + * + * This is based on: + * https://github.com/DMTF/spdm-emu/blob/07c0a838bcc1c6207c656ac75885c0603e344b6f/spdm_emu/spdm_emu_common/command.c + * but has been re-written to match QEMU style + * + * Copyright (c) 2021, DMTF. All rights reserved. + * Copyright (c) 2023. Western Digital Corporation or its affiliates. + */ + +#include "qemu/osdep.h" +#include "sysemu/spdm-socket.h" +#include "qapi/error.h" + +static bool read_bytes(const int socket, uint8_t *buffer, + size_t number_of_bytes) +{ + ssize_t number_received = 0; + ssize_t result; + + while (number_received < number_of_bytes) { + result = recv(socket, buffer + number_received, + number_of_bytes - number_received, 0); + if (result <= 0) { + return false; + } + number_received += result; + } + return true; +} + +static bool read_data32(const int socket, uint32_t *data) +{ + bool result; + + result = read_bytes(socket, (uint8_t *)data, sizeof(uint32_t)); + if (!result) { + return result; + } + *data = ntohl(*data); + return true; +} + +static bool read_multiple_bytes(const int socket, uint8_t *buffer, + uint32_t *bytes_received, + uint32_t max_buffer_length) +{ + uint32_t length; + bool result; + + result = read_data32(socket, &length); + if (!result) { + return result; + } + + if (length > max_buffer_length) { + return false; + } + + if (bytes_received) { + *bytes_received = length; + } + + if (length == 0) { + return true; + } + + return read_bytes(socket, buffer, length); +} + +static bool receive_platform_data(const int socket, + uint32_t transport_type, + uint32_t *command, + uint8_t *receive_buffer, + uint32_t *bytes_to_receive) +{ + bool result; + uint32_t response; + uint32_t bytes_received; + + result = read_data32(socket, &response); + if (!result) { + return result; + } + *command = response; + + result = read_data32(socket, &transport_type); + if (!result) { + return result; + } + + bytes_received = 0; + result = read_multiple_bytes(socket, receive_buffer, &bytes_received, + *bytes_to_receive); + if (!result) { + return result; + } + *bytes_to_receive = bytes_received; + + return result; +} + +static bool write_bytes(const int socket, const uint8_t *buffer, + uint32_t number_of_bytes) +{ + ssize_t number_sent = 0; + ssize_t result; + + while (number_sent < number_of_bytes) { + result = send(socket, buffer + number_sent, + number_of_bytes - number_sent, 0); + if (result == -1) { + return false; + } + number_sent += result; + } + return true; +} + +static bool write_data32(const int socket, uint32_t data) +{ + data = htonl(data); + return write_bytes(socket, (uint8_t *)&data, sizeof(uint32_t)); +} + +static bool write_multiple_bytes(const int socket, const uint8_t *buffer, + uint32_t bytes_to_send) +{ + bool result; + + result = write_data32(socket, bytes_to_send); + if (!result) { + return result; + } + + return write_bytes(socket, buffer, bytes_to_send); +} + +static bool send_platform_data(const int socket, + uint32_t transport_type, uint32_t command, + const uint8_t *send_buffer, size_t bytes_to_send) +{ + bool result; + + result = write_data32(socket, command); + if (!result) { + return result; + } + + result = write_data32(socket, transport_type); + if (!result) { + return result; + } + + return write_multiple_bytes(socket, send_buffer, bytes_to_send); +} + +int spdm_socket_connect(uint16_t port, Error **errp) +{ + int client_socket; + struct sockaddr_in server_addr; + + client_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (client_socket < 0) { + error_setg(errp, "cannot create socket: %s", strerror(errno)); + return -1; + } + + memset((char *)&server_addr, 0, sizeof(server_addr)); + server_addr.sin_family = AF_INET; + server_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + server_addr.sin_port = htons(port); + + + if (connect(client_socket, (struct sockaddr *)&server_addr, + sizeof(server_addr)) < 0) { + error_setg(errp, "cannot connect: %s", strerror(errno)); + close(client_socket); + return -1; + } + + return client_socket; +} + +uint32_t spdm_socket_rsp(const int socket, uint32_t transport_type, + void *req, uint32_t req_len, + void *rsp, uint32_t rsp_len) +{ + uint32_t command; + bool result; + + result = send_platform_data(socket, transport_type, + SPDM_SOCKET_COMMAND_NORMAL, + req, req_len); + if (!result) { + return 0; + } + + result = receive_platform_data(socket, transport_type, &command, + (uint8_t *)rsp, &rsp_len); + if (!result) { + return 0; + } + + assert(command != 0); + + return rsp_len; +} + +void spdm_socket_close(const int socket, uint32_t transport_type) +{ + send_platform_data(socket, transport_type, + SPDM_SOCKET_COMMAND_SHUTDOWN, NULL, 0); +} diff --git a/MAINTAINERS b/MAINTAINERS index 93546cfb14..d76b49a597 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3401,6 +3401,12 @@ F: tests/qtest/*tpm* F: docs/specs/tpm.rst T: git https://github.com/stefanberger/qemu-tpm.git tpm-next +SPDM +M: Alistair Francis +S: Maintained +F: backends/spdm-socket.c +F: include/sysemu/spdm-socket.h + Checkpatch S: Odd Fixes F: scripts/checkpatch.pl diff --git a/backends/Kconfig b/backends/Kconfig index 2cb23f62fa..d3dbe19868 100644 --- a/backends/Kconfig +++ b/backends/Kconfig @@ -3,3 +3,7 @@ source tpm/Kconfig config IOMMUFD bool depends on VFIO + +config SPDM_SOCKET + bool + default y diff --git a/backends/meson.build b/backends/meson.build index 749b491f12..da714b93d1 100644 --- a/backends/meson.build +++ b/backends/meson.build @@ -33,4 +33,6 @@ endif system_ss.add(when: gio, if_true: files('dbus-vmstate.c')) system_ss.add(when: 'CONFIG_SGX', if_true: files('hostmem-epc.c')) +system_ss.add(when: 'CONFIG_SPDM_SOCKET', if_true: files('spdm-socket.c')) + subdir('tpm') From patchwork Mon Jul 22 00:19: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: 13738190 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 567CEC3DA7F for ; Mon, 22 Jul 2024 00:28:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgms-0003Az-Pk; Sun, 21 Jul 2024 20:20:22 -0400 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 1sVgll-0003yj-59 for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:15 -0400 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 1sVglh-00061T-PO for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607548; 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=Ents0T9O23OXsCQtfncMUcPntmQHxFloICVjUgGeuy0=; b=OXWUEmDiAPkxf9RCeOgcZTVU+a83t5vNGUP2NqTG7/r6whZBbHdiePr2G5fTEUaiMi77Iq Ts1S//rVMZ9U04sJUx/kKA1EHUZmTSNoN06lwtPHFxgGfsDp5inQtEmrNmktjG1Fcwuvfk pqNuch8m8OD6lsSRnEodAyBzr2tkTb4= 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-441-GfDVXaBsMUODlCauBJ0-gQ-1; Sun, 21 Jul 2024 20:19:06 -0400 X-MC-Unique: GfDVXaBsMUODlCauBJ0-gQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-36873ed688dso2099376f8f.1 for ; Sun, 21 Jul 2024 17:19:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607545; x=1722212345; 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=Ents0T9O23OXsCQtfncMUcPntmQHxFloICVjUgGeuy0=; b=UV4rwLuZoagl0muBDZlrgg1gytjWxBiwxJtkrnc55nQVlRCLw9I4ZJj+lEP9FwlG+I eudebvbM6NI7zvLbFdf/ZylExhL5CJxGfA/tFWhTdejm/VrW0UUBTW1TQhmrHmEMgM0w TKRrs2u++towVm9FhOjWFSKuYeymx2QXv7lka5XOu9IPSAbhW6iDw4yzGB5o/zu+mDCj R0dKM6u9btEfcQWklubiQIecyq4y0k73X3qVVhfmh2/kZsE4DrSG+EOVxAVifbB1V95D ncgFSJ9Pqu29FyhravLBya0hPQOKUQsp0iUZC14T6P1fWCQL6FCYU3FfRJzXdmPzYzqo ONpw== X-Gm-Message-State: AOJu0Yym/qsqifaPOhG53p0tswdSczjCcW7rheb9klvLvm3DPo8FAxdE +LCP0wjGXlPE8ndOMYKu3HL7AcUE+zBx0EUBS+8/zReXcukeAW+0HlovsJUtpell6ObIgFTf8lO pa/00ZRVbby/R1bbPwtwQBXCoSKSTKhuZTZ4x+tECLAyuYNoL0T/2uQ+ieuoI+Vk61xr3qJhTSZ mWxori4bH3VSPGI9Hi1Og3uUycFEVp1w== X-Received: by 2002:a5d:480e:0:b0:368:3198:5ac4 with SMTP id ffacd0b85a97d-369bbbe2a91mr2555405f8f.39.1721607545151; Sun, 21 Jul 2024 17:19:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyskwU5BxNoqg+B7LLciKH9I6X03MKkeFL1oxiEh2B3M8PZAtpqeH0cvxSCL/iH/tcJQb2Sw== X-Received: by 2002:a5d:480e:0:b0:368:3198:5ac4 with SMTP id ffacd0b85a97d-369bbbe2a91mr2555385f8f.39.1721607544584; Sun, 21 Jul 2024 17:19:04 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a94af6sm131775005e9.42.2024.07.21.17.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:19:04 -0700 (PDT) Date: Sun, 21 Jul 2024 20:19:02 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Wilfred Mallawa , Alistair Francis , Jonathan Cameron , Klaus Jensen , Keith Busch , Klaus Jensen , Jesper Devantier , Marcel Apfelbaum , Huai-Cheng Kuo , Chris Browy , qemu-block@nongnu.org Subject: [PULL 62/63] hw/nvme: Add SPDM over DOE 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.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Wilfred Mallawa Setup Data Object Exchange (DOE) as an extended capability for the NVME controller and connect SPDM to it (CMA) to it. Signed-off-by: Wilfred Mallawa Signed-off-by: Alistair Francis Reviewed-by: Jonathan Cameron Acked-by: Klaus Jensen Message-Id: <20240703092027.644758-4-alistair.francis@wdc.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci_device.h | 7 ++ include/hw/pci/pcie_doe.h | 3 + hw/nvme/ctrl.c | 62 +++++++++++++++++ docs/specs/index.rst | 1 + docs/specs/spdm.rst | 134 ++++++++++++++++++++++++++++++++++++ 5 files changed, 207 insertions(+) create mode 100644 docs/specs/spdm.rst diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index cefd6f7640..e7e41cb939 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -3,6 +3,7 @@ #include "hw/pci/pci.h" #include "hw/pci/pcie.h" +#include "hw/pci/pcie_doe.h" #define TYPE_PCI_DEVICE "pci-device" typedef struct PCIDeviceClass PCIDeviceClass; @@ -159,6 +160,12 @@ struct PCIDevice { MSIVectorReleaseNotifier msix_vector_release_notifier; MSIVectorPollNotifier msix_vector_poll_notifier; + /* SPDM */ + uint16_t spdm_port; + + /* DOE */ + DOECap doe_spdm; + /* ID of standby device in net_failover pair */ char *failover_pair_id; uint32_t acpi_index; diff --git a/include/hw/pci/pcie_doe.h b/include/hw/pci/pcie_doe.h index 15d94661f9..9e1275db8a 100644 --- a/include/hw/pci/pcie_doe.h +++ b/include/hw/pci/pcie_doe.h @@ -108,6 +108,9 @@ struct DOECap { /* Protocols and its callback response */ DOEProtocol *protocols; uint16_t protocol_num; + + /* Used for spdm-socket */ + int spdm_socket; }; void pcie_doe_init(PCIDevice *pdev, DOECap *doe_cap, uint16_t offset, diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 5b1b0cabcf..6ee72014cf 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -203,6 +203,7 @@ #include "sysemu/hostmem.h" #include "hw/pci/msix.h" #include "hw/pci/pcie_sriov.h" +#include "sysemu/spdm-socket.h" #include "migration/vmstate.h" #include "nvme.h" @@ -8113,6 +8114,27 @@ static int nvme_add_pm_capability(PCIDevice *pci_dev, uint8_t offset) return 0; } +static bool pcie_doe_spdm_rsp(DOECap *doe_cap) +{ + void *req = pcie_doe_get_write_mbox_ptr(doe_cap); + uint32_t req_len = pcie_doe_get_obj_len(req) * 4; + void *rsp = doe_cap->read_mbox; + uint32_t rsp_len = SPDM_SOCKET_MAX_MESSAGE_BUFFER_SIZE; + + uint32_t recvd = spdm_socket_rsp(doe_cap->spdm_socket, + SPDM_SOCKET_TRANSPORT_TYPE_PCI_DOE, + req, req_len, rsp, rsp_len); + doe_cap->read_mbox_len += DIV_ROUND_UP(recvd, 4); + + return recvd != 0; +} + +static DOEProtocol doe_spdm_prot[] = { + { PCI_VENDOR_ID_PCI_SIG, PCI_SIG_DOE_CMA, pcie_doe_spdm_rsp }, + { PCI_VENDOR_ID_PCI_SIG, PCI_SIG_DOE_SECURED_CMA, pcie_doe_spdm_rsp }, + { } +}; + static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pci_dev, Error **errp) { ERRP_GUARD(); @@ -8200,6 +8222,25 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pci_dev, Error **errp) nvme_update_msixcap_ts(pci_dev, n->conf_msix_qsize); + pcie_cap_deverr_init(pci_dev); + + /* DOE Initialisation */ + if (pci_dev->spdm_port) { + uint16_t doe_offset = n->params.sriov_max_vfs ? + PCI_CONFIG_SPACE_SIZE + PCI_ARI_SIZEOF + : PCI_CONFIG_SPACE_SIZE; + + pcie_doe_init(pci_dev, &pci_dev->doe_spdm, doe_offset, + doe_spdm_prot, true, 0); + + pci_dev->doe_spdm.spdm_socket = spdm_socket_connect(pci_dev->spdm_port, + errp); + + if (pci_dev->doe_spdm.spdm_socket < 0) { + return false; + } + } + if (n->params.cmb_size_mb) { nvme_init_cmb(n, pci_dev); } @@ -8446,6 +8487,11 @@ static void nvme_exit(PCIDevice *pci_dev) g_free(n->cmb.buf); } + if (pci_dev->doe_spdm.spdm_socket > 0) { + spdm_socket_close(pci_dev->doe_spdm.spdm_socket, + SPDM_SOCKET_TRANSPORT_TYPE_PCI_DOE); + } + if (n->pmr.dev) { host_memory_backend_set_mapped(n->pmr.dev, false); } @@ -8491,6 +8537,7 @@ static Property nvme_props[] = { DEFINE_PROP_BOOL("msix-exclusive-bar", NvmeCtrl, params.msix_exclusive_bar, false), DEFINE_PROP_UINT16("mqes", NvmeCtrl, params.mqes, 0x7ff), + DEFINE_PROP_UINT16("spdm_port", PCIDevice, spdm_port, 0), DEFINE_PROP_END_OF_LIST(), }; @@ -8562,11 +8609,25 @@ static void nvme_pci_write_config(PCIDevice *dev, uint32_t address, { uint16_t old_num_vfs = pcie_sriov_num_vfs(dev); + if (pcie_find_capability(dev, PCI_EXT_CAP_ID_DOE)) { + pcie_doe_write_config(&dev->doe_spdm, address, val, len); + } pci_default_write_config(dev, address, val, len); pcie_cap_flr_write_config(dev, address, val, len); nvme_sriov_post_write_config(dev, old_num_vfs); } +static uint32_t nvme_pci_read_config(PCIDevice *dev, uint32_t address, int len) +{ + uint32_t val; + if (dev->spdm_port && pcie_find_capability(dev, PCI_EXT_CAP_ID_DOE)) { + if (pcie_doe_read_config(&dev->doe_spdm, address, len, &val)) { + return val; + } + } + return pci_default_read_config(dev, address, len); +} + static const VMStateDescription nvme_vmstate = { .name = "nvme", .unmigratable = 1, @@ -8579,6 +8640,7 @@ static void nvme_class_init(ObjectClass *oc, void *data) pc->realize = nvme_realize; pc->config_write = nvme_pci_write_config; + pc->config_read = nvme_pci_read_config; pc->exit = nvme_exit; pc->class_id = PCI_CLASS_STORAGE_EXPRESS; pc->revision = 2; diff --git a/docs/specs/index.rst b/docs/specs/index.rst index 1484e3e760..e2d907959a 100644 --- a/docs/specs/index.rst +++ b/docs/specs/index.rst @@ -29,6 +29,7 @@ guest hardware that is specific to QEMU. edu ivshmem-spec pvpanic + spdm standard-vga virt-ctlr vmcoreinfo diff --git a/docs/specs/spdm.rst b/docs/specs/spdm.rst new file mode 100644 index 0000000000..f7de080ff0 --- /dev/null +++ b/docs/specs/spdm.rst @@ -0,0 +1,134 @@ +====================================================== +QEMU Security Protocols and Data Models (SPDM) Support +====================================================== + +SPDM enables authentication, attestation and key exchange to assist in +providing infrastructure security enablement. It's a standard published +by the `DMTF`_. + +QEMU supports connecting to a SPDM responder implementation. This allows an +external application to emulate the SPDM responder logic for an SPDM device. + +Setting up a SPDM server +======================== + +When using QEMU with SPDM devices QEMU will connect to a server which +implements the SPDM functionality. + +SPDM-Utils +---------- + +You can use `SPDM Utils`_ to emulate a responder. This is the simplest method. + +SPDM-Utils is a Linux applications to manage, test and develop devices +supporting DMTF Security Protocol and Data Model (SPDM). It is written in Rust +and utilises libspdm. + +To use SPDM-Utils you will need to do the following steps. Details are included +in the SPDM-Utils README. + + 1. `Build libspdm`_ + 2. `Build SPDM Utils`_ + 3. `Run it as a server`_ + +spdm-emu +-------- + +You can use `spdm emu`_ to model the +SPDM responder. + +.. code-block:: shell + + $ cd spdm-emu + $ git submodule init; git submodule update --recursive + $ mkdir build; cd build + $ cmake -DARCH=x64 -DTOOLCHAIN=GCC -DTARGET=Debug -DCRYPTO=openssl .. + $ make -j32 + $ make copy_sample_key # Build certificates, required for SPDM authentication. + +It is worth noting that the certificates should be in compliance with +PCIe r6.1 sec 6.31.3. This means you will need to add the following to +openssl.cnf + +.. code-block:: + + subjectAltName = otherName:2.23.147;UTF8:Vendor=1b36:Device=0010:CC=010802:REV=02:SSVID=1af4:SSID=1100 + 2.23.147 = ASN1:OID:2.23.147 + +and then manually regenerate some certificates with: + +.. code-block:: shell + + $ openssl req -nodes -newkey ec:param.pem -keyout end_responder.key \ + -out end_responder.req -sha384 -batch \ + -subj "/CN=DMTF libspdm ECP384 responder cert" + + $ openssl x509 -req -in end_responder.req -out end_responder.cert \ + -CA inter.cert -CAkey inter.key -sha384 -days 3650 -set_serial 3 \ + -extensions v3_end -extfile ../openssl.cnf + + $ openssl asn1parse -in end_responder.cert -out end_responder.cert.der + + $ cat ca.cert.der inter.cert.der end_responder.cert.der > bundle_responder.certchain.der + +You can use SPDM-Utils instead as it will generate the correct certificates +automatically. + +The responder can then be launched with + +.. code-block:: shell + + $ cd bin + $ ./spdm_responder_emu --trans PCI_DOE + +Connecting an SPDM NVMe device +============================== + +Once a SPDM server is running we can start QEMU and connect to the server. + +For an NVMe device first let's setup a block we can use + +.. code-block:: shell + + $ cd qemu-spdm/linux/image + $ dd if=/dev/zero of=blknvme bs=1M count=2096 # 2GB NNMe Drive + +Then you can add this to your QEMU command line: + +.. code-block:: shell + + -drive file=blknvme,if=none,id=mynvme,format=raw \ + -device nvme,drive=mynvme,serial=deadbeef,spdm_port=2323 + +At which point QEMU will try to connect to the SPDM server. + +Note that if using x64-64 you will want to use the q35 machine instead +of the default. So the entire QEMU command might look like this + +.. code-block:: shell + + qemu-system-x86_64 -M q35 \ + --kernel bzImage \ + -drive file=rootfs.ext2,if=virtio,format=raw \ + -append "root=/dev/vda console=ttyS0" \ + -net none -nographic \ + -drive file=blknvme,if=none,id=mynvme,format=raw \ + -device nvme,drive=mynvme,serial=deadbeef,spdm_port=2323 + +.. _DMTF: + https://www.dmtf.org/standards/SPDM + +.. _SPDM Utils: + https://github.com/westerndigitalcorporation/spdm-utils + +.. _spdm emu: + https://github.com/dmtf/spdm-emu + +.. _Build libspdm: + https://github.com/westerndigitalcorporation/spdm-utils?tab=readme-ov-file#build-libspdm + +.. _Build SPDM Utils: + https://github.com/westerndigitalcorporation/spdm-utils?tab=readme-ov-file#build-the-binary + +.. _Run it as a server: + https://github.com/westerndigitalcorporation/spdm-utils#qemu-spdm-device-emulation From patchwork Mon Jul 22 00:19:04 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: 13738165 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 711D7C3DA5D for ; Mon, 22 Jul 2024 00:24:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVgmf-000197-4P; Sun, 21 Jul 2024 20:20:10 -0400 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 1sVgll-0003yk-5E for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:15 -0400 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 1sVglj-00061n-AN for qemu-devel@nongnu.org; Sun, 21 Jul 2024 20:19:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721607550; 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=csYPPQ6V3Zw3B+Skv6+vmMgGos87nUcKxMNRDL7UsyQ=; b=PL6cjX7G/t1EEuqDmWB7+hGjFdIj9nP/Q6XYp0HB7wcB1iNisxnD3oCOFpcIdDa+UB1zCY Jq6W/KuVqIfnwuA+arZTsZjYHEQNyTPTk4UUdWFtolPkOfr8h5tHxmmL+LG6t8C7t1fnjg V8kdZLeg8cXR5cAxyLIMt3LMLSX38/E= 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-499-TxGAVbfKNZe_CSYm3y6u5A-1; Sun, 21 Jul 2024 20:19:08 -0400 X-MC-Unique: TxGAVbfKNZe_CSYm3y6u5A-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-42668699453so37772155e9.3 for ; Sun, 21 Jul 2024 17:19:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721607547; x=1722212347; 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=csYPPQ6V3Zw3B+Skv6+vmMgGos87nUcKxMNRDL7UsyQ=; b=u2p+sXkYXDFSpfz39wlpnW8jCVzW2ppLoyiQjegd6vrnG2qYuGfN4YUlqMz4hW/CBM r8Jt5dMUPI2+cwbCvDgH7ca8rIm/BkUD5u5ICb23sHeIgTU29mzwvwNigc/ZO2rfWiL8 sIDLVn5gMADP0tmlf11xaNKolkGEiHKSRsYcmOJdhkP3PvCq4/UULeSpWZJRga8EFC+n sdNOoLxVciYWAzizNVd6c0fc/ClHCotbRLiGOErNzHpjMUgp7tlCnCxO/0D/z3lkUZYn /ja06blalhuQbmrNRnDzY9m/+DxQYJVVsI/jVjvzKEP/LZ9zS8sEe+jqEAJVaCtisQGN dv7w== X-Gm-Message-State: AOJu0YxprMzXXB5++Jwi4/1zAUGT3+Gin6X082RmMG20lO4L2+gD/7zA maFdOBaKTWqnRW2h0QtnuSd4eHC0WSTnXAAIe7cHOq87v4zqaqlL/4y4sWjO3iIXbgcbMsRFxJP GSVX6GanDxVrU7HG16u11f871grxIRdvgTv9bvnpnI21+bCXh8d1Qq1JNIw60v7U/znRx1ItpuB KUXxB1K0t+sWAMLk1kJLPJ6p1yJVsZrQ== X-Received: by 2002:a05:600c:4452:b0:426:63f1:9a1b with SMTP id 5b1f17b1804b1-427dc56b427mr32415075e9.33.1721607547295; Sun, 21 Jul 2024 17:19:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEhg98lL2fJAKGAldy02gl285EAdjgl11w2DXscYdCLR+LWILqoX1SqFzzHKLblz+m1yPWQg== X-Received: by 2002:a05:600c:4452:b0:426:63f1:9a1b with SMTP id 5b1f17b1804b1-427dc56b427mr32414955e9.33.1721607546723; Sun, 21 Jul 2024 17:19:06 -0700 (PDT) Received: from redhat.com (mob-5-90-113-158.net.vodafone.it. [5.90.113.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d692977asm106911665e9.31.2024.07.21.17.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jul 2024 17:19:06 -0700 (PDT) Date: Sun, 21 Jul 2024 20:19:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi Subject: [PULL 63/63] virtio: Always reset vhost devices Message-ID: <67d834362c55d6fca6504975bc34755606f17cf2.1721607331.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: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: Hanna Czenczek Requiring `vhost_started` to be true for resetting vhost devices in `virtio_reset()` seems like the wrong condition: Most importantly, the preceding `virtio_set_status(vdev, 0)` call will (for vhost devices) end up in `vhost_dev_stop()` (through vhost devices' `.set_status` implementations), setting `vdev->vhost_started = false`. Therefore, the gated `vhost_reset_device()` call is unreachable. `vhost_started` is not documented, so it is hard to say what exactly it is supposed to mean, but judging from the fact that `vhost_dev_start()` sets it and `vhost_dev_stop()` clears it, it seems like it indicates whether there is a vhost back-end, and whether that back-end is currently running and processing virtio requests. Making a reset conditional on whether the vhost back-end is processing virtio requests seems wrong; in fact, it is probably better to reset it only when it is not currently processing requests, which is exactly the current order of operations in `virtio_reset()`: First, the back-end is stopped through `virtio_set_status(vdev, 0)`, then we want to send a reset. Therefore, we should drop the `vhost_started` condition, but in its stead we then have to verify that we can indeed send a reset to this vhost device, by not just checking `k->get_vhost != NULL` (introduced by commit 95e1019a4a9), but also that the vhost back-end is connected (`hdev = k->get_vhost(); hdev != NULL && hdev->vhost_ops != NULL`). Signed-off-by: Hanna Czenczek Message-Id: <20240710112310.316551-1-hreitz@redhat.com> Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 397c261c3c..624fdcae91 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2275,8 +2275,12 @@ void virtio_reset(void *opaque) vdev->device_endian = virtio_default_endian(); } - if (vdev->vhost_started && k->get_vhost) { - vhost_reset_device(k->get_vhost(vdev)); + if (k->get_vhost) { + struct vhost_dev *hdev = k->get_vhost(vdev); + /* Only reset when vhost back-end is connected */ + if (hdev && hdev->vhost_ops) { + vhost_reset_device(hdev); + } } if (k->reset) {