From patchwork Tue Jul 23 10:55:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739849 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 2ABA7C3DA49 for ; Tue, 23 Jul 2024 10:56:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDAy-0006Tp-J8; Tue, 23 Jul 2024 06:55: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 1sWDAw-0006Se-Kj for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55:22 -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 1sWDAv-0001Xi-4s for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732120; 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=XaKpkn8WljIfaB2gHccQ0Vi94TGktq7O6y5w8kx+0f3fI0ilQ8ayNCkIIKBtQrOMqBUgUq jA4DpJg4mW+OJcyA4ZvINkSlwqoeu3I8HKMza+oU69fI6yYNqKydTqd3aQcEDOfnPfNrCh KV3k/szENcywKoM24gI7X0DnSwNVqdw= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-455-AD72pIXVO76hVfZDjpHZIg-1; Tue, 23 Jul 2024 06:55:18 -0400 X-MC-Unique: AD72pIXVO76hVfZDjpHZIg-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2ef286cf0e8so25250501fa.0 for ; Tue, 23 Jul 2024 03:55:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732117; x=1722336917; 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=hESpjqo0d5uB8mbP+6JXU7vomfsX7DgrtBZUq0Fy2PVDkIdiUjpfEAcfy8yYfPNJX9 nTSIZizsLolZ8QkcIoJMKHO2pWPwaTbMB8yLh8xEoyOdABdUAzPUek7K5JTyYvEVg0H8 rc8OnnHnP0an3ARRME5VQy3ihF/s0QHV3EnFWgx2lroJ8bbuPrHYvjmUYu4ZQ4MUY9tc ovgDbPyCVQkExUuwN2ny+eCi9VY1q8AvRKDtcEDJ/Otky8W7JI2n0V4rPqws91cEqVXP 9ak8ch1oEcZnlZeTsMrqa2Pgl6lgkvA174UCkOqpUUsoDOwyn+f5D1z59/1iFGDD5uy6 rKyQ== X-Gm-Message-State: AOJu0Yy2k7A+uQ48nhxr5Zry9r7WzaOfC1OOz+YYMxXQsnvxNMFt8T89 cHh0/iRd99eZm3rA/4w7aEhx/vg3691PbfIaYleMeW3SXU+jyKsW2ROwW/TOj+b8KWVlHmD9zvB DfKC4ZT7ydsugbMO9cZDEhLo93iXn2xg/kiNXFD4kAFHz0v/Yrn9/GOWOw720luzkFo2/69Z4+w zBM1flPr7tXotwjRhSmuZWB5//Ri72nQ== X-Received: by 2002:a2e:9ec4:0:b0:2ee:8555:4742 with SMTP id 38308e7fff4ca-2ef167dfa9bmr66561101fa.27.1721732116640; Tue, 23 Jul 2024 03:55:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7eD1smRFN8gpJ2r6smIxD1GGqUURRg99gLh1itInWSjE6tthfbBVEntsNv+xW8+4D9e6xPg== X-Received: by 2002:a2e:9ec4:0:b0:2ee:8555:4742 with SMTP id 38308e7fff4ca-2ef167dfa9bmr66560821fa.27.1721732115763; Tue, 23 Jul 2024 03:55:15 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a5ef56e2c4sm3848296a12.39.2024.07.23.03.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:55:15 -0700 (PDT) Date: Tue, 23 Jul 2024 06:55:09 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zheyu Ma , "Gonglei (Arei)" Subject: [PULL v2 01/61] hw/virtio/virtio-crypto: Fix op_code assignment in virtio_crypto_create_asym_session Message-ID: <89cf6574bc4bcdb99894e9401ecea0063d8212ce.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:55:16 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: 13739851 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 5398AC3DA63 for ; Tue, 23 Jul 2024 10:56:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDB3-0006e7-Pm; Tue, 23 Jul 2024 06:55:29 -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 1sWDB2-0006co-29 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55:28 -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 1sWDB0-0001Zc-Jx for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732126; 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=ca+BRSfa8iaDUgW66dTdG1eEWTAhgQPGtE89L1pv/rb5bwtGvNqE1jgX29zijXXDp8FfR+ bzcuJB0svD/d0maBTnc0nLSIEWGW+h15gA1E/sCX+RjAPivIRnSnoCFoE1Gt4fMLHA9ofo H60vzz+HpuuU7wgjcxOaSvsU/ISFxf0= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-260-q0rO56RJNI671sDCHTLauQ-1; Tue, 23 Jul 2024 06:55:24 -0400 X-MC-Unique: q0rO56RJNI671sDCHTLauQ-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a77f0eca759so399505766b.3 for ; Tue, 23 Jul 2024 03:55:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732123; x=1722336923; 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=LvaOistQPaT4wYPcv0sfr7JbnaTlJfMgefS0hrmTKmioNl43oSnsgnc9HBRxjnzju+ Ij1wlUaTz7P3l0gap8VtA2n8iibJouEzJ+8eZfTgZFashaGIDlnGu/aCzdS6UtW2L6WH EciBkvErWl3eZ7FCqSCdhvBYC3IcrMwucKDVLQMqGNn87f8xBUJ+ljh1DXl5w5S5A96Y 3ArqOiR5jdGfiweQrv9dj65tTJhkq+YwLyeLi6Z6svCfPCwvhaR973eIJoeVcG6jTI5H dn7H1vxZ8JL+klrsNSCnQHPaKM4XlOc/xuoJ1ZKdcgi9Pi00TgEB6SSeydyo8KZQuRI6 DyQA== X-Gm-Message-State: AOJu0YwLvJaiePxRWKdZlhTVUrvv+kPGCwZVTyrZCivzYsXZTYYts8/N 2to7xrKquWq6pnSMenXQX37mLlriDrdeyatjEWwV0upXpLN5VJxtQk12h/Bnww12fGY4fzEeHky BrvHKXYqtaMzdcK9ah6N+HUZKssvAcI0/PL6qPkCy3V5QIjR4FXCo/yQnzotGJUOWtEt8C2o5XR I1tlwWln33HBzvSv0CkFkB1uB5dq6DJQ== X-Received: by 2002:a17:906:eec5:b0:a72:6e13:a4b6 with SMTP id a640c23a62f3a-a7a4c44701bmr613851066b.58.1721732123059; Tue, 23 Jul 2024 03:55:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXf1r3h9et8o1eEBEF6VrxZkHWCb/x5P5vC7q1UkD2xo/ZLaW6rnGhV4bpYKZDle3ROdIqJA== X-Received: by 2002:a17:906:eec5:b0:a72:6e13:a4b6 with SMTP id a640c23a62f3a-a7a4c44701bmr613847866b.58.1721732122264; Tue, 23 Jul 2024 03:55:22 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c922b27sm525639566b.164.2024.07.23.03.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:55:21 -0700 (PDT) Date: Tue, 23 Jul 2024 06:55:16 -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 v2 02/61] MAINTAINERS: add Stefano Garzarella as vhost/vhost-user reviewer Message-ID: <7967b7e0b17cb5e700ca040e0b68ba8fb0035c0d.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:55:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739850 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 58057C3DA7F for ; Tue, 23 Jul 2024 10:56:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDBV-0006sX-Im; Tue, 23 Jul 2024 06:55: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 1sWDB9-0006nL-Ql for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55:35 -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 1sWDB8-0001aM-0f for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732133; 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=TdwwKqEDKbRfjQ90orl6IXNgOC5zoJfUaFe1157ZINbxbGeb+i8OVbejcXY3De2W4jjPjc lpRd+ctFe339iKOtNek9L9EEnY+c4RaPN6n9eTNvP6+4W4M6ehQm/0Xyo++Jpv/pK8hK3s N5SnuU9+nfC0+txrYIm6hn0x93FdJcY= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-548-MLtbJdfPPAa60-5_x8A19w-1; Tue, 23 Jul 2024 06:55:30 -0400 X-MC-Unique: MLtbJdfPPAa60-5_x8A19w-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-52efe4c2372so2703486e87.1 for ; Tue, 23 Jul 2024 03:55:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732128; x=1722336928; 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=sp2J7tRPIx3Zb3I+7/BvDWMS/B4C4Rowx9NDLisctulqz129mDtuWdpW+kNrz6ugMk rB0CyWUxxTWUwECrMkDtK+lrZGRB71KCnaQmEl2U5w++WgAh8fm0X+0ShW0+gKJZLbWx 04YHqS7x7kiTFBzpddtInI7GzNglbQ1B5pr4tRegLCOO8DtU4cN9kTbMNtrLnoBAmmjz /Ap77iR1JdbZcCDUV2huidPWGOCTMBRgfQdpXi4/XRGrw7KwfZr+EL4YbnTkFK/D8sip dKe320//BZRfjfixCrJX3guc4UDqvARMJDsEALhMZ4nA5U10oV4IOqoftWTj0dC9dZRZ Qh0A== X-Gm-Message-State: AOJu0YzgSFu5n0TwyYrPbmjO0nermTjZ180gD98qki0N0yijReAVvBNg 32+U2VEP44EPuKJbtYRq7EIZsGCDhji4Fo+lIv+jB5gwDDV5QrLfxudYeysjCin+o/zXG4oMub+ e0MUZ7gUKq9qJq3B99KKTsFfM+oXssmNMKy3n0iMONB0bX1MCOeYHciV9J1xkYsABqkvbKm7G8s UNElmFUsIEcSF2tNGaCtUfohQXsE9QYw== X-Received: by 2002:a05:6512:3984:b0:51a:f689:b4df with SMTP id 2adb3069b0e04-52efb7db65bmr6462017e87.44.1721732128466; Tue, 23 Jul 2024 03:55:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPipkBu7Sx8Ha++7Pa53+7D7zfR7I9vHXYbrNov+mntCi1onf43jttho9KeVffjrBT2SPLCQ== X-Received: by 2002:a05:6512:3984:b0:51a:f689:b4df with SMTP id 2adb3069b0e04-52efb7db65bmr6461982e87.44.1721732127625; Tue, 23 Jul 2024 03:55:27 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30aaa31e0sm7328912a12.27.2024.07.23.03.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:55:27 -0700 (PDT) Date: Tue, 23 Jul 2024 06:55:22 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Jonathan Cameron Subject: [PULL v2 03/61] 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.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni 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 Tue Jul 23 10:55:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739856 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 B887EC3DA49 for ; Tue, 23 Jul 2024 10:56:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDBb-0007Jn-0e; Tue, 23 Jul 2024 06:56: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 1sWDBG-0006oD-Cf for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55:42 -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 1sWDBD-0001ax-Uk for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732137; 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=QGgj0xe2DGn8fLx9iWON/KekDYKdvkpKVXBQfoyM5XfZ3fZRKc22WB/4NOEwDTFW+pFV2j ZuEXatD8nZlwkYSlYg/BMdIVSiet/wiU8SfeVPFptjPNJy3e3LkXt32zUoyEOGpuIw0/Zq OQWEV/4GcOVUsjdYq6EqNftpVlRGyKI= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-CO8eQNS-MTeeNydjN4nA9Q-1; Tue, 23 Jul 2024 06:55:35 -0400 X-MC-Unique: CO8eQNS-MTeeNydjN4nA9Q-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5aa4fd656e0so105804a12.2 for ; Tue, 23 Jul 2024 03:55:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732134; x=1722336934; 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=kiOAKLzOV5T5UPUVkjS0ZNEWRtrSo6H1/4hx6qLkIinnsfwuQs+CkBvoAY/g84MHi4 X9/lTi7Rqo/4exskfDjLifYJXEdao5VdjvVH67Oh243IB0/l/6Lyxgj9pG7bDmQmsOEr jIw/vnOLM1ghjFU1/Z3LDGVMNS8xc8Oq73hfuOrdqEiQ9cNJ0a2JGwnDGh3El8u9Cgb0 k5MPQMjPIzubkpbKa+/0OzFgEB3b+M2oPVNGkwoX1I6EnzACIri2JBN933XAN6Z9EaGy XIvwrD8Enlwpps4pDYkaWKozg2OCyVsN79hcPaQ0GiiYSMe0rWAq13zgpeL7EMHf60W1 P4nw== X-Gm-Message-State: AOJu0YwCorSf2s0x97y44o9GWuUJ63aI0HjwvQY2K0gA/+Ej994O9E1l s10GnWwqlBqjTaRtBpAZbZoLe6uVj0X0wlTcXvWbWIKFpMdGj32GHhKMdt3AYud5drJLqX2xKvD 9s0PqZtdM0yr+dhkWOSvtTzoSmjl0XM3bI0PiYrgm8YgGmWnHHFreDkwg3JoNyTxaiw5lTBfjrl fqYdDhxL0GJvG9V8ELZw1Dn3Pg0JXYqQ== X-Received: by 2002:a50:9547:0:b0:5a2:2b56:e08e with SMTP id 4fb4d7f45d1cf-5a47ab1083cmr5315039a12.18.1721732133875; Tue, 23 Jul 2024 03:55:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEy2IYsDzghT6tDYN+/yi4O25vrabVfFyBuogGqJEfrU177uLbDmG+nKfG8u0imWjwgAfTniQ== X-Received: by 2002:a50:9547:0:b0:5a2:2b56:e08e with SMTP id 4fb4d7f45d1cf-5a47ab1083cmr5315008a12.18.1721732133289; Tue, 23 Jul 2024 03:55:33 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30aaa2d48sm7347855a12.32.2024.07.23.03.55.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:55:32 -0700 (PDT) Date: Tue, 23 Jul 2024 06:55:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL v2 04/61] hw/cxl: Check for multiple mappings of memory backends. Message-ID: <9de2049c95e1a94e27430e71a9d9ace07ec8eda6.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron 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 Tue Jul 23 10:55:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739855 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 39E88C3DA70 for ; Tue, 23 Jul 2024 10:56:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDBY-00075Q-Sj; Tue, 23 Jul 2024 06:56: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 1sWDBI-0006ps-Tf for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55: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 1sWDBG-0001bQ-JH for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732141; 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=D8ec92uoQvkCNvCNPjP+DnoxQQU04YBrkQ3+C/PqKvfQg+QG6mYFzhE/o/zZXbtjp0q9oz Gcp7jzW8m25qYMCsvYeSoV/QXSkQz91pqumCBFbGcOGqK7p5IOmWGzL0hPOvrKJpoOtNYt V9Ot+TsITN3EGIk6ez4SfOTR0bzQx2s= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-iJ1wGkcEP5e-098yrsaRGQ-1; Tue, 23 Jul 2024 06:55:40 -0400 X-MC-Unique: iJ1wGkcEP5e-098yrsaRGQ-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a77e024eaa4so457928066b.0 for ; Tue, 23 Jul 2024 03:55:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732138; x=1722336938; 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=JXWNObgo5K70xT585NeIY0uq9BaefwsSQFeRLYFjgLRT7o2i3oFxouiKI37xblLnXO eaAzBf2F8M5i8w7++ycjmLMRx4WJxgKuVgJRKvubc3rBLz2dhNF4oLqnLNupCfLWZyCk YUdly5JyXEQh0RawlAabT4EYJByt3WWY0E6I2RenMtjbO3/RkBqNCFH5vd0YvVzGWKBa A3eT5qr4Wn1jb8fI41T4rLFR2z2HNWQsL+NGFv04FRnccOh1Yqqv9q8t3UMi/FPe8mm9 +KcOLpntEJFfFoBM6DaQRjLs/E1eEC1Kp45lF0mWA+Ttc44P29RXEccr8wFl01LLwRRF N5iQ== X-Gm-Message-State: AOJu0YytLHYqFKfDMmt7VGzCts4o/TzP2gfIyx+O9/0dRmNmGX4Bhf20 aOumV4/wUczHXDl6aqZbgiR+ID+MHaGvob2ohE3CYYRIOpt46B2oGuVT5sBuypkZh3Es58+ec7T uhieMA7cHVwFddX2/rxSyF7XOCO3KctKWhMErb8Na31+iXrIBGixR7LDZnZ0hrlMDQ5GjgeaH1w Sqp+WuX3tqRmqiBNgET0cSwXzOhPUINw== X-Received: by 2002:a17:907:3da5:b0:a6f:52db:7e5e with SMTP id a640c23a62f3a-a7a87c3c2camr214360266b.19.1721732138355; Tue, 23 Jul 2024 03:55:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkYgoi+jSTMgVfZHdQoMeqYb5pIm3jrabdzUx7D3NnuJ2NQ8XzBLnQXM7L2S5D+Oh8GGtcfg== X-Received: by 2002:a17:907:3da5:b0:a6f:52db:7e5e with SMTP id a640c23a62f3a-a7a87c3c2camr214357166b.19.1721732137698; Tue, 23 Jul 2024 03:55:37 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c91713bsm527286966b.150.2024.07.23.03.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:55:37 -0700 (PDT) Date: Tue, 23 Jul 2024 06:55:33 -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 v2 05/61] 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:55:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739852 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 E29C0C49EA1 for ; Tue, 23 Jul 2024 10:56:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDBY-00075E-Ie; Tue, 23 Jul 2024 06:56: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 1sWDBQ-0006se-0t for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55:56 -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 1sWDBN-0001bw-IE for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732146; 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=CBdGCzlOT1WMwOXBzy48sMDhX0zy4X7TK/XJo0uyAqN7wCbYVaHRlb4HAn/MWOsmAiPCvP K+2F7XRmXWaxZR6Z8sQ4c9SUqWix3hgoHvq6xn2UEQB31Uhqy2rnBqcf5QFQMuyqTHjXJR qwTugJqAUAUhV25/iIa9xN4BfqFqxCk= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-2NHQm-QPPi6EpBXXjj2Nnw-1; Tue, 23 Jul 2024 06:55:44 -0400 X-MC-Unique: 2NHQm-QPPi6EpBXXjj2Nnw-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5a69c1f5691so3379564a12.1 for ; Tue, 23 Jul 2024 03:55:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732143; x=1722336943; 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=RTEJt4ihbggBfbGdHSsaVJZGGmtSb+0JJqbsTMX2tE3lsTexqZLUmemQrd/Jm7lEtl mJukc+Si1BXqz5df0v6QHcdsDuaqZuH8pJOj8binDnzSoIl8fUIAjfycACF07iFSYygp RWDiy96N/AEu0dJOYA3uoNPURSaX0lPRMndaNwMuTXG9bMj1raXO88kYQ9tP0IQrI9qE 15qEwQQjwlyZmhsWoKi4lubAZOypFQ1mXme+lyTrbIf7z5TIwX0OZnKgrc2/k6kItC9U fIYBz4kK20xMSL+vrTHt49uLcBZOUKqQ41SzesH0wLDOl9WPvB0Y1YjNPbBm3CV15cP6 ZK7w== X-Gm-Message-State: AOJu0YyEgltlZvOdzknxaE1clngbs2/YF+fhS7l6BnAY0qCM89MbpUi2 e6rhtuSpO7rsPg/ewIXmH/ZacWdEXbv3iILsBwLc+Pu0paFXRUyjs6DKdgnjFMuap+a4sx2l0+y Z8CdxLqQb3p3GhdQmUiigVH5SKz7c5oHXFL1xOvmN73m6FJ/ltBno/z3W42FJwYBBhmAxrGIKX/ du8MW5eHLSWHYpFnki7QYAVlk04RZ9jg== X-Received: by 2002:a50:c041:0:b0:57d:d59:461b with SMTP id 4fb4d7f45d1cf-5a99e770443mr1621583a12.13.1721732142965; Tue, 23 Jul 2024 03:55:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHaC3gsoeAY14WUlzBxeDnekI//ao84Z4WhLV6PfM/ydeGhIut3H7opkTIveB4l7wTsPwZ9QA== X-Received: by 2002:a50:c041:0:b0:57d:d59:461b with SMTP id 4fb4d7f45d1cf-5a99e770443mr1621545a12.13.1721732142253; Tue, 23 Jul 2024 03:55:42 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30c2f87dcsm7363262a12.68.2024.07.23.03.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:55:41 -0700 (PDT) Date: Tue, 23 Jul 2024 06:55:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Jonathan Cameron , Fan Ni Subject: [PULL v2 06/61] 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:55:42 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: 13739868 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 43412C3DA63 for ; Tue, 23 Jul 2024 10:57:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDBZ-000769-3E; Tue, 23 Jul 2024 06:56: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 1sWDBT-0006tM-Ph for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55:56 -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 1sWDBR-0001cU-O7 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:55:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732152; 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=OpqAYFA2HRWgHMRzLISoKW2XSYvH/xzh9DIrug3OOtgaFxodYXeFKS10LoFIUc6n0CMjbd qKHCmo4GbarX8kqiaqgPcQyYaXvD3tJi6NA1zchFXtcs3RUhTKJ/1Q/xOjUdDFcNUbs1N7 AxqZ9Uc63ibLBhvp0K2QwxurR5EFkuk= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-168-7cqhZtsUN1SS4TpOkhC9MQ-1; Tue, 23 Jul 2024 06:55:51 -0400 X-MC-Unique: 7cqhZtsUN1SS4TpOkhC9MQ-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a77c6ea022fso114813766b.1 for ; Tue, 23 Jul 2024 03:55:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732149; x=1722336949; 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=VGhcCKG2jwuuFzTvWVTM6LU2Ue96d3uRmCgZajXBpCMa/RaDdFXP73OocJMlnaSTNF gGt37TQJM2LqMUdVsdDJHcAB6Hw2nsZGR4qWNwt9iYQcXswo17sYd2/z2hauyr0PX0M1 hM59IzPnoZu+keTY1q5yGXSmSWA/p8R+fqkftqe8bFn5BHEhtIaHLXVD9N77c18+Qw4E kkEJJzbJvJY/bR48BrZkC/3jDYXmAIuxtEdGMa2vNBRs2T8ZcvV9TBm3TIDYZpi7ZAmD TD0T9ALG2flAN4JMxs7G4klErLmNacSk8NsJHOaip/xFldYc1M9N1scxZw/2k73rYCCR /ZKA== X-Gm-Message-State: AOJu0YymwSV52AtyJGHyV1Y46ROE9CWO5iRRFJ6EEEhk842SrRLrNSWu KYEure13/jDsX1L0vBhf/pdPeNmP7U5/b4S+BznRDeBD86f6OqNT93ZtRucWSlp1kzQEJdPU0O5 oyRthQgU3NfNns6el9ThxzUYd47y4m7B9jzrqzJUDZDLgH358SxR0Sth9ll+BZQ/108d6CYO8i/ GVBKHFDDnujy7MeHWnhRJ+MK6ypCyn3g== X-Received: by 2002:a17:907:7d8e:b0:a77:d9b5:ad4b with SMTP id a640c23a62f3a-a7a9424ec2dmr181696066b.9.1721732149194; Tue, 23 Jul 2024 03:55:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvoju6b5vCAj8EA4VcKDeoobYMsBJMkN8J1IpSVOFJiXrGNM23fEaDWeTucskl12KYa3cCAA== X-Received: by 2002:a17:907:7d8e:b0:a77:d9b5:ad4b with SMTP id a640c23a62f3a-a7a9424ec2dmr181693266b.9.1721732148637; Tue, 23 Jul 2024 03:55:48 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c9273a5sm525604566b.165.2024.07.23.03.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:55:48 -0700 (PDT) Date: Tue, 23 Jul 2024 06:55:42 -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 v2 07/61] hw/cxl/mbox: replace sanitize_running() with cxl_dev_media_disabled() Message-ID: <75b800dd3bd8042503ddd4e8a4169f34349325e2.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:55: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: 13739871 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 07618C3DA63 for ; Tue, 23 Jul 2024 10:58:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDBa-0007EA-1R; Tue, 23 Jul 2024 06:56:02 -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 1sWDBZ-000793-85 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:01 -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 1sWDBX-0001dN-DZ for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732158; 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=D9j5OSNI0ISnUerZj/8BSLe/TAV9X3DBkQV3r6O/UQf4v4p02xLClPjDa8ykjCOgvIGIOr gw89QJUR5gd2/Hc1vozQjrC4BHbVT+LO7AlOqY8dAIKk/vMwapoK0IfePRK3WcLIosC4GS m9uaAu5gN3/J6SLxw7a3W7FOY8jWmhw= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-D2PsyTSQPW60N7kFZnADlw-1; Tue, 23 Jul 2024 06:55:57 -0400 X-MC-Unique: D2PsyTSQPW60N7kFZnADlw-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a7a822ee907so49682866b.1 for ; Tue, 23 Jul 2024 03:55:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732155; x=1722336955; 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=U7BlELdAEHh35bOW5NHN4juq6EpHGNnFgPyoXvbY5ECRLGo0T3WCYgZRjSSQEPd2ZM 58kjaTdn7TzoDD2HynQogbPzcwZg4Oy4tHaHtjv6+86PlcwaQdY6PSs8Ylvxf8T+iiPp NkHZ3Cg9XenCoGVUCkU9FIgrUTSDldDJdRBUKNQGT8nVra81toYGH24NILgNXktb6eCe 7zFHUV7v1ZBdZIdBvPfwl1FFE0Go44k39zcZSWFlbGQhrIT+oGsPbiCkTScrW/IBfPed m0nv9rhFr4NkMiUfNy3d4grB97HmdwwD9FmhQ8ngitipJYG+ijSJljrpDHNxcef87dAX 0qYg== X-Gm-Message-State: AOJu0YwIhQ4julKcn3tfVf3zv5XXtUaKveMZIlIZ9w5jgkrzEZxfogK9 Nu4zuMM2jYDZWCTn6boj8QkV0qJZzPGhwWSqDk8Mtyff/GNl4nMGhmS0W00YglXr3NH5PauhtcG HQkTssABblgxQxoPwgn2UxB4SDqGWZnhD8CUPSqxW3tFJX0JbClYRRzO4+pik+tvyA9gm88e52r K7RCE5cQDd/cBrk1Cze+mWZCW3ZIdVuw== X-Received: by 2002:a17:906:6a2a:b0:a77:cf9d:f498 with SMTP id a640c23a62f3a-a7a4c034e10mr616138366b.40.1721732155631; Tue, 23 Jul 2024 03:55:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElq73L5/g3H/MTcz1j7Pp0I7Y1Z4gghK+5DeH3+uYuyC0JGBC91N4G0sz73VHT8MYfkzHYww== X-Received: by 2002:a17:906:6a2a:b0:a77:cf9d:f498 with SMTP id a640c23a62f3a-a7a4c034e10mr616134466b.40.1721732154920; Tue, 23 Jul 2024 03:55:54 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7aa5b165c9sm3089366b.210.2024.07.23.03.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:55:54 -0700 (PDT) Date: Tue, 23 Jul 2024 06:55:49 -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 v2 08/61] hw/cxl/events: discard all event records during sanitation Message-ID: <7d65874ba0ea8cdb2a5ac51c397d721d7d49d828.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:55: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: 13739853 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 8926DC3DA70 for ; Tue, 23 Jul 2024 10:56:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDBg-0007ob-LL; Tue, 23 Jul 2024 06:56: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 1sWDBe-0007gP-RV for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56: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 1sWDBc-0001eB-VD for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732164; 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=T9TjOGOTXSfTU8f8n3BaSUGlA+REP/nofkpr7qgYXhVYtJkourxKQmmgCYq8Rh5xpGm9dj KgYVPcwbuHl7Kt4f6FYyIO5NJbt4ThImI4rVKKmvHtt5oErlY8QIUm76+El60Quc5ftQ67 TBHSPDtQTDH6ha+MSu2HXXJmZh0XKh0= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-nTEO2rEmMjGtGq9H8I5oXg-1; Tue, 23 Jul 2024 06:56:02 -0400 X-MC-Unique: nTEO2rEmMjGtGq9H8I5oXg-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a77f48f2118so114382466b.1 for ; Tue, 23 Jul 2024 03:56:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732160; x=1722336960; 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=FKJRUMn8HRwhQ60XcH6PjTUzs9GdkdALSW1wRaRAurd4RKpBo/8lw6LhexvXOOPq74 faARd0RXXtpVYd3waHL671T3N7iF8VqH5pJ+Lqltkh6dXw/umLOS1xEpcsO90r5ZYBea qP1CUmwEVHJNwhIUAOa1KqXTWa0H7w/2oaStQmkjIKmEUAlw1SraJ6cwV/8F3i7LJ1tP iwfu+ka8+908LfCW6Zrc/L2jlYLVgOwaR3AfQP7coUutdJWKxrAxAqV140/O6JCarcMz PjEltcEL0RvatYpS5IeygXPuVsUolf0b42+ckRwe+J8Zafz3q6AChiNbvo+qkHwzi9/e 4RWQ== X-Gm-Message-State: AOJu0YwnNQhCAm5Pxu1cg5TqeLhOXAAhEpLNooMjnAnG2qiTaFOxL4B3 /cpPkmzSaSEU4XPhe1PiGfoAnXhf45AD56aGTwo+aq2lVFt2B4BumuYbaeBg2Tt1Eq4hrdnAjHR MoHcDRt5kAC1d6PUKh+vxqCabsI6J7+NqAI427R/CGwiqcWE32/IlU4NK4l/LaVzLSDQk79tLZL VP/6u4eE6Y1f+l3Jp2VnsL2S4Rz+0Opg== X-Received: by 2002:a17:907:2dab:b0:a72:7a71:7f4f with SMTP id a640c23a62f3a-a7a93f36b39mr172560466b.7.1721732160508; Tue, 23 Jul 2024 03:56:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF76SdFlrWp+Ys26+TZ6xK0PB1WL69clRlKVeQWxEuDBRCzDmr0RcbvyOyJyJpm/GVOoc6tzQ== X-Received: by 2002:a17:907:2dab:b0:a72:7a71:7f4f with SMTP id a640c23a62f3a-a7a93f36b39mr172557266b.7.1721732159845; Tue, 23 Jul 2024 03:55:59 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c7bea7esm527848766b.83.2024.07.23.03.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:55:59 -0700 (PDT) Date: Tue, 23 Jul 2024 06:55:55 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Jonathan Cameron , Fan Ni Subject: [PULL v2 09/61] hw/cxl: Add get scan media results cmd support Message-ID: <89b5cfcc31e655a40919698a7f95a9208d6f12a3.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:56: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: 13739854 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 3BBA0C3DA49 for ; Tue, 23 Jul 2024 10:56:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDBm-0008Iw-2N; Tue, 23 Jul 2024 06:56: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 1sWDBk-00083d-Ew for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56: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 1sWDBi-0001ep-Fs for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732169; 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=dduTp5wcYjo09vfpghdORbOgCkDoPTC+bHFvhS4/wSgw2Bla3eKaPt1UsLNt12/r/xR8WA uoB54iZtDkOUEmEzxrS5QQfbVGgcgL/c8IUKaJfsJDZ8i4gabTbLdC7wq/+1nvE+CDFDJ9 q6tk2VNJJQYKt7w6ZryhAdz9MDZyOeY= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-134-4ZVNCmOrOROvaIvjdyJSgg-1; Tue, 23 Jul 2024 06:56:07 -0400 X-MC-Unique: 4ZVNCmOrOROvaIvjdyJSgg-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a77e024eaa4so457963466b.0 for ; Tue, 23 Jul 2024 03:56:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732165; x=1722336965; 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=b8Q0I2OwzKYscqBgvWtHkGePdN/BUs2MJ/kms2KLEkl7Gonn/tv4gWTyvEin9z3B7w ihMVbRuhMRAHMh7bXBYiHjSdr2uarQAyroq1tKYHkSTt9xXZLt5CtAlWNhqN88Jd8+oA rC7sdboljW759uLKa40zLIvp1uzmTrgM2DexRS8pqn510TfP2rZO985b7yTyPbPC+DQk vk2b6N3X22gsJWjAxokM6gDCJNcIvaMe6knK38pNrbhvgusjrc5duhW8xjc6GmupiGI7 3aUH2X0U37L1g9WOJjOSVl4+3K1/X642snM0YwjAfmeviVtj0inMGwSQdnEYFZCxzpZp 9K2g== X-Gm-Message-State: AOJu0Yzxy0NxCxHZokl/CKNHBdTk9UjaLso5sEVu3lwbgauYyk+OXJk8 H//6qTNGkFglv/r5030H4AKuxZogkodJvgm+jLPidGCTZchNBLzGUxk+Q6T6G1oQxPEj7wSKTqI M5kEtGcSybmQXMCeqbUvU+CUObZHUgIUmk0jnuyPiDIvdfD/jKeNd+dyjcc1jS7IPMjq+ihPk2e eSNFDjz9s/lBWHhWM0i11WH9G5YvPWSA== X-Received: by 2002:a17:907:72c9:b0:a7a:8da1:eb00 with SMTP id a640c23a62f3a-a7a8da1ec15mr165797366b.7.1721732165415; Tue, 23 Jul 2024 03:56:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrSalsGqBYZzhHzVrVAS1CkYT3XspGDskbnbFFcL86VZL18zWZPZEMi+Az6S5Y+oLZtwLHHQ== X-Received: by 2002:a17:907:72c9:b0:a7a:8da1:eb00 with SMTP id a640c23a62f3a-a7a8da1ec15mr165793866b.7.1721732164662; Tue, 23 Jul 2024 03:56:04 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c926bc8sm528401166b.157.2024.07.23.03.56.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:56:04 -0700 (PDT) Date: Tue, 23 Jul 2024 06:56:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Gregory Price , Gregory Price , Jonathan Cameron , Fan Ni Subject: [PULL v2 10/61] cxl/mailbox: move mailbox effect definitions to a header Message-ID: <25da36d5d04deb8869bd6ad1223832f09f3efe79.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:56: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: 13739863 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 CBE7EC3DA49 for ; Tue, 23 Jul 2024 10:57:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDBq-0000aP-Qp; Tue, 23 Jul 2024 06:56: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 1sWDBo-0000G1-T4 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56: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 1sWDBm-0001fH-CD for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732173; 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=g7JGZR31OU6BGD8ElOLPSBOCKlt4Cj96yd8+pBS1sl4LfItbb+rUHB4U5+f5L21bpTvHyn 1e5qGqME3xd1/pzf0V9WUchEsl08+hSP7/KGGrFhrQsDc5R1JAE4hpnl7vj6r9t3KUCrsv l5HPBIvuOxUqiYfMxeydCXpb4622N3M= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-197-5Iyw4yKyOe6AOr0R5ZRtbQ-1; Tue, 23 Jul 2024 06:56:12 -0400 X-MC-Unique: 5Iyw4yKyOe6AOr0R5ZRtbQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a7a97665b8bso46398166b.2 for ; Tue, 23 Jul 2024 03:56:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732171; x=1722336971; 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=c6SpBxPd81IXiRk2wmpjQbOxpw6pUN4xYZB/JFFl1DAJ0S4Y1VlJKGE5vh4iU3tkKR 4OBHxhejSaOpS1ua7qO7VnNVijqLFRo3gK+m+CvEldi97lntcnLDpGVXfi2V2kqRXRE4 dNEXd9a9KL+g7ZcR7VMGWGL5z0XrcCakrVC10vKmaYebLT6RiPu4PwjkmkZ4m3FWCCVi hKzItniIAMaxBLooT2cUe0N9AULsLi2W+2XJwMUX5IMpadE4ZjafMiQl+OCd9Zz/8N0s eEDtmLkkMBzbGxTPoTcIocpV4doS4zi/W/GFmLWsSNolezM88vkobBUzovz4sRUO1LbM 1EKw== X-Gm-Message-State: AOJu0YxH+104n04eSjcFqDmCQwUttl/fuERabKdIlTQAZZCgBxyxlIfH VvgGh5WajhvtvbWD0brRpPr8L5U2/bOiXwY/SuFOpo2Z0suhN87rr2LkObY8Zyj5UC99SKeiEO7 m1MQVAsrQ4ty85HUebXPqUDhg0n05Yyzs24VIu7OwYYT5hu+K6GxVTQEBAcjj1LtJ9bKzkYWyAn +LkTxMNIMkCbdJQMLv+U54IoGn8UCreg== X-Received: by 2002:a17:906:d25f:b0:a7a:9fe9:99d6 with SMTP id a640c23a62f3a-a7a9fe99af0mr66063066b.31.1721732170543; Tue, 23 Jul 2024 03:56:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiA5GbHYmoq5no6U0EE7NODEzbJVw7qdD23ongX7aJPc7ZwoCn37uz2csSiezBB2y7q7SIlg== X-Received: by 2002:a17:906:d25f:b0:a7a:9fe9:99d6 with SMTP id a640c23a62f3a-a7a9fe99af0mr66060066b.31.1721732169629; Tue, 23 Jul 2024 03:56:09 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a9450ba13sm66815366b.92.2024.07.23.03.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:56:09 -0700 (PDT) Date: Tue, 23 Jul 2024 06:56:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Shiju Jose , Davidlohr Bueso , Fan Ni , Jonathan Cameron Subject: [PULL v2 11/61] 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:56: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: 13739858 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 0A3C8C3DA63 for ; Tue, 23 Jul 2024 10:56:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDBw-0001Vs-Li; Tue, 23 Jul 2024 06:56: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 1sWDBu-0001CU-BM for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:22 -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 1sWDBs-0001fr-2p for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732179; 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=i4WzW+kBf6TRNsqthDeFzrE/cejVcVY8won2Nr4waP8lwO8/c7CzzwSm1YR7Kp6ppsN/TC NYuBA1t3Q/7zW49vtpmCK7G1Cb45TV0D8/8yq8R0MiWWQ5GdWnutaivZ5Ag2FdhmXuacBR Kk+3oBSshoirguZaz5AQcY//70hjXKw= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-679-QrKLZB1aMm-lsend54fwfw-1; Tue, 23 Jul 2024 06:56:17 -0400 X-MC-Unique: QrKLZB1aMm-lsend54fwfw-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a7275e17256so66446566b.0 for ; Tue, 23 Jul 2024 03:56:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732176; x=1722336976; 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=fQsU9NKPYCOzFkLcb1DjqO9OZkBp89Sc1aZ5IPUfN1G4Lvr0Xwx5m3Zj0+9fA+zG7K FLcvxuji7Ixu3qoIrspJHMViPRSFs/5HzdsW/HPA8iIsueoCSd3oTCPxp/oNd9ngB7Hk iEDRrfeI1IfeckdWvDgiLwPuGe1GbU37mn77YAdQ3F+qrXnTcXyPtwEFz78EaG+kdfYe 9BgMME6izfBVss5s8iXr22nOw8dxIv02TR7cWxkLEYJ2CRvgzG8OqkIRuvMHVch/2rPJ 65O27MbtSagUxA4t/XJcqh8DWydHPApc09+JMWDg3Ey9SkNMbflzE/nQznJ/bwN1Se51 lrNQ== X-Gm-Message-State: AOJu0YwhlF3S6T4GV3HEbLO8Z+jeUuypcIjp4j6quy0rBmHA5NjLsfHr Szy7z58T5zbtYewLizE5sNZCdCE4P3l6D7E2o+C+M3jHfeHq4+a+LIYISzADhiAVX8Vy+czJZzn fLIwuTfDRbG1zCrVOLLv401z81Nv4y/MbdDu35kh5WMwfrFHqPju8vJLVc1ktlPTF0dj6tz+OMp izC7M9HJmo1xRfMjNyrvxMNyeTrwUnRg== X-Received: by 2002:a17:907:7202:b0:a7a:9d74:21c3 with SMTP id a640c23a62f3a-a7a9d742b08mr90207266b.35.1721732175757; Tue, 23 Jul 2024 03:56:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG47+ya0PgifbhX+BSVJkLIaa7YW60xII+d2HO7Tj5KHfVg/jYPCrSOMoa7tBRV0SdaVDxRVA== X-Received: by 2002:a17:907:7202:b0:a7a:9d74:21c3 with SMTP id a640c23a62f3a-a7a9d742b08mr90204966b.35.1721732175178; Tue, 23 Jul 2024 03:56:15 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a92b11f7fsm70739466b.30.2024.07.23.03.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:56:14 -0700 (PDT) Date: Tue, 23 Jul 2024 06:56:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Shiju Jose , Davidlohr Bueso , Fan Ni , Jonathan Cameron Subject: [PULL v2 12/61] 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:56: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: 13739860 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 95F21C3DA49 for ; Tue, 23 Jul 2024 10:57:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDC2-00021n-91; Tue, 23 Jul 2024 06:56: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 1sWDC0-0001o7-IM for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56: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 1sWDBy-0001ho-EN for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732185; 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=XKBCha1/Vx1viC3nZvFtN82qZt9w1cICXD5dYKoT69mg8vph1FZ+EcMRPwMNy+B5J6I5Ib tS+ID6QpNq9rTS0H9yOaveS2Xu+k3ZGhRkNusLbxQ7HJkLyo0v/h8xGJgJUMV6XVSr3Bo0 nR1rB4AdJv30bl1NM5mENiFCy/A/Sxw= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-VXAP5w-ENFuZjmlymlYmOQ-1; Tue, 23 Jul 2024 06:56:24 -0400 X-MC-Unique: VXAP5w-ENFuZjmlymlYmOQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a77e024eaa4so457986066b.0 for ; Tue, 23 Jul 2024 03:56:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732182; x=1722336982; 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=E7aVas9steL2wTcezKaX9feuGKs6qjLicjHc9i4iCFLo5sFZTSfsfqPLyrS8QGh0RY M+ELfEm+Bbuh3OpY45gX30+oTKhGUic5C4D1MEHKitCRQWq6PaXK9thxWGt5s/cURa82 FRArdw6PB+P2igAB9GkYQP6Wa+PL/4alzzEANVrS7OkDDhVJJQt33MgUzgWvi2QLZEiY tcaHFB7hdoQpeom4QkRKQSp72nn2nDv8odoUbQDuOnbDjVLnWn8i5O8UuGC5MIcNJ0m4 8tC3+pEw1bpueniCRIlI785ioN9loBb1639hB3T8RFxJLUWmeCJ3saB5gxfNkS07S61+ oGtw== X-Gm-Message-State: AOJu0YxiHEyyMNgrLjGS/4XOqRLcqpfxOV/dMflHyyE33/GXN+5RfruY 8GDz+XNXLttHLPphmzgKn4uwNSf1Y21+NNLQ78blyHiDBmu2+UEByQWt/NfcojwDu3oFZFQesJZ AmHlQLgyCnc2xj+A+wLUDDVX8kG+x+qSDvrUfOrS3rI73WyRZH60oFLAnElCHzqVdaU35evaKzP uAxtgXnZtHNgMdqO1GeLviFghkZ9Vk0w== X-Received: by 2002:a17:906:dc8f:b0:a77:bf32:b91e with SMTP id a640c23a62f3a-a7a8847a781mr214491866b.49.1721732182383; Tue, 23 Jul 2024 03:56:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZ3zodNmP4n7W4iHdyxeYC4wWlOHBzHMcdXJQSd3ngCCD8gBPkF6cxCiSHfczMzDc0GifvPg== X-Received: by 2002:a17:906:dc8f:b0:a77:bf32:b91e with SMTP id a640c23a62f3a-a7a8847a781mr214488766b.49.1721732181665; Tue, 23 Jul 2024 03:56:21 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c785c6csm522830766b.20.2024.07.23.03.56.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:56:21 -0700 (PDT) Date: Tue, 23 Jul 2024 06:56:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Shiju Jose , Davidlohr Bueso , Fan Ni , Jonathan Cameron Subject: [PULL v2 13/61] hw/cxl/cxl-mailbox-utils: Add device DDR5 ECS control feature Message-ID: <2d41ce38fb9af3e66f85c8b8f9c3f83148c3d549.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:56:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739857 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 85BBEC3DA63 for ; Tue, 23 Jul 2024 10:56:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDC9-00034s-Bk; Tue, 23 Jul 2024 06:56:37 -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 1sWDC7-0002pe-9Q for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:35 -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 1sWDC4-0001iW-Oc for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732192; 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=bweogRqnx3PCECCs62pe9P+vtFzYQP0SyMr3minTO0bpuUXdreUNjIox5twfAnTdZlSgxe wAD6VCh+MJ+UJ2iIEoBSHTbR2YR1Xuv/jTrIX4FgYCHP2pOnkhO0ADEu+vjuebRFLHYaU6 gljrnRmF80cDZ2Y2wHxqyDd+Z9woP0c= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-371-7rnGWBXNMB2FbSX766miUQ-1; Tue, 23 Jul 2024 06:56:30 -0400 X-MC-Unique: 7rnGWBXNMB2FbSX766miUQ-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a7aa56d8b14so3855366b.1 for ; Tue, 23 Jul 2024 03:56:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732189; x=1722336989; 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=TSqmvFE0c29jOoJreLRpp9ZLaVT3avn0fOdwsMp0ogYRJqZ9h92mw81FHdlvDeFXWM LsEu24I/+X+byA0E8MN6mQyYMFtQ9T9CzioE5bSvOmiqDu9zfBaxZZvWaALyhvYeTvxx /Dw2FSU4mcpo0upoKrpmFzv8xW2BY2um6dZVla6BvPb4b67wczoQsPMRPNa23L4DbDED TDghby3PkrrrgOkR88hwZ/yOJ/dlvOBFWRFy50TJojO9CcX73TRtTI2xQ4pJanm4zTF5 VmEskgL9kOjEJvRlGAaT48sbnNG0f4kAtKmRsoy0J3WNsOqlBkxiUZFHP6LsJIz+OjiU XHTw== X-Gm-Message-State: AOJu0YypV1g7wGbkN2A3v/rLsTkqlcR04K+2B9pSJFoqmTLimIWiGUuw duzuKuDHQZhO1+BMmM6wWkd2ISsVVApO97C5tKDLGJfaLpj4YApSBQnaZNQe/idurmD5+nxj77E +zOXxRMWNSc8qJMJbrn9QKh9cV6ajWhTVTiWA5VOJ/DqVHNkrNRr+5nOCA0pZWoQ6KBmLLUjGUC OxUNpfmmwWvyvUh0oZTgq/fkLktlXqQw== X-Received: by 2002:a17:907:7244:b0:a77:e48d:bc2 with SMTP id a640c23a62f3a-a7a4bfbdd2amr701568066b.3.1721732188859; Tue, 23 Jul 2024 03:56:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHf+miQGCVRG1jmn9x+RTL/R3CVN6tV/LegxzmAHCZ9fZe0CjwURjHc3usx6/AR5EKEY/xaBQ== X-Received: by 2002:a17:907:7244:b0:a77:e48d:bc2 with SMTP id a640c23a62f3a-a7a4bfbdd2amr701565166b.3.1721732187897; Tue, 23 Jul 2024 03:56:27 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c94edb4sm523962266b.196.2024.07.23.03.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:56:27 -0700 (PDT) Date: Tue, 23 Jul 2024 06:56:22 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Jonathan Cameron , Fan Ni Subject: [PULL v2 14/61] hw/cxl: Support firmware updates Message-ID: <3c1e1e5e240e683f0611b96cd325471639f22c6d.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:56:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739866 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 4EFEFC3DA63 for ; Tue, 23 Jul 2024 10:57:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDCE-0003g8-UH; Tue, 23 Jul 2024 06:56:42 -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 1sWDCC-0003UE-Tc for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56: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 1sWDCB-0001jQ-AX for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732198; 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=i3GX1HB7tu+3OnPjXGKxg+gKrck0q7EohXOfKQoTSMR5/9C9aGTTx7YVog8MzsFpvryPt/ CRIDLgGhvvGBui6Wrib+v98JGLR4QspjXwELpD5MAngvD3Wi10BXH1TTsgBV6D/fCVfQOk m5b0m/ihPNTGf5kxt3t9rrFVNhU2fBo= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-36-izjAw0bnO_aiAP1cT9rKKw-1; Tue, 23 Jul 2024 06:56:36 -0400 X-MC-Unique: izjAw0bnO_aiAP1cT9rKKw-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a77f48f2118so114452866b.1 for ; Tue, 23 Jul 2024 03:56:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732195; x=1722336995; 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=S2CVHxuzpI7d6INg9Oe7KBxNCoJ9n8IVER+vdimkubbTswJ5xHU9HY47T0UmT7Haw6 RXELq2CPXcPxEGpwkLDSB+x4DUOfjhwZul3jLOS3Ou8EnHVIRHyu2OjrhbU2MMdG4ZU8 NG7Z31JmgRk4lO/+ME1VvpteeVPlLqr4Eehypyycxc10H3RtyA6URkL3qDCZGq1sQK1x x08grT8+Zx+i42f3u64QliPmsTa9Kjt3LKMf7gT2hely+Soi7/eOCeOrriThkr3qah8v nXTVRSMkKPOaC7duZvbXzfW/8z7K/hr8C9ot0qF3aro9Z7Oqtjf2o0OehXSXIN4NganK LQQg== X-Gm-Message-State: AOJu0YzBkL+v4rWwNOl8/UDLFuBMoaXrUfANtdtMsdMXGkO5zaKMrmJ/ jf5zVtSVAYcuCo/ooW3us07u6ND95qic2YpOC9nQeRAZOZ2x0Kw7QY1rXxka0LqRuKUMhdNHbp3 /brxA2lyMkggOYEolVn6e7WR2OjHuc5Gxh5M9ZmtUeXn0Lv/Fx15cVFr/k9XdwLyuCJhLPhqUhS RPjbzUmEhKsksTELx2lH7GNhELVn9lZA== X-Received: by 2002:a17:907:7282:b0:a7a:8a46:f613 with SMTP id a640c23a62f3a-a7a9435e5bcmr160969266b.26.1721732195034; Tue, 23 Jul 2024 03:56:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2cGc4HmC1jkYl3tVsc6EFNcsxxNcYs8XGOgz+X8EBEMEx4tZlKp5tRu7/BV8q5mWHQ1rhmg== X-Received: by 2002:a17:907:7282:b0:a7a:8a46:f613 with SMTP id a640c23a62f3a-a7a9435e5bcmr160966566b.26.1721732194567; Tue, 23 Jul 2024 03:56:34 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a99524d1bsm55567866b.137.2024.07.23.03.56.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:56:34 -0700 (PDT) Date: Tue, 23 Jul 2024 06:56:28 -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 v2 15/61] 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.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:56:35 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: 13739870 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 C56A7C3DA49 for ; Tue, 23 Jul 2024 10:58:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDCO-0004tG-Nz; Tue, 23 Jul 2024 06:56: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 1sWDCJ-0004Ki-99 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56: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 1sWDCH-0001kH-BJ for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732204; 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=ew+8NrDRlBjXidqWohQvNRrzbxcDmLes9Hq4DFgMTMbrNmx6ZZWh1L+qVoihYTYk+5ZA9W 7psABuKMZZOO9CkDzASsNL6/Ogt0BaE5j9MJFtj1LMZ3cl4ECVK/MS5h+bVHYXTlkrEL8O yxA3DEQPNFZ/DyOJMMQprM30L95/01o= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-aDQvbWMrMYW28nFPRlKDGA-1; Tue, 23 Jul 2024 06:56:43 -0400 X-MC-Unique: aDQvbWMrMYW28nFPRlKDGA-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2ef2018bb2dso26349621fa.0 for ; Tue, 23 Jul 2024 03:56:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732201; x=1722337001; 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=qGveR6qTQ1nUswJh8BlzjvgKZy1sZF6T799WosWZensOMpGHTKgi/7Vrdko9+lWY+w 18+rGkdEVhT4D7KNKdsS5BA97DrVfKDwL5jYZr+QX+3gTVqV8o6Iw0yaB+AUk/veRgBX ao7449TVje0LFKrOqXlKxd0Rl/JUIkh3XwfefcbNnwSfxFMdOy8/MlJSchrO0i2h3GmN jIaWlwluARtIsTBkDoFHSe5I0HM0NoHDT5vK+QB1dj49H0R76otTIbV0lC8ZWvCr101/ Mf2zngg4LUMCSuX9OtBQ0FG27m6maC1ON/95SmbfP4sJ8qrdWvhqORkqxufZ3WujQGCE jU1A== X-Gm-Message-State: AOJu0YwnE6wv3UUJ7niSUZlhex7+8O1xLUNKIHyOWfv1YVhEEs4fKL6g xeIgUMIHnpACchlt8WneVdw1UgwFm56KYhD5CdeA7T8vNdcZ3LTDhq2fz/nlSPP1xPoXk31vKZB 5795E570S95IdqAg4MPOZCzGqVUjLv27EZuUEIKTonsM/svNy/XzwzJpbBWue5/dA6lOojJpZ9A XxVlsiTXv3YV+u+Xg81Ff0kS6MCqabsA== X-Received: by 2002:a2e:b554:0:b0:2ef:2dfd:15dc with SMTP id 38308e7fff4ca-2f01ea4b5f7mr17443541fa.9.1721732201291; Tue, 23 Jul 2024 03:56:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5HdpyqHIKsj0FNrdF5wVYLLwxlqzQkGqXzwbx3/cb8qu/uj4paqtIC0zuSfQoowfZM50yKw== X-Received: by 2002:a2e:b554:0:b0:2ef:2dfd:15dc with SMTP id 38308e7fff4ca-2f01ea4b5f7mr17443251fa.9.1721732200568; Tue, 23 Jul 2024 03:56:40 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30a4d6c17sm7384250a12.5.2024.07.23.03.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:56:40 -0700 (PDT) Date: Tue, 23 Jul 2024 06:56:35 -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 v2 16/61] virtio-snd: add max size bounds check in input cb Message-ID: <98e77e3dd8dd6e7aa9a7dffa60f49c8c8a49d4e3.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:56: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: 13739867 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 4BDF3C3DA63 for ; Tue, 23 Jul 2024 10:57:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDCT-0005Nz-BL; Tue, 23 Jul 2024 06:56: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 1sWDCP-00055X-Mf for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:53 -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 1sWDCN-0001lL-Rn for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732211; 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=KERljwoP6zoUHktrkJH4gK8fqz2ZTv2FwtUV1qFPH1kiamExE8sI02ZSeV9AfvqW4Fa0/Z GQPxcTHGCPh76hTZnyEsy0K5mYKfGmrdOdRjeKYBd/hbRDC+a9pcdX5JPehvXYgMw7fGNH HZ9WsUEiWFHxdHWK20rVh2l7fPO0PSs= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-657-qk1FQLxzNgipUY9LWDBprw-1; Tue, 23 Jul 2024 06:56:49 -0400 X-MC-Unique: qk1FQLxzNgipUY9LWDBprw-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-52efc9f2080so2620011e87.3 for ; Tue, 23 Jul 2024 03:56:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732207; x=1722337007; 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=RcDsUooBne3bIUhQU8rKlP1WGIlzyzuCE3BdjXAx8BUEdJAxzq4MGK+jxeN+tbe82w OTNpeG+5/DLLKUDzp4oRyaA1asUTmq7xrHQaTnABucEdizp7qmUm+lES6NL7LnLYzEjO mzFkrLnCkk2Q2XmiYGg01FZgynAZB7iSGLUvTGoPyyF3bt9GFVFMBZeqviz10fDntNGt az4HUzfMudjuWSjKoq3CCR5DQZUlYeQqHIUrllxplQ+CsIHZv7vkHyD24D8gipi5TKzW WS7ksp/NQFYN/9rH0WISg9414Yta1A13/a5iN9p2Ku9v19OvYG9FzsOBiZOhh8indpym ItYw== X-Gm-Message-State: AOJu0Yx3RuFdW0Oo9uYFnOBzkO7Dh4Rakt8oUaqLXo/n7E3TUipYW59V nwyAMnj24GMc0NFmnX/aDxJsQkfc4yCr823vUVJwgDJ6PRToD96DW6PRFSkGLZuQqn5pU8c8HvD mr2v0RHyWP6jW+qls6wnRO8LFuNhJ4h3yiB7Zk+6WLirCBQegfFQAENQa8gnR6R5OFWa2GCbPws ik5yVtfIty3t8gKmtXFfx8KovXxLDHhw== X-Received: by 2002:a05:6512:3d88:b0:52c:e0ce:2d32 with SMTP id 2adb3069b0e04-52efb830c92mr6113915e87.36.1721732207221; Tue, 23 Jul 2024 03:56:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHc0VxlKxATko0Gnhu0Jn9ExUHt61MMhGDKdijp/QoF4C/PIjqdCNvyv7tdyehsG2ZNWQbznA== X-Received: by 2002:a05:6512:3d88:b0:52c:e0ce:2d32 with SMTP id 2adb3069b0e04-52efb830c92mr6113888e87.36.1721732206561; Tue, 23 Jul 2024 03:56:46 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a9fe99a67sm38047666b.168.2024.07.23.03.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:56:46 -0700 (PDT) Date: Tue, 23 Jul 2024 06:56:41 -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 v2 17/61] virtio-snd: check for invalid param shift operands Message-ID: <9b6083465fb8311f2410615f8303a41f580a2a20.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:56: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: 13739861 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 1B6A2C3DA63 for ; Tue, 23 Jul 2024 10:57:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDCY-00067z-9v; Tue, 23 Jul 2024 06:57:02 -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 1sWDCT-0005XS-G1 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:57 -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 1sWDCR-0001m0-4z for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:56:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732214; 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=S6YxBldOImiy/25yeTrFfisjV+4HdciBctL5RUTzJq085gpYw7xHMgBOhJ28N2hARtlbQg KN02j1xBWTiuV8HNx6vXXOgxG4k/+zDldpvRlkv41slnqyDtgWiMzwWZUBHj1Nho4k2GDd zKL31IbyjPPlyTWVlOqrkVlX5w4+83c= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-216-jHHNXMuIOqGxR89qSrvmng-1; Tue, 23 Jul 2024 06:56:53 -0400 X-MC-Unique: jHHNXMuIOqGxR89qSrvmng-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5a4c36f66c3so2157364a12.3 for ; Tue, 23 Jul 2024 03:56:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732211; x=1722337011; 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=lGx5UkE93Cl9XhZjYzqzS9RgTHmGKT14/8PasrkhpRg0esuPjy6W48chvJEzph49wB zVolVroPU98Wk40gLxa5KfRVRe5HRmGf/ockHgk7SgbYDRY+sd++CGOfJnZu0toeZeuO ceP3aZvF4cKdiEYZfKz0mh8MHWVDMAOtl6o60MfZ8hS3d7lcepi8ZOIp61iG81WyokTD EX9jof6/kHCT5+bM73SPzEj/i1d0qqhkad8v4dTzivU71i27UdNuW3TIbLG7oKNHliiA 9P6SBNCkFcf6EYseVwSGmM9vdQsSA1tyDfum3YDZxs/xd7GU3BO2K+6t6eNB6XZKonZ0 zt+w== X-Gm-Message-State: AOJu0YxBLWVqmvC2X8yrz8JMIyQAgJtVa14KBGY0voUQNib6ZENWSHJm 0m2JZYmsJasFxPIPG20bceNoDTa5lBd34jX3lCLDcOE5ebeAbbjf29OOR5O6L4J2SwLWDDmnw48 u4wMuCfYHnqZMLDq3UCMUKeK4zhxL2pkZLfwwXbR+FSTgdj6coFmh0uldO4d9xwMme3Crx68RaG iKXu41KpXKAsCA/LA6B3g+/hzNcTy/4A== X-Received: by 2002:a50:d703:0:b0:5a1:6c50:a3d with SMTP id 4fb4d7f45d1cf-5a9425dcb32mr1784973a12.20.1721732211518; Tue, 23 Jul 2024 03:56:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3Bf2C7fYAddN+JwEXsuze8rTSUY/vvZLURON/scoIZsM13h8EivqGbiTLJ7rlwCtDFVOQAg== X-Received: by 2002:a50:d703:0:b0:5a1:6c50:a3d with SMTP id 4fb4d7f45d1cf-5a9425dcb32mr1784951a12.20.1721732210988; Tue, 23 Jul 2024 03:56:50 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30c7d213csm7307711a12.80.2024.07.23.03.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:56:50 -0700 (PDT) Date: Tue, 23 Jul 2024 06:56:46 -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 , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL v2 18/61] 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:56:51 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: 13739888 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 498A3C3DA49 for ; Tue, 23 Jul 2024 11:01:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDCt-0007kD-9P; Tue, 23 Jul 2024 06:57: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 1sWDCc-0006gb-Ma for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57: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 1sWDCY-0001nJ-TH for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732222; 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=HhkN6j1TUamlZYS2pNnZ1MwtU0UISzRtgkwth6Cs7b1kN8YvtICeYtBWXtoNDgPxrV3jLp r/+iihxHM5/bSTwJfzd+0Gu6S/330VuqX6bfsOyILUAt04hzC0i5dnzBeJN0x5h5d+DDNe tQIwddFk+86Q9TsqKhUy44eCDKNs58w= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-538-gCzwjs6uN0a7ROcBD6BD1g-1; Tue, 23 Jul 2024 06:56:59 -0400 X-MC-Unique: gCzwjs6uN0a7ROcBD6BD1g-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-52f02833519so2403657e87.2 for ; Tue, 23 Jul 2024 03:56:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732217; x=1722337017; 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=s49UZNT4y2Hy4JHxlw4Dw2FmgraVZ+RLqkVVPDHd5jzjdKjnTewR96XOMJxog6IdqA B+ycTRRZ5bfNZBBTHPF1Wu8lLq1tFjiv9SL6ucCbSlgnV1pxEG1NWTir4eBaRa8v7jey haI+gvi9JlfoGNohrzLAmPzWIICrO0DumpTor3U3oHWwiQjTZcJly3r2FTx9Bawsk0H+ JxYTE1xkk4y0SF2FiXu/O5deSEUQZIA9fhzLeZIjAj/Uc54BKHr7yZV6vFm39iNCgrVA 196XReZPnJfxiNDPX3UDs0G0xad6IDMVYmk40ddci84vwMaSo7aMQ8KSt9lfLmRJCENP 6Gew== X-Gm-Message-State: AOJu0YwW2wTZUgG/UBEq6Q6SoHL+J1Dbc0xbt1iOXtcpDf76pP814UVY ulkLz6daCsTd6IiADRCuZf49a96cpR7l8kIKzsRG2CT0WrG7ftCuEFKl30ta6mdYgg/75mb+8OB 24Im8wZzDY0d559qJ/iJ9QCpELBHCW0R5crOJtjGbaIWASWhqdcIZNlQGELUo0Kw5tPsp5yVDut mlpaG8GRc5u2TLw4SWNeU9O4IOwoVPgQ== X-Received: by 2002:a05:6512:ea0:b0:52c:dac3:392b with SMTP id 2adb3069b0e04-52fc404bbbemr1763546e87.33.1721732217162; Tue, 23 Jul 2024 03:56:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGA/nkg2nG+CmFagKaSvPvSmjfuzyLxQzejYMP7Lxd8rCbJUCC7UtdqL0qn+BYoEb0VUjTf1Q== X-Received: by 2002:a05:6512:ea0:b0:52c:dac3:392b with SMTP id 2adb3069b0e04-52fc404bbbemr1763516e87.33.1721732216378; Tue, 23 Jul 2024 03:56:56 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30c3f0673sm7298041a12.61.2024.07.23.03.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:56:55 -0700 (PDT) Date: Tue, 23 Jul 2024 06:56:51 -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 v2 19/61] intel_iommu: move VTD_FRCD_PV and VTD_FRCD_PP declarations Message-ID: <3a23554f91c01cf75705a36a5eed3ebef6636d41.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:56:56 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: 13739862 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 A43C1C3DA63 for ; Tue, 23 Jul 2024 10:57:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDCw-0000Bz-RZ; Tue, 23 Jul 2024 06:57: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 1sWDCe-0006u3-IQ for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57: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 1sWDCc-0001nq-Dr for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732225; 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=FF7hEwLlmZ43G008jmf7cv1KSINLu1NUmspkMudW3NIyJCMnJn1SE0vSZXjkvKelJce2h9 TJmRfFfx06esNi/9Lax0VWSrWIxtbcR51ndG+gh0mKoCEZr7lziWAKcmmrEsm5Xu+uZJyM gZeO8BXpySGt5E/TR36MyDhTxG6wW0E= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-573-fyRdH6TVNZ-x-MstMVQ81Q-1; Tue, 23 Jul 2024 06:57:04 -0400 X-MC-Unique: fyRdH6TVNZ-x-MstMVQ81Q-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5a2a0e94a66so3994082a12.2 for ; Tue, 23 Jul 2024 03:57:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732222; x=1722337022; 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=ItuQA0GanUAoiwA3d1CKR+Sda7Y/jHD1U2PwBpzM5Jk6iRMqw5Ijffy128xReh4LOf v2z7EfEBuKMETmUGm87dOHT+/tC+qHMJfu+XK0+SeMnbx43AxjcJN4sqcCNzYGi5NsTJ SbOvYMPg3USY7cyE7fKJJ32D+noLaKvxQenHik5jVrxqsK5nQoYksRPBGiqOVrZ9oUYn lfa83rK+oLu/9t6zYCRG+HWvjGr40WtfUCIyfQUwEC05eHQFV9o7eK4l9tdmP6YCYweC PcQY0uND7PVER72wH5DXfKiQ5ZFG1/2nbBVtu31jO1B1KfrKj8JDtD9YH5X2jt/jdn7v 7xdA== X-Gm-Message-State: AOJu0YyRAlNE8+ndKz1QzAZHsAHPDUxBbqTaDGXVQ7RgXJJsPwCCVCKk kgK23AIYIT6ipgjwVP1uTmM1Ndtz8HS06ZXBoShL21VMsjW6crbdiw6bg0NWek+JniieneAr2uJ /NEw7E9e6YQdL+V2VMkwVm09Tk8uqHAgioRN6RxZyZx+rFxN/frs+YbxvgJO0zUrT1++4mwOdJk nSZ1nlOLebNhlrkKN1pLDgNjKeOInR+g== X-Received: by 2002:a50:9fa8:0:b0:5a2:6e1c:91ed with SMTP id 4fb4d7f45d1cf-5a47a61f401mr6277824a12.27.1721732222516; Tue, 23 Jul 2024 03:57:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFngaLEWVNAm2xW3IjAH02fubLsBqMy5kprjDrw0tjkKVvh094BB0CqQbSXa190El3/pM08WA== X-Received: by 2002:a50:9fa8:0:b0:5a2:6e1c:91ed with SMTP id 4fb4d7f45d1cf-5a47a61f401mr6277800a12.27.1721732221895; Tue, 23 Jul 2024 03:57:01 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30c2f8645sm7313748a12.72.2024.07.23.03.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:57:01 -0700 (PDT) Date: Tue, 23 Jul 2024 06:56:56 -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 , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL v2 20/61] 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:57:02 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: 13739869 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 7924AC3DA63 for ; Tue, 23 Jul 2024 10:58:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDCy-0000TG-OL; Tue, 23 Jul 2024 06:57: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 1sWDCk-0007Jd-Na for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57: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 1sWDCi-0001p9-DF for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732231; 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=f7PgfjR90IluEk5/oUicWFAV1co/i1Lw0jq4WKI6tNB1oCm4eFjfhQp5pRKdUj3HKGR1wl 2eliOAddH5eHERXj2S7IArgo5m2KAR2YreFiiZcT+PKpHwKRXhsNX2JD2UOBFj9UlsO2tg KQjq21LTs1jaofyAe8756+PHKZHrVjI= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-259-GbKX1lkWNKqmO3pb2-HCoQ-1; Tue, 23 Jul 2024 06:57:09 -0400 X-MC-Unique: GbKX1lkWNKqmO3pb2-HCoQ-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a6f571c3eefso47958966b.2 for ; Tue, 23 Jul 2024 03:57:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732227; x=1722337027; 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=oMLxQtesteecibGPK1MzIqjWzfXXcTubxBH1nTe3DjbSAhttmolhnAkhGpa9TkhICS jKYDprKy3dXxxvGnE6PaGH7IhjD3uSOzKf3yZZsx6SAveMrH/N0ojVkk6JEkIpM2oe9E pWsy0meQonh1VSFvC8fRapTnblhuIbkXYI3bylHyL69xU+sUhyuqtHEedUVk/JFs8Vxt 8pn4Zu2T2Z4MbVKy9mcDWU8Nv+dQ05uKafEnxyRdX9G+Xb017mI/kwEEKH2yj+7bZtXA fOOa9LeWYC9w5EayvwFgnRSKEl+TASRk9PcH7T3BfrJBkYrtiu9ZOl4tWgOyFlnIJvYm rJFQ== X-Gm-Message-State: AOJu0Yxre7/cWF8kOA2GBB+59mVigSLjeAeqxpanG/YgsRZnAiX9Quqc zBWZ/VAhxHkt5Mkbt36ZyMqepWLSAYmMvU2dzZ7GdTZOoI7hN/kqOZhj9BkrMYFfuSMDNOGZDuX ZhEGFo3Tp6SozUqURep4zQ+TlPKKyssbrjarU95dv37b4LJvEI7aulMwpOYY9SA3id2LnJZAmNL mijqP4PjfHnT2ZcWo4AchOUr95zhXXlA== X-Received: by 2002:a17:907:d8e:b0:a77:eb34:3b4b with SMTP id a640c23a62f3a-a7a87c006e3mr208357666b.11.1721732227410; Tue, 23 Jul 2024 03:57:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEx7tvHe+yWAO1iXftKoVDSyAZJFbauRNkPZtPTlgWz5Ug1UR82mHbjHEXMSJooAXJRVukIw== X-Received: by 2002:a17:907:d8e:b0:a77:eb34:3b4b with SMTP id a640c23a62f3a-a7a87c006e3mr208355366b.11.1721732226874; Tue, 23 Jul 2024 03:57:06 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c926bc8sm528496166b.157.2024.07.23.03.57.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:57:06 -0700 (PDT) Date: Tue, 23 Jul 2024 06:57:02 -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 v2 21/61] 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.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:57:07 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: 13739873 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 E9358C3DA63 for ; Tue, 23 Jul 2024 10:58:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDD0-0000dl-2C; Tue, 23 Jul 2024 06:57: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 1sWDCo-0007b4-0P for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:19 -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 1sWDCm-0001pm-FI for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732235; 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=BCNrajToRvOWZ/l/Hwu8v/qHwfMgopz5gMWf8Jdm31xMZeEjXeRbtIwW7VgsN2aruQIEU0 IfuWr539+V/2c4dgNyxQ0XJyrOzB08mpEozI9c+6ovFSE6oAeXfW7pRe0Ci5d/J3yBxp88 blu7a/zq3j5B9HyiKJKXcdKR22Fg7J4= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-100-OFSDCSTcN1CoExorfHofUg-1; Tue, 23 Jul 2024 06:57:13 -0400 X-MC-Unique: OFSDCSTcN1CoExorfHofUg-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a77c6ea022fso114972366b.1 for ; Tue, 23 Jul 2024 03:57:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732232; x=1722337032; 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=rnxK8TnMhb4ttSzZ60NNaS7G33+YSXVz0cjMsseEUXQWJy1TVQRFJjed63Zt1rxFid hLVvDH3wJtZNpivmsc4mlHk57eDOW/txWI18ZPtUIvqlUrj/eA7xAXRsf48pZxyj4+oM SbwDcyWTfg6zH53cmTGPDHIcR+/epGhT5tHRyD7LD8njLTEVCOIZqWJngld/r332OJxd Jihsf5yE4iKHeUUIvYSRfa1j0c7rBuqdm6imnO5atP8ih3zgMgAzIlLwSoL3Pp9NptJE WcjE5zcUfZ7rF+dMoNbtFssLg6Ocg2gAp94P5xSQJTjBV2GzpVoRgDt/+2ucUhP1o3MS 21LQ== X-Gm-Message-State: AOJu0YzQShL15TekZy5HcKXHvbZtigaFIV2Kp8r6io6ZlTFzn+K9t8Zy BsEDlK7xVa0Ra7jbzaoe4FGDgoofHi7BCLvqdLEnh8pR2/lpW/OsyWwUdTj+mOY442DvQsBNLkZ g7s42oGx7HOk7e2cAHZR99YpqjmNgxEKMXdkJFAwLh2F7iGYH/OVvstlNhZkG5pMN3lk6D8p+Eq C9kWaGMTcBAIbPYS2C5pstiiNjPtsAww== X-Received: by 2002:a17:906:794b:b0:a72:afd9:6109 with SMTP id a640c23a62f3a-a7a9427d9bemr179256466b.16.1721732232093; Tue, 23 Jul 2024 03:57:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHL7jyIfDFXSQ/d72+GKtR9rBxX7yfG4N0kg9gOGRBb5nwyx8wO6MsdoEGs9Tbx5KlxG4MLQ== X-Received: by 2002:a17:906:794b:b0:a72:afd9:6109 with SMTP id a640c23a62f3a-a7a9427d9bemr179254766b.16.1721732231623; Tue, 23 Jul 2024 03:57:11 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7aa309243esm22425266b.151.2024.07.23.03.57.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:57:11 -0700 (PDT) Date: Tue, 23 Jul 2024 06:57:07 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?b?UMOpcmV6?= Subject: [PULL v2 22/61] 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.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:57: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: 13739864 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 178C1C3DA63 for ; Tue, 23 Jul 2024 10:57:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDD0-0000pK-UA; Tue, 23 Jul 2024 06:57: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 1sWDCt-00080R-0V for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57: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 1sWDCr-0001qK-A0 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732240; 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=Q4EOPnsRjhpPojfIM4x6YUP7NYaoph/fok9p6Av2+4z5b96lNZbzB1y+2GAr65eyNkgct9 LpXmGoQ1/U/SKSadJwYxuEws/P23qw2nBmQIve0ir3HXXD/JsIrT2NmcSRLakWlQqnsylX 2egmNsR5Y8t2NftgI7b3DxzAxzWPBe8= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-240-FM7KPkqYNHe0zXPYMzAYdQ-1; Tue, 23 Jul 2024 06:57:19 -0400 X-MC-Unique: FM7KPkqYNHe0zXPYMzAYdQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a7aa5885be3so3308666b.0 for ; Tue, 23 Jul 2024 03:57:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732237; x=1722337037; 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=xDfk9K9OpgkAHM7Ug28qPo63lKLrQrt5g/oKSLemHQhrmCyK73I2KTitmYSqOXGSLl a9/OSFmzzYUZWptLTtEvlsl21N5hOq6fpprvIHhdmuz9/c2ZTh6expE09ZpirYzKtnyf cg+9AGOCL1miZVWE4ZkQkdG4SX6EAwoWnYdRtUH/YxOlYF3olEQGDDXidCiItu9RAZpJ kmykyoWRh6UwuOBAso//tjOU/Gy3LIWwM1oOgxCV52j3Sky13a336R3KjD13jtPRzsf8 nbsFi3eWYupSePTXeuMvatMIqsOLI1PUyMCs3v9jlgzby1yQpAyxSi/y4q+YcG5Cmmif CVlg== X-Gm-Message-State: AOJu0YxRXCOu9xYM059C2y6xTBmj9BeXL4+n3UcvyiYEH+7hJLoOFBr5 WDu58kRvAAbiirvh5KHI2XVdu6Te7ICcsawWJBvkhzoMHuUQUlniPIK4hgOGVbrLq4Y+rj7/kX5 kKal3kks0GgFwq4w5ASHr37/U4BApaa/28zf90A56L7aVLfUF+A1/EpQWiQkyrVv0Jja6/LRnyv 6Zdstbs3+iQYPfAGqMwF2oUBI7edYH6w== X-Received: by 2002:a17:907:7244:b0:a7a:9d70:82ba with SMTP id a640c23a62f3a-a7a9d708385mr87936166b.16.1721732237566; Tue, 23 Jul 2024 03:57:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6VnwoambekezAkLISItS3GlqwHu9fF82uSeCq6y9O3BBfcgtJOi+FnmHXe43ZAjxqNUQq0w== X-Received: by 2002:a17:907:7244:b0:a7a:9d70:82ba with SMTP id a640c23a62f3a-a7a9d708385mr87932766b.16.1721732236822; Tue, 23 Jul 2024 03:57:16 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a81ba1eeesm119402066b.71.2024.07.23.03.57.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:57:16 -0700 (PDT) Date: Tue, 23 Jul 2024 06:57:11 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?b?UMOpcmV6?= Subject: [PULL v2 23/61] virtio: virtqueue_pop - VIRTIO_F_IN_ORDER support Message-ID: <2256e8482b2bba88abcc734dbc6951b825773f0b.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:57:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739880 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 4639DC3DA7F for ; Tue, 23 Jul 2024 11:00:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDD3-0001ee-T7; Tue, 23 Jul 2024 06:57:33 -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 1sWDD1-0000xT-C3 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:31 -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 1sWDCz-0001sT-OL for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732248; 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=E4ZKQ0/TcxIX0j9wYI2b9JN7j8LZd9TzjDbQ2Jw0xQKsvPw95SJ1WGtrvZXYAJZep7PlDt /AiINXbu4jk/ki5bahOweomGEDwYebdIFtSSWNV5npfONSQbMlD/WcTRYxlPK+9RkdWC4t ZuLjQFhI6UZAcwxCqkaBMRpI8hPAeZs= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-597-mU4XfLthN2qpQq0-765Bng-1; Tue, 23 Jul 2024 06:57:23 -0400 X-MC-Unique: mU4XfLthN2qpQq0-765Bng-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a7275e17256so66563366b.0 for ; Tue, 23 Jul 2024 03:57:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732242; x=1722337042; 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=hfm+setplO28ArN1kkKZzKbu5yu+hkIm5jx7LyuEGiYz94xM82FrSEkj7g7RLCreCi mbLSdAByWpu7TawB5AaHMWVm0247YK88zKjxMh6BfQJKh5HaHufJRdTwvbcLOaZGKZXi yx+gzOqwr4DAEGae2ihjj2dNPGoUiEkJRvjos3t+2GC5/GvwFPx4Svt9osys18gITgBa uOaNTPxAZjl8sNKGrcw/bXz7MXrCvgYvW0M/mb+nbdek2PHQeiCUBmduq/caB+T6hH3v tZU4+lATvXtjHZcAFBeOHwHpaAtfwNkyEjIXfeJsQeTkOYDHmaHql+/tQSGIoPF1wQeW 1q4Q== X-Gm-Message-State: AOJu0YxNAxSZukUPTwmyV7ADboUUbY4BNw+2E0w55yEMH688zPeCz8Ix 5US9Q5cIT9Xb//VxZ30YKrrUAW0cIYm4VvB6u50qTbHq9DhCnAnvUWSmnUwzRGYXAzrhR3dyTFu uFALLW4kORyDgH/0gmXS7Mp621GkcQ4Gz0DsY+p7fYZwDmfCaR4BPvrxpcFrIsC1ToASI8B8WoT CChGuyCF5e+eQjymRD4P/WNJflDj7+CQ== X-Received: by 2002:a17:907:9802:b0:a6f:501d:c224 with SMTP id a640c23a62f3a-a7a885c0000mr198632366b.57.1721732241801; Tue, 23 Jul 2024 03:57:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHg34gI0PgrJ8cHVpW3Qth79LE9q4nprJV8uQAqveHQXGSiOOwd4XNJceaFYMoptbKPqZ0MTw== X-Received: by 2002:a17:907:9802:b0:a6f:501d:c224 with SMTP id a640c23a62f3a-a7a885c0000mr198629766b.57.1721732241074; Tue, 23 Jul 2024 03:57:21 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7aa49f3dfdsm11788166b.145.2024.07.23.03.57.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:57:20 -0700 (PDT) Date: Tue, 23 Jul 2024 06:57:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?b?UMOpcmV6?= Subject: [PULL v2 24/61] 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:57:21 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: 13739872 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 63A53C3DA49 for ; Tue, 23 Jul 2024 10:58:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDD9-0002kn-Hs; Tue, 23 Jul 2024 06:57: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 1sWDD5-0001zd-2N for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:36 -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 1sWDD2-0001sw-RM for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732252; 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=DB7B4Gjwk0ntAzqJC0vFgXXe1bD2LnE+Y5FKAzbrB4tJyTImnlL8/wGv5oXrLqJee7hMz8 93Vv1kipt81tM3WaXgVfrrVhgyfaZFFDd6SBNCML863gJVolW+iqM708vv8aYxgnEZv7qM ycb3rJExRJy0HNN3BI4GybvHmmkB9oU= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-306-_zXZJW8qNFKqBFN-AonMSg-1; Tue, 23 Jul 2024 06:57:28 -0400 X-MC-Unique: _zXZJW8qNFKqBFN-AonMSg-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5a25d0755f3so3236057a12.2 for ; Tue, 23 Jul 2024 03:57:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732247; x=1722337047; 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=dGgXCUkjxH3+enAoZDsxA8r4JYfEolKpDZH0tu/aNiRIxiZiivGMEcUh0XQFLpjgrs wLi9z/bkNi43AOcAwGSY8rR8KV/4eJqm8f/HAuj/4dCrWd80pAvE5CtLQ4H47NcoUJQr 9RHXDKd160IZNCedSO0Tniq59woa+H8ikp35LFiuir/RNGsK5nM5GH13h3szzHuFuJ00 +KeQsdRO85OV0y2BabBWjtHrliZK1htfDBd5rXwYoO2kUpbzUWoi3fWv+r0ewXeVRjXC 4nLkEZHLqCyzR5EOIoym+UbM/GPU0pCfchH6SDfAlJguZJ0HsKMWI/eI91Ewp20+Rzoz uoSw== X-Gm-Message-State: AOJu0YzplaYcnknuXoZQmpW2piIbVDQJq/aI1jFo1A5pG6k4T8TvjakD /UgJ32LcR+IFkZMkmq88hAn237fYO6370SyDfKsTo50E/6wyq5/hNDlrhC/wzwXz8NT8yQNIeh4 3hDfJLbMmldA2TCE31+8ZZE19M98iMtzVfKJvCtuSr/btIwBwhNwiJoogRfMWHzqJ0Lh83w0yoY DGwXaNlQHZQmVqcGdudkcMLKe/Mri2pw== X-Received: by 2002:a05:6402:3546:b0:5a2:1f7b:dffa with SMTP id 4fb4d7f45d1cf-5a941a3b8efmr2343590a12.3.1721732247224; Tue, 23 Jul 2024 03:57:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpfts+xPIp1bMaRTQsfI3VQT9rHvUAt79xd2cpBbDz9kAKi1U+YS1AYWowlYiTHFtKDyTG8Q== X-Received: by 2002:a05:6402:3546:b0:5a2:1f7b:dffa with SMTP id 4fb4d7f45d1cf-5a941a3b8efmr2343553a12.3.1721732246195; Tue, 23 Jul 2024 03:57:26 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30c2f86d1sm7280295a12.73.2024.07.23.03.57.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:57:25 -0700 (PDT) Date: Tue, 23 Jul 2024 06:57:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?b?UMOpcmV6?= Subject: [PULL v2 25/61] virtio: virtqueue_ordered_flush - VIRTIO_F_IN_ORDER support Message-ID: <844619147c5110f335cbbbad51cda6a898c7ef33.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:57: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: 13739883 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 3E50DC3DA70 for ; Tue, 23 Jul 2024 11:00:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDDI-00045q-Bs; Tue, 23 Jul 2024 06:57:48 -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 1sWDDD-0003T8-Vy for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:44 -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 1sWDDC-0001uB-8R for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732261; 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=RrCJuI1Fr/OvP9PzjcXlbigbZqWUtUGG6UVRPcfP2R9z657KHEijZTPwPj81ub+D5tx7Ho Cr168vLY2z1jXWBpDOOdqDfoj1Pl3ap7Pspgx1iTycyAAxuZHxzqTnwFrsfkdHBcmfbzOC tc0QxvclV0w88yOE6gt2pPocGBzvb8Q= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-284-QRwusUtDP4-Vft7CwHvlQw-1; Tue, 23 Jul 2024 06:57:40 -0400 X-MC-Unique: QRwusUtDP4-Vft7CwHvlQw-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5a30be1c5cfso3657855a12.0 for ; Tue, 23 Jul 2024 03:57:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732258; x=1722337058; 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=KwwRR3e/cbnmmDj6AYBo+XWskB9YhQan+GsREgIzb7mnZ5ab+hBEN5B1DIS+Z05aid axYBM7a/qJ2jDy7CIGUEKUurfmc0W8OS7qEaxfoXlsBvoTCndVZHBvlA/9c4YKfJXeDO JRAh2sxdkA6OUAI+KY6YoCv/Z6u1ZBP9taPQW/6jCF7oY1t+/2p4tBD43eo28XOHuC6x L04IP3ZQodkaM9ir0O6ffOHtyj4AOsyPM9SZDvI+F/Y151DnjG6omDQOSk32OKwIjXnj axotPPiVWK8nhwhpjUishS5z0ImnU0TcKoMpNYmh1epC9SSUW1OrjkBM9JMmwO+JLcVh R64Q== X-Gm-Message-State: AOJu0YzG8oRpVGUgakMnR3F7DpRO8h1Nqh6NF8wMDeI3IaSFgpgifbSG +FoRWB/K/wbT/8PhsUZ2IHCL+YNlZmP32ZlacymeVZGSUIhJhnd0I/Z2YqrsGVCTWk0kmpkPNuA 4/gfYVRaikLVlyrZMpWtNh/EfTpUdJGebFIg5gXPGzk/8p+DzHzfQcAPcNAL7Ljm3/e3rNeyg+J vy1IvHJixua37lkOurCbsfUTnTqEFoNg== X-Received: by 2002:a05:6402:1d4c:b0:57c:78fb:1a32 with SMTP id 4fb4d7f45d1cf-5a479868705mr7207792a12.19.1721732258544; Tue, 23 Jul 2024 03:57:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiXAdByeISpuzV0J0R8F+5FeBI1tgARwVqnGDO/N30uEpPs6FmJ6G9oxSAqnIxOPEkqAF/7w== X-Received: by 2002:a05:6402:1d4c:b0:57c:78fb:1a32 with SMTP id 4fb4d7f45d1cf-5a479868705mr7207750a12.19.1721732257899; Tue, 23 Jul 2024 03:57:37 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30a4d6c17sm7385168a12.5.2024.07.23.03.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:57:37 -0700 (PDT) Date: Tue, 23 Jul 2024 06:57:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?b?UMOpcmV6?= , Stefano Garzarella , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Jason Wang , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , qemu-block@nongnu.org, virtio-fs@lists.linux.dev Subject: [PULL v2 26/61] 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.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:57:38 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: 13739889 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 AFDC9C3DA49 for ; Tue, 23 Jul 2024 11:01:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDDK-0004Rf-CD; Tue, 23 Jul 2024 06:57:50 -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 1sWDDH-00043V-Tm for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57: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 1sWDDG-0001uy-98 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732265; 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=RnT5chH9gEV7x5r+TLRalWaAJ84lFaEVhlODwhXmsUNE9bKbVXo8PRj5egVtkdebT1l1sQ kfJmsR4WkJS13h3CSx7NKNCo8KT/auCQqnybesSGd+4ZVQ7GRajhrp+c2O+ODQSyiL47S0 yKV3uHB9ERFKi/6YtS7VT6g8q9bvQg4= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-49-3XUBFoKbOIiuEusXqvRiHQ-1; Tue, 23 Jul 2024 06:57:44 -0400 X-MC-Unique: 3XUBFoKbOIiuEusXqvRiHQ-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a77c6ea022fso115023866b.1 for ; Tue, 23 Jul 2024 03:57:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732262; x=1722337062; 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=aric/AkE6M5beGpnKCD1jC6N7aFdP+n+wkclYFMJufKBSU4Ikf9MWDtmWB+KiYM3Hd gZTKfbnBHYSP1avnjqR3N/0V8QLIMkb+PDeDlUz5Fw2GXYSNgpo9ofnjtxMA97IWz5kn hQB1Dd1P9WCcnUjs5opbdnii+PzM2WiaAR0pOi3lylI5rLqIwZsMlAfxrsHE+RvkgYSH y7yiHSHUyTD77i7d8t4iLupr7B15yvdmr+Q5ajG6bZi7kbYgltS/il3ayZRlmnw++PzM C4+eZkSByn1Aq/XvLfpUBEOWAd6/NzBcIZk4/7KYh+vPPHxgHARo4MIiS+7NaqBHbSgC 0J4A== X-Gm-Message-State: AOJu0YyqguIDXAJRD2KGGIbve0oOw5iIPAYn6RtfawrbMpHfUTbNIeiv km/xaW+NUYRoWRmCKew0UdNU+tXYFjwRjx6oUV8Y+HhNzF5mQGguu+uJ8RqjPClmClMTiES6Cyp dxVRz5Ooi6K6Dyk0VJiGljBDW24dR+xVGm1W4JnNIuyED4Wot7gbKsP2cXXL+myfMLxyqxYx8aN qr1va+Zbrwu75SJl0rb8RoVObDvZgIjg== X-Received: by 2002:a17:907:7d8e:b0:a77:d9b5:ad4b with SMTP id a640c23a62f3a-a7a9424ec2dmr182119066b.9.1721732262497; Tue, 23 Jul 2024 03:57:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEB6lXnvla0A7/BGaTicXR+yl9n6GLM/shEz2UcbCs5L5zya+ff8MnsMI2uJag6zk6cTyQf1Q== X-Received: by 2002:a17:907:7d8e:b0:a77:d9b5:ad4b with SMTP id a640c23a62f3a-a7a9424ec2dmr182116566b.9.1721732261858; Tue, 23 Jul 2024 03:57:41 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c8bed67sm523190266b.124.2024.07.23.03.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:57:41 -0700 (PDT) Date: Tue, 23 Jul 2024 06:57:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?b?UMOpcmV6?= Subject: [PULL v2 27/61] virtio: Add VIRTIO_F_IN_ORDER property definition Message-ID: <0b0bb34f342f04ab8255a64edb7c6aec7105dc94.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:57:42 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: 13739881 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 DBE4CC49EA1 for ; Tue, 23 Jul 2024 11:00:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDDQ-0005Zn-IA; Tue, 23 Jul 2024 06:57: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 1sWDDO-0005Av-LW for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57: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 1sWDDM-0001vZ-Ts for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732272; 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=Yn8e5JB+gwUr0KeGSgGtOmL7c6Ee+mmuq6tEjByEkeNltqV8V1FLb+EAIPVTAtDJDJlKNy L6vHoO0Msu+q+J7MFRy4XDrSfHEvvwt/+dnjAZ6EkQMyNaIG36YT8jDy2+4+eRXpmBstwe Z2LsxdpSXAFHqaFoyQZsK8sMqhko2sY= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-MiOI5KRUMjynlv24USLzSg-1; Tue, 23 Jul 2024 06:57:49 -0400 X-MC-Unique: MiOI5KRUMjynlv24USLzSg-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5a8b0832defso2166585a12.1 for ; Tue, 23 Jul 2024 03:57:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732267; x=1722337067; 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=fJfSmAj6deUpNEoqgTDJXYqgb1Qi7lXHVJB+sYWQaGtlCpPAbwl4yrpf17G1O8wWWn cFGUCXYSuhigy0YymaFFOZCyRefOU12ENDxtQZWNd4AkO99rUPlBn/fcHVD7+RZsBWFw BKI9Wl75NLE3NxUJg7M11xRqqokDD3MwhXTuJu2LW93xBJrpoj37dGJZGdxhqKwPSz+V p7nw5vAR1dhqUEoGnKXDFrPdzqXKaAgao30Gy7HnWvGc57lVAojeWv3xRNgYyko/TJLN i6sjOHKOLjmfNB7oo4oIy41BEAGtXFeVVIGllTWEFooduDJpTepnQKCCl5qBRvxSqOF9 A2CQ== X-Gm-Message-State: AOJu0Yxvyd777twFTisTmwdL1tzIGqmPG5ZBc7ve6dJIHV44QRHtpfQJ 1BukfDNx6TW/Nu5VHuvIsl0XuxsdbrQxDP687VSPL2/dCnfAVFfUaV+Kah5i+TvNHCtEzuOdbvG JGcD+glLh+gTwi1bHvhOkAFj/X+DeOkj15LGSQKiBU6M/hAuIDp5VmzxsH832mlnsxRkUoAgvXP VVQ/7d5Vf/NzE1YULYkA48/DzA73u/0g== X-Received: by 2002:a50:d50c:0:b0:58b:bb69:763e with SMTP id 4fb4d7f45d1cf-5a99d304448mr1515377a12.7.1721732267424; Tue, 23 Jul 2024 03:57:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJIVWtaTeKjKde7N0jPWl801Uf70p4/47YecoBtFV9nT8OnXhRCx2uTQnzF/qPUbt7JxLiIg== X-Received: by 2002:a50:d50c:0:b0:58b:bb69:763e with SMTP id 4fb4d7f45d1cf-5a99d304448mr1515356a12.7.1721732266873; Tue, 23 Jul 2024 03:57:46 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30a4d6bf8sm7339533a12.18.2024.07.23.03.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:57:46 -0700 (PDT) Date: Tue, 23 Jul 2024 06:57:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , changpeng.liu@intel.com, Raphael Norwitz Subject: [PULL v2 28/61] contrib/vhost-user-blk: fix overflowing expression Message-ID: <99d7c1b99a3fdb69213c09da6b7614243f877bee.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:57: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: 13739877 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 2FFCBC3DA63 for ; Tue, 23 Jul 2024 10:59:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDDT-0006LD-NP; Tue, 23 Jul 2024 06:57: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 1sWDDR-0005y9-UN for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:57 -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 1sWDDQ-0001w8-6G for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:57:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732275; 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=pwA2VBCGiz4cO1daPjJvYeYj04ydpVIhSZo7OAfHiTw=; b=ieJD1E1+ynnlFiMnBL5nQNWS42FpabnMw82KHHncWK7jqjLCI4IeNqlve1h2hZaBfM90nt ww7o5ghOpxunDMmvA7b/PjZ7eCecaf6IXqdjYQfci+MvuiYfEfa5iqCsdn43qxVjUmTaus aXdlKh6y4fhgQIq5f48KpDUYjrmwIQ8= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-670-xQ1RFnPvM_GFSOCOUo8rHQ-1; Tue, 23 Jul 2024 06:57:54 -0400 X-MC-Unique: xQ1RFnPvM_GFSOCOUo8rHQ-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a7a859d777aso61161266b.2 for ; Tue, 23 Jul 2024 03:57:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732273; x=1722337073; 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=pwA2VBCGiz4cO1daPjJvYeYj04ydpVIhSZo7OAfHiTw=; b=eKqXjgFxHS2Sg9ravFEuvhPni9HL29Cw7aTGDHLEtrw8ABbQAOfvFcQjUv/gM1wu8o MmNcL7T0PlXJCszm/ml6F5F8sr+46/4vcRS9mkDU2GCHKZhzEVjipnuPANuKIIJjA3Mb KBHQdO+jZ4lonVWhdZesUF/02eRxOx8P7V0ZQ+4BVwM6LLUbAuWGkigjUH2PnufHbgSp 0a4H3528OAQi7ifGSrxf9dGNGkoS7MU3NNYG6BBRJkWg5NnZ+6LatVgKBzCNBpxvwB4a oiBMm1WJqzKT7+PEgrzjzNv+BEeGOZNAiPm5VUjW6LWeYWVmYesRdGPc5IvmhmSM/v7q 2xhA== X-Gm-Message-State: AOJu0YxFgWTOZrrpZtgiqq+EdpAMlU6JXQbvULdPlnlCj/zZY1FxmN3v aM1krSxkvcRmxxHyJ79TjSpKFwx91TdAN/j1qfCYe3jkS0gg0WRyFoxxYfvwKix2mwCz+4GkaP2 WsqXnERRP13lGqr5eykMdnuGP13StJVW+SQjS5AcVADKw4JiI3YzMGtdK6apK+dSjrZohJatyla KyPZY+/YebtR94oq2vhJqwx3LkkIrgcA== X-Received: by 2002:a17:907:2d0a:b0:a72:48dd:46a4 with SMTP id a640c23a62f3a-a7a87ac5321mr200009066b.0.1721732272660; Tue, 23 Jul 2024 03:57:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0ZLSssb5IJgCKYwhDNCmmX1MEgUG+E75g7V/qs+XbUujmENRP1OFMq/IjvKNvbOv5e0xlCQ== X-Received: by 2002:a17:907:2d0a:b0:a72:48dd:46a4 with SMTP id a640c23a62f3a-a7a87ac5321mr200006166b.0.1721732272070; Tue, 23 Jul 2024 03:57:52 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7aa439e40esm14094466b.48.2024.07.23.03.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:57:51 -0700 (PDT) Date: Tue, 23 Jul 2024 06:57:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL v2 29/61] 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.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 4c7be52951..cf2794879d 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 Tue Jul 23 10:57: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: 13739874 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 27C3BC3DA49 for ; Tue, 23 Jul 2024 10:59:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDDf-0007yR-Sp; Tue, 23 Jul 2024 06:58: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 1sWDDZ-0007TD-KE for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58:05 -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 1sWDDX-0001xG-W6 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732283; 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=BOJoRTYNaDI863daH82J/tD+rOJ2ad/Jp9S/pgjKVuXzOQwssykdLLU0RGeiq3amNSDQBN vJzvSZHI/uMqXIK0jd4E6iLuJLYFdTQI112PbyHiKv/ebAkREhslgxPWjFH4vSVpA2DDsE 0wRB9Hu74G1dMuj1nhc9w/bGJxWkkUY= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-164-kEyWMpaXMlyHO6Dc9JRysg-1; Tue, 23 Jul 2024 06:58:02 -0400 X-MC-Unique: kEyWMpaXMlyHO6Dc9JRysg-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-52efe4c2261so3546393e87.1 for ; Tue, 23 Jul 2024 03:58:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732280; x=1722337080; 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=Qblzu4N0aMl4y/zAuwtHbv+aFi+1GgZkY/8e2I/vwSMiuIZTmtUzf0nIAvIzYuujSy p3C8mROc4X3JBOxlpvEjkWtodwU/yfUlkksGYl8qZJQ16pxIioiRcFzLm6wnda3ySjXK aIYGAS0U96YgqF/HsWH7SG8cBZR3coFvbW2a3XY6bQjSgefM//dubQTmxvVuSwOBt2Xf 3Vsl0WYp41m6K8jAeGpMxT2b+TaPx299y9JEuxIbP0xjW85TlPJMRgjiilDarzoTwC2I q2yqOssbWJlBobcBej4xohEfk4d+1ycG/uKIoN00A7+SsZvmBnwFY7jLxBkuZR0KPnnH dz5w== X-Gm-Message-State: AOJu0Yx5YN5ECYPMsSm9DH859+w0xKRRTXgqYMt1vk5co4u0Ov5Tk6tE ga9y99IGTe3CS6hVAYyY6UvIH7NXcaAw0bvbWCSaisWiaJUJN2xmclb0xMXnwQmssMI+T0UGvWx fS4DX8Tkg36RCdBJfngRJJHwPpbizaEDTXy5FgkhAr4CGH0SLJ8/b5R+CytMycv7eiqPPKX4Uat LROJ9G+PxDcKygJ6maSAB5rkMDB+Jq+A== X-Received: by 2002:a05:6512:3d88:b0:52c:df74:1577 with SMTP id 2adb3069b0e04-52efb7ae98cmr8776440e87.45.1721732279960; Tue, 23 Jul 2024 03:57:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnwwWZ8y4aMbR9vd5lfu1BOH1yEITGJhHGuW6LFJgXfv2rdnEtuCLM0mY6V3IPYaiGIhZPDg== X-Received: by 2002:a05:6512:3d88:b0:52c:df74:1577 with SMTP id 2adb3069b0e04-52efb7ae98cmr8776396e87.45.1721732279135; Tue, 23 Jul 2024 03:57:59 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7aa08b6f18sm35935766b.46.2024.07.23.03.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:57:58 -0700 (PDT) Date: Tue, 23 Jul 2024 06:57:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL v2 30/61] pcie_sriov: Ensure PF and VF are mutually exclusive Message-ID: <78f9d7fd1989311040beff54979bcb2a1ba0aff2.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:57: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: 13739905 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 C50CCC3DA49 for ; Tue, 23 Jul 2024 11:06:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDDl-0008SD-DU; Tue, 23 Jul 2024 06:58: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 1sWDDf-00080M-3y for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58: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 1sWDDd-0001zg-Bu for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732288; 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=ZSeOqHK2T3nT+rfFombdVcI614Cs36Vu0twnnA8najaylT5OVrwAePWaR+sR0izsiY1Kuf 469YKR07LPzZbuItt+ENZNEcaoA4EOmdum16sY5wwn5PuEj0fdVVn29skHoOGVqqBhI9xT dEoCvHfz7gC2T7dS2nDXpidp3pnaYB0= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-379-TFyoPy-rMqKg-szauTTM2Q-1; Tue, 23 Jul 2024 06:58:07 -0400 X-MC-Unique: TFyoPy-rMqKg-szauTTM2Q-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a77c9c6bdadso49428666b.2 for ; Tue, 23 Jul 2024 03:58:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732285; x=1722337085; 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=dM1gCBTCAjBJ3FxTI19U8Q9bopR1onOH44Sqp6lwafsAKrBLE9yJxzNb3lrUObmr8g bGH/wl9PfS0kdYttg/H4U/sShSj8V8t3q/lqhvkIQJSDIwMtUCX5KyL13omFZtrLFsH3 7hkHCrRmgMKOier8em8df2efHUZ+E8K5A+JkVaPfr9U2ncz887JyypfDUgb2ym29RTgW Dbx2FIckZYXCQOHbUNOyw7RqbCEhsyNKkZLhtIE4LE35TrZHAng7LeGXhLyf9itCYZAf +UIyH2yIjlzxeZOUmQeV0t7qXuh7ghMXhVbd3yc823WPLmTj+GSVoCyNk58l9ABe6gyc AMgg== X-Gm-Message-State: AOJu0Yw7t/2mS8/o0eDsvUABj1rOTG4fPv3tOF+7IKeVvFD+j4iMTn9H cYgnC57cOzJQ6inEP1IC2J1mFfwp6iJluFnxKqw0QFEKGMLCVGzzXp1RyNvtNgQJVlWLfOj3C03 WjQghkB/TVTXFm7L9fjFdgpRSqD5X+7k8SJxIbOT72XbR2GRW+x0g9qZG3sqtvG7wOFCFo/YJYw Aw2lsQc6AwlOuD228BRzavKg+WdNeQ4A== X-Received: by 2002:a17:907:72c9:b0:a7a:9ca6:530 with SMTP id a640c23a62f3a-a7a9ca61448mr102186666b.15.1721732285607; Tue, 23 Jul 2024 03:58:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAMQsJhpmY8QtPvRSK0lRctPSq9aimacbA+5UIDYnlMxAhSumexQia6lfbGizwtruv9bbKLQ== X-Received: by 2002:a17:907:72c9:b0:a7a:9ca6:530 with SMTP id a640c23a62f3a-a7a9ca61448mr102184666b.15.1721732284957; Tue, 23 Jul 2024 03:58:04 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c7b650asm524771166b.49.2024.07.23.03.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:58:04 -0700 (PDT) Date: Tue, 23 Jul 2024 06:57:59 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL v2 31/61] pcie_sriov: Check PCI Express for SR-IOV PF Message-ID: <47cc753e50076c25334091783738be9f716253b1.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:58: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: 13739904 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 C66CBC3DA63 for ; Tue, 23 Jul 2024 11:05:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDDu-00014N-1J; Tue, 23 Jul 2024 06:58: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 1sWDDo-0000Zb-Ev for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58:22 -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 1sWDDl-00026E-D2 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732296; 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=Eq8q4QWbRnEkEx8giZM5sb1jfBL59arZa0DneCo3J50=; b=LW0gOoeOLlQ1cLDLIdiJglGoNTNvk5eOkGOh2sjG61/2ewHWvl97PgITB2U1sU9lFVcjvO zd5VIfPzjcT4FnWC7l04h8KQj+Buke7CtyeqzbbkTiFrFg6exOqFQufkLG2Bw69F8+fSaF BYMXcrm8auV/H0kLaKNC2lMkMvCUXHM= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-367-ljLISzQjMEq0xvlSEW3yfA-1; Tue, 23 Jul 2024 06:58:13 -0400 X-MC-Unique: ljLISzQjMEq0xvlSEW3yfA-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5a7c6a0f440so1290457a12.0 for ; Tue, 23 Jul 2024 03:58:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732292; x=1722337092; 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=Eq8q4QWbRnEkEx8giZM5sb1jfBL59arZa0DneCo3J50=; b=a8Jqz+hwf/h7QecpAbDJC3cKalGjXoN+UuyAWqoa6kQ5dfAmqIGZQW+xtB/vIjHEzH T7p9nZsca+lpRo5K/5SLTsMi0Yp2I1gZPgSjvOGTWOSiwVd1KOE3kBceyVUnSOqEeqiR q+i9d3b79zQvn+S9Vw7x98Tu3cfLy2XC0ZDuWfHuIzeQiwCdUQ2aQ/GXpA78MFGWAAgX OgUssPm1qtsVAWObP2uVXjpqDe+9SVu3BAVlja1M8ORCAcyKLR+HmioqYt7N3g6eqbbS 9yxDDvAU3hybC41Olxu1dysEoUqZZtpOmxCZiZZV6/iG1ET4mj0sJDipUbUGCwf+mYv1 fmJA== X-Gm-Message-State: AOJu0Yzml+nDF8uR+gvlzr9d99cGwG3e/uYry8lO/WTQP7/+UG9Vn95M dLr0FIjHy+AUlCOR3AfVnMOaYZiteUAz7NpJNdCPThJEzFyC7IOrAWwVPCaV+rjQj6myKsaeWo+ kLu20EGWGKovdqhkOOlHbDx5QJd7yOawyj4VNLpuk3p6Ua1bK90lyb60IpxPlGXYeO/j2rF3aWk IoU057rditCe/wehqw0HBApXChJKnFLw== X-Received: by 2002:a50:ab1c:0:b0:5a1:32d1:91a6 with SMTP id 4fb4d7f45d1cf-5a3ef375f5fmr6625166a12.22.1721732292091; Tue, 23 Jul 2024 03:58:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGG/huzhlCoi1BTDCo0Z3LgVsn9MY4brGdsw+EgtW113awJdOcZxQYtDQxptb1PdoPHw9EVug== X-Received: by 2002:a50:ab1c:0:b0:5a1:32d1:91a6 with SMTP id 4fb4d7f45d1cf-5a3ef375f5fmr6625130a12.22.1721732291322; Tue, 23 Jul 2024 03:58:11 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30c2f8645sm7315014a12.72.2024.07.23.03.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:58:10 -0700 (PDT) Date: Tue, 23 Jul 2024 06:58:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL v2 32/61] pcie_sriov: Allow user to create SR-IOV device Message-ID: <122173a5830f7757f8a94a3b1559582f312e140b.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 cf2794879d..8ad5d7e2d8 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 Tue Jul 23 10:58:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739884 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 CB116C3DA49 for ; Tue, 23 Jul 2024 11:01:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDDt-0001DJ-SI; Tue, 23 Jul 2024 06:58: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 1sWDDr-0000k0-6p for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58: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 1sWDDp-0002CY-Ij for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732301; 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=E/fvjTz5ovr570QNuYYH95nQFVDXO5a4BexYas6Q/Vz9Bq0KBm35BjXYK9e9voJ7lX+7wa 8d2cAccTkljlO5yASSeV1DAYw8wBx3EEFK+PVbMlST2qN7POMv3Z2CHzXiocWfXxSIb6TY qUCa0IJhe29ps8QKcFV3hrlg+iP2+Yo= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-504-ei_kHM-hPs6V5w-dEgfoEw-1; Tue, 23 Jul 2024 06:58:18 -0400 X-MC-Unique: ei_kHM-hPs6V5w-dEgfoEw-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a77cba34cd0so446987166b.2 for ; Tue, 23 Jul 2024 03:58:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732297; x=1722337097; 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=fnuPrdyqNYJkTp21homVSCt9TB3+b/PAbFwBSp1GKDpDdtXsDFVqnl1UUHd3ym1ql4 Ds1lJr7/yMjExxDpNeUB4ABxq/ldbJsRdurqtc9AM479coXMNuC8NcZMD0sLOIFiLRVI OanJ2uJ/B7Dmc44ifdn8Aznpe6RYRVxzx3r8Nq0dXBr3Zc+Bl27GWyHxnqc+/m2R9wUx rrgnoFO0X+rFZdt0JDLvzmgRzN+ziCX22siodKvd0q4R+wMw4xgSG/ZQ6B5biQE+etyN 5wBdtyQqsZlrwelIPhrVuxeIk8hDG0kqnXDLyJj5jUQEW9MrmLNKC/55bc+DWt3pGzaj YtDg== X-Gm-Message-State: AOJu0YzwlCGEvnTfqPFC4AgAdVUujkz69Zr3rOLLW8z6dSrooOKBbc5O 5dD73dZVbOp86TKgwZS1LrgQh7d7StPbyqEdxi6+iGSRHvV9JvQP2STyy3SvmlyLv4mMGkea/57 mCS9Ts9kH1FrjUtRESUOHXCXy4h8bqJCXJHxDSxNFcP3asKAztoJ5TmyTyYaAwPK5cSlFlylCbQ lHMxoSHNXGP/gX9yxg+7FCp8UsIbJIRQ== X-Received: by 2002:a17:907:9489:b0:a77:c548:6456 with SMTP id a640c23a62f3a-a7a4c424f3dmr634679966b.59.1721732296905; Tue, 23 Jul 2024 03:58:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFweVQKmXHbqUATmnqFQoWBtqJw2FJ0qOg8J0UrhS0eGsBG778Vhh9bP9C6O6utBnt/rHPJlA== X-Received: by 2002:a17:907:9489:b0:a77:c548:6456 with SMTP id a640c23a62f3a-a7a4c424f3dmr634676866b.59.1721732296136; Tue, 23 Jul 2024 03:58:16 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a8a4de922sm93197466b.56.2024.07.23.03.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:58:15 -0700 (PDT) Date: Tue, 23 Jul 2024 06:58:11 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki Subject: [PULL v2 33/61] virtio-pci: Implement SR-IOV PF Message-ID: <3f868ffb0bae0c4feafabe34a371cded57fe3806.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:58: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: 13739885 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 C5BD3C3DA70 for ; Tue, 23 Jul 2024 11:01:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDE3-0002JC-LU; Tue, 23 Jul 2024 06:58: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 1sWDDy-0001us-MC for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58:31 -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 1sWDDx-0002F1-7j for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732308; 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=IvRe32dAAqhFKQff/7jlT8Mn8C+IDG+Ld2ZOwM6Ji85o2Wl1cdw/acd4570uc9DyVm7OI6 vAFE9RFCrRXK6OA+Y/D2sHIN067lbmhjRfnat5rdkMDth+Nd26U911r6rJfsByBWSjqd3d cp2I0lW5rxcyjrlq3gPT7jwRBeM/sUg= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-531-perHOdtjPaSij4Nj3H32Zg-1; Tue, 23 Jul 2024 06:58:26 -0400 X-MC-Unique: perHOdtjPaSij4Nj3H32Zg-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a797c5b4f47so51214166b.2 for ; Tue, 23 Jul 2024 03:58:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732305; x=1722337105; 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=OeX9ppJSeHRxj68EB6ff0P9p+bnmi4EzNwzgNk60PDtALWv4qQDK6wBj8TCX+cliAi 1w3yNG3qedtWgZadL9JJO+7TnglSVCSPTY7vXKgnjTp4ddkp5nHe3vGlFw1yaMV9GOoD WEZhtA6+2I7CuqDz1twdnl9YUHlWkzf7Tf76ozetr/DGR+8SnHBA4cXgwzt+SjkHQ5D+ ZfZKJ0Tk/rC5vPdPY3I+UnfZIk+lrmYEpQ+/W8KNgd5DF/Z45BvAN7I3iHxZKw5MXAa8 S8uAHq+E0iVd9wfx1HSt+se8Yp9pCDRalUvqSCCZTmd9rfXOjR/R2mVtcsEGPZu7ZmO1 eFwQ== X-Gm-Message-State: AOJu0YyMsDChNhY9PyCym5VORB76uvXthMQBhG8pVeoPr+aCu3kI7R+X uU+DSTMAJBN1KiDVJj7z+npHcPV8XKTH4z8u1HYhTucoSvAsQL2nDS6OptoZeR9YitOMRZfT7yu LN78+KeAkmv3ixzSRXsQxVBGuBdg7fNnGwe9ldtsfXqKXxHpbnVEOVyz7+hpA6fQU+LyJ2j0Frg 6+qtUWQP5L+ZWsRlip/gJMo0hyKmPn3g== X-Received: by 2002:a17:907:980a:b0:a77:c5e4:eebf with SMTP id a640c23a62f3a-a7a4c225797mr708769866b.54.1721732304990; Tue, 23 Jul 2024 03:58:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdD1iUnh961jTRqz5Kemev4gldowZNdF/cKaZYE6BgoqY3EOTc4rw/rGpz+LMsnxKRqEOkrg== X-Received: by 2002:a17:907:980a:b0:a77:c5e4:eebf with SMTP id a640c23a62f3a-a7a4c225797mr708767666b.54.1721732304442; Tue, 23 Jul 2024 03:58:24 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a8d9b2d1dsm81809766b.63.2024.07.23.03.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:58:23 -0700 (PDT) Date: Tue, 23 Jul 2024 06:58:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki Subject: [PULL v2 34/61] virtio-net: Implement SR-IOV VF 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:58: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: 13739875 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 C2FA0C3DA63 for ; Tue, 23 Jul 2024 10:59:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDEB-000303-OE; Tue, 23 Jul 2024 06:58: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 1sWDE5-0002R9-2S for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58: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 1sWDE2-0002Fw-NI for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732314; 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=UkJPngvuhDLfMcpKX/790upCuh+i67sUh5G6cs18I5FqvQn/Id7a3j1WMsjL+fqxuKeiOA x7ul62PAIUNIen7T8dEisSLe5Y3kP5RX7S3PeoW1yuK/LpHkBoz4PLMRK7aWzHkW5PVIpZ P0MXooGkJGiDSaBNMl7qaQasOiMvpXg= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-2vkn-68UOT2ldQhHvwdXVg-1; Tue, 23 Jul 2024 06:58:32 -0400 X-MC-Unique: 2vkn-68UOT2ldQhHvwdXVg-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5a355a541efso1428423a12.0 for ; Tue, 23 Jul 2024 03:58:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732311; x=1722337111; 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=sI/Dq0kS74Rf2DsN6A2LUMg6VrQ2LrHbhrnQlEHdNwqDk+PFHXfBWmUDoDbTApVKmZ JzXftn3b90jTlBGFsPqLdi20AX8IGldBx7sqUqKdoCVQ9yNwuojqy6bM0KY7LccVT795 AMvA/FKE2RoGyBJEPWusAaSqj1A708y+5cJFL7IM6aPgjxODKfkBTFUJN82onI13maCv L4l+bhll/RnbEbUm2/J5oSHHDDskeIqts/FgDanCr3q+hF0HQYKULMTw/oi6vQcoSjo6 JLT5BaLt+jWKhF/Tmw0nCiIT4h3HvX1FbJWUNJdj9gVJ3K+QjnR36q0IvS9HPdj5djg5 EQ2g== X-Gm-Message-State: AOJu0Yxw3RETZ+2f8hjCJL0RBQZ85w/Mxk0ETUr2EcySa5Spg7mdr1aX L5zznWrDPImrKyssTrJiZg0vrbxIzPnTKUrKMu0fJJsqEpjDsXmU4xqR7QZ2u8ooruZT1Kaf0tA IoPRtQBZOVs8VbS2cKNYIAousQrRyVenuN65KiTrdG5850NZYZEEP0iAH1d1+5M7/00gzDGkLFA MrZqlnUc658P7upq2NR7oaIFyQiry6Yg== X-Received: by 2002:a50:99db:0:b0:5a1:c4e3:a7a8 with SMTP id 4fb4d7f45d1cf-5a47b1de8afmr7229807a12.30.1721732311277; Tue, 23 Jul 2024 03:58:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcv9lXMcodxGXV8Uj0uGofXExG9ARXxwDi0tk9K4EadDUX6g4anfSTnwersMGA619+JYIY3g== X-Received: by 2002:a50:99db:0:b0:5a1:c4e3:a7a8 with SMTP id 4fb4d7f45d1cf-5a47b1de8afmr7229786a12.30.1721732310592; Tue, 23 Jul 2024 03:58:30 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30c7d38f7sm7412156a12.88.2024.07.23.03.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:58:30 -0700 (PDT) Date: Tue, 23 Jul 2024 06:58:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL v2 35/61] docs: Document composable 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:58: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: 13739879 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 CA725C3DA49 for ; Tue, 23 Jul 2024 11:00:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDEL-0003hf-3e; Tue, 23 Jul 2024 06:58: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 1sWDEE-0003MF-GW for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58: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 1sWDEC-0002HP-OZ for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732324; 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=BNENl+EqPo0MKZ++21VbVJSF3mJNTbaK9OfbmkzUl7bAqYyb7/x02nlXLqbnmZ48NbR3U7 auLjx4aY4W/qH25EhRJBbkMD2QQFp9XpRzcuDy775WuBftCjOZX3a4gLLcPBq1GxRo7pFn 2UXShn8dfj1eeP/ijBivL2aojKZrA0M= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-enijoQrVMKqRxYYwmOnqiA-1; Tue, 23 Jul 2024 06:58:42 -0400 X-MC-Unique: enijoQrVMKqRxYYwmOnqiA-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a7a9761bf6dso48742466b.3 for ; Tue, 23 Jul 2024 03:58:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732321; x=1722337121; 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=VV96IggrwFqSy79h/Dqcy2XTYw3jADn56nMiVYv0MEGxfSfwwUR4BbjvpNrKxgXdHi CT9+H2qUbjecz34x7bdC5y3Kp5b/5G4KEscNBXHmPnN9++K35ha88ePb+jOfSIm7Vlmm rt+7r4DVaL8cdnW5XvkKVxcUsQdqRNcQvtybHzAawUwHVMmk8YwjQ73c07c10AzSTQdp vQug7KKBmhsNfcKSh/osMty9d7UGA9cLFPlF0CyB9m71FMfDLQ1e/JVl7jl1mFJfomWA fgU3zp5hMARxkbpu9CHT36N6uir6/+xYviLURMDIu7NlO1k7oGmhmy6MEVPmKxjG7jc+ OZVA== X-Gm-Message-State: AOJu0YwgGsYlsidfhbkpidb2QPxS3QkTs9twjzhlGP63o8oTPBZIStCJ 3M0wdqYtsNjehVK1Xl/QnSFpbuccsYa7/Zkj8OzWRa4JePt9b/f7X26/upivcxwpKHrUrG/T8XR DwsJoSguARRcCVPOhHNlgxfHvW+O7KGB4Cf2r4StC7ZzWQCBgvHMg9S70kvOQ5qUE2dWFUJ1+6s kqEeKsDf/1BLOYRLDwwYRBX6pJxxLL5w== X-Received: by 2002:a17:907:6d17:b0:a72:5f9a:159a with SMTP id a640c23a62f3a-a7a4bfa2290mr646429566b.2.1721732321257; Tue, 23 Jul 2024 03:58:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPiDP6q4yFh2zc8g244p/9/BKe3OcO4IPrS8Gp/M67qY/vw4jzg6IKp/NzrzMhDC9zSSgkPQ== X-Received: by 2002:a17:907:6d17:b0:a72:5f9a:159a with SMTP id a640c23a62f3a-a7a4bfa2290mr646427366b.2.1721732320657; Tue, 23 Jul 2024 03:58:40 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a8c70c3b9sm87295866b.136.2024.07.23.03.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:58:40 -0700 (PDT) Date: Tue, 23 Jul 2024 06:58:31 -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 v2 36/61] smbios: make memory device size configurable per Machine Message-ID: <62f182c97b31445012d37181005a83ff8453edaa.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 10:58:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739876 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 EB8AFC3DA49 for ; Tue, 23 Jul 2024 10:59:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDEY-0004kP-Jp; Tue, 23 Jul 2024 06:59:06 -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 1sWDEP-0004JO-4N for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58:57 -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 1sWDEL-0002Ih-TB for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:58:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732333; 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=EEwJ/ObAviXV/9XXY+j3mkIxDvzZNOSjvMFEcV9aEDP5IQxS6xzsc/EIRKgDDckrS/ncWZ M1HRoJDefLaXlS/+2ccJfNSS2X2jSXCOJaR67VEfU6ldM3yNNN0TOm+Krkc3yt3n+ACc4E hLCX5azCOYGc2X+OE4mREP13XquXL3g= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-315-EY4eTrk-MsuG6-pm5oj2QQ-1; Tue, 23 Jul 2024 06:58:51 -0400 X-MC-Unique: EY4eTrk-MsuG6-pm5oj2QQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a7275e17256so66665766b.0 for ; Tue, 23 Jul 2024 03:58:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732330; x=1722337130; 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=GWcLUc4xvSGclC26cmqf9Kq/iRLHiJWaObinniOhwFAByOR9ILHvAnnFhtCsmCkD9v /fUcVcfPzx96mLTJ1tP8XDKf7wJ19DeUeW3s2TCzSF86/iw0AP04zUIh9SeqhfLNX57I dLqK1f8T1b1gfT+m5DaJvK5MVLZ2NfFrFejP7nl4IQCOOkcEvhNcFa1bMUdkVM1vDE3z ZLcbwOVKyk4EuCnKEdJsr/Y4Qq2G8PPWscfJqLA9sq4yPjGJYXqmcC75RBuAMIJ9fCi9 5eH9MeUTbDWOVvybSUMZuzluDzaYx2Jiwr81No4x7Em3JtwIQ7ZKywzlkojOOQ1RZQp6 pRwQ== X-Gm-Message-State: AOJu0Yys2sLnKEEo8+CBBhLfFEoyfuuDxT6bGlQjmCS2OzJPfKLip2nM qwpBEgWvi9P6eq+ALPnCjbkt5g+rmKMHWO7ROf8QFnkrtV44zr8jCpe1o/wxw8ZUNchGMdQeorC 6SRYJZpGjIncL4kFs+3nA+vJeApRC1KH6dm1Uq0yyJWjtV4RsLkVM0chM8Bin8IJPW8Ids0b9rl PPvAnK6VPh0uzooRzxyHYtnDp5XQGYfw== X-Received: by 2002:a17:907:3e1a:b0:a72:4281:bc72 with SMTP id a640c23a62f3a-a7a885c0116mr213143766b.63.1721732330344; Tue, 23 Jul 2024 03:58:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHS+lV5X0KnV2eekJ8Nr7/km7oFVnBuMqehOWK6EvbJcKcc9Fpvl/buXNOEi+jKmpCtI2rLpA== X-Received: by 2002:a17:907:3e1a:b0:a72:4281:bc72 with SMTP id a640c23a62f3a-a7a885c0116mr213139566b.63.1721732329546; Tue, 23 Jul 2024 03:58:49 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a97c0731dsm59682266b.19.2024.07.23.03.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:58:49 -0700 (PDT) Date: Tue, 23 Jul 2024 06:58:41 -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 v2 37/61] accel/kvm: Extract common KVM vCPU {creation,parking} code Message-ID: <08c328682231b64878fc052a11091bea39577a6f.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:58:50 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: 13739906 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 B7616C3DA49 for ; Tue, 23 Jul 2024 11:06:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDEd-0006C4-Lf; Tue, 23 Jul 2024 06:59: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 1sWDEb-0005hs-Ki for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:59: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 1sWDEZ-0002K0-Tr for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:59:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732347; 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=MrCI/F/ucFYcd7SEi1v3X6KJITdejSwgDsKKSO61C5AilyWL5SMGWL1ss3xAF/Px0Y1TTJ a8lfLDE+dANNdniAGRv+OnDeE0UoASixFysI+TMSjtx8motOif82ePE8lAR7Mz1J0KSq1r gJEviis+mcCBllLxDCUu16RS3JWNbAA= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-141-BMycfZljPgOHIGIHDLjp6g-1; Tue, 23 Jul 2024 06:59:06 -0400 X-MC-Unique: BMycfZljPgOHIGIHDLjp6g-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5a2d4fb1e73so4085013a12.2 for ; Tue, 23 Jul 2024 03:59:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732344; x=1722337144; 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=jnannnBtmkaq6Wr5UnUHxdeogVvVjj1XBcQov3ZIDHXMFaq+kURTHHEKIoisk0mHdJ mCOy84E6L2tHtWaHBP4uII1gsn3hvvMa7HwjeOkcSXA4urJ9btmAVT+O7I/kAPvaHZqn tFhdO4IcT5xU5DcUn8usiwvOVUe/MK+5ghTW7cf/V8MPK+n7jHfNR+3KcqK0R9VYrE26 G21oIabkvAIFwB5dRjV329O60PmVe/u2mBYTzgfoKGbQXLtgaupszr1qM9KAewdpCROA AlSvS97gdBW7o9L6XkdfzX6NEYjeWeHhdA3UlAHAyfeP9ooV7hZTDsjdt/7UsC4jc7/4 PpFA== X-Gm-Message-State: AOJu0Yy2IPmiXzgoSV16cExakaKt4dNziRx4RNmbIXRR4ogM/LHsV18u WFrMeAo7t+xR1IRShV8h/Qa5OD7k4uf11QGmmu76V64MHTgSzGzdzwHhf/SiT89+XEfyrFXgicx JfI8HN65fHmQVEYf5E+alDPGtzPaq4QPH/TxTmdlS/iKXSpnzfwuIV9lRSqkPMh+eCphPy9NviI DghYPaHyadMRTSQNYCKpJnTkPusy0thQ== X-Received: by 2002:a50:ccc2:0:b0:5a2:1f7b:dfff with SMTP id 4fb4d7f45d1cf-5a478b79a8fmr5602345a12.6.1721732344495; Tue, 23 Jul 2024 03:59:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkY1B+SxNO1bP+niY0kZAQGjsvQnd71EA4XVumgGGeth4M7eQkjnVAjspzmDUcI7AeGLwo/g== X-Received: by 2002:a50:ccc2:0:b0:5a2:1f7b:dfff with SMTP id 4fb4d7f45d1cf-5a478b79a8fmr5602315a12.6.1721732343914; Tue, 23 Jul 2024 03:59:03 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30c2f8808sm7305396a12.78.2024.07.23.03.58.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:59:03 -0700 (PDT) Date: Tue, 23 Jul 2024 06:58:50 -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 v2 38/61] hw/acpi: Move CPU ctrl-dev MMIO region len macro to common header file Message-ID: <2f1a85daf3d8d06e4b204c29c1d47c76a2bc81e6.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:59: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: 13739898 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 A8618C3DA63 for ; Tue, 23 Jul 2024 11:03:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDF7-0000VM-1k; Tue, 23 Jul 2024 06:59: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 1sWDEq-0008P8-Cn for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:59:25 -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 1sWDEn-0002LO-I6 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:59:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732360; 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=hG9fCVv1qjBeZ6VhDAZa212tt0TiZjelbvYUsT/5G7ivbuqLfp8ukQPG2FPwAX75vVr9Vs brr25rWBMlORJCu+bFBxPSb693a3Fouyd3H4HsGl0GAa1+33cEzmSAo34ka42M1QLOvEJz M08EUVNfdTfcXmGE55UX630j6FBhcQM= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-b_sODgK-OkemPukwQ_Ex7w-1; Tue, 23 Jul 2024 06:59:19 -0400 X-MC-Unique: b_sODgK-OkemPukwQ_Ex7w-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a77f0eca759so399699966b.3 for ; Tue, 23 Jul 2024 03:59:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732357; x=1722337157; 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=b8KfkegxTwRdY1DiqQpj+KO5BtTnxNHbMV/HkzV/fulOnWOAffgqKTMBs8TDteWSXf DIq7q/gmmJXKRyhU+Go+18cU8HyfXrPAq1M0WlBaLJlChu4/LRv6UOc/zK7+uiytjLTz phPSGBSZqTrosKXCB9Skp1LH1rXyhaB2lsZTLSG1d+/grvLA07jcmTfYSECXL17A44xp juxj3GHGGJoOBYv88F+0+ETnPQ6ILR5rEULK2ulI6D2tB61Tm4BXv1l1d+gu3zSOeyIS JtNVFAkNdnsIvwQblBh3AkxN9BPZsWFviRj0fqhs0Laoe0EoLV6v6Q1ew+PJKeBOBh5v kiBQ== X-Gm-Message-State: AOJu0Yx8O3ciBZpCyUtfHx0wVnHS6bqQhcV5mQxH98JLi8Duis/p2/KD G9Ch0Fu6CTy7v+MKTEVcD9X12WyVsDX0RUT99xXpteIFsctGzP6rf26qbPwMT4IZI2yWG79nmcM 2A3FdiQeKKKfclt0N/aowHFIz0+9TllMKJEHyY9ESOtKsfRVUNpHDzwX9sDofFveUYXRuI5HcVn Fg4LK7p59A+iQI+RrSHCC04mVTIjnJFA== X-Received: by 2002:a17:907:3f0a:b0:a7a:a138:dbc5 with SMTP id a640c23a62f3a-a7aa138e2e2mr76768966b.65.1721732357589; Tue, 23 Jul 2024 03:59:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLpCrlLhamV0OrNTZjlgfyDV53/NhAPnUho+nlyyFEhzDphz9o/9Xmz/lTg/1zhuphCywJjA== X-Received: by 2002:a17:907:3f0a:b0:a7a:a138:dbc5 with SMTP id a640c23a62f3a-a7aa138e2e2mr76766266b.65.1721732356989; Tue, 23 Jul 2024 03:59:16 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c9510fcsm525971766b.218.2024.07.23.03.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:59:16 -0700 (PDT) Date: Tue, 23 Jul 2024 06:59:04 -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 v2 39/61] hw/acpi: Update ACPI GED framework to support vCPU Hotplug Message-ID: <06f1f4958be70f14f527d1f03d1e9a141650bbc5.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:59: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: 13739878 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 048B8C3DA49 for ; Tue, 23 Jul 2024 10:59:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDFD-0001eP-7L; Tue, 23 Jul 2024 06:59:47 -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 1sWDEx-0000XB-Rq for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:59:39 -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 1sWDEv-0002NW-UR for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:59:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732368; 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=NTvI+PgpzMLUfhGDur9ZMnej8IbcnZObz2AWFOaoVgKPj27jz3nGA6tG2bweEM0v86tlm7 8IUaC1hJeZ1YJM5fePgxzrkVU1ZgAzWdSyro+IpKXBT26VpjqCULeYiI50a+WU0ekKo8hc Norpbif+13CXl7cMARqqMgLxVinhaRk= 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-567-xyfaqT61P4abb_3Y26_FqA-1; Tue, 23 Jul 2024 06:59:26 -0400 X-MC-Unique: xyfaqT61P4abb_3Y26_FqA-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-427df7c3a2aso20041875e9.1 for ; Tue, 23 Jul 2024 03:59:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732365; x=1722337165; 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=SBUur9tzE/HEEHZA6P6WpS6G5HbQb/k0K5wq2NgOJfe1G5toBDxPvDribno4WuF6kS 9/Z2vCMyVCvEuEDEFWOUFCuZdGThjytbprb9Gp00u5LZ4lDM5KjoTljfbT0a58DLAFWA u21Y8PTb3zkGhXwE4RE/lLXCx6pOZvYSYsGA6tUOYxmwuADgRzJvWKZq3u//WVLFHa84 LAQHEOEPqW6vLzXgJKf1RmFE/qvPRaILcDoNb5lg8SQmtWmvihLs1hzFfO1D9viDjR0v jzacb8wDoasAH6vwtDgxPDC16Sg7r/y7G7JN6eOJTOQRZkn05rzf8bs1WIN1vPshRadu 7AoA== X-Gm-Message-State: AOJu0Yz0ZmAs+U5WZU0zRhzNlA01Ad6+gJZgD6B4AtoP2DyM5brN6Q3h 1KtShLfS7tPGQdLTp98w4kKiA8kowLawUKHEVxklhq7KdhruDjRE/Wn4LW6rCP1vsK1na9Urjfc Tg1oDP+XkdzVItc3Yh4DFOXIS+kFDwIBeuJ3Ok8ZfW9AeYm4BCBlIjJaELDv308CtS5GibLikln ixNPGRk/n0oE5Ve7NSybnUD86Ox7CKBw== X-Received: by 2002:a05:600c:1c27:b0:426:62c5:4741 with SMTP id 5b1f17b1804b1-427dc515f90mr58917435e9.2.1721732365224; Tue, 23 Jul 2024 03:59:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0C/0uC6m5IL0qVb7HMUY+AUzbnJl48FID37cxT3ijTRR6OYAKyjXokxjyyIACahz0wL6VRA== X-Received: by 2002:a05:600c:1c27:b0:426:62c5:4741 with SMTP id 5b1f17b1804b1-427dc515f90mr58917135e9.2.1721732364587; Tue, 23 Jul 2024 03:59:24 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d7263687sm166836685e9.4.2024.07.23.03.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:59:24 -0700 (PDT) Date: Tue, 23 Jul 2024 06:59:18 -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 v2 40/61] hw/acpi: Update GED _EVT method AML with CPU scan Message-ID: <549c9a9dcbc1592ea79496f7b3ab234f366adeba.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:59: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: 13739882 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 0BAC6C52CD8 for ; Tue, 23 Jul 2024 11:00:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDFG-0002F9-GU; Tue, 23 Jul 2024 06:59:50 -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 1sWDF9-0001Rv-7F for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:59:45 -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 1sWDF5-0002OI-4f for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:59:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732375; 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=iTZAHSVJi+5ETWRGyVkPmBUonF840jWqNMNGOOU3gN9fSZnRUzQVELV/15/cPw/4Hb5IMx Cij1td2o56kpkJHSrJMC2FST6ZXtVXzERElf15EMPVbkakBZgO7aKUGh0KLTG0c5Yl04Ng LaFsPRHIODC5E1M1eTkSKE0sGO4JB3Y= 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-629-LrPQlfsLPwWUrdA-6Z3mPw-1; Tue, 23 Jul 2024 06:59:34 -0400 X-MC-Unique: LrPQlfsLPwWUrdA-6Z3mPw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-427b7a2052bso55069395e9.2 for ; Tue, 23 Jul 2024 03:59:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732372; x=1722337172; 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=dvcSNJeMxLgMImOAoZhHMgi0h48fNk12PqpL5yuowNMWlpSO93OPt5Iw+K6KhG/g5l NptruYCyQfubPeggKLsThh4nBv6FRYOOx6haQpsM70e18K10YTvojsVfsJXyLpXeOW1C VlHbGqucJ84TaWGRAlGG278PJtARFqOb9WqlrfYYjy0Kh0A+UfLfDnqzeEpG+ecD4J70 nO0eZjxi9FBtnCH1lm9HrkdDX8hMZjK8nRBJbJ2+R8SM42hqyfzbbOwVWO5W8Q4SeWM+ UzSp475YXEXTN9cdfjVcJJaYeYzmaZjEj1er1DrL22KJBneCEqbbRnqtzCrmir4pmyC4 JiVw== X-Gm-Message-State: AOJu0Yy1i5dXmJs97wPXEKiADMssJXMIvJyecFVrPmfmJsdSXkp3Ng34 V7tsZpEvHX6vdymYJagptRICLKKES1kAmgyW6niq3HxgjSmNNLqfquTl3+C+U1wzwpYGiGdKVRd rksx700bJtHOQzCRru+81tCUl51ZH9otHgH3E+PUUYm1CDAymF2N6fDgIl/jb5cohEfhCbKn6iK poKpt4h2UlXPNbm4B9jcPnP9cBOMiD6A== X-Received: by 2002:a05:600c:470d:b0:426:5e8e:aa48 with SMTP id 5b1f17b1804b1-427dc52910amr90650355e9.22.1721732372615; Tue, 23 Jul 2024 03:59:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGecRMxkjpR4Sccdyo7KnsP9n3mM6TbmRpleA3HN3P8Qlb/bddI5UAMH4LbfAI6PL472xf4JQ== X-Received: by 2002:a05:600c:470d:b0:426:5e8e:aa48 with SMTP id 5b1f17b1804b1-427dc52910amr90649825e9.22.1721732371979; Tue, 23 Jul 2024 03:59:31 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f1f4c274sm14744815e9.1.2024.07.23.03.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:59:31 -0700 (PDT) Date: Tue, 23 Jul 2024 06:59:24 -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 v2 41/61] hw/acpi: Update CPUs AML with cpu-(ctrl)dev change 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:59:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739908 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 E9158C3DA70 for ; Tue, 23 Jul 2024 11:06:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDFH-0002R0-Tb; Tue, 23 Jul 2024 06:59: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 1sWDFC-0001lZ-Qa for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:59:47 -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 1sWDFB-0002Qr-4G for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:59:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732384; 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=IcG+BwXAtnTNdpMu6hSp/9JnAcp+RoFAk4hzliwvrFqq4eFkJK++ljO6nbgMZXcYqBYYKd UB0fLQCezaHmbrVMPTzIAd1enLV7oMeUiMx0b/022/i7mbh9wl4sc45i+4BwGOhoEoz9Eg IXN+FriFWlCHpXAxoyFdrSCWgQoq3Gc= 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-654-Qe2uRs4EOJ-9_35Iymmz7g-1; Tue, 23 Jul 2024 06:59:41 -0400 X-MC-Unique: Qe2uRs4EOJ-9_35Iymmz7g-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3685e0df024so3335509f8f.0 for ; Tue, 23 Jul 2024 03:59:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732380; x=1722337180; 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=GR/fdSe6qOEhU5475bRFDebmMXjNLAK9FYKn9ln0xAe2/JeWtZ4ojb7fz5GLeJi1ks dRHEXj1HWm5Xxq/x/alVbk/z1IeOj1C1jPUkv6oEduh5XP2hUIAsHwMXLhMewl06LrwW izq/97ZCmKAFlZx88ttYUB5s5/2wujRxeD2Co5HKA7NkRcMJLIT79DAPN36lrmW1VHlA XAhoYhR+ocz7tP7FXjTo6R6EXiNNMDto+MVM//sE8jej7uVjG4J4xiAFdfHb2bCz3EsM 7YvaPNTsakLzohE0fWAiP5desxxAa3gArlyXJOQy6wPw4haUfYSHCd8QdYR5qbwwKTy7 PKMA== X-Gm-Message-State: AOJu0YxuWPkqN/u5SAQx4Gkb6h6RwSeVlY1tIftDSyhS6R67zs9mhzbP rhc4OtPZCBAfcdEVXZsWk2GNlOaWey//J273tU7eQFurN4XsIko6CiP5x2B/V9hm7HY/jPRIqsp jTgcG/VmeBa6pVKPqN1CfCYez60YGFTRKIABZzb+Bv6CEj/Dsj0TsQ6+1moK/blRoRfvB114Z2w 7RgSvdW9Has2ySs45Ge5IdShD7BEdr+A== X-Received: by 2002:a5d:6192:0:b0:368:3717:10b3 with SMTP id ffacd0b85a97d-369bae23a3bmr6996556f8f.8.1721732380237; Tue, 23 Jul 2024 03:59:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDGkgAVP/kDuWMvOLLt2He34A3BPca17yvCYj+TCX1z68E06+pzGqzRCme1ILua2kzi5o69Q== X-Received: by 2002:a5d:6192:0:b0:368:3717:10b3 with SMTP id ffacd0b85a97d-369bae23a3bmr6996510f8f.8.1721732379504; Tue, 23 Jul 2024 03:59:39 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a3b763sm196791985e9.10.2024.07.23.03.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:59:38 -0700 (PDT) Date: Tue, 23 Jul 2024 06:59:32 -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 v2 42/61] physmem: Add helper function to destroy CPU AddressSpace Message-ID: <24bec42f3d6eae035d5df48c057157f83b260e17.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Salil Mehta 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 Tue Jul 23 10:59:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739886 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 C00D8C3DA63 for ; Tue, 23 Jul 2024 11:01:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDFR-0003TP-0M; Tue, 23 Jul 2024 07:00: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 1sWDFP-0003Li-56 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:59:59 -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 1sWDFM-0002Wp-HW for qemu-devel@nongnu.org; Tue, 23 Jul 2024 06:59:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732395; 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=CuqXedyF7KzDQ2MdY6KVPUjmga1Kzlp8CPCiIiVi2ngleVBZpYgiChaWH66GSV+ny4b0O+ /7O8+llLwPd0Q1HNn0Wo7gNEVE84Jmu5x0Mz6Bj/3gZe6A2Il3rBliFRJKV6BErDS5Dg7l 6/DB5Xa10nSWvkULXPocFW0ZoAJbUxc= 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-46-PcpjAzY7MMClMxH4unmj4A-1; Tue, 23 Jul 2024 06:59:54 -0400 X-MC-Unique: PcpjAzY7MMClMxH4unmj4A-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42666ed2d5fso36725305e9.3 for ; Tue, 23 Jul 2024 03:59:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732393; x=1722337193; 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=r231hgxjepeZ+TsCYYH6SaxKHcZz45NDyI+Q+ENXZKYCwILOyOFNQOdzdaJYe3tJu3 d3moAQ7N/hBPVbliu+/VyYLirVHhAtWrNZtIXtFqUjRCe2P4XzFSSNNprIQsVO2dj4j8 gvWN8MEUlr/hMM1OJf6JQMyNMqhKtKCmwTdOxBnUwDaCiw+25PAd7BN+KAS/I2NtpgIW o5Q98HeYedTFhDce0CsBfUlKBjWwn9Vx1JNu8kjIPlAYY1z1zsdKwHJpYcAxVxsfOPVL p5sDl7VOFO04yCi10pF55qnjXQcsz7gwp2wcanJ5+kdHiDu9AFkwIsviDoVYS2ibGSS/ i5rA== X-Gm-Message-State: AOJu0YxgO4fV18uiTNZ/qC44XxPLcYrjpapx86Z6BdaHSkfyrLaWDkbR NSZBTRKf60W0IFLOs9nxb34V9uCeSExJWK8/Db6+1EFj+TeSr6N/DG0XEzsBcHDJJQGqDFtHtj7 2IpIONHtUOKC1pFUed1Yeg5LHnBWJ2kCHd9HLHMDljj2tq38qm1SACG/VfAk6rgtU5Ymugad81d EyIRv9bhu/J05tdyd+oSEg45G+HaVRZA== X-Received: by 2002:a05:600c:4f45:b0:426:6f0e:a60 with SMTP id 5b1f17b1804b1-427dc529c91mr58119835e9.17.1721732392755; Tue, 23 Jul 2024 03:59:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLHMq9/6jWi11FGt/bR/SNRFSuF0pCPecl27meNHsd3fFidFx8pz35N13KmEvHnv6v1vk+zA== X-Received: by 2002:a05:600c:4f45:b0:426:6f0e:a60 with SMTP id 5b1f17b1804b1-427dc529c91mr58119475e9.17.1721732392020; Tue, 23 Jul 2024 03:59:52 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d6902a1fsm163973385e9.20.2024.07.23.03.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:59:51 -0700 (PDT) Date: Tue, 23 Jul 2024 06:59:39 -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 v2 43/61] gdbstub: Add helper function to unregister GDB register space Message-ID: <242da18082abc9310ecd528c528501acbcf718c7.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Salil Mehta 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 Tue Jul 23 10:59:52 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: 13739903 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 1347AC3DA63 for ; Tue, 23 Jul 2024 11:04:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDFr-000657-Ro; Tue, 23 Jul 2024 07:00: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 1sWDFa-0004b1-Iv for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:10 -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 1sWDFX-0002kY-H9 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732405; 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=YDuN0lM0M+oD7D3Qa5v7n6TmqR6tdC0YJg/sX4PQ8BQI3EuKBtEnSSiObXmZwOoMcQzsvD TOTkxlhu0zhopET4mPt6W+wF9NCWnu1qeu4A/+/AVfm9AOSURtGueYdWasmJKyahlx7T/1 SpPwC4QNrFHHRIyEiS0QTQ/5Vt0p93c= 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-255-iuLz5_mCM52gRKNQtxwjuA-1; Tue, 23 Jul 2024 07:00:02 -0400 X-MC-Unique: iuLz5_mCM52gRKNQtxwjuA-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3687f5a2480so3115211f8f.3 for ; Tue, 23 Jul 2024 03:59:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732398; x=1722337198; 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=oNpGkjPwyz6DstI+qiNyHlrvjFLXDv9SQY3MCWf2nLnSaBR9qZrjk9L4KU3IBOczGM hBIUphBJgi/YKg65t/JLAQqQZA30mTton/gtQUa4Wxz8iX+3eS/8W4WR2Hz+aAonxbDj zKKXegTbm1qtHApzGkkPuywizW3bHsMsGV6k3CxKecotj6MrWqVXUyA6op4o4KqwQLDp MeNlfeV0SCTfolgxDXFhB26SvybvYK5czpiXqHGqkOIMHMuicinrYArYUv24vze+MMaz yBY0pRW+fj8Gdx6pBdmFAanoWIMMV+nFDC0PMW6t8i72NKiuXDxdWu30U3U14ahld18R szhg== X-Gm-Message-State: AOJu0Yzhizv2kOqlHEAGhwnsXb8Fi+D0vS9v2J8zvWkut0tes2i58eBr /odwInz1o9aS+cxijtDrhfqZrY6r1U2KnkOFhhEpfUwwxVH0leOYp/NPdnGXBgkM1qNBWjlzm/i hhy5m5iUpsUSC4GNpuHR3VjqFAoLR4ArWya4x+azaCIY28x+JcGFARa5g2DucfzLnTuH2BKlr9i 2mAwXJpFvN15kr1WAjpUKMwbnui0kpjg== X-Received: by 2002:a05:6000:881:b0:367:916e:4206 with SMTP id ffacd0b85a97d-369dee46164mr2209256f8f.46.1721732397773; Tue, 23 Jul 2024 03:59:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHG7bO1brr7fBBfuIFQuCndrMWRKXgHwfHk2CN0x441KigocNiTbuJ3MnvX6kS7QgPStArrVg== X-Received: by 2002:a05:6000:881:b0:367:916e:4206 with SMTP id ffacd0b85a97d-369dee46164mr2209228f8f.46.1721732397002; Tue, 23 Jul 2024 03:59:57 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868b262sm11156565f8f.30.2024.07.23.03.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 03:59:56 -0700 (PDT) Date: Tue, 23 Jul 2024 06:59:52 -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 v2 44/61] Revert "virtio-iommu: Clear IOMMUDevice when VFIO device is unplugged" Message-ID: <935c3914184c4ebb1a4c545fc77fe2f0b24645c2.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 10:59:57 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: 13739910 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 8F016C3DA7F for ; Tue, 23 Jul 2024 11:06:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDFd-0004px-EU; Tue, 23 Jul 2024 07:00: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 1sWDFZ-0004Wg-OH for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:10 -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 1sWDFW-0002i2-Jg for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732405; 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=E+jNNbPz35RAf1J88zZ8LBs10MaOWfGVxn2CxdP3p8iV1nEYCEk3bVFmubhvD2lV81injZ Sse7jnUYt+V33AFP+f5CjgC7Zv2rHofpwDKYCaLtsb7kPh0tx8NUPZIUJDvKUMlf9Gf1DT 9jImuYwud7HxxtgLodIhGkU3Knywzo4= 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-586-hEIhuPr3OG-Aqi8TmJWyLw-1; Tue, 23 Jul 2024 07:00:03 -0400 X-MC-Unique: hEIhuPr3OG-Aqi8TmJWyLw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-426703ac975so24145875e9.0 for ; Tue, 23 Jul 2024 04:00:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732401; x=1722337201; 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=qMVWQmK6oTyDH9/Mgrw7Kl9B0KIv748XdNUimDJCESPzzoNgR/ymLQMXfUK0wtBpPL MsnZyzsLfS/CtxLrwiPDqya7sxCTHCHSuybGsDU//pvFRKIbtQPeuho3yNxHA4r74SrL B0SZItxr5uThUzSqCwJCvrkfitJydPoeTrVnpFGZh1cuWFSvNUj5h33I1RRgGsE20i4N xTpLA92EoGdJU9P7t39vJZ/o2ULApTQJv208eR0P63YqJVAo4c27lki9sBo6ICauQhzh Wr6Sl+nxQqTYSu2ZMRdrgrH17lKMOx9Fxy+Qdo0ZF63oS7gRjYI9yQzVCyP4YZ0JsFNd bAMg== X-Gm-Message-State: AOJu0YwgtI9nycNGjHuOo+3JTzK8yDlP1wWUIVYZvB0ltInb5OchyprE cxaf59D+hu3nicS2QeIBhqzC6wOVCfEtcRjSiQECCufJZHo/yujJo7UMkeCHl3JtJnFT+yUIA00 v4HF/c4VSLGEncJN3MeotphxSEMwNvygODgernd9QswcOItbGHMclbwO4ul4N49/dlhQyhN7xVv 7yXD/y9gP3f6qh81MdI0DGY8Mir0TQnQ== X-Received: by 2002:a05:600c:4451:b0:426:65b0:3035 with SMTP id 5b1f17b1804b1-427ef3b6278mr12057205e9.15.1721732401695; Tue, 23 Jul 2024 04:00:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0zdZsfiKSFMmQvEeoFmScvb/ZeaA3Kanjiif1CQiLfWsajwyEszs2WSl8si8hMQkPkDxihw== X-Received: by 2002:a05:600c:4451:b0:426:65b0:3035 with SMTP id 5b1f17b1804b1-427ef3b6278mr12057005e9.15.1721732401158; Tue, 23 Jul 2024 04:00:01 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d8fbacc8sm154791575e9.28.2024.07.23.03.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:00:00 -0700 (PDT) Date: Tue, 23 Jul 2024 06:59:57 -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 v2 45/61] virtio-iommu: Remove probe_done Message-ID: <3745768918c2528f2b00b63bb3a764c458364f70.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 11:00:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739899 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 4677EC3DA49 for ; Tue, 23 Jul 2024 11:03:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGG-0007xc-5n; Tue, 23 Jul 2024 07:00: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 1sWDFe-00059w-Pc for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00: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 1sWDFb-0002mw-5H for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732409; 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=Oo1rKhzEwgpFBD+V4bpKSuflUt/av0NHnpfCYa9QWJc6BlD0UxsfajkSepZVSPIWiUer66 Gr4fhoEMiRHPcUO4Sr3u8vMgsUplBJT68NJp7Ujj64fXeMCQxlJDlQRXuoPjQzsutJ7Y6N pufUEv4/X5akMoJKMiI8uTQ2CoOPPSw= 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-151-jNiqqswuOdahHBROYyDtdQ-1; Tue, 23 Jul 2024 07:00:08 -0400 X-MC-Unique: jNiqqswuOdahHBROYyDtdQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42667cc80e8so40125375e9.2 for ; Tue, 23 Jul 2024 04:00:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732407; x=1722337207; 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=K2SrzxIERDgeoQflxJzv2yjVwHxlB7qfGG25EnJSvAnrmyLBTPToW8P7m4w8zkI5aq WvxLhISWYDpfO35b6aALWYfG5cT9HnCQJ02pLMFKlB9yOv4cNT2+AACMJsnfRJca5fBX LHGqmzZWSwInxB/NkB8csoSu+M7u783BZyDejwigN7DoQqzC8UDHj5sefIpuAlzh0kHV YRhXgQvBSD4CBKCE/X6LU2LVb3yocYvKPzOI9xhgajJEMwMS58cTTSJ1dghDlMoof80S DCfqIuXK4wQOCRkhsacSmyRnnrBevg9UST2k88U2UksGoo14m+T2i79jZxmy5BCeychd UdJA== X-Gm-Message-State: AOJu0Ywvue8/KoUgR8+hDFJpTwms3b5qwERShdktlIqvYN5Qr077LeQX nzcAjp6hOlCSQBvkWJqP3S2Sgsjd7SSbMPXsTcQZjAoKV9ZExdSomfmNfkdWZTgEYsID/cb/p7d ULyoPb2uqQ4qzq+nX+VvNUpUrRa0rrhgrIbM87yNbst4F3uzHvo8xPhEhYr5WRMMwqIEcmiT0Yt 072lAB1XT8lQ+OO3cvyECfS3SvSt1t4Q== X-Received: by 2002:adf:a3d2:0:b0:367:9903:a81 with SMTP id ffacd0b85a97d-369dee57a01mr1656352f8f.43.1721732406696; Tue, 23 Jul 2024 04:00:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEs4ZaqvDfD4PGNpyQFZizlutPINy7iS7blsqX23Oh2qTn92E6vzYIzyMcF8jI5zDmzLyyP1A== X-Received: by 2002:adf:a3d2:0:b0:367:9903:a81 with SMTP id ffacd0b85a97d-369dee57a01mr1656328f8f.43.1721732406036; Tue, 23 Jul 2024 04:00:06 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36878811bedsm11225122f8f.117.2024.07.23.04.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:00:05 -0700 (PDT) Date: Tue, 23 Jul 2024 07:00:01 -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 v2 46/61] virtio-iommu: Free [host_]resv_ranges on unset_iommu_devices Message-ID: <62ac01d1de5096022e08355f8df47bf1191a3ed1.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 11:00: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: 13739892 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 F2598C3DA63 for ; Tue, 23 Jul 2024 11:02:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDG1-0006lQ-1m; Tue, 23 Jul 2024 07:00: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 1sWDFi-0005k8-Ps for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:22 -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 1sWDFh-0002sM-2c for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732416; 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=fDQ8JiECSs6v6fhi93xEUF23fubAGLQqYNfvBzj9JItZHFrKJB2+9qoBXbfm1Lz/Qv5VKu hLyO9bhFVHF7UTClMMz6ybpCmwCu7Pb/86p1izTF3xPcSauqsSJQTMP23lVb1JVHB0Yvqc yjm8bl7P6OFsX1fiUGByvyLvHDJrU0A= 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-GF6x2VEVPWmYdJotyRjKIw-1; Tue, 23 Jul 2024 07:00:13 -0400 X-MC-Unique: GF6x2VEVPWmYdJotyRjKIw-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-367962f0cb0so3169065f8f.1 for ; Tue, 23 Jul 2024 04:00:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732412; x=1722337212; 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=YeAOFnOaQVCN0wbASAJMiNw63WB0CHP1ApAsYRKWWLGow79LgUL648/pfoHAwp1Mxi SBOYQgAEekv1Id2M56FLXe8f9iCBShg2vU3ver5XvQo0H1bLG6p1X7nihtaUaqZAFOEI qX8tyVRcMrdAlcG7peH/79yEf7pJrchZYkn2R1nuHl/B556BGxE/OXoAZ2DsdHzzEhef uKmk6901m72t2lJziSFz0ntHWBSosfO6eyCHIspzr4cpvzaQ6oI3vyqlBd4uH99Fsji3 jqLXUKe9FIOCGIraK2RCM0mfZVS5EC2GoPvweGvVe8Qs53OK0QRxOkNmWnHKVoi5EOcC VnjA== X-Gm-Message-State: AOJu0Yx7ebXkraYpnOdVhDdmLEQcWBh2jjZxF/R2ApZXoRU3CaBHs1jS ct02F1T1eNc0mxM88LHEmdIKnegGcAfYTEtzn7LPtaCPRvUMJHcSb9IyJt/An5zsN2R1DMsT9KF FNUDspqSIQtQWBUNfI/W7WQweaHu67DrhdjQHdDWg4Jtr3mxDQHEZFwcza59Zh66j6BGdnw9M1i E+zObyHKL0DPQ2qFmF0oKvQWHMVt+7Fw== X-Received: by 2002:a5d:5009:0:b0:368:7fca:9040 with SMTP id ffacd0b85a97d-369bae25150mr5262601f8f.39.1721732412252; Tue, 23 Jul 2024 04:00:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+BNfMM8nS6aU8G8BR+o4eeCV+qwUohnxtOCVkIHK/RgCUwBdVDVYzzC/Of+/HyYF2TQPbbw== X-Received: by 2002:a5d:5009:0:b0:368:7fca:9040 with SMTP id ffacd0b85a97d-369bae25150mr5262578f8f.39.1721732411704; Tue, 23 Jul 2024 04:00:11 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787ec8ccsm11133845f8f.97.2024.07.23.04.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:00:11 -0700 (PDT) Date: Tue, 23 Jul 2024 07:00:06 -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 v2 47/61] virtio-iommu: Remove the end point on detach Message-ID: <1993d634d57718d6eb107c973b7c8b80a6d91338.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 11:00: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: 13739911 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 43206C3DA49 for ; Tue, 23 Jul 2024 11:06:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGI-0008BU-AN; Tue, 23 Jul 2024 07:00: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 1sWDFm-00060f-AP for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:24 -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 1sWDFk-0002te-4w for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732418; 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=Ead2z9nvYNb8s9hcP5ksBaLOVJ1vt1xLuQXulzCNsFf4FmbIvYUhnbrZwChviLFjoKQpTC c17pHxjnRiKe7fztIo+qDAGbXnAb4afM4MOTSwa8QqX1KzXXSSNAdsrMa4kn+UZc2KZ99f XcnNnEOC9rLBd2PBtl40VP2wiLmwRps= 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-360-SlcFmwKOMvyCU1XHAg1jMg-1; Tue, 23 Jul 2024 07:00:17 -0400 X-MC-Unique: SlcFmwKOMvyCU1XHAg1jMg-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-427a7a65e7dso21580245e9.1 for ; Tue, 23 Jul 2024 04:00:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732415; x=1722337215; 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=TLJAXPi0G6HSocF72tVZrSxanT3Gtf6SXgAK1GuU0Ng/b3Xo2pSG3frW12OB5Uiad0 Yn/AmrdzqHYpatAGlB1OItFFV2XV8wzhMezzkkrtttCx+MQTQN2EN7C6mkle7xKZ5MHH y/LPIId53hn77VWRDgF2OFHrFlz19Lp+ReO3YBfMuxceuRQKcoFvC6f1TfibU9fupM8Q hyPSNOEtKcqspkTizZpq3XOqOA/3UlDV8OCCk81rE6Hr1plPXAHkHR0+XTkHKWZQbusA lB6oVX/HmHVYSssbsowQ1KUuz0bH+brn0JR5mlGpIoRZcj1ak3yvSDRq3K2M9cJH7FhJ lfWA== X-Gm-Message-State: AOJu0YyMg4XZ336kAr59ExhptKTvX4j98cDoCEuHQJrxnZ/7PKw0hVhx jpYAzfrWcjBcrh87JzoTFSWvRUp/hhgJmX3/B73rBE4XW3isi/zdjWQDYT2eL+hdUYUjT+rAw71 N/Xlfd03GJkdNXnhxDCa4cub544p34LWJ9Q8rN0C5mBOfsM/OJYpKHBG6kpQiqEWqTnfi5jdeDT Ne7GeKAamR57EES6ED3BTnEQGL7X5NVQ== X-Received: by 2002:a05:600c:3504:b0:426:6eb6:1374 with SMTP id 5b1f17b1804b1-427eef58c6fmr14045925e9.0.1721732415776; Tue, 23 Jul 2024 04:00:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfafN4lDxgYgbXHTAVzIRDQhBtOA3sYlDRqUCS/oFzlj1zIkomEFRXOFphrBxX18vIr79fYA== X-Received: by 2002:a05:600c:3504:b0:426:6eb6:1374 with SMTP id 5b1f17b1804b1-427eef58c6fmr14045525e9.0.1721732415220; Tue, 23 Jul 2024 04:00:15 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d7263687sm166867875e9.4.2024.07.23.04.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:00:14 -0700 (PDT) Date: Tue, 23 Jul 2024 07:00:11 -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 v2 48/61] hw/vfio/common: Add vfio_listener_region_del_iommu trace event 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 11:00:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739887 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 D213AC3DA7F for ; Tue, 23 Jul 2024 11:01:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGK-0008P8-Cc; Tue, 23 Jul 2024 07:00: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 1sWDFo-00068J-CE for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:27 -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 1sWDFm-0002ul-OO for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732422; 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=iQXpH2uhgOsSZ1oISXXRH6VHD2luYIhA2zBW2E00Gk7S8y/ACXRSZtOO2fTqjEsLVZX567 iScZPWQMIk6d88fqvcuOtXM7Q/qdhk0HJ9JYtRiCW2qbrNw9qyYJ8G0LymIH5hFVvc7O7X i/AxbIrJPNAy06i3qSJHKkxT87uPiu0= 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-458-Tp-q91B-MrGLniD9WERHRQ-1; Tue, 23 Jul 2024 07:00:20 -0400 X-MC-Unique: Tp-q91B-MrGLniD9WERHRQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-427df7c3a2aso20047725e9.1 for ; Tue, 23 Jul 2024 04:00:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732419; x=1722337219; 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=lhuFzYJa2FN+xAiiVlfWOqlFQawOPnpIu5tJ9mSN8TRVNpNLUFojnTTWaHMibfOoCT 1lrJYfm5OlN3+t7LumLvSIThPvXq9gtadCjrrutGjjH6ZGC+0ebKAwMLTpJJ4FU6Iw4g 3KkbmwfQjqtGsMu7yx9w+xP/al9O0+U3PTLWLsVnZrZtC6jH4Ks64gsApL0rj2JZqVGn +kOY9lnfY+SliV9z2a8uUPi827mBxEY6Ry+EvfycU+p7XXK+6y7RHOb3hJ44NJVcR4zM NzCIBr61IqERk/oCRvNZdTPiTBCAqZMvGGxh1Z15dZmO4p5q4LSH1gOVpo9kNpGSrgeR CUWw== X-Gm-Message-State: AOJu0YxXvBrshfvKM5gUN7RBgtA99cjd6sJ714eL9y9M0B3enbwnIXhy blx/xvmmcwpuNQ3szHi77Ppgp/uS/6GTyx/qnHWnsKYsk1hxPCo5R7oLqDSjZwGyIlV/5vJxNcF Ifkf9UQ03FIBZpEf2YRolUcd8fReh9UPu1eBXg/9duji6a2WUfPafkoBAvAuX2L0wiDDt6JWV1Q 8rLt6TMg7dk7OfcbrFdXZRBAbEtAwkag== X-Received: by 2002:a05:600c:138b:b0:426:6edf:6597 with SMTP id 5b1f17b1804b1-427dc5290ffmr59045985e9.19.1721732419412; Tue, 23 Jul 2024 04:00:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvzJmZOxWpQRfFBp7VjshzP9XB2kRIrkzhmIipSXjNXt7fmpkYodRBPdoUm4jhQhtLWf4rNg== X-Received: by 2002:a05:600c:138b:b0:426:6edf:6597 with SMTP id 5b1f17b1804b1-427dc5290ffmr59045665e9.19.1721732418897; Tue, 23 Jul 2024 04:00:18 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a3b8ccsm199501005e9.2.2024.07.23.04.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:00:18 -0700 (PDT) Date: Tue, 23 Jul 2024 07:00:15 -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 v2 49/61] virtio-iommu: Add trace point on virtio_iommu_detach_endpoint_from_domain Message-ID: <6c027a9de3fae3b8a3a4868e17c7a28ba5372463.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 11:00:19 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: 13739893 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 68DC4C3DA7F for ; Tue, 23 Jul 2024 11:02:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGD-0007TF-I3; Tue, 23 Jul 2024 07:00:51 -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 1sWDFv-0006Wi-95 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:34 -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 1sWDFs-0002zJ-Hb for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732428; 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=egS7n7cu2CKPX0p3loUW2kPe4VQeTupLhZu8RMNWmy8cQDKttaSMExV2YfUUJz0Q4mVOF1 +IWgn6XrjJDE1idAugnN3PWnxLOB/rwlT9ukW+ajBYcsKJRFPIylsZbECOxZqcTVXp2T/2 hprE9acm5ptD0JlhCn6XIKVmBoWXvxI= 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-396-SG58dCv5NA26NZhM_FFVSw-1; Tue, 23 Jul 2024 07:00:26 -0400 X-MC-Unique: SG58dCv5NA26NZhM_FFVSw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4266fbae4c6so39755285e9.0 for ; Tue, 23 Jul 2024 04:00:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732425; x=1722337225; 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=HTEJiMWb+oIGI32DW2BLigD1ZvL+tS2Ji2GGasgO/h+NTaKNyOcqh0LH2qT2RHRXrH GJuYaz7ZfCZLDbSJWQb/UCOIh9suyDhBkKNNSc/1WKi/HyBgWJ4YxZELHYzuMHwZiubc EGOM9PrlEB/fZ2mI8Y/FtqlVvwucRwDKwnrn0BiMxuTD0oVKjSNfOU+uHrbWSxwtfMLw AaYUvVTGYBKCtO6C2IwA/P3Zm2nDct+zcGyz8LKgVCrCkVAZFu0vSLj9BObmxWbM23Dz B1GZKo1v/nR82GWCAaF3Kl4YhZbGR5+8UBnBXVgBMQ1xr0EVXUEwgFhX8jSLKig+FFn0 WJRw== X-Gm-Message-State: AOJu0YwudSpJDde3sboE9L4EXcPRkGXsCx5imptlE9BdqeEbi/d3miLI B5UTV5OqR0y+f7CjlH3s1e9KHwYmm8qwpk6/BDHjl5wO6zM+ZO/au3WRMTx0cTMuVCrbkejDLPX XCFwNxVQZCkT2VPFCrzfLJIq2fCuYRpY2zUGhaOSUz8NTzeqdkqm47o6hdqZeZQylattanlNhJH +I8befW4B0/Kf5A1RTUu3+9DTWboulpA== X-Received: by 2002:a05:600c:4e47:b0:426:6e8b:3dc5 with SMTP id 5b1f17b1804b1-427dc56753emr76771885e9.32.1721732424662; Tue, 23 Jul 2024 04:00:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IES2xGA854gQwoyFz4WEDiNhXqaTPv4cn1iY75vXqabsEsDP7O8DHpzV4z3K1Vb2qkzWcRCVw== X-Received: by 2002:a05:600c:4e47:b0:426:6e8b:3dc5 with SMTP id 5b1f17b1804b1-427dc56753emr76771375e9.32.1721732423942; Tue, 23 Jul 2024 04:00:23 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d8f1cf7esm158567575e9.39.2024.07.23.04.00.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:00:23 -0700 (PDT) Date: Tue, 23 Jul 2024 07:00:19 -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 v2 50/61] 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.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 11:00: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: 13739909 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 0101CC3DA63 for ; Tue, 23 Jul 2024 11:06:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGH-00081N-2H; Tue, 23 Jul 2024 07:00: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 1sWDFy-0006ht-5T for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:35 -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 1sWDFw-0002zw-E1 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732431; 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=UbPzDVmzmAuyvBdvLmR72HMJNbkWbIJsyp18HTnqzPg/EAiM4891SQVWvvXAqqlwRTiBEu W08sn7vvJ2OFDvFLiLqhqgSwE0+AJMW1a7Y0FiZ5oQrUZ2Z5O0kja4JS8oAlnra4jFcMXu 9CMxOAc5BiHNNlN3VrPw/jaaH49XNnU= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-hFtjP2QiPNyukDuqSNlRiA-1; Tue, 23 Jul 2024 07:00:30 -0400 X-MC-Unique: hFtjP2QiPNyukDuqSNlRiA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-42668796626so40276675e9.0 for ; Tue, 23 Jul 2024 04:00:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732429; x=1722337229; 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=vXa1nNpcNhEIFHLSuCtJFlVHwU/lS2KdaGisflH/rPlAfqPhfQntkzXDa4t41d+22t hFSxNHDHpgK0BVSGjai+q6XcrAu1RWGhA8lEmVAvUv78AMOUl/Pujpe2ehcAWnCipnBu F5S+WKwMRumEzAjPADPCyijq3c/hTuSVfRpZC2Uh309Ql8i5PwOpKlJFb66UxVUu0y+e pGrplaiyL3FAczTN/FGaYmFwVuWjnXhE6oIySRzmHIVel5M5XEN7lV9PvkhL/YR0UBke dBrFu8gPN8iPFtuEkDBl/z/sLYDX1xkUVUJGPO8KEd6PAbeQZxv2XG/GEPMgSsanGg5r oMLw== X-Gm-Message-State: AOJu0Yycz/+gELsmhIPMwj6C8NC26SVryUUe8g5SJdiS8rNocg008URB 2prJ5Q9sCtMbOY72M824d2bYCd4Wz+mGa+EjbsfT6DGx1FlD33KOCnEq8WCjYEb/iavAk0EX/Om 68/bFVzMxTbwm1D6DPCBMRNBMF/XlcGOVsWw6yxidSzfS3r8btbrBK16y9Nx0k07Pexk0No87hd 9fOgdPuHHCe1klENI3ckrEVouYSK25oQ== X-Received: by 2002:a05:600c:4752:b0:426:6edb:7e14 with SMTP id 5b1f17b1804b1-427ed06197fmr16759045e9.35.1721732428854; Tue, 23 Jul 2024 04:00:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+lVsF4SUdxXtBno6EpPUiUoCkONqPT2tvAJwb6e/syW+3H8UrZS+IHTebWDA0zCE28rZCPw== X-Received: by 2002:a05:600c:4752:b0:426:6edb:7e14 with SMTP id 5b1f17b1804b1-427ed06197fmr16758765e9.35.1721732428353; Tue, 23 Jul 2024 04:00:28 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a947fasm195197935e9.43.2024.07.23.04.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:00:27 -0700 (PDT) Date: Tue, 23 Jul 2024 07:00:24 -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 v2 51/61] 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.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 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 Tue Jul 23 11:00:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739896 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 EBE80C3DA63 for ; Tue, 23 Jul 2024 11:02:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGM-0000AE-M1; Tue, 23 Jul 2024 07:00: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 1sWDG7-0007JD-Ky for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00: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 1sWDG3-00030s-OY for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732439; 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=aznLcRFW9WCeqzfl1Mj5jbCAjK1RFmNO2Q5dz2yj0kN+XiOmKO/o29bC/SACvDoJ+Hzljn 0c156Nu+9uQUqKTuME4CBG4kN8NXhHD7Zk0U5rxEi8rSO4Dy6fk3kJphcmFtS2bTl6SlIm LgkM4qKIK0saACDvqaJlRFq3OUu1Kb4= 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-526-l2uQRFDyN8aQKsgpIszzZA-1; Tue, 23 Jul 2024 07:00:37 -0400 X-MC-Unique: l2uQRFDyN8aQKsgpIszzZA-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-36875698d0dso3779872f8f.3 for ; Tue, 23 Jul 2024 04:00:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732436; x=1722337236; 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=O1AzPlv6NqaYf4qw0F3PEH2ygyLQcKSGdjmshfLk0w+tV2DtGa5tHBZ9meKTEkVS+F nSRgGmJIqqBG883zuNySc+jxB55PS8GUo1L+yl/U5zcDZEDZNncyF0s6y8Db+vzy7hY7 fqvx9/fmMFUlN+HQ8iyNW1PehrpNeSnr03wOR8++EkizWorBf7ilAEyAMPlEQdsfi5AT yvFTCw2eOtlTM++AY7jMBONYl0MlaAzeSS0FbCUm0aRoIviSyjqTzt7GL4rsrGKgEMxK 5tkybRfKT5PjmlheNell28dzPfBS62zJZfep1WfTAZDVBd4dPNrT0t0oLZ7Ez7MSpK+W iCfA== X-Gm-Message-State: AOJu0Yzixyfe32pTu+i6MAUe6ROSIkTVSUVHbgBhc5HCZlCp4UJ1BgFN aQG8WABhbVUy2sIrX+sPjMRWMr1USEHEmkwuPnpTCe+EBBvJIW9EYmlEliLlQPsPxPeDlIatQhb FMq2QOchygEqvenM5eXHKizYSJLjj7mASWCeLE5dshx3JWEsdxKpSarrifIfh4B42QroArrWUX5 kPc+h7xDfdMKUQUUDsSeGPF6l5f8SE3w== X-Received: by 2002:adf:e952:0:b0:363:d980:9a9e with SMTP id ffacd0b85a97d-369bb2c2a1dmr5823627f8f.55.1721732436022; Tue, 23 Jul 2024 04:00:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIBQBfFrhcW/Hs11XYdjeLpCXDnds7WpsiyRZtrGlE6eFiyHOF3DzKg38ss9ZwAMqk1ak7zg== X-Received: by 2002:adf:e952:0:b0:363:d980:9a9e with SMTP id ffacd0b85a97d-369bb2c2a1dmr5823593f8f.55.1721732435399; Tue, 23 Jul 2024 04:00:35 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868b33bsm11222985f8f.33.2024.07.23.04.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:00:34 -0700 (PDT) Date: Tue, 23 Jul 2024 07:00:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Igor Mammedov , Ani Sinha Subject: [PULL v2 52/61] tests/acpi: Allow DSDT acpi table changes for aarch64 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 11:00:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739912 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 6F86CC3DA63 for ; Tue, 23 Jul 2024 11:06:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGI-0008DF-H4; Tue, 23 Jul 2024 07:00: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 1sWDGC-0007en-R2 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:49 -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 1sWDGB-00031M-6H for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732446; 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=YLazTbqbystr1fUWyNBKMsMcZW1ybM3WNjCTut3eGczOqLLD0AzTz94ZlNQw5LL3qQOIfe qIwthFIiSKfFV+iA5DERvsCBvEOpar8aMR0Tt5qubAzdBJ+bEj90q439ohZfCc+RKOZHXf 2lOU+Qr8aVwVM40TPThwLGnhcDm6k00= 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-696-Mh3ApXBKM5uraHrG4lmnUw-1; Tue, 23 Jul 2024 07:00:44 -0400 X-MC-Unique: Mh3ApXBKM5uraHrG4lmnUw-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3687a1a6846so3053149f8f.3 for ; Tue, 23 Jul 2024 04:00:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732442; x=1722337242; 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=dR6fZ4gRLNSby4JwiPQxklRRo6EryaSY1Yk/IvHbBu/MXNl3MizKqdECZPxa3Fplqg tz1BmW3Dh41v6bDZKeRVRW2vCvZMzHf3nSh5u5uRxi8UoLzWHlQl1X2WCubuy7IVEQul RdDd2bR/7G8xwbH2v6OBf8d82LUdC8jci4u/JZ8jKtfLu5T2k4bqFIBSWHLkDMCUe2dH xxjUpXgiCm/0c76OnY/JyMaVLU18VhAyfPUhSPN28gHpDlzHxjxZ4/0icvGUYGarTaSX rJ+ZI3vtffdXfaCc0yVcSKjBHiUzazIBnosrX9oBc4AnBL0DiTeX0+/7Bd3E6MJvjcC/ 1xgQ== X-Gm-Message-State: AOJu0YzAmfgFPRBFGxOdX+Nr4GPulGfqlJ8SjVTblqri8bXjdAMenaS4 38WB5mVcm6XUUEaVaHhnwAMcZVk8MzxXNBLJIVzdTnWNko2UcbraZTIS3jdNYS1nFmbIT++7F9R bQAFbrqdDsgzBryFkWCGmy0iy37jlacRkzFEXmqXml/1n19bV2ZSiqAxyUdNrO2gxfIHxNZvZiu CBQOYtye9oH9HjA3PXfi1AD4vgefhYog== X-Received: by 2002:a05:6000:c11:b0:366:eade:bfbb with SMTP id ffacd0b85a97d-369dee4fae5mr1826395f8f.46.1721732442125; Tue, 23 Jul 2024 04:00:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsebRkAOtJJeyWouMvgJv5+KTf0JwYM9JvFkYSDQYUHvQtmHi4i9YjQUs2EA0vybefzC98NQ== X-Received: by 2002:a05:6000:c11:b0:366:eade:bfbb with SMTP id ffacd0b85a97d-369dee4fae5mr1826352f8f.46.1721732441416; Tue, 23 Jul 2024 04:00:41 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787ced56sm11179803f8f.80.2024.07.23.04.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:00:40 -0700 (PDT) Date: Tue, 23 Jul 2024 07:00:36 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Igor Mammedov , Alistair Francis , Daniel Henrique Barboza Subject: [PULL v2 53/61] acpi/gpex: Create PCI link devices outside PCI root bridge Message-ID: <35520bc702a8c3d7b434305ac403de437003d4bc.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 11:00:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739897 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 A82A1C3DA63 for ; Tue, 23 Jul 2024 11:02:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGN-0000KN-Oi; Tue, 23 Jul 2024 07:00: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 1sWDGJ-0008Jj-Fe for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00: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 1sWDGF-00031i-Dl for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732450; 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=SIh91ciRITpYBLufjDSKRGC5Lgm+QzP7ohopUQIRvptfQv+U3PFr3XW0HTHTtJI3d4F0CQ XQBEB+mbN4l57OfQDsHvcsctFqEvb6YUqCLzHpv1PXphN4YzNT6x87YPGSZyGbyYSBgtYl Tc5qynOC2e4miTwlKuWThcVaXFdnTaE= 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-310-SJE15ggnMhOA8QeqVYD2jw-1; Tue, 23 Jul 2024 07:00:49 -0400 X-MC-Unique: SJE15ggnMhOA8QeqVYD2jw-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-36841edbc32so2684610f8f.3 for ; Tue, 23 Jul 2024 04:00:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732447; x=1722337247; 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=OUaMIlqb8QmUNTNPRs7HNiNOtyG00Oj9ZCApeiqK7WVHDKijgx+HdNFHVT+PSD4sXH EFg5q9OLje/16dONAZTkV6iGYIIJ+r9mW7RaFyh2xbFzE/zQUBjItcrO/2XlsRfGtG/X FU+RuZiO8/sQ/5qxjmGrGlEFqbw1E3N6BSn9dgf2uJ9jRHzu8tXSNNu2ufZxohIJyDtr KMe9q4BCClOIavpU33b+QkrQDFErhv4kbZZ/kKYjToiJL5cAHiDt3WMtCK6SsQCFnAYh rTCYBcW4S9ZHsCEbvt98l0sgmh2/WvLWZ9Q3Gb5SI+OzTFfFmhiCoixNuLB8C5IvSDgG toEw== X-Gm-Message-State: AOJu0Yz9QEXMiNVxF3cge88Tgvc7e2pJajN/oviB5y+yvSzYbnElLkT1 qAluJY2A9Y4Qc04/tsJuAkRmhKG01zA13eIF9MvVfm6JTcn7iJjqNcZEhWkdeWXyjfpCh5TCA0I x1L7iKvgYmrhxUE7uivZmTCmzJbHHEdzFpjEQDTJB/ECrWXEELveaq5KJ1IVxZnKBTlbyjaP6iJ bj507l6FxjL3H3QTkgsmYhaJPFTpQFmQ== X-Received: by 2002:a05:6000:4026:b0:368:5d2:9e58 with SMTP id ffacd0b85a97d-369bad7d500mr6749595f8f.0.1721732446624; Tue, 23 Jul 2024 04:00:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtilGMZfRXFb0gBRHLvelJw9uW4IeubSoeafYySjjQydANmCHQnpuNFy12zJ3Fq4wZLmBFlw== X-Received: by 2002:a05:6000:4026:b0:368:5d2:9e58 with SMTP id ffacd0b85a97d-369bad7d500mr6749539f8f.0.1721732445751; Tue, 23 Jul 2024 04:00:45 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868bc42sm11205707f8f.46.2024.07.23.04.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:00:45 -0700 (PDT) Date: Tue, 23 Jul 2024 07:00:41 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Igor Mammedov , Ani Sinha Subject: [PULL v2 54/61] tests/acpi: update expected DSDT blob for aarch64 and microvm Message-ID: <0af3dfa5c5590ae21d1f58a389968d4b90112fd7.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 11:00:46 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: 13739895 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 793B5C3DA49 for ; Tue, 23 Jul 2024 11:02:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGP-0000R9-3g; Tue, 23 Jul 2024 07:01: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 1sWDGL-0008Us-C9 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:57 -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 1sWDGJ-00032D-LZ for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:00:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732455; 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=Aa3/9TdreT9DRm4WZvb2F2W2otjgNCRYeXaCFatCfvUq93rJOLZViZrx2KInGyoTZng665 MdramDFQTe3hwOFOxkA6cNbkhirmEcoNyqmjtDdbAI+FmeOg/xwQO7sYFz53lL3TtkIO4K w6AUD9velCVepGZ9vF0FEDPSv3j8QtA= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-577-gRanoD9HNEukumnNNk3pVw-1; Tue, 23 Jul 2024 07:00:53 -0400 X-MC-Unique: gRanoD9HNEukumnNNk3pVw-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a7a9761bf6dso48912566b.3 for ; Tue, 23 Jul 2024 04:00:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732452; x=1722337252; 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=FCFhF1qW3NgT2ennF52q88Iz3A3+xfL0uTjKYj4/47SZSeqNPFAxwmf2yESKKjxnzh FOnFAZZ7O6eTe0Zly+jTlr4c/vkAskgDpOIUXVir6bQ5ivSZWFJNRIHhShWQvmM2fIhI YDj6zTRreFnb0delKQa96vHRgFOWlWC2fT9Eg1I1/hb2XBEIHw8qxLBNPuzHn7xZC9sV wKybQAaV2G4Gz3UOqQE/gxi6C1gD7KKRmXh9vBorGgKGyHQSvHuqzupe8VO+qnwF2x0X pF6WeekEWeTCfHyhTYq1R8ugfd5S93LBjkLk+1zZpZfKmdMvXkLvYsiOFqVjKBwB46sh Ohow== X-Gm-Message-State: AOJu0Yw9EBcBEkosUS5mG+3pNkRKrGNTzBwI/fF/RgL1M/cjyBZMvWn5 UIJtk26d1gMugkDwvcP9t6zCq3npwJY9NEXgDeiqeXl0OhIo3OrP4NlDUlb6NLAq1LXP5vDwTeC ZeyPUalRiwwpLhvP7UXj9WknEWaUhoC2Nw0C50a7qPHcBc7HK8Zs3oKi3Jrql+EycICGgrXjv/i jZpGsb3pwTPxyI9ZgZFgi6Vfo7FJnY7w== X-Received: by 2002:a17:907:3f23:b0:a77:dd1c:627a with SMTP id a640c23a62f3a-a7a4bfa22bfmr689300966b.8.1721732451738; Tue, 23 Jul 2024 04:00:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBOQnXdyHeiqjUdHA5GvIGWN9almpKd08ifcygVg9qsL7rzHke9Nv5ARnxbgZTDQoTYD/tvQ== X-Received: by 2002:a17:907:3f23:b0:a77:dd1c:627a with SMTP id a640c23a62f3a-a7a4bfa22bfmr689297366b.8.1721732450903; Tue, 23 Jul 2024 04:00:50 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a9256553bsm71657966b.70.2024.07.23.04.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:00:50 -0700 (PDT) Date: Tue, 23 Jul 2024 07:00:46 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Igor Mammedov , Alistair Francis , Ani Sinha Subject: [PULL v2 55/61] tests/qtest/bios-tables-test.c: Remove the fall back path Message-ID: <329b327924f7e1a7a735c91b31f722708599e10f.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 11:00: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: 13739890 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 EE92EC3DA63 for ; Tue, 23 Jul 2024 11:02:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGR-0000f0-OV; Tue, 23 Jul 2024 07:01: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 1sWDGP-0000SP-5t for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:01:01 -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 1sWDGN-00032q-Dd for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:01:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732458; 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=frzaX/9P2g2JHb0y+rcKJ68OZ7FiVshaqXNIBgucR7J6P5eW2OwMuSADiFhxTvznJs8Gzb w0Re+H0wgeHSUkVfyzRagG6WyWfTj9UGy+Bsc34YHLLr1LnnSPRpDbKbEZ6nJfJsJ5bw4a qNJAzK9sgjMUH53qalw5O+Fa6Me9W1g= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-600-X8rJZoFJMCqcojAAMlIepg-1; Tue, 23 Jul 2024 07:00:57 -0400 X-MC-Unique: X8rJZoFJMCqcojAAMlIepg-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a77c9c6bdadso49569166b.2 for ; Tue, 23 Jul 2024 04:00:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732455; x=1722337255; 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=AGcqCTRJhKCGFli8QIZdqDyTqHwQqQA4vDN5LUJGF6gCfyfWxyxEB2zz+lUoNwyc3O on335BmuJ8m0qalf+B9vChkAK90lZT157pQvtxtq5ZJMqLnaRuNRF5LNtHu7rSUpiX9Y lrC9ij12dP7TtrG0RILfYx30smR6rtZS+R6kEk/r8SoLC7oeImsjs+RBLSYbMwybYwjl skveiWJvTPZSpXTtD6OqyEOKNZwySm8eFQPZlAiEk3BvI/rK8YfwhvGyA4hPWJFanY2o saAlF5fCBb8s/WfLZUek9S+lskAkBxmUFZv0xy5zc9iVMBY1ukvx/0WTnC52nLnIf3S/ DEGw== X-Gm-Message-State: AOJu0Ywv+1V5GhDf2PW0tyPssXxp+oiWPoFVdfK6UJUIm/s69rtx/Eyb c5Frhh17IepQ+3c+vhpMGkJkX0pJJr2LX4F96ufwgJTWITN0KJTmEERl2xFqzweMlM2L+v0LeiL ckUKQcoWOJbhJtB9oYcKP8NuuHJujWY+0AcwBPFLI2ze0NRa4bR5lqwoXjPOw0UD5rZ49Jm5lEg LtdeRQuCOQO9Qv3+W+NRxi/LHmuq+KKA== X-Received: by 2002:a17:906:7315:b0:a77:cd51:3b32 with SMTP id a640c23a62f3a-a7a4c45555amr703390766b.62.1721732455593; Tue, 23 Jul 2024 04:00:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMlIEs/VclIdqLZ0sRivY+ZDHiB3WnRjOkoZq5ol3WksP4uaEgNGUJNR6RmnnsuqhfEn1MQw== X-Received: by 2002:a17:906:7315:b0:a77:cd51:3b32 with SMTP id a640c23a62f3a-a7a4c45555amr703386866b.62.1721732454838; Tue, 23 Jul 2024 04:00:54 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c922b49sm523517266b.181.2024.07.23.04.00.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:00:54 -0700 (PDT) Date: Tue, 23 Jul 2024 07:00: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 v2 56/61] 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 11:00: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: 13739901 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 6003AC3DA63 for ; Tue, 23 Jul 2024 11:03:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGa-00012r-8J; Tue, 23 Jul 2024 07:01: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 1sWDGU-0000sY-9l for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:01: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 1sWDGR-00033U-R0 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:01:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732463; 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=SVFVkkp9UNBGqDiUJZxAdtrSW6PP/z43UCWx+g8TDR4/6OB4LcoJIPsmyzUtsxYenCRuwP kOHcG+ELBJ5w1P1+AkXSltFChyWZkvrkJQb1YFKpMKJSX1tR4e3GnP1sUSFH/geivAIqmn Xbz4oZvhh617Nzf7xtxJ9lpn9Zu4GcU= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-odEllz1VNPaf61ykFfxviQ-1; Tue, 23 Jul 2024 07:01:02 -0400 X-MC-Unique: odEllz1VNPaf61ykFfxviQ-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5a766a51b0dso1454857a12.1 for ; Tue, 23 Jul 2024 04:01:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732460; x=1722337260; 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=ammD+2SST0dlOrv4QcytykTGR/rxSXOg6A4ngxBdVR1UZ/8exNDnRSqU0ctSDzWVn7 IU4Y6ynOKAIbCoYCauziEJsCNVjrPcK+LpqNaCkKlOngIjBocaygjw7CmdS8b9jIXrk6 OspbYkjq8PSiO8o/Ocu7n7lw88TIYH1fuDPIiGDCoGTL6BpbHtm7wzC1hprDCsl2ZiZW d+m9F/dth+ck+4DaXOG2mCmOKJQUaM0TbkHtAwqbertqFggTV2n/glK7Dvpf9BdZgYfC nvjJwKwB5J9IuUXQTRheLefSpt6eAMuswSJhpj4oiWBJP0IqSqIUlMVh2gmI1P8S3Sby 0Wmw== X-Gm-Message-State: AOJu0YwRBDyO5i68BzyevFZe3RdwoxXP0Oy8+HVrAVj3TG7yFKni7sKd BzX8eEED2ZKNmE4Zx33kIlfXusTkEHpLMtrQTBKHTw9lKQD1wHTyQmVTkHR0ZQp3JQZsaVrjcU/ Ltt5KvB5p7dE/HdefhVdd52nSTu0usFz8uJLZmb8ts84Fp5T2IM2CluTFiOVJlQm7fWekct67tG /IMVxv2gFjID2DZtV4G+xdXdCccZ3PyA== X-Received: by 2002:a50:c316:0:b0:5a2:2654:7fd1 with SMTP id 4fb4d7f45d1cf-5a479c68cc3mr5390683a12.36.1721732460402; Tue, 23 Jul 2024 04:01:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEBYVThZX7ANk5IUMxdIRk0Vu14SbL3gPO8WF7QGVZAyZ8iPgX4EIBb+/Fbxohn7nCi3rQ2Gg== X-Received: by 2002:a50:c316:0:b0:5a2:2654:7fd1 with SMTP id 4fb4d7f45d1cf-5a479c68cc3mr5390651a12.36.1721732459775; Tue, 23 Jul 2024 04:00:59 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30aaa2c72sm7306317a12.33.2024.07.23.04.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:00:59 -0700 (PDT) Date: Tue, 23 Jul 2024 07:00: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 v2 57/61] tests/qtest/bios-tables-test.c: Enable basic testing for RISC-V Message-ID: <5b966e548fb7a530431379bab053eb1d6fb25867.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 11:01: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: 13739902 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 DA945C3DA7F for ; Tue, 23 Jul 2024 11:03:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGh-00029j-Pv; Tue, 23 Jul 2024 07:01:19 -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 1sWDGZ-0001K3-TG for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:01: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 1sWDGX-00034G-UM for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:01:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732469; 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=WrxhFKCRwxQ3be9QrNOeGnF/sX9Gw962dcVN1eb+5i9Dhw35ketMsJiR8Ma6uEwDd1gnKt CnqoPZ/mQx5ej3KrTxaEaQQ8EyP8idX5F/ChgUrT/vgeCYuXXhPLVIAcT9vifRnPM9bgh5 g5atlO0Qnx1khlR0qT1hJ64FCtSeX8s= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-127-Cv0cazVyNzikwozuR2Qxkg-1; Tue, 23 Jul 2024 07:01:07 -0400 X-MC-Unique: Cv0cazVyNzikwozuR2Qxkg-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2ef311ad4bcso17984551fa.0 for ; Tue, 23 Jul 2024 04:01:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732465; x=1722337265; 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=anrKIizCZ25AuiP0llJbs9KxNIGNqNFuvoeU1c2kF+No79rxIY1x21+Wi/iH1zlXQ3 Lb3izXzhQShOqZDqABl0wS6Bt2aNb/CcfXCQfbMGCRY8JWIwbVLm9j6KaPAxRPEqSH6Q zygDd+/arFxtj2dKwM+PtyUF2vI3MpTwuGn4tZYXrGaQIKnErIpE3UxuW3+FIlEYWJ2/ cyAiq0jFIivbeH/TijQ6vWCb5LCh9+mvOTXR+Z7Cp+FyPnaAc6g0acFcI/lxY9DP1LvM HYjDFbn6ksblkJ9Ib4sQkZrrzleW+j7/wnYRkgA2X8PoOwHUvxSgvBP4PpcBavlBXaz1 7g3A== X-Gm-Message-State: AOJu0YzhvLZKhaqSvGXWB1dyxCsfYZ/RNQC45/PixHoA+4Gz2krLLFeE fIqXG0jtzb2Wdjw/UIovFIqgWDXNzPq2OHW1NLou8TBKPF7m0BAF4OifsYqBzVbdhWn9vURLD6g XLX3EPgqAZbs4DzoVzwJ8SYdss8g+mzZudYCQV1sFLnYvfJKK/53dAdLIpdNjVl8pCPRupZsvGs iXzpSg92W043YpYFEG8YR/rij85Rzy0Q== X-Received: by 2002:a2e:b5b7:0:b0:2ef:18b7:440b with SMTP id 38308e7fff4ca-2ef18b7487cmr57324851fa.12.1721732464981; Tue, 23 Jul 2024 04:01:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGk4nm09xoUh8cIMmS3LS83RAFgUA+XZw7BRqAtMwF4Omqwx0DD5SaIbJEssNRSdJx3QuDPVA== X-Received: by 2002:a2e:b5b7:0:b0:2ef:18b7:440b with SMTP id 38308e7fff4ca-2ef18b7487cmr57324471fa.12.1721732464078; Tue, 23 Jul 2024 04:01:04 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30af83177sm7419744a12.42.2024.07.23.04.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:01:03 -0700 (PDT) Date: Tue, 23 Jul 2024 07:01:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Alistair Francis , Igor Mammedov , Ani Sinha Subject: [PULL v2 58/61] 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.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Tue Jul 23 11:01: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: 13739900 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 DD5F7C3DA70 for ; Tue, 23 Jul 2024 11:03:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGi-0002LX-W4; Tue, 23 Jul 2024 07:01: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 1sWDGd-0001jO-Uz for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:01:17 -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 1sWDGb-00034a-Nl for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:01:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732473; 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=FPPMqBXBbopfrVn2oO1xaIdgxG+1KT6+t54O0ejsppQUpr8taB/d75yAkcGhh82j53OQEo BGZBUFOovwOrE9tBu58ZCY0s7AYyFfHQ0VNte7BjDfqHs9/lHtQbQq75J4nUHsE2urr9/S NdSDobkQu5BAR0P5zuZozDAEWSPGCw4= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-678-hQBZiScvPRGwZJIYJr7F4Q-1; Tue, 23 Jul 2024 07:01:11 -0400 X-MC-Unique: hQBZiScvPRGwZJIYJr7F4Q-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a77c6ea022fso115440966b.1 for ; Tue, 23 Jul 2024 04:01:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732470; x=1722337270; 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=qXi22SCcYPlErqGItiW6iduKwDhjqPCJYFDUXB8iFvbHGjF1WKP7Ln0J7tuweBDhZN q5ifa4tejxhvTu3bfUkFDvKvSLn5fyNE5R5cgMsWsbycwYfr74J8bwbkpTBfaM+DxNl6 N7Z0Meunmn+fybA1GILsKD4CNMeRw1sgI9bUc4iHTjvpAXgsIUbgFKJYOB7PueSR/tzx jkeESqF1bxrcCVqCDLyst+B7a0MfzM9Kb6Z4VxfqIAsgZo8eIByb/gsJbVLG5CaWcr6z IeaAv/QD0/LaWjn/KHoU9VtHGHDTupDBAcX4fNssy9ejDPqLngNRTDpY1rI4Wcn3+xGR 035A== X-Gm-Message-State: AOJu0YxFHwQgvH3wGuUNaXn7Fd1yYmWBfQjLoFbQDDQYd2JHfG9oY4kE mlwJz9DN078/RA0tqTFzJNTacEG0OUbvAjLkGIKkCP7QejoeUM5lPGEKUSVVq5Ep3DlXG42eBNG 0Bb3bZHZpyIfHJHzTkka3C2H+3zdvjjnYP1AM0oaPXuulZWzZDgcsMS2aq2QC73JLyhz/ecRBql 3waeTbOrjvaZx15vm9EcVvkD+2Mt0wOA== X-Received: by 2002:a17:907:80c:b0:a72:83ad:f087 with SMTP id a640c23a62f3a-a7a9424f0dcmr177432066b.10.1721732470068; Tue, 23 Jul 2024 04:01:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgXb83KakDr1nH38tMDI093Vx93BbNff5N+ytvs/3oIj4VGTpGgE0zdK7+7MKVE63Ol7jkaA== X-Received: by 2002:a17:907:80c:b0:a72:83ad:f087 with SMTP id a640c23a62f3a-a7a9424f0dcmr177421966b.10.1721732468489; Tue, 23 Jul 2024 04:01:08 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c785b89sm524326966b.36.2024.07.23.04.01.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:01:07 -0700 (PDT) Date: Tue, 23 Jul 2024 07:01:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alistair Francis , Alistair Francis , Jonathan Cameron , Wilfred Mallawa , Marcel Apfelbaum , Huai-Cheng Kuo , Chris Browy Subject: [PULL v2 59/61] hw/pci: Add all Data Object Types defined in PCIe r6.0 Message-ID: <78cc8c69475042ce6b6f720f8c81920fead0d86e.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 11:01:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13739891 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 E6716C3DA70 for ; Tue, 23 Jul 2024 11:02:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGm-0002jw-QG; Tue, 23 Jul 2024 07:01: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 1sWDGk-0002TH-5I for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:01:22 -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 1sWDGh-00035J-Gj for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:01:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732478; 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=cu9uDt4RM/WMmXlulpiqQyttdpYpr5lIsuVtnVqiAZPmt4woCf44v4jvpHXbIHF2PvAv8b 601badVSN+tMEDbUVFWfpkwNp513NAFaKMII4mj9vr3EhtlPUwWegJzFqETWhSbvifZE8t AP/7szCGzA+euRvFCALrpJU6byEBGv0= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-104-ZTcY5wGyM1mucySRcrLQqQ-1; Tue, 23 Jul 2024 07:01:16 -0400 X-MC-Unique: ZTcY5wGyM1mucySRcrLQqQ-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5a2a0e94a66so3997170a12.2 for ; Tue, 23 Jul 2024 04:01:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732475; x=1722337275; 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=k6LoCBJK2Xk7BwFIAUw7hSEdingA+KSM+AfXu5A6zjlfWVjGz7hfn6AMEVVDe1u7dJ Lca5hxXPXNbXavyWZ0/PTP9wJ6I03ULz0oeTOBbPiap1PByiXUcY6GjmYOdmT1lfeNHY u5PuDeVOFJUYYmDmlobTV5p6tys40AvyVztWO0RJPzCDdvmOndTusnI2GWvprIPyDUUr W3eccAv5iBccRezZD8SSlfJDiYUZIcVX24EFCAB7gtHvH/m0zYb1CKhLpGlaodn81E3m UxiwXBMZLikJTvknb1ALiSTucm94cloNcx2cAs8gbeMcoBQQY7bVCd2rCNjX6YDNx9zh 6r5A== X-Gm-Message-State: AOJu0Yz0IotEp9jqYsQc615eCREXXBI5UgSK2ESy1vyS8EMJjx5wPS6y lc0zofOjMU9MB9USHss2MXIN/HP93V0d4gC3ZNf0cwjXfLQXNIVW2vWovJWr4dcjvIIXk08H7OA gEu6kpe5HeylWnh2R6UBFZiRa8hmG5bIq+DiQ/AZFyk5ybe+3GhN2JrA8I1fG7Tmq64reR/eHzI uZ/yGbV1UltR2r/rDoojRK5HRQfer70g== X-Received: by 2002:a05:6402:234d:b0:5a2:2fa5:f145 with SMTP id 4fb4d7f45d1cf-5a47a61f4b0mr7933980a12.25.1721732475212; Tue, 23 Jul 2024 04:01:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEVwTINZGpZFcO897R6Kq2PrdhsUFBLbBRGNNhepGZmOrR5vwSijTm7mI+EiDtskU/ke1HOaQ== X-Received: by 2002:a05:6402:234d:b0:5a2:2fa5:f145 with SMTP id 4fb4d7f45d1cf-5a47a61f4b0mr7933927a12.25.1721732474499; Tue, 23 Jul 2024 04:01:14 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5a30c2f87d1sm7406620a12.70.2024.07.23.04.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:01:13 -0700 (PDT) Date: Tue, 23 Jul 2024 07:01:09 -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 v2 60/61] 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.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, 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.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: 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 Tue Jul 23 11:01:15 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: 13739907 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 BA670C3DA49 for ; Tue, 23 Jul 2024 11:06:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWDGt-0003pp-T8; Tue, 23 Jul 2024 07:01:32 -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 1sWDGq-0003Mc-U0 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:01:29 -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 1sWDGn-00037T-UM for qemu-devel@nongnu.org; Tue, 23 Jul 2024 07:01:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721732485; 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=Eg2L/BqMSj+7yxkRaNszGg93SYz4q9bZnHVOtdS0PSlBOHhzKTnKcBy/JHmv1uM1zZXk6B A90BGxrDh1HIBBCekJqRcX8dw/wandh71GTP2cRLwn7tV8ZTBxCJBcN7Unz/EoGPJW0m2b Pk0es0g1zbmvmTB0crRcVMan0AsXYH8= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-Jor61nVzMFWp_UIpY--IXg-1; Tue, 23 Jul 2024 07:01:23 -0400 X-MC-Unique: Jor61nVzMFWp_UIpY--IXg-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a77c6ea022fso115469866b.1 for ; Tue, 23 Jul 2024 04:01:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721732482; x=1722337282; 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=TyqFeQdPNi1im9a6zLzKvMy97xKBhv5bF5JfYZiIQM2msFIYJ3sfw2xwU8UqbHdMXS oaIIFze9KwgCbIctHuDXSSWAqhC5vsICqlTU3TgoenGCb9kVHmAd7cOqbaL0biqEqhS0 0K0yPJuTruU5s+nSjytIIbC9esDvHq+DN/Pxd654M17II9sI220XmuW7dJivoHfKltqG 0u1GdaCKwbkB41iwTeg1WVh1Za9rjwIdoHmVO4qBUIx1vqwz7vS9MdFCFqWhauZA5Ru7 iMsOQYznsTAsk9KOBia2m9NPfTxd+fX3s+M9pvJFPx+pB+rJe/POsiazcq4Z4UOQYGzX YxOA== X-Gm-Message-State: AOJu0YybMFoNTkEOwm1o+CM/w3DEN6N/EwfZI/m024Zc04SUrkzFui/z Aamr1lUnYjnfi7gl6zwcHg3HZdbqmscDJvzlR7ET0qPYTTC58i8XEZg+bSkQ84u5kjUONMTseZy AzDZiBrelp1E3+pWrCdZMBKtZXaU9vQGT+RjiQ2AA4c8cnnE9lRFdsqyRRgeAvxPlx59RTX4PJ+ T76WyR8ZqtDQuCh7GiH6hLZk3Nl9s0Bg== X-Received: by 2002:a17:907:968e:b0:a6f:5609:954f with SMTP id a640c23a62f3a-a7a9424f8abmr191016366b.12.1721732481857; Tue, 23 Jul 2024 04:01:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzhrm6oRIkal/3g+8hl1Qd+d93FkXIakgUOWiPKALl8AYc4nkxKfqJjrncyCuyhTgtIKNHdg== X-Received: by 2002:a17:907:968e:b0:a6f:5609:954f with SMTP id a640c23a62f3a-a7a9424f8abmr191010366b.12.1721732481125; Tue, 23 Jul 2024 04:01:21 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:440:9c9a:ffee:509d:1766:aa7f]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c785ea4sm524248266b.37.2024.07.23.04.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 04:01:20 -0700 (PDT) Date: Tue, 23 Jul 2024 07:01:15 -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 v2 61/61] hw/nvme: Add SPDM over DOE support Message-ID: <4f947b10d525958578002848a92eeb6152ffbf0d.1721731723.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.133, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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