From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351833; cv=none; d=zohomail.com; s=zohoarc; b=UmEF1yQfuetYGf6EW6ATuEGaPWplFWDWcdNxOt9adnkmkdBueVjLmqGCaAqqKyBmHxKYzR/1Ej6qyysM+svsJeZ7c91BAEpImrfuFfaHe9rqASHdeMLrrfxjl4woF5z9UEaOCcN9/6TBFE1rKlnPm5wl44olH6YQDLiWXWpqqR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351833; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DeT9trR7h5e0mt3T72UGK2kZ1Wd+DrRHHhGgZvqMeCU=; b=EgVxypznqKyWRqtY7DxgivxJh2okqAgfU1Rw4pg9bKbCiDc8wAHpGHloQgCasp0hA20cPPwOG59/vIzPGeE/aToI/1kE2lx1QBZfDyFvO1CqN+rOtGfU8LdaQMW4Ubab064OeJzsdcxmgrOvtkcPN3LZw9hGVCchmr8qdlWrJ4Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699351833175227.03419999026994; Tue, 7 Nov 2023 02:10:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J28-0001Fb-7L; Tue, 07 Nov 2023 05:10:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J1f-00010O-5D for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:09:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J1d-00029c-BY for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:09:38 -0500 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-480-kKwni7kBNEGXNr59FblkFw-1; Tue, 07 Nov 2023 05:09:35 -0500 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-5093a1a0adcso6167172e87.3 for ; Tue, 07 Nov 2023 02:09:35 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id a11-20020a05600c348b00b0040813e14b49sm15542037wmq.30.2023.11.07.02.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:09:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351776; h=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=DeT9trR7h5e0mt3T72UGK2kZ1Wd+DrRHHhGgZvqMeCU=; b=QCI7f7ASvGHyjjrZZJtALym4t0MK+hrtjmNMmaRR0WssVx1cmy2UjXjy17DrCLNtAhDh6d 7aLdqqHXOHv6rlbFn/pX52Zs2bHv5ictS6oMHu4PqEE9EjqJu8HhGvXp8WCh0E2khlT9BP gTZ6uTSDop88FB5ZR8D6cEhvr8fmxfk= X-MC-Unique: kKwni7kBNEGXNr59FblkFw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351773; x=1699956573; 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=DeT9trR7h5e0mt3T72UGK2kZ1Wd+DrRHHhGgZvqMeCU=; b=uLkqq95CwrHO/2P0GaLItDFV3eYZlEcdHmvSkeF2iZf8wlOGWPe3DCDv8jFZnumWVF VIbDERjykUL8dyOO3xIOE4V9/BRmfA5PHN2GHdIkdASzNTvxzYRJcKWFeoUuX2ArcCU8 FiZ3Cr/52mAwKGFDy5azpekH66BD2qfOIVj2hCCDtbix303xTf55NWBc/kReXk4nSITf dwyTBtzlgs9POuXdnGkx+Xn3h9muMBAiovXi7Syf3A7Y21MrMSwPGKOOA0+eE/O+AIj5 t0XneQsjcNpME1oQKJZZGr9uLhACCpF9lAn2szq+ygzUth1scgdKJ1Jj1W8+6NWav3tJ GkPQ== X-Gm-Message-State: AOJu0Yzlos3r8YBDMWxUn2/J5K1METUpPjn0JRtqZpN7394LO+OlSK7L I0lrBcaLxX3ddYkQdCt7TNxSOxuVBEjhXVAsP6ECgXuIve8ufKxa+UnD3s946j3g+8mGldYPSeG j7nqoRyYSnHeZ8/urkbXGpyjZ1sNtX+hQbLyFDw+/bxh3gu5yr812xrVdvS8gVOlhh3v2 X-Received: by 2002:a05:6512:3e1a:b0:500:7a23:720b with SMTP id i26-20020a0565123e1a00b005007a23720bmr29179045lfv.55.1699351772990; Tue, 07 Nov 2023 02:09:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqhPMdFekfI3h0XME1AiiBJ1hG+KzAc6hF17BRpUj+A15LT9SLMbOAEqhwRtn64O8XvIF0NA== X-Received: by 2002:a05:6512:3e1a:b0:500:7a23:720b with SMTP id i26-20020a0565123e1a00b005007a23720bmr29179020lfv.55.1699351772465; Tue, 07 Nov 2023 02:09:32 -0800 (PST) Date: Tue, 7 Nov 2023 05:09:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek Subject: [PULL 01/63] vhost-user.rst: Improve [GS]ET_VRING_BASE doc Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351835210100003 From: Hanna Czenczek GET_VRING_BASE does not mention that it stops the respective ring. Fix that. Furthermore, it is not fully clear what the "base offset" these commands' documentation refers to is; an offset could be many things. Be more precise and verbose about it, especially given that these commands use different payload structures depending on whether the vring is split or packed. Signed-off-by: Hanna Czenczek Message-Id: <20231016134243.68248-2-hreitz@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/interop/vhost-user.rst | 77 +++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 768fb5c28c..9202b167dd 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -108,6 +108,43 @@ A vring state description =20 :num: a 32-bit number =20 +A vring descriptor index for split virtqueues +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ++-------------+---------------------+ +| vring index | index in avail ring | ++-------------+---------------------+ + +:vring index: 32-bit index of the respective virtqueue + +:index in avail ring: 32-bit value, of which currently only the lower 16 + bits are used: + + - Bits 0=E2=80=9315: Index of the next *Available Ring* descriptor that = the + back-end will process. This is a free-running index that is not + wrapped by the ring size. + - Bits 16=E2=80=9331: Reserved (set to zero) + +Vring descriptor indices for packed virtqueues +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ++-------------+--------------------+ +| vring index | descriptor indices | ++-------------+--------------------+ + +:vring index: 32-bit index of the respective virtqueue + +:descriptor indices: 32-bit value: + + - Bits 0=E2=80=9314: Index of the next *Available Ring* descriptor that = the + back-end will process. This is a free-running index that is not + wrapped by the ring size. + - Bit 15: Driver (Available) Ring Wrap Counter + - Bits 16=E2=80=9330: Index of the entry in the *Used Ring* where the ba= ck-end + will place the next descriptor. This is a free-running index that + is not wrapped by the ring size. + - Bit 31: Device (Used) Ring Wrap Counter + A vring address description ^^^^^^^^^^^^^^^^^^^^^^^^^^^ =20 @@ -1042,18 +1079,50 @@ Front-end message types ``VHOST_USER_SET_VRING_BASE`` :id: 10 :equivalent ioctl: ``VHOST_SET_VRING_BASE`` - :request payload: vring state description + :request payload: vring descriptor index/indices :reply payload: N/A =20 - Sets the base offset in the available vring. + Sets the next index to use for descriptors in this vring: + + * For a split virtqueue, sets only the next descriptor index to + process in the *Available Ring*. The device is supposed to read the + next index in the *Used Ring* from the respective vring structure in + guest memory. + + * For a packed virtqueue, both indices are supplied, as they are not + explicitly available in memory. + + Consequently, the payload type is specific to the type of virt queue + (*a vring descriptor index for split virtqueues* vs. *vring descriptor + indices for packed virtqueues*). =20 ``VHOST_USER_GET_VRING_BASE`` :id: 11 :equivalent ioctl: ``VHOST_USER_GET_VRING_BASE`` :request payload: vring state description - :reply payload: vring state description + :reply payload: vring descriptor index/indices =20 - Get the available vring base offset. + Stops the vring and returns the current descriptor index or indices: + + * For a split virtqueue, returns only the 16-bit next descriptor + index to process in the *Available Ring*. Note that this may + differ from the available ring index in the vring structure in + memory, which points to where the driver will put new available + descriptors. For the *Used Ring*, the device only needs the next + descriptor index at which to put new descriptors, which is the + value in the vring structure in memory, so this value is not + covered by this message. + + * For a packed virtqueue, neither index is explicitly available to + read from memory, so both indices (as maintained by the device) are + returned. + + Consequently, the payload type is specific to the type of virt queue + (*a vring descriptor index for split virtqueues* vs. *vring descriptor + indices for packed virtqueues*). + + The request payload=E2=80=99s *num* field is currently reserved and must= be + set to 0. =20 ``VHOST_USER_SET_VRING_KICK`` :id: 12 --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351915; cv=none; d=zohomail.com; s=zohoarc; b=hccDYEAeWiV41PtJGEsjeCjB7Iu0IvLYEgfcq8RRXO+Wg5zKerYBBEP2cU6HUdWjJQngRKrDwB/V3UirRhu/jJCfqQ7z0GWOsfDyPOIRpXFLusWQQIZuit/PnmwkTDT69BhNi0Vw/hthmwXAITnKQ26fRnyTT03WvDJc1/USK4U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351915; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=G27Bg2CuZWkA/233UntEih70bv+0jSA10exjx5QF86o=; b=MHbs8gDVv7H7Hmp7bwKlc4NAw7YdIqyoF//JEa1zRNOkkk9ddHtEAYMpVM/37Bh+uveiLC6E8nWS7Yf3WjFZ0MfFDrJAGJFa/vibkeqg9O4kJCs+ZV3SKQIKiUyaDQfEpHyHG+B5p+ywafsQVcJ3bUOpvWAb2iK8sXnyzIoaVlE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169935191506635.91629107046549; Tue, 7 Nov 2023 02:11:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J2f-0001u2-Ok; Tue, 07 Nov 2023 05:10:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J1j-00019n-S5 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:09:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J1h-0002A8-SJ for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:09:43 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-xwj_t_VnMc6fpsC6nj3_mw-1; Tue, 07 Nov 2023 05:09:39 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-32de9f93148so2913859f8f.2 for ; Tue, 07 Nov 2023 02:09:39 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id x6-20020a5d6506000000b0032d88e370basm1915059wru.34.2023.11.07.02.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:09:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351781; h=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=G27Bg2CuZWkA/233UntEih70bv+0jSA10exjx5QF86o=; b=IO3gBY4bX3w2mNMIJzCAKVsJHBJvfSNggnPEpLAl3MRg34TlKN9XfhnTGiXaf5Zp+mzi8f zP8P626yCS8wFVc8TrOMGJe3TmWQXVA8N/hg/P3AtGIuVFoZGn2vn5DlukMBYzjAKggD3y Z7W9Db+O/BdXmpmM5sH02v/RmmmwhSw= X-MC-Unique: xwj_t_VnMc6fpsC6nj3_mw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351778; x=1699956578; 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=G27Bg2CuZWkA/233UntEih70bv+0jSA10exjx5QF86o=; b=WWpHGfOLZD7+ybyP4jfKU6m51jn+YnqnNvVkDuwngmq85IJRMiPpcb9H1eG21yKWqN zb8JO9KQtUtpDtmac/8w0Qb8ZrIv1X+HA/AthE3RawmyFrePJMX8acHr8Ka5OLFlKYhA Rmx8VOsxOEb9CfjcByGZFqdeAWWTLsCEgNt7uMZKeoPtejJ2w9qqPihMRWyjujHqbz22 g6amfXpLJ+xCJ+BMRJb286lBhDNvzV0YjfMglrCZX+Xa3KSBKRxdo8D0QmbbmdIxwRuT L8/ppUuR5xLmD78AmA4fT99lGjQHmD32xSWXWRLAbWGx8Lbp1+g9olp15zTdWB4a29uz 94cQ== X-Gm-Message-State: AOJu0YxcA6i/EOuSGCxRXMwAscfp54+9MOZ3KWBh8bXtB9m53emCv4tr JZKOTCtDSc87ajQs5a0KTu2RCWm4ZrlX/3ZWEPhxXOC+tETm6jiSz5t+PrVW2tfArYgKVS4FJni bKM2Wcd9rm5f38vLQ9RNYeNCscmaJyV4pyVV0W9PLbmvj5le+3Ri6j+koFce+m7dBrWvQ X-Received: by 2002:a5d:4147:0:b0:32d:a335:e33d with SMTP id c7-20020a5d4147000000b0032da335e33dmr19807291wrq.58.1699351777817; Tue, 07 Nov 2023 02:09:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IG18XI6ATGCEJOY9QGFrs2KRvdjD4SN3Q09Rgl/NqZaVEDCz4JmjD/8NLhgFP7agrdtjjYfsQ== X-Received: by 2002:a5d:4147:0:b0:32d:a335:e33d with SMTP id c7-20020a5d4147000000b0032da335e33dmr19807273wrq.58.1699351777307; Tue, 07 Nov 2023 02:09:37 -0800 (PST) Date: Tue, 7 Nov 2023 05:09:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi Subject: [PULL 02/63] vhost-user.rst: Clarify enabling/disabling vrings 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351916814100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek Currently, the vhost-user documentation says that rings are to be initialized in a disabled state when VHOST_USER_F_PROTOCOL_FEATURES is negotiated. However, by the time of feature negotiation, all rings have already been initialized, so it is not entirely clear what this means. At least the vhost-user-backend Rust crate's implementation interpreted it to mean that whenever this feature is negotiated, all rings are to put into a disabled state, which means that every SET_FEATURES call would disable all rings, effectively halting the device. This is problematic because the VHOST_F_LOG_ALL feature is also set or cleared this way, which happens during migration. Doing so should not halt the device. Other implementations have interpreted this to mean that the device is to be initialized with all rings disabled, and a subsequent SET_FEATURES call that does not set VHOST_USER_F_PROTOCOL_FEATURES will enable all of them. Here, SET_FEATURES will never disable any ring. This interpretation does not suffer the problem of unintentionally halting the device whenever features are set or cleared, so it seems better and more reasonable. We can clarify this in the documentation by making it explicit that the enabled/disabled state is tracked even while the vring is stopped. Every vring is initialized in a disabled state, and SET_FEATURES without VHOST_USER_F_PROTOCOL_FEATURES simply becomes one way to enable all vrings. Reviewed-by: Stefan Hajnoczi Signed-off-by: Hanna Czenczek Message-Id: <20231016134243.68248-3-hreitz@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/interop/vhost-user.rst | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 9202b167dd..e5a04c04ed 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -411,31 +411,33 @@ negotiation. Ring states ----------- =20 -Rings can be in one of three states: +Rings have two independent states: started/stopped, and enabled/disabled. =20 -* stopped: the back-end must not process the ring at all. +* While a ring is stopped, the back-end must not process the ring at + all, regardless of whether it is enabled or disabled. The + enabled/disabled state should still be tracked, though, so it can come + into effect once the ring is started. =20 -* started but disabled: the back-end must process the ring without +* started and disabled: The back-end must process the ring without causing any side effects. For example, for a networking device, in the disabled state the back-end must not supply any new RX packets, but must process and discard any TX packets. =20 -* started and enabled. +* started and enabled: The back-end must process the ring normally, i.e. + process all requests and execute them. =20 -Each ring is initialized in a stopped state. The back-end must start -ring upon receiving a kick (that is, detecting that file descriptor is -readable) on the descriptor specified by ``VHOST_USER_SET_VRING_KICK`` -or receiving the in-band message ``VHOST_USER_VRING_KICK`` if negotiated, -and stop ring upon receiving ``VHOST_USER_GET_VRING_BASE``. +Each ring is initialized in a stopped and disabled state. The back-end +must start a ring upon receiving a kick (that is, detecting that file +descriptor is readable) on the descriptor specified by +``VHOST_USER_SET_VRING_KICK`` or receiving the in-band message +``VHOST_USER_VRING_KICK`` if negotiated, and stop a ring upon receiving +``VHOST_USER_GET_VRING_BASE``. =20 Rings can be enabled or disabled by ``VHOST_USER_SET_VRING_ENABLE``. =20 -If ``VHOST_USER_F_PROTOCOL_FEATURES`` has not been negotiated, the -ring starts directly in the enabled state. - -If ``VHOST_USER_F_PROTOCOL_FEATURES`` has been negotiated, the ring is -initialized in a disabled state and is enabled by -``VHOST_USER_SET_VRING_ENABLE`` with parameter 1. +In addition, upon receiving a ``VHOST_USER_SET_FEATURES`` message from +the front-end without ``VHOST_USER_F_PROTOCOL_FEATURES`` set, the +back-end must enable all rings immediately. =20 While processing the rings (whether they are enabled or not), the back-end must support changing some configuration aspects on the fly. --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352442; cv=none; d=zohomail.com; s=zohoarc; b=YfJNajpM7t/qmTy2M59PF640tA7icf0pEVyQyNG3bvC6GN9C+04Bmn0L+pkMWxMG/RTjvWJop22nGZBYrr01IdDkhDDa0j5t575H/CocEvVd3nHNKxxgUPGpdz76B5cxGY8MyipB45z+mLrN7w3vFKsyTWBLHh2zOK/+0IdPaPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352442; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Fdk3Bbk2ygBigMnmlg+/ceuCimXYtURlgtx7u8r0kG4=; b=HoRJwJjIoWTTZRtbHOkOv+/EayMqPOEdE1HcaM8uF+jr6orh63IdE+eBjq4OcR5GuJUuq3yHwPFUZex5fY9dnmM5MsoKR+cizhfIeJlj2TMssLfMaMN+j368vMBeleeQE16yL+X138ZVRnlSMNd0pqXU8SjTTGQVBi1iHSRsnJY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352442223320.5588065912211; Tue, 7 Nov 2023 02:20:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J2t-0002SI-K9; Tue, 07 Nov 2023 05:10:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2H-0001Sq-75 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J27-0002Of-3x for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:09 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-Zk3MAzJ7M_W2M8j9UDw-eg-1; Tue, 07 Nov 2023 05:09:44 -0500 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-32db6a28e24so2626894f8f.0 for ; Tue, 07 Nov 2023 02:09:44 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id z6-20020a5d4406000000b003196b1bb528sm1894354wrq.64.2023.11.07.02.09.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:09:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351806; h=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=Fdk3Bbk2ygBigMnmlg+/ceuCimXYtURlgtx7u8r0kG4=; b=HcwWXcBIveDmmWI3fsOXlgZCivZKvUvpQpFH4dPbo1qcxUQ4XCqIcAPhSiaPbG+GdbtJXh WugY6PL9CKLsp0RHVCV3bqju+6UNF9D2zUVwp+HPDIFMVRFf94xG26OSWkX8oL00OYRmrf KGqO7G8veGpZ9IjIiOEGDTqikvpCDgo= X-MC-Unique: Zk3MAzJ7M_W2M8j9UDw-eg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351782; x=1699956582; 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=Fdk3Bbk2ygBigMnmlg+/ceuCimXYtURlgtx7u8r0kG4=; b=gnRC42ovzaZ7IEfrDADwMOci1iINDK9O3WC7Pw/EJMflnrLt8KeFwRnMG2JOhyqc6K cNmBsAXfefgLuTFTLeyKP+0aBWK8bH3/z+LOM5RilhoF7chsD+DZGUyxfVo5OKprJhud tDxYYVKD2RZQmo1b29xB+GzEqOSJQYPvPOFg+84Jg/OXQWgBlc1ppEkrlV5DfntVwVno TdpUUcuX5a0jLbX5vxz2yjNOMF3UW4HZfbCXb4Z0DxmUakB/3ZPBvgMl/Qpjglx+qbp0 5PmzkjOInmbVh9cgVCXOAkJ5agJdHB79hLh837uygsCgGIau8EttiWyFDlmml0UXXK7G x3XQ== X-Gm-Message-State: AOJu0YzSNhfYQpijuIjtWwD/l5R9S9a6nLVR0zG8kETg2CYcozRyS+8u 81N2cuS047NXY6hViuhAlpFycBms4SGzY7Q/ReyOD2MCgHqvDpVCfGIi8xNNUVpY4ok9bKFx1XD aIZsPggu6pqZNt44H89sEkRn9tSauHzQWXOW1URQD3Rgze3ZKKy3wMZrSe61bmXJ3TedV X-Received: by 2002:a05:6000:548:b0:32d:967d:1baf with SMTP id b8-20020a056000054800b0032d967d1bafmr23511936wrf.1.1699351782161; Tue, 07 Nov 2023 02:09:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEr5L896pwP5bqSY39ejRGZe6dqCKmxCznHAarXfvgcW4vUZRzAigeBK1FmoRDI6cCV2LqHGA== X-Received: by 2002:a05:6000:548:b0:32d:967d:1baf with SMTP id b8-20020a056000054800b0032d967d1bafmr23511915wrf.1.1699351781775; Tue, 07 Nov 2023 02:09:41 -0800 (PST) Date: Tue, 7 Nov 2023 05:09:38 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi Subject: [PULL 03/63] vhost-user.rst: Introduce suspended state Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352443580100001 From: Hanna Czenczek In vDPA, GET_VRING_BASE does not stop the queried vring, which is why SUSPEND was introduced so that the returned index would be stable. In vhost-user, it does stop the vring, so under the same reasoning, it can get away without SUSPEND. Still, we do want to clarify that if the device is completely stopped, i.e. all vrings are stopped, the back-end should cease to modify any state relating to the guest. Do this by calling it "suspended". Suggested-by: Stefan Hajnoczi Reviewed-by: Stefan Hajnoczi Signed-off-by: Hanna Czenczek Message-Id: <20231016134243.68248-4-hreitz@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/interop/vhost-user.rst | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index e5a04c04ed..035a23ed35 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -442,6 +442,19 @@ back-end must enable all rings immediately. While processing the rings (whether they are enabled or not), the back-end must support changing some configuration aspects on the fly. =20 +.. _suspended_device_state: + +Suspended device state +^^^^^^^^^^^^^^^^^^^^^^ + +While all vrings are stopped, the device is *suspended*. In addition to +not processing any vring (because they are stopped), the device must: + +* not write to any guest memory regions, +* not send any notifications to the guest, +* not send any messages to the front-end, +* still process and reply to messages from the front-end. + Multiple queue support ---------------------- =20 @@ -529,7 +542,8 @@ ancillary data, it may be used to inform the front-end = that the log has been modified. =20 Once the source has finished migration, rings will be stopped by the -source. No further update must be done before rings are restarted. +source (:ref:`Suspended device state `). No +further update must be done before rings are restarted. =20 In postcopy migration the back-end is started before all the memory has been received from the source host, and care must be taken to avoid @@ -1123,6 +1137,10 @@ Front-end message types (*a vring descriptor index for split virtqueues* vs. *vring descriptor indices for packed virtqueues*). =20 + When and as long as all of a device=E2=80=99s vrings are stopped, it is + *suspended*, see :ref:`Suspended device state + `. + The request payload=E2=80=99s *num* field is currently reserved and must= be set to 0. =20 --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351891; cv=none; d=zohomail.com; s=zohoarc; b=AeWeYx5Zk0BjROk0Qe6LbLVAI3YGrJPLWfqe6zEmXWc4gh+digSblB5RxjLFcxadg696NA60xvu+AoypwI0jf1QsN4hoO6y+5KuJTkm12WaTmMbKc0bkTTkv2cpPTfhCx41Pi68YyIN0xCUNCw6/oWEcA56r+TVqA2chjw6Izek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351891; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YWLBUPNHyqIgaDsH/NKMJYaI7p7tGB+GFjMGe7gNgQ8=; b=F3A3rqxqnHAoWkWYPkM1PPllgm7zWP0prYEpXlGpiNry7KwJ6wzti3ppdw8UeC+9+yNwxZ5ozwlDDZ0xWa++hQFnp8IM3Y40DrnCWxWNvlYYuh7rlrFMKFOIqP93r6NxHQs28cbAC6krjhwN8ZHQGgzcTEMbtzFb2SCW7/0LKaI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699351891897966.051162595979; Tue, 7 Nov 2023 02:11:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J2p-0002Pn-Oc; Tue, 07 Nov 2023 05:10:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2H-0001Sv-Mc for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J1v-0002BM-I8 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:16 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-29-K3OVFPB_PViU3caLIaE0wQ-1; Tue, 07 Nov 2023 05:09:48 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-32fa41d0564so2858658f8f.0 for ; Tue, 07 Nov 2023 02:09:48 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id dk11-20020a0560000b4b00b003197869bcd7sm1912597wrb.13.2023.11.07.02.09.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:09:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351794; h=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=YWLBUPNHyqIgaDsH/NKMJYaI7p7tGB+GFjMGe7gNgQ8=; b=PHMQjq4A4Yd8p6YtX7XCkL/JWqHiE/kFVWYGu8aXZVakdh6TDt85YJx9l+JEZFMDONfp6r IXDqZL4tcQ8wIFZ+XNy3hsFWEF/t2LDprkgluIf9Vbx6h7QpkLT6PADfzOuWKp76HSYYkO HP3UlqKUAD93mr+xlU5Frx3vpevRChg= X-MC-Unique: K3OVFPB_PViU3caLIaE0wQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351786; x=1699956586; 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=YWLBUPNHyqIgaDsH/NKMJYaI7p7tGB+GFjMGe7gNgQ8=; b=EjwRC2PAoIL0hpcvBQeO1e2uDqGoL9+U2WmxCsPo5yn6lCKpUKiUdtbUq2ZFNIfyzT cD3FaFrq/rAamCkZ/6K5XUq2eVgwPl50yjrASBndATcJcvJ6L02SaG0zw95Vyz16Ents Y46K9aSE8RtnTJ8TP1pFPN5FmqG0L3Xsw9iC3uROaWDiudD6LBswlxM0L5JVmJSoXLCX OK4h8QWc/n2NqykGbS0PrZJqTd+z7W9fvdE+8+i/CINlAqc2c9PYYuvbxfefMcJc9qgt /xEElVgpRXroifxGFX7erxvKy4H/EAS2jhhl0pnI245iN6Sh69DL/ns4YqM+2qdAwoSo 2HPg== X-Gm-Message-State: AOJu0YyiqqnlQTdVHORNJAF3lzV/AvBXNnpj2gkexLn7S2hZ+uUCejm/ rkNya4DtViluGFb51c0K+OLt4Zx8MksPMb+V+Yg6VU/lCp8D0iYXOwQLCmpTJj0EDAVm/3M0PP2 7//d46G//6zlHfdzMogB0kcOySbh587SmOUVXZVI+yHH7oC38MMPz3uqXdfpVDmJgiVDn X-Received: by 2002:a05:6000:1864:b0:32f:7f32:ed3f with SMTP id d4-20020a056000186400b0032f7f32ed3fmr27089335wri.49.1699351786443; Tue, 07 Nov 2023 02:09:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHCcOSkrk9aHJmOqRk/IWbLsjMS5n+eqmFYj2XTdKk2mKPrV3NmN0frnAyvBthTZ2Xa635Nvw== X-Received: by 2002:a05:6000:1864:b0:32f:7f32:ed3f with SMTP id d4-20020a056000186400b0032f7f32ed3fmr27089307wri.49.1699351785847; Tue, 07 Nov 2023 02:09:45 -0800 (PST) Date: Tue, 7 Nov 2023 05:09:41 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi Subject: [PULL 04/63] vhost-user.rst: Migrating back-end-internal state Message-ID: <019233096c03b826e0e677115b6e3c550a54a48d.1699351720.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351894338100003 From: Hanna Czenczek For vhost-user devices, qemu can migrate the virtio state, but not the back-end's internal state. To do so, we need to be able to transfer this internal state between front-end (qemu) and back-end. At this point, this new feature is added for the purpose of virtio-fs migration. Because virtiofsd's internal state will not be too large, we believe it is best to transfer it as a single binary blob after the streaming phase. These are the additions to the protocol: - New vhost-user protocol feature VHOST_USER_PROTOCOL_F_DEVICE_STATE - SET_DEVICE_STATE_FD function: Front-end and back-end negotiate a file descriptor over which to transfer the state. - CHECK_DEVICE_STATE: After the state has been transferred through the file descriptor, the front-end invokes this function to verify success. There is no in-band way (through the file descriptor) to indicate failure, so we need to check explicitly. Once the transfer FD has been established via SET_DEVICE_STATE_FD (which includes establishing the direction of transfer and migration phase), the sending side writes its data into it, and the reading side reads it until it sees an EOF. Then, the front-end will check for success via CHECK_DEVICE_STATE, which on the destination side includes checking for integrity (i.e. errors during deserialization). Reviewed-by: Stefan Hajnoczi Signed-off-by: Hanna Czenczek Message-Id: <20231016134243.68248-5-hreitz@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/interop/vhost-user.rst | 172 ++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 035a23ed35..9f1103f85a 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -322,6 +322,32 @@ VhostUserShared :UUID: 16 bytes UUID, whose first three components (a 32-bit value, then two 16-bit values) are stored in big endian. =20 +Device state transfer parameters +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ++--------------------+-----------------+ +| transfer direction | migration phase | ++--------------------+-----------------+ + +:transfer direction: a 32-bit enum, describing the direction in which + the state is transferred: + + - 0: Save: Transfer the state from the back-end to the front-end, + which happens on the source side of migration + - 1: Load: Transfer the state from the front-end to the back-end, + which happens on the destination side of migration + +:migration phase: a 32-bit enum, describing the state in which the VM + guest and devices are: + + - 0: Stopped (in the period after the transfer of memory-mapped + regions before switch-over to the destination): The VM guest is + stopped, and the vhost-user device is suspended (see + :ref:`Suspended device state `). + + In the future, additional phases might be added e.g. to allow + iterative migration while the device is running. + C structure ----------- =20 @@ -381,6 +407,7 @@ in the ancillary data: * ``VHOST_USER_SET_VRING_ERR`` * ``VHOST_USER_SET_BACKEND_REQ_FD`` (previous name ``VHOST_USER_SET_SLAVE_= REQ_FD``) * ``VHOST_USER_SET_INFLIGHT_FD`` (if ``VHOST_USER_PROTOCOL_F_INFLIGHT_SHMF= D``) +* ``VHOST_USER_SET_DEVICE_STATE_FD`` =20 If *front-end* is unable to send the full message or receives a wrong reply it will close the connection. An optional reconnection mechanism @@ -555,6 +582,80 @@ it performs WAKE ioctl's on the userfaultfd to wake th= e stalled back-end. The front-end indicates support for this via the ``VHOST_USER_PROTOCOL_F_PAGEFAULT`` feature. =20 +.. _migrating_backend_state: + +Migrating back-end state +^^^^^^^^^^^^^^^^^^^^^^^^ + +Migrating device state involves transferring the state from one +back-end, called the source, to another back-end, called the +destination. After migration, the destination transparently resumes +operation without requiring the driver to re-initialize the device at +the VIRTIO level. If the migration fails, then the source can +transparently resume operation until another migration attempt is made. + +Generally, the front-end is connected to a virtual machine guest (which +contains the driver), which has its own state to transfer between source +and destination, and therefore will have an implementation-specific +mechanism to do so. The ``VHOST_USER_PROTOCOL_F_DEVICE_STATE`` feature +provides functionality to have the front-end include the back-end's +state in this transfer operation so the back-end does not need to +implement its own mechanism, and so the virtual machine may have its +complete state, including vhost-user devices' states, contained within a +single stream of data. + +To do this, the back-end state is transferred from back-end to front-end +on the source side, and vice versa on the destination side. This +transfer happens over a channel that is negotiated using the +``VHOST_USER_SET_DEVICE_STATE_FD`` message. This message has two +parameters: + +* Direction of transfer: On the source, the data is saved, transferring + it from the back-end to the front-end. On the destination, the data + is loaded, transferring it from the front-end to the back-end. + +* Migration phase: Currently, the only supported phase is the period + after the transfer of memory-mapped regions before switch-over to the + destination, when both the source and destination devices are + suspended (:ref:`Suspended device state `). + In the future, additional phases might be supported to allow iterative + migration while the device is running. + +The nature of the channel is implementation-defined, but it must +generally behave like a pipe: The writing end will write all the data it +has into it, signalling the end of data by closing its end. The reading +end must read all of this data (until encountering the end of file) and +process it. + +* When saving, the writing end is the source back-end, and the reading + end is the source front-end. After reading the state data from the + channel, the source front-end must transfer it to the destination + front-end through an implementation-defined mechanism. + +* When loading, the writing end is the destination front-end, and the + reading end is the destination back-end. After reading the state data + from the channel, the destination back-end must deserialize its + internal state from that data and set itself up to allow the driver to + seamlessly resume operation on the VIRTIO level. + +Seamlessly resuming operation means that the migration must be +transparent to the guest driver, which operates on the VIRTIO level. +This driver will not perform any re-initialization steps, but continue +to use the device as if no migration had occurred. The vhost-user +front-end, however, will re-initialize the vhost state on the +destination, following the usual protocol for establishing a connection +to a vhost-user back-end: This includes, for example, setting up memory +mappings and kick and call FDs as necessary, negotiating protocol +features, or setting the initial vring base indices (to the same value +as on the source side, so that operation can resume). + +Both on the source and on the destination side, after the respective +front-end has seen all data transferred (when the transfer FD has been +closed), it sends the ``VHOST_USER_CHECK_DEVICE_STATE`` message to +verify that data transfer was successful in the back-end, too. The +back-end responds once it knows whether the transfer and processing was +successful or not. + Memory access ------------- =20 @@ -949,6 +1050,7 @@ Protocol features #define VHOST_USER_PROTOCOL_F_STATUS 16 #define VHOST_USER_PROTOCOL_F_XEN_MMAP 17 #define VHOST_USER_PROTOCOL_F_SHARED_OBJECT 18 + #define VHOST_USER_PROTOCOL_F_DEVICE_STATE 19 =20 Front-end message types ----------------------- @@ -1553,6 +1655,76 @@ Front-end message types the requested UUID. Back-end will reply passing the fd when the operation is successful, or no fd otherwise. =20 +``VHOST_USER_SET_DEVICE_STATE_FD`` + :id: 42 + :equivalent ioctl: N/A + :request payload: device state transfer parameters + :reply payload: ``u64`` + + Front-end and back-end negotiate a channel over which to transfer the + back-end=E2=80=99s internal state during migration. Either side (front-= end or + back-end) may create the channel. The nature of this channel is not + restricted or defined in this document, but whichever side creates it + must create a file descriptor that is provided to the respectively + other side, allowing access to the channel. This FD must behave as + follows: + + * For the writing end, it must allow writing the whole back-end state + sequentially. Closing the file descriptor signals the end of + transfer. + + * For the reading end, it must allow reading the whole back-end state + sequentially. The end of file signals the end of the transfer. + + For example, the channel may be a pipe, in which case the two ends of + the pipe fulfill these requirements respectively. + + Initially, the front-end creates a channel along with such an FD. It + passes the FD to the back-end as ancillary data of a + ``VHOST_USER_SET_DEVICE_STATE_FD`` message. The back-end may create a + different transfer channel, passing the respective FD back to the + front-end as ancillary data of the reply. If so, the front-end must + then discard its channel and use the one provided by the back-end. + + Whether the back-end should decide to use its own channel is decided + based on efficiency: If the channel is a pipe, both ends will most + likely need to copy data into and out of it. Any channel that allows + for more efficient processing on at least one end, e.g. through + zero-copy, is considered more efficient and thus preferred. If the + back-end can provide such a channel, it should decide to use it. + + The request payload contains parameters for the subsequent data + transfer, as described in the :ref:`Migrating back-end state + ` section. + + The value returned is both an indication for success, and whether a + file descriptor for a back-end-provided channel is returned: Bits 0=E2= =80=937 + are 0 on success, and non-zero on error. Bit 8 is the invalid FD + flag; this flag is set when there is no file descriptor returned. + When this flag is not set, the front-end must use the returned file + descriptor as its end of the transfer channel. The back-end must not + both indicate an error and return a file descriptor. + + Using this function requires prior negotiation of the + ``VHOST_USER_PROTOCOL_F_DEVICE_STATE`` feature. + +``VHOST_USER_CHECK_DEVICE_STATE`` + :id: 43 + :equivalent ioctl: N/A + :request payload: N/A + :reply payload: ``u64`` + + After transferring the back-end=E2=80=99s internal state during migratio= n (see + the :ref:`Migrating back-end state ` + section), check whether the back-end was able to successfully fully + process the state. + + The value returned indicates success or error; 0 is success, any + non-zero value is an error. + + Using this function requires prior negotiation of the + ``VHOST_USER_PROTOCOL_F_DEVICE_STATE`` feature. + Back-end message types ---------------------- =20 --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352201; cv=none; d=zohomail.com; s=zohoarc; b=O4gZ+Si+2jUVShjZ38MmpGwrbvFSGEXvG0VWwjA4MLvoyr/5Wn4ti6O3rfJARRUSOsjaxrUfORTtINvD1p3c8flaT0avhh3rD5KwMbx8DmvA6B/0oJMJBcQFzqvQ2aoRb4dVGJa9xAbcqCmE5wKu3ZI1LLYzPa+NpbFM8WQjFNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352201; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=++r82DcRgaafZbYYvM+lZq8D84ztJ0xCMQ4u0fVv87w=; b=JKdvGPcYYW+soeDu0N0p2ZbBOEFUBQ8gLSwn/9K8AYb6nKD+7Ec4j5k9YUKsTgheC9YWnK9app1lOktabnCV0O54eCX1oOxeaHRKaSzTlLyNyM9hDYs+RTLwsBBYhXtd/3UaQaRHjmySpUSC2Uk/k3+VJkEdU+qn84iT/eBx0xE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352201920999.8606808169515; Tue, 7 Nov 2023 02:16:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J31-0002ye-Sx; Tue, 07 Nov 2023 05:11:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J1z-0001G1-7C for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J1v-0002BH-Co for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:09:58 -0500 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-59-9nKpcX0pPpy1ebyZmF7Zxg-1; Tue, 07 Nov 2023 05:09:53 -0500 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2c6f33ee403so50751221fa.2 for ; Tue, 07 Nov 2023 02:09:52 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id a15-20020a5d456f000000b0032fab28e9c9sm1901173wrc.73.2023.11.07.02.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:09:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351794; h=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=++r82DcRgaafZbYYvM+lZq8D84ztJ0xCMQ4u0fVv87w=; b=dRtjhWCi4ho91SJEviWV9JA94f2y4KMTmZOMUhFUzQIOspo930QghaSeh0AZbY//fp8yfK iDENlbV0a6aI+nNU1R2tohZVaOuapjE/0b66uaZ3NId2cMtKyyzvfeZBfnGM2bRVsMJ5VY UzA0WPMDXjnh8LEx/SfsLzQ88/ebX28= X-MC-Unique: 9nKpcX0pPpy1ebyZmF7Zxg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351791; x=1699956591; 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=++r82DcRgaafZbYYvM+lZq8D84ztJ0xCMQ4u0fVv87w=; b=D8zoJMjKKB9mPtThLBg30KqgC6jNbVHDk65UB+Ae1Xvz9c8wxFi4ooAYmtV/bix1gs 104QaqyFWc4sjJm/D0n0RhQNTErzFmKzh9CiDff0Hm2PSQ3+w9v9RHvo+g4TsrYrwe/i NGtGlL/L3YnOvkedlp/DVHqRh4Oo16KE1zWKgnzWUEmV4TbC4twkiNQnKD8O7Eg9nS0+ INGZuAxHMTtG8ClC6m2tvD+8bfrf+ypqldHegg0B1Xh0Oz0Axvn2COkC45gnRwJ+M33N c/ygZJHZCCmvH8z0lngzzl/ZyaXdpwT6oobIFIQ27NwlJeEOp5AWyAd5xAAL3PHMc/WS GTwQ== X-Gm-Message-State: AOJu0Yw3WtOzOixkrWMICDg7Xx3jedYdt+zPbdXtyt5XzIhHXhgCkkng sOY6qPn4V3JHVx5+F8td6c54IXfjGgqK2f7v1qoMcleAEAVRUfw1c2nbWN57WD1I4qPhs2dWgCl TvLRLjWPYF96+xTIWkpUq/Y7yIochGB5mt/YPB67sK+SvF2TGcVpMQHFbglewpO+ofp12 X-Received: by 2002:a2e:b254:0:b0:2c5:fde:e457 with SMTP id n20-20020a2eb254000000b002c50fdee457mr24236805ljm.3.1699351790870; Tue, 07 Nov 2023 02:09:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFTzX2KDdyhlAsr0b0DCuvNhpKqYE8CM4Z8klWgqilBx3c791YpTuA+jVoIOuAyUVqti5vXKA== X-Received: by 2002:a2e:b254:0:b0:2c5:fde:e457 with SMTP id n20-20020a2eb254000000b002c50fdee457mr24236784ljm.3.1699351790363; Tue, 07 Nov 2023 02:09:50 -0800 (PST) Date: Tue, 7 Nov 2023 05:09:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi Subject: [PULL 05/63] vhost-user: Interface for migration state transfer Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352202372100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek Add the interface for transferring the back-end's state during migration as defined previously in vhost-user.rst. Reviewed-by: Stefan Hajnoczi Signed-off-by: Hanna Czenczek Message-Id: <20231016134243.68248-6-hreitz@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-backend.h | 24 +++++ include/hw/virtio/vhost-user.h | 1 + include/hw/virtio/vhost.h | 78 ++++++++++++++++ hw/virtio/vhost-user.c | 146 ++++++++++++++++++++++++++++++ hw/virtio/vhost.c | 37 ++++++++ 5 files changed, 286 insertions(+) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index 96ccc18cd3..a86d103f82 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -26,6 +26,18 @@ typedef enum VhostSetConfigType { VHOST_SET_CONFIG_TYPE_MIGRATION =3D 1, } VhostSetConfigType; =20 +typedef enum VhostDeviceStateDirection { + /* Transfer state from back-end (device) to front-end */ + VHOST_TRANSFER_STATE_DIRECTION_SAVE =3D 0, + /* Transfer state from front-end to back-end (device) */ + VHOST_TRANSFER_STATE_DIRECTION_LOAD =3D 1, +} VhostDeviceStateDirection; + +typedef enum VhostDeviceStatePhase { + /* The device (and all its vrings) is stopped */ + VHOST_TRANSFER_STATE_PHASE_STOPPED =3D 0, +} VhostDeviceStatePhase; + struct vhost_inflight; struct vhost_dev; struct vhost_log; @@ -129,6 +141,15 @@ typedef int (*vhost_set_config_call_op)(struct vhost_d= ev *dev, =20 typedef void (*vhost_reset_status_op)(struct vhost_dev *dev); =20 +typedef bool (*vhost_supports_device_state_op)(struct vhost_dev *dev); +typedef int (*vhost_set_device_state_fd_op)(struct vhost_dev *dev, + VhostDeviceStateDirection dire= ction, + VhostDeviceStatePhase phase, + int fd, + int *reply_fd, + Error **errp); +typedef int (*vhost_check_device_state_op)(struct vhost_dev *dev, Error **= errp); + typedef struct VhostOps { VhostBackendType backend_type; vhost_backend_init vhost_backend_init; @@ -176,6 +197,9 @@ typedef struct VhostOps { vhost_force_iommu_op vhost_force_iommu; vhost_set_config_call_op vhost_set_config_call; vhost_reset_status_op vhost_reset_status; + vhost_supports_device_state_op vhost_supports_device_state; + vhost_set_device_state_fd_op vhost_set_device_state_fd; + vhost_check_device_state_op vhost_check_device_state; } VhostOps; =20 int vhost_backend_update_device_iotlb(struct vhost_dev *dev, diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 20b69d8e85..d7c09ffd34 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -31,6 +31,7 @@ enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_STATUS =3D 16, /* Feature 17 reserved for VHOST_USER_PROTOCOL_F_XEN_MMAP. */ VHOST_USER_PROTOCOL_F_SHARED_OBJECT =3D 18, + VHOST_USER_PROTOCOL_F_DEVICE_STATE =3D 19, VHOST_USER_PROTOCOL_F_MAX }; =20 diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 5e8183f64a..b6ee6da6ce 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -351,4 +351,82 @@ static inline int vhost_reset_device(struct vhost_dev = *hdev) } #endif /* CONFIG_VHOST */ =20 +/** + * vhost_supports_device_state(): Checks whether the back-end supports + * transferring internal device state for the purpose of migration. + * Support for this feature is required for vhost_set_device_state_fd() + * and vhost_check_device_state(). + * + * @dev: The vhost device + * + * Returns true if the device supports these commands, and false if it + * does not. + */ +bool vhost_supports_device_state(struct vhost_dev *dev); + +/** + * vhost_set_device_state_fd(): Begin transfer of internal state from/to + * the back-end for the purpose of migration. Data is to be transferred + * over a pipe according to @direction and @phase. The sending end must + * only write to the pipe, and the receiving end must only read from it. + * Once the sending end is done, it closes its FD. The receiving end + * must take this as the end-of-transfer signal and close its FD, too. + * + * @fd is the back-end's end of the pipe: The write FD for SAVE, and the + * read FD for LOAD. This function transfers ownership of @fd to the + * back-end, i.e. closes it in the front-end. + * + * The back-end may optionally reply with an FD of its own, if this + * improves efficiency on its end. In this case, the returned FD is + * stored in *reply_fd. The back-end will discard the FD sent to it, + * and the front-end must use *reply_fd for transferring state to/from + * the back-end. + * + * @dev: The vhost device + * @direction: The direction in which the state is to be transferred. + * For outgoing migrations, this is SAVE, and data is read + * from the back-end and stored by the front-end in the + * migration stream. + * For incoming migrations, this is LOAD, and data is read + * by the front-end from the migration stream and sent to + * the back-end to restore the saved state. + * @phase: Which migration phase we are in. Currently, there is only + * STOPPED (device and all vrings are stopped), in the future, + * more phases such as PRE_COPY or POST_COPY may be added. + * @fd: Back-end's end of the pipe through which to transfer state; note + * that ownership is transferred to the back-end, so this function + * closes @fd in the front-end. + * @reply_fd: If the back-end wishes to use a different pipe for state + * transfer, this will contain an FD for the front-end to + * use. Otherwise, -1 is stored here. + * @errp: Potential error description + * + * Returns 0 on success, and -errno on failure. + */ +int vhost_set_device_state_fd(struct vhost_dev *dev, + VhostDeviceStateDirection direction, + VhostDeviceStatePhase phase, + int fd, + int *reply_fd, + Error **errp); + +/** + * vhost_set_device_state_fd(): After transferring state from/to the + * back-end via vhost_set_device_state_fd(), i.e. once the sending end + * has closed the pipe, inquire the back-end to report any potential + * errors that have occurred on its side. This allows to sense errors + * like: + * - During outgoing migration, when the source side had already started + * to produce its state, something went wrong and it failed to finish + * - During incoming migration, when the received state is somehow + * invalid and cannot be processed by the back-end + * + * @dev: The vhost device + * @errp: Potential error description + * + * Returns 0 when the back-end reports successful state transfer and + * processing, and -errno when an error occurred somewhere. + */ +int vhost_check_device_state(struct vhost_dev *dev, Error **errp); + #endif diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 7b42ae8aae..f214df804b 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -103,6 +103,8 @@ typedef enum VhostUserRequest { VHOST_USER_SET_STATUS =3D 39, VHOST_USER_GET_STATUS =3D 40, VHOST_USER_GET_SHARED_OBJECT =3D 41, + VHOST_USER_SET_DEVICE_STATE_FD =3D 42, + VHOST_USER_CHECK_DEVICE_STATE =3D 43, VHOST_USER_MAX } VhostUserRequest; =20 @@ -201,6 +203,12 @@ typedef struct { uint32_t size; /* the following payload size */ } QEMU_PACKED VhostUserHeader; =20 +/* Request payload of VHOST_USER_SET_DEVICE_STATE_FD */ +typedef struct VhostUserTransferDeviceState { + uint32_t direction; + uint32_t phase; +} VhostUserTransferDeviceState; + typedef union { #define VHOST_USER_VRING_IDX_MASK (0xff) #define VHOST_USER_VRING_NOFD_MASK (0x1 << 8) @@ -216,6 +224,7 @@ typedef union { VhostUserVringArea area; VhostUserInflight inflight; VhostUserShared object; + VhostUserTransferDeviceState transfer_state; } VhostUserPayload; =20 typedef struct VhostUserMsg { @@ -2855,6 +2864,140 @@ static void vhost_user_reset_status(struct vhost_de= v *dev) } } =20 +static bool vhost_user_supports_device_state(struct vhost_dev *dev) +{ + return virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_DEVICE_STATE); +} + +static int vhost_user_set_device_state_fd(struct vhost_dev *dev, + VhostDeviceStateDirection direct= ion, + VhostDeviceStatePhase phase, + int fd, + int *reply_fd, + Error **errp) +{ + int ret; + struct vhost_user *vu =3D dev->opaque; + VhostUserMsg msg =3D { + .hdr =3D { + .request =3D VHOST_USER_SET_DEVICE_STATE_FD, + .flags =3D VHOST_USER_VERSION, + .size =3D sizeof(msg.payload.transfer_state), + }, + .payload.transfer_state =3D { + .direction =3D direction, + .phase =3D phase, + }, + }; + + *reply_fd =3D -1; + + if (!vhost_user_supports_device_state(dev)) { + close(fd); + error_setg(errp, "Back-end does not support migration state transf= er"); + return -ENOTSUP; + } + + ret =3D vhost_user_write(dev, &msg, &fd, 1); + close(fd); + if (ret < 0) { + error_setg_errno(errp, -ret, + "Failed to send SET_DEVICE_STATE_FD message"); + return ret; + } + + ret =3D vhost_user_read(dev, &msg); + if (ret < 0) { + error_setg_errno(errp, -ret, + "Failed to receive SET_DEVICE_STATE_FD reply"); + return ret; + } + + if (msg.hdr.request !=3D VHOST_USER_SET_DEVICE_STATE_FD) { + error_setg(errp, + "Received unexpected message type, expected %d, receive= d %d", + VHOST_USER_SET_DEVICE_STATE_FD, msg.hdr.request); + return -EPROTO; + } + + if (msg.hdr.size !=3D sizeof(msg.payload.u64)) { + error_setg(errp, + "Received bad message size, expected %zu, received %" P= RIu32, + sizeof(msg.payload.u64), msg.hdr.size); + return -EPROTO; + } + + if ((msg.payload.u64 & 0xff) !=3D 0) { + error_setg(errp, "Back-end did not accept migration state transfer= "); + return -EIO; + } + + if (!(msg.payload.u64 & VHOST_USER_VRING_NOFD_MASK)) { + *reply_fd =3D qemu_chr_fe_get_msgfd(vu->user->chr); + if (*reply_fd < 0) { + error_setg(errp, + "Failed to get back-end-provided transfer pipe FD"); + *reply_fd =3D -1; + return -EIO; + } + } + + return 0; +} + +static int vhost_user_check_device_state(struct vhost_dev *dev, Error **er= rp) +{ + int ret; + VhostUserMsg msg =3D { + .hdr =3D { + .request =3D VHOST_USER_CHECK_DEVICE_STATE, + .flags =3D VHOST_USER_VERSION, + .size =3D 0, + }, + }; + + if (!vhost_user_supports_device_state(dev)) { + error_setg(errp, "Back-end does not support migration state transf= er"); + return -ENOTSUP; + } + + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + error_setg_errno(errp, -ret, + "Failed to send CHECK_DEVICE_STATE message"); + return ret; + } + + ret =3D vhost_user_read(dev, &msg); + if (ret < 0) { + error_setg_errno(errp, -ret, + "Failed to receive CHECK_DEVICE_STATE reply"); + return ret; + } + + if (msg.hdr.request !=3D VHOST_USER_CHECK_DEVICE_STATE) { + error_setg(errp, + "Received unexpected message type, expected %d, receive= d %d", + VHOST_USER_CHECK_DEVICE_STATE, msg.hdr.request); + return -EPROTO; + } + + if (msg.hdr.size !=3D sizeof(msg.payload.u64)) { + error_setg(errp, + "Received bad message size, expected %zu, received %" P= RIu32, + sizeof(msg.payload.u64), msg.hdr.size); + return -EPROTO; + } + + if (msg.payload.u64 !=3D 0) { + error_setg(errp, "Back-end failed to process its internal state"); + return -EIO; + } + + return 0; +} + const VhostOps user_ops =3D { .backend_type =3D VHOST_BACKEND_TYPE_USER, .vhost_backend_init =3D vhost_user_backend_init, @@ -2890,4 +3033,7 @@ const VhostOps user_ops =3D { .vhost_set_inflight_fd =3D vhost_user_set_inflight_fd, .vhost_dev_start =3D vhost_user_dev_start, .vhost_reset_status =3D vhost_user_reset_status, + .vhost_supports_device_state =3D vhost_user_supports_device_state, + .vhost_set_device_state_fd =3D vhost_user_set_device_state_fd, + .vhost_check_device_state =3D vhost_user_check_device_state, }; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 9c9ae7109e..4db9dbfd64 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -2159,3 +2159,40 @@ int vhost_reset_device(struct vhost_dev *hdev) =20 return -ENOSYS; } + +bool vhost_supports_device_state(struct vhost_dev *dev) +{ + if (dev->vhost_ops->vhost_supports_device_state) { + return dev->vhost_ops->vhost_supports_device_state(dev); + } + + return false; +} + +int vhost_set_device_state_fd(struct vhost_dev *dev, + VhostDeviceStateDirection direction, + VhostDeviceStatePhase phase, + int fd, + int *reply_fd, + Error **errp) +{ + if (dev->vhost_ops->vhost_set_device_state_fd) { + return dev->vhost_ops->vhost_set_device_state_fd(dev, direction, p= hase, + fd, reply_fd, err= p); + } + + error_setg(errp, + "vhost transport does not support migration state transfer"= ); + return -ENOSYS; +} + +int vhost_check_device_state(struct vhost_dev *dev, Error **errp) +{ + if (dev->vhost_ops->vhost_check_device_state) { + return dev->vhost_ops->vhost_check_device_state(dev, errp); + } + + error_setg(errp, + "vhost transport does not support migration state transfer"= ); + return -ENOSYS; +} --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352361; cv=none; d=zohomail.com; s=zohoarc; b=l0ZlQruXPTrqGL9I8eub/XECp291EuuR/u0VB54j0u0yUvXjgI2cBEXGO2UXBMAcIoul//coP0genoliV9z46DD6UpAj8zgerZZw5atqjOe8qrfjH0R7fz4RTbcZRqV1x7FtiOn7xgunexClwnFbbRi7S1PqcPG9rF6n9TogPfg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352361; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=J8Dcqs9F1nelYCSSeKsdhkwCix1cnMWXMvvonVw8o4A=; b=myqLc8efKam7XxmQvhHRV/ztHVOQsXSoK2XqEre7b6IABkn97TmYibfYKfQJQeOBJMPv+32Dc8ejxAhTRMF2wNPlgLtjsU1TZPNj4IUVLS6wq2wQzQw3XngqoB5bn2kzSAUFfHbeVjtzJikA8a6yQFEr+bDjTwssFV8xfZo6g10= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352361261348.1476793607535; Tue, 7 Nov 2023 02:19:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J2l-0002EH-Hu; Tue, 07 Nov 2023 05:10:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J21-0001I1-EL for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J1y-0002Bm-9N for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:01 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-212-n69CgskLN4SJMiZ2ZfCK5w-1; Tue, 07 Nov 2023 05:09:56 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-408374a3d6bso34527525e9.0 for ; Tue, 07 Nov 2023 02:09:56 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id dk11-20020a0560000b4b00b003197869bcd7sm1912929wrb.13.2023.11.07.02.09.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:09:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351797; h=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=J8Dcqs9F1nelYCSSeKsdhkwCix1cnMWXMvvonVw8o4A=; b=C5300MQgCVzbqsbWqIF7G5Ca3bzSThsdLcEpIRPh3Kp7PjY31/NVcZTlzo0TICG8jWw7qt Qv+0B11Y9e5wRS1mHR6nJCvWweuZgIyCeU+PXf9LycZRapM6F+pEuYNPwiwt5jVBIoG3IT wgF5ahusIcB35uBsYfBem8xgpsoKosc= X-MC-Unique: n69CgskLN4SJMiZ2ZfCK5w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351794; x=1699956594; 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=J8Dcqs9F1nelYCSSeKsdhkwCix1cnMWXMvvonVw8o4A=; b=d2ffoiufAp13vMWeYyoCT/Xekvx8EUhdTeadUJz5zEv4UUmRKJ3HA56dQCM7WRQPTs Ab/dGFLyVMyoqylWfZfuAEFgsqdrWUUcFWXQFsBFTDwsnhG0F4Lx3TYzzxtTaezcrePd jHp4fzo3a7cdKkqBHxbBkTDEQfCl+AMBjo/4Cr3IcxF7UE+ul4vL1BU2KUYNU7KkLG5z qMqT9xq4IUfREuR9YcuKww7WKjIo4emsEt+9L7AYIPzpNjF9iFm3cnPRi/zKFYCf6Aou a7azWqPauBB4Agc8Begk8IeP/Y2kPgal9Q3cGYolokQQHdZJ5j6o9/C3QL6fRiqU9QMH n6Hw== X-Gm-Message-State: AOJu0Yx5V+jH6DxAvTi6RvxDFv9oXolchgVsq+kzWa3wY1xkLoPI9tYJ 6CZ7Fy9gpnCuAnCaZvbLjMIysp6NckIjpXTikrovXOUy1+oV7Sz7R3qU1WedHs9HAeGlCPywrPX HWvJJQQPBFDWwzt+yFOErACxDVKiWOmjTF0ZFOE85QYbBcSRHSKIG5VbiXIicwxAMv0// X-Received: by 2002:a5d:64e7:0:b0:32f:996c:8b12 with SMTP id g7-20020a5d64e7000000b0032f996c8b12mr16973791wri.66.1699351794045; Tue, 07 Nov 2023 02:09:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUtPxb4dXGHhzlTpR11yZg6ntA1IcM5no/jiUsoWyvYwa9L/Xnp5nNR4/8ASlkseReUCQ3jw== X-Received: by 2002:a5d:64e7:0:b0:32f:996c:8b12 with SMTP id g7-20020a5d64e7000000b0032f996c8b12mr16973773wri.66.1699351793671; Tue, 07 Nov 2023 02:09:53 -0800 (PST) Date: Tue, 7 Nov 2023 05:09:50 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi Subject: [PULL 06/63] vhost: Add high-level state save/load functions Message-ID: <4a00d5d7f4b65ba99b33d5a0d6f8c563895839ea.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352361829100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek vhost_save_backend_state() and vhost_load_backend_state() can be used by vhost front-ends to easily save and load the back-end's state to/from the migration stream. Because we do not know the full state size ahead of time, vhost_save_backend_state() simply reads the data in 1 MB chunks, and writes each chunk consecutively into the migration stream, prefixed by its length. EOF is indicated by a 0-length chunk. Reviewed-by: Stefan Hajnoczi Signed-off-by: Hanna Czenczek Message-Id: <20231016134243.68248-7-hreitz@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost.h | 35 +++++++ hw/virtio/vhost.c | 204 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 239 insertions(+) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index b6ee6da6ce..05d7204a08 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -429,4 +429,39 @@ int vhost_set_device_state_fd(struct vhost_dev *dev, */ int vhost_check_device_state(struct vhost_dev *dev, Error **errp); =20 +/** + * vhost_save_backend_state(): High-level function to receive a vhost + * back-end's state, and save it in @f. Uses + * `vhost_set_device_state_fd()` to get the data from the back-end, and + * stores it in consecutive chunks that are each prefixed by their + * respective length (be32). The end is marked by a 0-length chunk. + * + * Must only be called while the device and all its vrings are stopped + * (`VHOST_TRANSFER_STATE_PHASE_STOPPED`). + * + * @dev: The vhost device from which to save the state + * @f: Migration stream in which to save the state + * @errp: Potential error message + * + * Returns 0 on success, and -errno otherwise. + */ +int vhost_save_backend_state(struct vhost_dev *dev, QEMUFile *f, Error **e= rrp); + +/** + * vhost_load_backend_state(): High-level function to load a vhost + * back-end's state from @f, and send it over to the back-end. Reads + * the data from @f in the format used by `vhost_save_state()`, and uses + * `vhost_set_device_state_fd()` to transfer it to the back-end. + * + * Must only be called while the device and all its vrings are stopped + * (`VHOST_TRANSFER_STATE_PHASE_STOPPED`). + * + * @dev: The vhost device to which to send the sate + * @f: Migration stream from which to load the state + * @errp: Potential error message + * + * Returns 0 on success, and -errno otherwise. + */ +int vhost_load_backend_state(struct vhost_dev *dev, QEMUFile *f, Error **e= rrp); + #endif diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 4db9dbfd64..2c9ac79468 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -2196,3 +2196,207 @@ int vhost_check_device_state(struct vhost_dev *dev,= Error **errp) "vhost transport does not support migration state transfer"= ); return -ENOSYS; } + +int vhost_save_backend_state(struct vhost_dev *dev, QEMUFile *f, Error **e= rrp) +{ + /* Maximum chunk size in which to transfer the state */ + const size_t chunk_size =3D 1 * 1024 * 1024; + g_autofree void *transfer_buf =3D NULL; + g_autoptr(GError) g_err =3D NULL; + int pipe_fds[2], read_fd =3D -1, write_fd =3D -1, reply_fd =3D -1; + int ret; + + /* [0] for reading (our end), [1] for writing (back-end's end) */ + if (!g_unix_open_pipe(pipe_fds, FD_CLOEXEC, &g_err)) { + error_setg(errp, "Failed to set up state transfer pipe: %s", + g_err->message); + ret =3D -EINVAL; + goto fail; + } + + read_fd =3D pipe_fds[0]; + write_fd =3D pipe_fds[1]; + + /* + * VHOST_TRANSFER_STATE_PHASE_STOPPED means the device must be stopped. + * Ideally, it is suspended, but SUSPEND/RESUME currently do not exist= for + * vhost-user, so just check that it is stopped at all. + */ + assert(!dev->started); + + /* Transfer ownership of write_fd to the back-end */ + ret =3D vhost_set_device_state_fd(dev, + VHOST_TRANSFER_STATE_DIRECTION_SAVE, + VHOST_TRANSFER_STATE_PHASE_STOPPED, + write_fd, + &reply_fd, + errp); + if (ret < 0) { + error_prepend(errp, "Failed to initiate state transfer: "); + goto fail; + } + + /* If the back-end wishes to use a different pipe, switch over */ + if (reply_fd >=3D 0) { + close(read_fd); + read_fd =3D reply_fd; + } + + transfer_buf =3D g_malloc(chunk_size); + + while (true) { + ssize_t read_ret; + + read_ret =3D RETRY_ON_EINTR(read(read_fd, transfer_buf, chunk_size= )); + if (read_ret < 0) { + ret =3D -errno; + error_setg_errno(errp, -ret, "Failed to receive state"); + goto fail; + } + + assert(read_ret <=3D chunk_size); + qemu_put_be32(f, read_ret); + + if (read_ret =3D=3D 0) { + /* EOF */ + break; + } + + qemu_put_buffer(f, transfer_buf, read_ret); + } + + /* + * Back-end will not really care, but be clean and close our end of th= e pipe + * before inquiring the back-end about whether transfer was successful + */ + close(read_fd); + read_fd =3D -1; + + /* Also, verify that the device is still stopped */ + assert(!dev->started); + + ret =3D vhost_check_device_state(dev, errp); + if (ret < 0) { + goto fail; + } + + ret =3D 0; +fail: + if (read_fd >=3D 0) { + close(read_fd); + } + + return ret; +} + +int vhost_load_backend_state(struct vhost_dev *dev, QEMUFile *f, Error **e= rrp) +{ + size_t transfer_buf_size =3D 0; + g_autofree void *transfer_buf =3D NULL; + g_autoptr(GError) g_err =3D NULL; + int pipe_fds[2], read_fd =3D -1, write_fd =3D -1, reply_fd =3D -1; + int ret; + + /* [0] for reading (back-end's end), [1] for writing (our end) */ + if (!g_unix_open_pipe(pipe_fds, FD_CLOEXEC, &g_err)) { + error_setg(errp, "Failed to set up state transfer pipe: %s", + g_err->message); + ret =3D -EINVAL; + goto fail; + } + + read_fd =3D pipe_fds[0]; + write_fd =3D pipe_fds[1]; + + /* + * VHOST_TRANSFER_STATE_PHASE_STOPPED means the device must be stopped. + * Ideally, it is suspended, but SUSPEND/RESUME currently do not exist= for + * vhost-user, so just check that it is stopped at all. + */ + assert(!dev->started); + + /* Transfer ownership of read_fd to the back-end */ + ret =3D vhost_set_device_state_fd(dev, + VHOST_TRANSFER_STATE_DIRECTION_LOAD, + VHOST_TRANSFER_STATE_PHASE_STOPPED, + read_fd, + &reply_fd, + errp); + if (ret < 0) { + error_prepend(errp, "Failed to initiate state transfer: "); + goto fail; + } + + /* If the back-end wishes to use a different pipe, switch over */ + if (reply_fd >=3D 0) { + close(write_fd); + write_fd =3D reply_fd; + } + + while (true) { + size_t this_chunk_size =3D qemu_get_be32(f); + ssize_t write_ret; + const uint8_t *transfer_pointer; + + if (this_chunk_size =3D=3D 0) { + /* End of state */ + break; + } + + if (transfer_buf_size < this_chunk_size) { + transfer_buf =3D g_realloc(transfer_buf, this_chunk_size); + transfer_buf_size =3D this_chunk_size; + } + + if (qemu_get_buffer(f, transfer_buf, this_chunk_size) < + this_chunk_size) + { + error_setg(errp, "Failed to read state"); + ret =3D -EINVAL; + goto fail; + } + + transfer_pointer =3D transfer_buf; + while (this_chunk_size > 0) { + write_ret =3D RETRY_ON_EINTR( + write(write_fd, transfer_pointer, this_chunk_size) + ); + if (write_ret < 0) { + ret =3D -errno; + error_setg_errno(errp, -ret, "Failed to send state"); + goto fail; + } else if (write_ret =3D=3D 0) { + error_setg(errp, "Failed to send state: Connection is clos= ed"); + ret =3D -ECONNRESET; + goto fail; + } + + assert(write_ret <=3D this_chunk_size); + this_chunk_size -=3D write_ret; + transfer_pointer +=3D write_ret; + } + } + + /* + * Close our end, thus ending transfer, before inquiring the back-end = about + * whether transfer was successful + */ + close(write_fd); + write_fd =3D -1; + + /* Also, verify that the device is still stopped */ + assert(!dev->started); + + ret =3D vhost_check_device_state(dev, errp); + if (ret < 0) { + goto fail; + } + + ret =3D 0; +fail: + if (write_fd >=3D 0) { + close(write_fd); + } + + return ret; +} --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351871; cv=none; d=zohomail.com; s=zohoarc; b=eyFJ4ELi+Ti1lqkBcJCtnvAgtQBvhhKKnJraiAUVqieV/Fqw97cFJ/O6VqYxbvHeXUtW8WIsCi8vv34FkxG+JxZiMH1paToOYFxfQyHC1S7/8cyarAI6dd5D8dothyjKS4Mp3362T/qcuWWDiEq5c8Ov/rAbssMKvGNFKwTwkCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351871; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=q5BKMN8AiQu0HrMpDRk8cwqjohWpFp/kFamZr3z+5m8=; b=F04qSnowzAKHTmgu+Jlg0us6ORgucEGTSmIjJh4i85SyrHw0YGjRXLMtKswyiVuklARFsrSpsIgrIYuIUdYChDUh0KqgFJYXxOUAZiYqt0+4lEUEc9kOaX25C0tsxu5AuoKcQzAMA6KII0O3raPFo00HK+4499+7zjC2t+IsDOg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16993518712911003.0183266435655; Tue, 7 Nov 2023 02:11:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J2p-0002Oj-PQ; Tue, 07 Nov 2023 05:10:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J27-0001O1-Am for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J25-0002Eh-BD for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:07 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-484-zV_ipk4OMxedMdAfP7Kluw-1; Tue, 07 Nov 2023 05:09:59 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-32f7384d5a2so2646977f8f.3 for ; Tue, 07 Nov 2023 02:09:59 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id i16-20020a5d55d0000000b0032d8354fb43sm1913865wrw.76.2023.11.07.02.09.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:09:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351802; h=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=q5BKMN8AiQu0HrMpDRk8cwqjohWpFp/kFamZr3z+5m8=; b=iGpkHSplzs9wPvhBqfmEScvqAm1y/9VKyiw3QGFLfsGibrDmDDBF036TuLA6RzPIQLqXfr cwH6HkZE+Yoe/VvoBKXkupoBQ4He36wI7Em3JcOZz9lz9HqN2SSJLQbW4NmqF5+YA76Txf W8K0EfQfjluh0EZSbhqDgC5rMhpwVpQ= X-MC-Unique: zV_ipk4OMxedMdAfP7Kluw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351797; x=1699956597; 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=q5BKMN8AiQu0HrMpDRk8cwqjohWpFp/kFamZr3z+5m8=; b=li7J/DDH1xvjwlCH5Bmsgt1JdOA13+mt9ZGqkySuI/dJ9/VM6E9ovqapRuxIQHAk2v Kx1QnJAkqmiHVmCB0t8r9Jl0y+Zd4mMMJNUsRpdOcJmIdzwsvw4FTZR/hFnoNwNG74Dc +cHRnYqDZg5MlrKwVSv8/5BUxJK2Gp8SnUcVR7SKUbhT9AwojAQUYW66tRo1nGXKd+PZ lXPKLdhTKq2/WScgVjUg9gyp1/hbkVrx7K6fpQPL7aBYdo1gtituLAJPKypKFtT/20d1 zQtjGxbv8WpbW4o39vOYwgiCghKapg/e8Jz1LECiT/9IDNF6XfzJd0/vcIgPnpFmPHsE UbbA== X-Gm-Message-State: AOJu0YzKgFd2iR++DnHFPIM6MIKDU4i5d4BTSS7UKVC41yekNrCI5yhn 2Aq+lMmzDjrKtgPoujxkvjs/Cs8eannvLc8RHmdn2LokMB/KEe3grlx9FUVv2vGwX8oOF96LIK2 rqVk7iI0gHvhIW6b3cks+i/AzH8bxoiFJ0/CxxLatY1N/VVmPuSuIjRhW8QDR6/hSyf7v X-Received: by 2002:a5d:6c68:0:b0:32f:79e5:8119 with SMTP id r8-20020a5d6c68000000b0032f79e58119mr30159910wrz.1.1699351797622; Tue, 07 Nov 2023 02:09:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IE+9jMtjbPlAmKct8/dx2yTk6oUw7LioQWUVnbnKmmNeeWo4yjACG1POTYzw3CWLoa0kX0+sA== X-Received: by 2002:a5d:6c68:0:b0:32f:79e5:8119 with SMTP id r8-20020a5d6c68000000b0032f79e58119mr30159892wrz.1.1699351797269; Tue, 07 Nov 2023 02:09:57 -0800 (PST) Date: Tue, 7 Nov 2023 05:09:53 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi , virtio-fs@redhat.com Subject: [PULL 07/63] vhost-user-fs: Implement internal migration 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351871764100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek A virtio-fs device's VM state consists of: - the virtio device (vring) state (VMSTATE_VIRTIO_DEVICE) - the back-end's (virtiofsd's) internal state We get/set the latter via the new vhost operations to transfer migratory state. It is its own dedicated subsection, so that for external migration, it can be disabled. Reviewed-by: Stefan Hajnoczi Signed-off-by: Hanna Czenczek Message-Id: <20231016134243.68248-8-hreitz@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user-fs.c | 101 +++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 49d699ffc2..eb91723855 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -298,9 +298,108 @@ static struct vhost_dev *vuf_get_vhost(VirtIODevice *= vdev) return &fs->vhost_dev; } =20 +/** + * Fetch the internal state from virtiofsd and save it to `f`. + */ +static int vuf_save_state(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc) +{ + VirtIODevice *vdev =3D pv; + VHostUserFS *fs =3D VHOST_USER_FS(vdev); + Error *local_error =3D NULL; + int ret; + + ret =3D vhost_save_backend_state(&fs->vhost_dev, f, &local_error); + if (ret < 0) { + error_reportf_err(local_error, + "Error saving back-end state of %s device %s " + "(tag: \"%s\"): ", + vdev->name, vdev->parent_obj.canonical_path, + fs->conf.tag ?: ""); + return ret; + } + + return 0; +} + +/** + * Load virtiofsd's internal state from `f` and send it over to virtiofsd. + */ +static int vuf_load_state(QEMUFile *f, void *pv, size_t size, + const VMStateField *field) +{ + VirtIODevice *vdev =3D pv; + VHostUserFS *fs =3D VHOST_USER_FS(vdev); + Error *local_error =3D NULL; + int ret; + + ret =3D vhost_load_backend_state(&fs->vhost_dev, f, &local_error); + if (ret < 0) { + error_reportf_err(local_error, + "Error loading back-end state of %s device %s " + "(tag: \"%s\"): ", + vdev->name, vdev->parent_obj.canonical_path, + fs->conf.tag ?: ""); + return ret; + } + + return 0; +} + +static bool vuf_is_internal_migration(void *opaque) +{ + /* TODO: Return false when an external migration is requested */ + return true; +} + +static int vuf_check_migration_support(void *opaque) +{ + VirtIODevice *vdev =3D opaque; + VHostUserFS *fs =3D VHOST_USER_FS(vdev); + + if (!vhost_supports_device_state(&fs->vhost_dev)) { + error_report("Back-end of %s device %s (tag: \"%s\") does not supp= ort " + "migration through qemu", + vdev->name, vdev->parent_obj.canonical_path, + fs->conf.tag ?: ""); + return -ENOTSUP; + } + + return 0; +} + +static const VMStateDescription vuf_backend_vmstate; + static const VMStateDescription vuf_vmstate =3D { .name =3D "vhost-user-fs", - .unmigratable =3D 1, + .version_id =3D 0, + .fields =3D (VMStateField[]) { + VMSTATE_VIRTIO_DEVICE, + VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * []) { + &vuf_backend_vmstate, + NULL, + } +}; + +static const VMStateDescription vuf_backend_vmstate =3D { + .name =3D "vhost-user-fs-backend", + .version_id =3D 0, + .needed =3D vuf_is_internal_migration, + .pre_load =3D vuf_check_migration_support, + .pre_save =3D vuf_check_migration_support, + .fields =3D (VMStateField[]) { + { + .name =3D "back-end", + .info =3D &(const VMStateInfo) { + .name =3D "virtio-fs back-end state", + .get =3D vuf_load_state, + .put =3D vuf_save_state, + }, + }, + VMSTATE_END_OF_LIST() + }, }; =20 static Property vuf_properties[] =3D { --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351880; cv=none; d=zohomail.com; s=zohoarc; b=Vm10bG3dgOBpDbZk5Wwnxul+G+5okobvL+KyMqTFCVnHuyKpD2RPrZT9d1bOCr2D+FppbEuwry3Wr30T75lomz+IWSrmeYdUdp9W6cD3EUamHdZDje8AZvMLVRh8H+z9LnPkCiY1ePJLe8oDrAtLdeYC+vbI9jf4I7rbO6NnVU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351880; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bUpG4ajzCq4chZHh+UY3ExxDXvLs2vmtbHEleG49rFc=; b=engEGk2KoC+JCJmM4O3JRxGlwP0tWUCEl5OTwBO78QK13JmCsWh7EC3tPVHNIbn//M90+jlozyVB6E2rovWTRQb7PCbIulzWsGAF8ybuQpXtNZxadlvwKEDtLxbGiY2hvM5UUSRbZuctvXRPvw1GKMeh/D0dYN/GDSPzGIHANK4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169935188080980.95053762612281; Tue, 7 Nov 2023 02:11:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J2f-0001tO-O5; Tue, 07 Nov 2023 05:10:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2Q-0001ZW-Ku for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2G-0002PV-Vt for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:26 -0500 Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-388-3AqSQ5PmOdu8mq7WkegHNA-1; Tue, 07 Nov 2023 05:10:06 -0500 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2c515541a25so58553161fa.0 for ; Tue, 07 Nov 2023 02:10:06 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id n20-20020a05600c4f9400b00407efbc4361sm15237356wmq.9.2023.11.07.02.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:10:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351808; h=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=bUpG4ajzCq4chZHh+UY3ExxDXvLs2vmtbHEleG49rFc=; b=fgcv6sBiyoxJtSuDOjHX4IpZBwrJJfTez2aEj6Yf/X4mx+7mzklxASymLvFSERLEWmgqj1 KrY7w5JDtLHE/hbck4H9PN4bGn2jNALhWm/iekJw1CJyRWh52opva85UCfjkgGDrrEcRJt cjA3lVHgdvZvvwv9gxkVW46l9ZG2Qn0= X-MC-Unique: 3AqSQ5PmOdu8mq7WkegHNA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351804; x=1699956604; 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=bUpG4ajzCq4chZHh+UY3ExxDXvLs2vmtbHEleG49rFc=; b=ESrkw/owiFERXq0xYm0fPWAOZck1av5Mas1xvZmzqwVW/DmkbZA1z9C5ilY/HKfUln +o+iea9nNEjrGin9hmrySMARypT+e/eHlZVUZhyhF4UyEcTZ3yCO5ZC+CkNAxAyF4/UG dBltPIY+V7Vr+vj4GyHplxrjJD1E++3YtWuKNI2pk/h/v2Po4WcT9ftgiGWgweyY0s8m 8auobKQMlEvR5pt9ra7p14oIdXGNAisY3DT8IBX+q4aEn+STYVSW67jt4JvnBr/t+ipE Ut2RWYUXEyLaaW94J96y1CiCAWYOS60EOawwoUa0+Uf46TBhelNBgELfpbmu2Z7V/hIa +Jvw== X-Gm-Message-State: AOJu0Yx27JhT+zTPS7gSUbbe8U4Ig0Mninjm1H04QHioc4tMIQyibWLV 9m1mx14zhZ09rIdQbsch+ceLitUV5ca4ohmykUjPE/8OR+j6i87slzuGDKGpI7npEpq91NEzZhw eOPLprUeaQ9gSsXy1uzsMzspHmal7uN/wQ8EwcgaV4DVk4wwYAvahCvRyIBQxUMkV/jaO X-Received: by 2002:a2e:9d47:0:b0:2c2:c450:c2d0 with SMTP id y7-20020a2e9d47000000b002c2c450c2d0mr23051543ljj.24.1699351804024; Tue, 07 Nov 2023 02:10:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFyj45OiPLDi7YzptjNp44dzRQCmCoKSgcGtTesl3q+kf1GNl24hs45W7JH+2FeLZ5wx2phvQ== X-Received: by 2002:a2e:9d47:0:b0:2c2:c450:c2d0 with SMTP id y7-20020a2e9d47000000b002c2c450c2d0mr23051523ljj.24.1699351803583; Tue, 07 Nov 2023 02:10:03 -0800 (PST) Date: Tue, 7 Nov 2023 05:09:58 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Igor Skalkin , Anton Yakovlev , Alex =?utf-8?Q?Benn=C3=A9e?= , Paolo Bonzini , Gerd Hoffmann , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Eduardo Habkost Subject: [PULL 08/63] Add virtio-sound device stub Message-ID: <2880e676c000a62828d3d9ece7b2ec7a513560a2.1699351720.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351881953100003 From: Manos Pitsidianakis Add a new VIRTIO device for the virtio sound device id. Functionality will be added in the following commits. Based-on: https://github.com/OpenSynergy/qemu/commit/5a2f350eec5d157b90d9c7= b40a8e603f4da92471 Signed-off-by: Igor Skalkin Signed-off-by: Anton Yakovlev Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Message-Id: Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/audio/virtio-snd.h | 79 ++++++++++++ hw/audio/virtio-snd.c | 233 ++++++++++++++++++++++++++++++++++ system/qdev-monitor.c | 1 + MAINTAINERS | 7 + hw/audio/Kconfig | 5 + hw/audio/meson.build | 1 + hw/audio/trace-events | 9 ++ 7 files changed, 335 insertions(+) create mode 100644 include/hw/audio/virtio-snd.h create mode 100644 hw/audio/virtio-snd.c diff --git a/include/hw/audio/virtio-snd.h b/include/hw/audio/virtio-snd.h new file mode 100644 index 0000000000..d08065941c --- /dev/null +++ b/include/hw/audio/virtio-snd.h @@ -0,0 +1,79 @@ +/* + * VIRTIO Sound Device conforming to + * + * "Virtual I/O Device (VIRTIO) Version 1.2 + * Committee Specification Draft 01 + * 09 May 2022" + * + * Copyright (c) 2023 Emmanouil Pitsidianakis + * Copyright (C) 2019 OpenSynergy GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * (at your option) any later version. See the COPYING file in the + * top-level directory. + */ + +#ifndef QEMU_VIRTIO_SOUND_H +#define QEMU_VIRTIO_SOUND_H + +#include "hw/virtio/virtio.h" +#include "audio/audio.h" +#include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/virtio_snd.h" + +#define TYPE_VIRTIO_SND "virtio-sound-device" +#define VIRTIO_SND(obj) \ + OBJECT_CHECK(VirtIOSound, (obj), TYPE_VIRTIO_SND) + +/* CONFIGURATION SPACE */ + +typedef struct virtio_snd_config virtio_snd_config; + +/* COMMON DEFINITIONS */ + +/* common header for request/response*/ +typedef struct virtio_snd_hdr virtio_snd_hdr; + +/* event notification */ +typedef struct virtio_snd_event virtio_snd_event; + +/* common control request to query an item information */ +typedef struct virtio_snd_query_info virtio_snd_query_info; + +/* JACK CONTROL MESSAGES */ + +typedef struct virtio_snd_jack_hdr virtio_snd_jack_hdr; + +/* jack information structure */ +typedef struct virtio_snd_jack_info virtio_snd_jack_info; + +/* jack remapping control request */ +typedef struct virtio_snd_jack_remap virtio_snd_jack_remap; + +/* + * PCM CONTROL MESSAGES + */ +typedef struct virtio_snd_pcm_hdr virtio_snd_pcm_hdr; + +/* PCM stream info structure */ +typedef struct virtio_snd_pcm_info virtio_snd_pcm_info; + +/* set PCM stream params */ +typedef struct virtio_snd_pcm_set_params virtio_snd_pcm_set_params; + +/* I/O request header */ +typedef struct virtio_snd_pcm_xfer virtio_snd_pcm_xfer; + +/* I/O request status */ +typedef struct virtio_snd_pcm_status virtio_snd_pcm_status; + +typedef struct VirtIOSound { + VirtIODevice parent_obj; + + VirtQueue *queues[VIRTIO_SND_VQ_MAX]; + uint64_t features; + QEMUSoundCard card; + VMChangeStateEntry *vmstate; + virtio_snd_config snd_conf; +} VirtIOSound; +#endif diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c new file mode 100644 index 0000000000..3a4b441c20 --- /dev/null +++ b/hw/audio/virtio-snd.c @@ -0,0 +1,233 @@ +/* + * VIRTIO Sound Device conforming to + * + * "Virtual I/O Device (VIRTIO) Version 1.2 + * Committee Specification Draft 01 + * 09 May 2022" + * + * + * + * Copyright (c) 2023 Emmanouil Pitsidianakis + * Copyright (C) 2019 OpenSynergy GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * (at your option) any later version. See the COPYING file in the + * top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/iov.h" +#include "qemu/log.h" +#include "qemu/error-report.h" +#include "include/qemu/lockable.h" +#include "sysemu/runstate.h" +#include "trace.h" +#include "qapi/error.h" +#include "hw/audio/virtio-snd.h" +#include "hw/core/cpu.h" + +#define VIRTIO_SOUND_VM_VERSION 1 +#define VIRTIO_SOUND_JACK_DEFAULT 0 +#define VIRTIO_SOUND_STREAM_DEFAULT 1 +#define VIRTIO_SOUND_CHMAP_DEFAULT 0 +#define VIRTIO_SOUND_HDA_FN_NID 0 + +static const VMStateDescription vmstate_virtio_snd_device =3D { + .name =3D TYPE_VIRTIO_SND, + .version_id =3D VIRTIO_SOUND_VM_VERSION, + .minimum_version_id =3D VIRTIO_SOUND_VM_VERSION, +}; + +static const VMStateDescription vmstate_virtio_snd =3D { + .name =3D TYPE_VIRTIO_SND, + .minimum_version_id =3D VIRTIO_SOUND_VM_VERSION, + .version_id =3D VIRTIO_SOUND_VM_VERSION, + .fields =3D (VMStateField[]) { + VMSTATE_VIRTIO_DEVICE, + VMSTATE_END_OF_LIST() + }, +}; + +static Property virtio_snd_properties[] =3D { + DEFINE_AUDIO_PROPERTIES(VirtIOSound, card), + DEFINE_PROP_UINT32("jacks", VirtIOSound, snd_conf.jacks, + VIRTIO_SOUND_JACK_DEFAULT), + DEFINE_PROP_UINT32("streams", VirtIOSound, snd_conf.streams, + VIRTIO_SOUND_STREAM_DEFAULT), + DEFINE_PROP_UINT32("chmaps", VirtIOSound, snd_conf.chmaps, + VIRTIO_SOUND_CHMAP_DEFAULT), + DEFINE_PROP_END_OF_LIST(), +}; + +static void +virtio_snd_get_config(VirtIODevice *vdev, uint8_t *config) +{ + VirtIOSound *s =3D VIRTIO_SND(vdev); + virtio_snd_config *sndconfig =3D + (virtio_snd_config *)config; + trace_virtio_snd_get_config(vdev, + s->snd_conf.jacks, + s->snd_conf.streams, + s->snd_conf.chmaps); + + memcpy(sndconfig, &s->snd_conf, sizeof(s->snd_conf)); + cpu_to_le32s(&sndconfig->jacks); + cpu_to_le32s(&sndconfig->streams); + cpu_to_le32s(&sndconfig->chmaps); + +} + +static void +virtio_snd_set_config(VirtIODevice *vdev, const uint8_t *config) +{ + VirtIOSound *s =3D VIRTIO_SND(vdev); + const virtio_snd_config *sndconfig =3D + (const virtio_snd_config *)config; + + + trace_virtio_snd_set_config(vdev, + s->snd_conf.jacks, + sndconfig->jacks, + s->snd_conf.streams, + sndconfig->streams, + s->snd_conf.chmaps, + sndconfig->chmaps); + + memcpy(&s->snd_conf, sndconfig, sizeof(virtio_snd_config)); + le32_to_cpus(&s->snd_conf.jacks); + le32_to_cpus(&s->snd_conf.streams); + le32_to_cpus(&s->snd_conf.chmaps); + +} + +/* + * Queue handler stub. + * + * @vdev: VirtIOSound device + * @vq: virtqueue + */ +static void virtio_snd_handle_queue(VirtIODevice *vdev, VirtQueue *vq) {} + +static uint64_t get_features(VirtIODevice *vdev, uint64_t features, + Error **errp) +{ + /* + * virtio-v1.2-csd01, 5.14.3, + * Feature Bits + * None currently defined. + */ + VirtIOSound *s =3D VIRTIO_SND(vdev); + features |=3D s->features; + + trace_virtio_snd_get_features(vdev, features); + + return features; +} + +static void +virtio_snd_vm_state_change(void *opaque, bool running, + RunState state) +{ + if (running) { + trace_virtio_snd_vm_state_running(); + } else { + trace_virtio_snd_vm_state_stopped(); + } +} + +static void virtio_snd_realize(DeviceState *dev, Error **errp) +{ + ERRP_GUARD(); + VirtIOSound *vsnd =3D VIRTIO_SND(dev); + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + + vsnd->vmstate =3D + qemu_add_vm_change_state_handler(virtio_snd_vm_state_change, vsnd); + + trace_virtio_snd_realize(vsnd); + + virtio_init(vdev, VIRTIO_ID_SOUND, sizeof(virtio_snd_config)); + virtio_add_feature(&vsnd->features, VIRTIO_F_VERSION_1); + + /* set number of jacks and streams */ + if (vsnd->snd_conf.jacks > 8) { + error_setg(errp, + "Invalid number of jacks: %"PRIu32, + vsnd->snd_conf.jacks); + return; + } + if (vsnd->snd_conf.streams < 1 || vsnd->snd_conf.streams > 10) { + error_setg(errp, + "Invalid number of streams: %"PRIu32, + vsnd->snd_conf.streams); + return; + } + + if (vsnd->snd_conf.chmaps > VIRTIO_SND_CHMAP_MAX_SIZE) { + error_setg(errp, + "Invalid number of channel maps: %"PRIu32, + vsnd->snd_conf.chmaps); + return; + } + + AUD_register_card("virtio-sound", &vsnd->card, errp); + + vsnd->queues[VIRTIO_SND_VQ_CONTROL] =3D + virtio_add_queue(vdev, 64, virtio_snd_handle_queue); + vsnd->queues[VIRTIO_SND_VQ_EVENT] =3D + virtio_add_queue(vdev, 64, virtio_snd_handle_queue); + vsnd->queues[VIRTIO_SND_VQ_TX] =3D + virtio_add_queue(vdev, 64, virtio_snd_handle_queue); + vsnd->queues[VIRTIO_SND_VQ_RX] =3D + virtio_add_queue(vdev, 64, virtio_snd_handle_queue); +} + +static void virtio_snd_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VirtIOSound *vsnd =3D VIRTIO_SND(dev); + + qemu_del_vm_change_state_handler(vsnd->vmstate); + trace_virtio_snd_unrealize(vsnd); + + AUD_remove_card(&vsnd->card); + virtio_delete_queue(vsnd->queues[VIRTIO_SND_VQ_CONTROL]); + virtio_delete_queue(vsnd->queues[VIRTIO_SND_VQ_EVENT]); + virtio_delete_queue(vsnd->queues[VIRTIO_SND_VQ_TX]); + virtio_delete_queue(vsnd->queues[VIRTIO_SND_VQ_RX]); + virtio_cleanup(vdev); +} + + +static void virtio_snd_reset(VirtIODevice *vdev) {} + +static void virtio_snd_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + + + set_bit(DEVICE_CATEGORY_SOUND, dc->categories); + device_class_set_props(dc, virtio_snd_properties); + + dc->vmsd =3D &vmstate_virtio_snd; + vdc->vmsd =3D &vmstate_virtio_snd_device; + vdc->realize =3D virtio_snd_realize; + vdc->unrealize =3D virtio_snd_unrealize; + vdc->get_config =3D virtio_snd_get_config; + vdc->set_config =3D virtio_snd_set_config; + vdc->get_features =3D get_features; + vdc->reset =3D virtio_snd_reset; + vdc->legacy_features =3D 0; +} + +static const TypeInfo virtio_snd_types[] =3D { + { + .name =3D TYPE_VIRTIO_SND, + .parent =3D TYPE_VIRTIO_DEVICE, + .instance_size =3D sizeof(VirtIOSound), + .class_init =3D virtio_snd_class_init, + } +}; + +DEFINE_TYPES(virtio_snd_types) diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 1b8005ae55..3c0aabec4b 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -111,6 +111,7 @@ static const QDevAlias qdev_alias_table[] =3D { { "virtio-serial-device", "virtio-serial", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-serial-ccw", "virtio-serial", QEMU_ARCH_VIRTIO_CCW }, { "virtio-serial-pci", "virtio-serial", QEMU_ARCH_VIRTIO_PCI}, + { "virtio-sound-device", "virtio-sound", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-tablet-device", "virtio-tablet", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-tablet-ccw", "virtio-tablet", QEMU_ARCH_VIRTIO_CCW }, { "virtio-tablet-pci", "virtio-tablet", QEMU_ARCH_VIRTIO_PCI }, diff --git a/MAINTAINERS b/MAINTAINERS index 8e8a7d5be5..d3ee463d21 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2310,6 +2310,13 @@ F: hw/virtio/virtio-mem-pci.h F: hw/virtio/virtio-mem-pci.c F: include/hw/virtio/virtio-mem.h =20 +virtio-snd +M: Gerd Hoffmann +R: Manos Pitsidianakis +S: Supported +F: hw/audio/virtio-snd.c +F: include/hw/audio/virtio-snd.h + nvme M: Keith Busch M: Klaus Jensen diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig index d0993514a1..daf060e1be 100644 --- a/hw/audio/Kconfig +++ b/hw/audio/Kconfig @@ -50,3 +50,8 @@ config CS4231 =20 config ASC bool + +config VIRTIO_SND + bool + default y + depends on VIRTIO diff --git a/hw/audio/meson.build b/hw/audio/meson.build index 8805322f5c..7a503be1fd 100644 --- a/hw/audio/meson.build +++ b/hw/audio/meson.build @@ -13,3 +13,4 @@ system_ss.add(when: 'CONFIG_PL041', if_true: files('pl041= .c', 'lm4549.c')) system_ss.add(when: 'CONFIG_SB16', if_true: files('sb16.c')) system_ss.add(when: 'CONFIG_VT82C686', if_true: files('via-ac97.c')) system_ss.add(when: 'CONFIG_WM8750', if_true: files('wm8750.c')) +system_ss.add(when: ['CONFIG_VIRTIO_SND', 'CONFIG_VIRTIO'], if_true: files= ('virtio-snd.c')) diff --git a/hw/audio/trace-events b/hw/audio/trace-events index 059ce451f5..525ced2b34 100644 --- a/hw/audio/trace-events +++ b/hw/audio/trace-events @@ -38,3 +38,12 @@ asc_write_fifo(const char fifo, int reg, unsigned size, = int wrptr, int cnt, uint asc_write_reg(int reg, unsigned size, uint64_t value) "reg=3D0x%03x size= =3D%u value=3D0x%"PRIx64 asc_write_extreg(const char fifo, int reg, unsigned size, uint64_t value) = "fifo %c reg=3D0x%03x size=3D%u value=3D0x%"PRIx64 asc_update_irq(int irq, int a, int b) "set IRQ to %d (A: 0x%x B: 0x%x)" + +#virtio-snd.c +virtio_snd_get_config(void *vdev, uint32_t jacks, uint32_t streams, uint32= _t chmaps) "snd %p: get_config jacks=3D%"PRIu32" streams=3D%"PRIu32" chmaps= =3D%"PRIu32"" +virtio_snd_set_config(void *vdev, uint32_t jacks, uint32_t new_jacks, uint= 32_t streams, uint32_t new_streams, uint32_t chmaps, uint32_t new_chmaps) "= snd %p: set_config jacks from %"PRIu32"->%"PRIu32", streams from %"PRIu32"-= >%"PRIu32", chmaps from %"PRIu32"->%"PRIu32 +virtio_snd_get_features(void *vdev, uint64_t features) "snd %p: get_featur= es 0x%"PRIx64 +virtio_snd_vm_state_running(void) "vm state running" +virtio_snd_vm_state_stopped(void) "vm state stopped" +virtio_snd_realize(void *snd) "snd %p: realize" +virtio_snd_unrealize(void *snd) "snd %p: unrealize" --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351871; cv=none; d=zohomail.com; s=zohoarc; b=MGGlflTzI46HTD1K0vMW/2WNLCj42R0Gtofu2tw+D5nvBqgX+GnbqYdw3DhHluJJM/A9igBHv/YNkfvnY2cgO9Z6x1thwrmsgJSzoilpF0qAfdvRq+fpeeCaFdL3gVp+YYd/mY7DpZ9ymQclepPdiHZkDJeeeyC4+xR0bALDsAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351871; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Bn3c/hYXstIUHJ2KWYzhrqPvOR8k4oDFgUxHHIUfAFA=; b=QkArz0D6T+UyaHSn0e/b2Vs6nXhPQ9k/j+Nrn+6U4QT4cHhrFYbA/74a7HANVJHfkOt8fHhQEHBWPxDcRQ9SIcNMXYsRJgnBFqQqwsHeg4wt6csiYzAKAETznrvprgLzB+IqWxFfyDTgORbVsKqXvSGoI51EV3vAD0zrKWAkQ6E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16993518709851018.8323492266292; Tue, 7 Nov 2023 02:11:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J35-0003Df-7Y; Tue, 07 Nov 2023 05:11:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2N-0001Xo-Qo for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2H-0002Pg-0I for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:23 -0500 Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-281-rSxhJevkPOOr5Y5jGBvlhQ-1; Tue, 07 Nov 2023 05:10:11 -0500 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-507d4583c4cso5858604e87.1 for ; Tue, 07 Nov 2023 02:10:11 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id i11-20020a0560001acb00b0032dde679398sm1923841wry.8.2023.11.07.02.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:10:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351812; h=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=Bn3c/hYXstIUHJ2KWYzhrqPvOR8k4oDFgUxHHIUfAFA=; b=Rsri9B6IyYCSajn2J6jkxoFmbuiTEPIdIIXjHzvcFygSFmAae55U8j6BOHcvTgRIYqn2v4 cr/MHRDQ6ggCvPJ4YSRbRFn3KrzxtCGMKxSpROVS2RgNCMom2TXJdVlDejHjlYEbD7VCHt NWN3/6pMo4O8vLOs46f+ILVIkwzhuqc= X-MC-Unique: rSxhJevkPOOr5Y5jGBvlhQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351809; x=1699956609; 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=Bn3c/hYXstIUHJ2KWYzhrqPvOR8k4oDFgUxHHIUfAFA=; b=pa2EWJkx/BleNwh7Bq04MP81BZLZ0+idHMMbflnxyekDbpoKGb0Rw3ucxeoqaoZTS2 Fr+OOGsdwFhH26DTPny30RcRIxWXVuiw+CYtd4XzxwCO8wa4sTlAjOziFQrv4kX/eBG+ pw8BW7ib7GNy0fA+s9M9KADpqH1hxlm/78CXuKwvXx0L9akaesAIrwtnvSPcOacoZI9r tPPxn4BLAaiOJ12HQ5gBK2AGuD562FQHImdh+WpREjA/HgOqOwUkxbJix0jwOyqtpw7m iQHQbMUAIQonZP4/yA5oL4iIWdp5Waqi8e5f7gOEc5wwKgWazmQ2YLLJUNu4CnfIMLSl E20A== X-Gm-Message-State: AOJu0YwnvuAGPmQLl8mYzkmotMKKJ0fz1s4lyt5MyA49XQdEWVHjgMZs uPj567TvJ06HX1nr7nx+Y066IG5kwhjmL3KIuMrIECXI42gIttQ6qfygYrhB8ffdbECoq0dNluK Rhy/PNM2PbFuok2Cj3Xrxzd1PZO3A1yKgwVdvTePfyD3ugssLAhD4caRP0yswYhhuPrjf X-Received: by 2002:a05:6512:230a:b0:508:11c3:c8ca with SMTP id o10-20020a056512230a00b0050811c3c8camr29365996lfu.7.1699351809514; Tue, 07 Nov 2023 02:10:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2PF6rXNhuXAN6HCD9WEIadiSp1b4BH+dCKyzFvyju0fjmqeN9OQYfNgnj8b9244WviioNmw== X-Received: by 2002:a05:6512:230a:b0:508:11c3:c8ca with SMTP id o10-20020a056512230a00b0050811c3c8camr29365969lfu.7.1699351809213; Tue, 07 Nov 2023 02:10:09 -0800 (PST) Date: Tue, 7 Nov 2023 05:10:03 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Igor Skalkin , Anton Yakovlev , Alex =?utf-8?Q?Benn=C3=A9e?= , Gerd Hoffmann , Paolo Bonzini , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Eduardo Habkost Subject: [PULL 09/63] Add virtio-sound-pci device Message-ID: <2426908590c1d8d9ffb741c5552ad45d9d3ba9f8.1699351720.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351871797100002 From: Manos Pitsidianakis This patch adds a PCI wrapper device for the virtio-sound device. It is necessary to instantiate a virtio-snd device in a guest. All sound logic will be added to the virtio-snd device in the following commits. To add this device with a guest, you'll need a >=3D5.13 kernel compiled with CONFIG_SND_VIRTIO=3Dy, which at the time of writing most distros have off by default. Use with following flags in the invocation: Pulseaudio: -audio driver=3Dpa,model=3Dvirtio or -audio driver=3Dpa,model=3Dvirtio,server=3D/run/user/1000/pulse/native sdl: -audio driver=3Dsdl,model=3Dvirtio coreaudio (macos/darwin): -audio driver=3Dcoreaudio,model=3Dvirtio etc. Based-on: https://github.com/OpenSynergy/qemu/commit/5a2f350eec5d157b90d9c7= b40a8e603f4da92471 Signed-off-by: Igor Skalkin Signed-off-by: Anton Yakovlev Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Message-Id: Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/audio/virtio-snd-pci.c | 93 +++++++++++++++++++++++++++++++++++++++ system/qdev-monitor.c | 1 + MAINTAINERS | 1 + hw/audio/meson.build | 1 + 4 files changed, 96 insertions(+) create mode 100644 hw/audio/virtio-snd-pci.c diff --git a/hw/audio/virtio-snd-pci.c b/hw/audio/virtio-snd-pci.c new file mode 100644 index 0000000000..0f92e0752b --- /dev/null +++ b/hw/audio/virtio-snd-pci.c @@ -0,0 +1,93 @@ +/* + * VIRTIO Sound Device PCI Bindings + * + * Copyright (c) 2023 Emmanouil Pitsidianakis + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * (at your option) any later version. See the COPYING file in the + * top-level directory. + */ + +#include "qemu/osdep.h" +#include "qom/object.h" +#include "qapi/error.h" +#include "hw/audio/soundhw.h" +#include "hw/virtio/virtio-pci.h" +#include "hw/audio/virtio-snd.h" + +/* + * virtio-snd-pci: This extends VirtioPCIProxy. + */ +#define TYPE_VIRTIO_SND_PCI "virtio-sound-pci" +OBJECT_DECLARE_SIMPLE_TYPE(VirtIOSoundPCI, VIRTIO_SND_PCI) + +struct VirtIOSoundPCI { + VirtIOPCIProxy parent_obj; + + VirtIOSound vdev; +}; + +static Property virtio_snd_pci_properties[] =3D { + DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, + VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), + DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2), + DEFINE_PROP_END_OF_LIST(), +}; + +static void virtio_snd_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) +{ + VirtIOSoundPCI *dev =3D VIRTIO_SND_PCI(vpci_dev); + DeviceState *vdev =3D DEVICE(&dev->vdev); + + virtio_pci_force_virtio_1(vpci_dev); + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void virtio_snd_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + VirtioPCIClass *vpciklass =3D VIRTIO_PCI_CLASS(klass); + + device_class_set_props(dc, virtio_snd_pci_properties); + dc->desc =3D "Virtio Sound"; + set_bit(DEVICE_CATEGORY_SOUND, dc->categories); + + vpciklass->realize =3D virtio_snd_pci_realize; +} + +static void virtio_snd_pci_instance_init(Object *obj) +{ + VirtIOSoundPCI *dev =3D VIRTIO_SND_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VIRTIO_SND); +} + +static const VirtioPCIDeviceTypeInfo virtio_snd_pci_info =3D { + .generic_name =3D TYPE_VIRTIO_SND_PCI, + .instance_size =3D sizeof(VirtIOSoundPCI), + .instance_init =3D virtio_snd_pci_instance_init, + .class_init =3D virtio_snd_pci_class_init, +}; + +/* Create a Virtio Sound PCI device, so '-audio driver,model=3Dvirtio' wor= ks. */ +static int virtio_snd_pci_init(PCIBus *bus, const char *audiodev) +{ + DeviceState *vdev =3D NULL; + VirtIOSoundPCI *dev =3D NULL; + + vdev =3D qdev_new(TYPE_VIRTIO_SND_PCI); + assert(vdev); + dev =3D VIRTIO_SND_PCI(vdev); + qdev_prop_set_string(DEVICE(&dev->vdev), "audiodev", audiodev); + qdev_realize_and_unref(vdev, BUS(bus), &error_fatal); + return 0; +} + +static void virtio_snd_pci_register(void) +{ + virtio_pci_types_register(&virtio_snd_pci_info); + pci_register_soundhw("virtio", "Virtio Sound", virtio_snd_pci_init); +} + +type_init(virtio_snd_pci_register); diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 3c0aabec4b..a13db763e5 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -112,6 +112,7 @@ static const QDevAlias qdev_alias_table[] =3D { { "virtio-serial-ccw", "virtio-serial", QEMU_ARCH_VIRTIO_CCW }, { "virtio-serial-pci", "virtio-serial", QEMU_ARCH_VIRTIO_PCI}, { "virtio-sound-device", "virtio-sound", QEMU_ARCH_VIRTIO_MMIO }, + { "virtio-sound-pci", "virtio-sound", QEMU_ARCH_VIRTIO_PCI }, { "virtio-tablet-device", "virtio-tablet", QEMU_ARCH_VIRTIO_MMIO }, { "virtio-tablet-ccw", "virtio-tablet", QEMU_ARCH_VIRTIO_CCW }, { "virtio-tablet-pci", "virtio-tablet", QEMU_ARCH_VIRTIO_PCI }, diff --git a/MAINTAINERS b/MAINTAINERS index d3ee463d21..c09bb8cf41 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2315,6 +2315,7 @@ M: Gerd Hoffmann R: Manos Pitsidianakis S: Supported F: hw/audio/virtio-snd.c +F: hw/audio/virtio-snd-pci.c F: include/hw/audio/virtio-snd.h =20 nvme diff --git a/hw/audio/meson.build b/hw/audio/meson.build index 7a503be1fd..2990974449 100644 --- a/hw/audio/meson.build +++ b/hw/audio/meson.build @@ -14,3 +14,4 @@ system_ss.add(when: 'CONFIG_SB16', if_true: files('sb16.c= ')) system_ss.add(when: 'CONFIG_VT82C686', if_true: files('via-ac97.c')) system_ss.add(when: 'CONFIG_WM8750', if_true: files('wm8750.c')) system_ss.add(when: ['CONFIG_VIRTIO_SND', 'CONFIG_VIRTIO'], if_true: files= ('virtio-snd.c')) +system_ss.add(when: ['CONFIG_VIRTIO_SND', 'CONFIG_VIRTIO', 'CONFIG_VIRTIO_= PCI'], if_true: files('virtio-snd-pci.c')) --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351909; cv=none; d=zohomail.com; s=zohoarc; b=gAuGyt0y6TKFYhZArbKdRMEwMLovl/rBPjoHkY4OwcUs0DpQz9LE3cViI+Pc6en/kxzUO9SfVA/1yVEUpaeB/fQcMJJKLAjx8kXNKg1HbQZC5/70rjP19aDeACrTF+SSzXvb2N0nWezgYE9JZ2Xcb7+bwA57d936CVKI9CtP4no= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351909; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4UfvakIUeWtpGE2wR9p2HqmyrsWftAh3dIjScGLp1oA=; b=JdqwMyDO6JR4tNGYT5k6CqlCC6v12ngu2iw3IFrKKuJOVW/Mw5e8zigkkRW0eESTfnb96zHvdWQ/qtJZqa72xOqF9vmipQZGNMO17smTx4KZ9le5+le5GBbUuHxjJLU9tNno4a7fm5sZmxiuDA7ntMl2Uh48uiU0VQz2uK04cQA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699351909570376.5458606074287; Tue, 7 Nov 2023 02:11:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J33-00032T-8U; Tue, 07 Nov 2023 05:11:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2Y-0001hz-1a for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2V-0002Sa-4j for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:33 -0500 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-64-70Mkb24UMOObiH59MQaPdg-1; Tue, 07 Nov 2023 05:10:18 -0500 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-507c4c57567so5357984e87.0 for ; Tue, 07 Nov 2023 02:10:18 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id c2-20020a5d4f02000000b00327de0173f6sm1892642wru.115.2023.11.07.02.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:10:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351830; h=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=4UfvakIUeWtpGE2wR9p2HqmyrsWftAh3dIjScGLp1oA=; b=EnSer3/CEoFlW4VBbuowOjzNFt+XO+yL0JTFzB7PzLNIcB9IqVvZDkypagff/6LxMulCNH pIAQZ39A+9J19gal2KPJGxCm3/mwXQIRjxgwu9y3SqhPwffp6MeTPbMq0TgrJTQ43nRyHi tjHbOc0we/OWazaEeJDyPyViHQ/uJRo= X-MC-Unique: 70Mkb24UMOObiH59MQaPdg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351817; x=1699956617; 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=4UfvakIUeWtpGE2wR9p2HqmyrsWftAh3dIjScGLp1oA=; b=V4d5nY+SOOmPkkog4sJimMD+uZYQ1BP9DvmDvcz85F6Um4PKa35YmzyxVxGaykwI4H v7588L2OaeyN7eBBQN5U0eoB+ihII/JY3gUiDNY/7vnUMVGJvKuCQBzMwx7+IXIJwY9r jjpA4AawaV5qvK5vxAmmT5uA/M94fuHORqYveDIgQX6VYH0SDEnWLzSfv6Mulsk3spzT YsNMbGtS1KXfCLQtDHvN2V6FS5kpvqNJ3Nbt7TtDn4nykqYj4kPwh6e1cFyGUsNmHaCR fDW8fupXdi/TKTe3CP4Z89hfmkNbWQwBAX++mvkJM2SD07qI+4RP0XkVpMOumIaqOsMH prsA== X-Gm-Message-State: AOJu0YxXu39lqJ3FU4dKAzrRte6XQQSBWp5DIILUB2LSvMiPNAHVRnwc hS2zv9FKK9CMogFTt85NtDUHcId54rTVBB8IPsFPu4mIq6AdUbMcwWWYf0VloEs/l1dPRlRTRwO nAweJDTra6QlT8G7ZGkFfEg68FMgQ+k9trEh4KxHOl/yrgfAI3gCmZGGPaTrrRzje1wZS X-Received: by 2002:ac2:5a02:0:b0:504:31a0:f9e2 with SMTP id q2-20020ac25a02000000b0050431a0f9e2mr24633732lfn.58.1699351816625; Tue, 07 Nov 2023 02:10:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8im8A2WY4NdzBAOcg4GioJnr1pOWVjkkkFrPFntgu8u+/oqa/5eRDMNvBZKBP5Uj4hNlYOg== X-Received: by 2002:ac2:5a02:0:b0:504:31a0:f9e2 with SMTP id q2-20020ac25a02000000b0050431a0f9e2mr24633702lfn.58.1699351816077; Tue, 07 Nov 2023 02:10:16 -0800 (PST) Date: Tue, 7 Nov 2023 05:10:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Igor Skalkin , Anton Yakovlev , Alex =?utf-8?Q?Benn=C3=A9e?= , Gerd Hoffmann Subject: [PULL 10/63] virtio-sound: handle control messages and streams Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351910560100001 From: Manos Pitsidianakis Receive guest requests in the control (CTRL) queue of the virtio sound device and reply with a NOT SUPPORTED error to all control commands. The receiving handler is virtio_snd_handle_ctrl(). It stores all control messages in the queue in the device's command queue. Then it calls virtio_snd_process_cmdq() to handle each message. The handler is process_cmd() which replies with VIRTIO_SND_S_NOT_SUPP. Based-on: https://github.com/OpenSynergy/qemu/commit/5a2f350eec5d157b90d9c7= b40a8e603f4da92471 Signed-off-by: Igor Skalkin Signed-off-by: Anton Yakovlev Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Message-Id: <3224aff87e7c4f2777bfe1bbbbca93b72525992c.1698062525.git.manos.= pitsidianakis@linaro.org> Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/audio/virtio-snd.h | 113 +++++++- hw/audio/virtio-snd.c | 487 +++++++++++++++++++++++++++++++++- hw/audio/trace-events | 4 + 3 files changed, 595 insertions(+), 9 deletions(-) diff --git a/include/hw/audio/virtio-snd.h b/include/hw/audio/virtio-snd.h index d08065941c..cc14c875ed 100644 --- a/include/hw/audio/virtio-snd.h +++ b/include/hw/audio/virtio-snd.h @@ -67,13 +67,122 @@ typedef struct virtio_snd_pcm_xfer virtio_snd_pcm_xfer; /* I/O request status */ typedef struct virtio_snd_pcm_status virtio_snd_pcm_status; =20 -typedef struct VirtIOSound { +/* device structs */ + +typedef struct VirtIOSound VirtIOSound; + +typedef struct VirtIOSoundPCMStream VirtIOSoundPCMStream; + +typedef struct virtio_snd_ctrl_command virtio_snd_ctrl_command; + +typedef struct VirtIOSoundPCM VirtIOSoundPCM; + +struct VirtIOSoundPCM { + VirtIOSound *snd; + /* + * PCM parameters are a separate field instead of a VirtIOSoundPCMStre= am + * field, because the operation of PCM control requests is first + * VIRTIO_SND_R_PCM_SET_PARAMS and then VIRTIO_SND_R_PCM_PREPARE; this + * means that some times we get parameters without having an allocated + * stream yet. + */ + virtio_snd_pcm_set_params *pcm_params; + VirtIOSoundPCMStream **streams; +}; + +struct VirtIOSoundPCMStream { + VirtIOSoundPCM *pcm; + virtio_snd_pcm_info info; + virtio_snd_pcm_set_params params; + uint32_t id; + /* channel position values (VIRTIO_SND_CHMAP_XXX) */ + uint8_t positions[VIRTIO_SND_CHMAP_MAX_SIZE]; + VirtIOSound *s; + bool flushing; + audsettings as; + union { + SWVoiceIn *in; + SWVoiceOut *out; + } voice; + bool active; +}; + +/* + * PCM stream state machine. + * ------------------------- + * + * 5.14.6.6.1 PCM Command Lifecycle + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * A PCM stream has the following command lifecycle: + * - `SET PARAMETERS` + * The driver negotiates the stream parameters (format, transport, etc) = with + * the device. + * Possible valid transitions: `SET PARAMETERS`, `PREPARE`. + * - `PREPARE` + * The device prepares the stream (allocates resources, etc). + * Possible valid transitions: `SET PARAMETERS`, `PREPARE`, `START`, + * `RELEASE`. Output only: the driver transfers data for pre-buffing. + * - `START` + * The device starts the stream (unmute, putting into running state, etc= ). + * Possible valid transitions: `STOP`. + * The driver transfers data to/from the stream. + * - `STOP` + * The device stops the stream (mute, putting into non-running state, et= c). + * Possible valid transitions: `START`, `RELEASE`. + * - `RELEASE` + * The device releases the stream (frees resources, etc). + * Possible valid transitions: `SET PARAMETERS`, `PREPARE`. + * + * +---------------+ +---------+ +---------+ +-------+ +-------+ + * | SetParameters | | Prepare | | Release | | Start | | Stop | + * +---------------+ +---------+ +---------+ +-------+ +-------+ + * |- | | | | + * || | | | | + * |< | | | | + * |------------->| | | | + * |<-------------| | | | + * | |- | | | + * | || | | | + * | |< | | | + * | |--------------------->| | + * | |---------->| | | + * | | | |-------->| + * | | | |<--------| + * | | |<-------------------| + * |<-------------------------| | | + * | |<----------| | | + * + * CTRL in the VirtIOSound device + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D + * + * The control messages that affect the state of a stream arrive in the + * `virtio_snd_handle_ctrl()` queue callback and are of type `struct + * virtio_snd_ctrl_command`. They are stored in a queue field in the device + * type, `VirtIOSound`. This allows deferring the CTRL request completion = if + * it's not immediately possible due to locking/state reasons. + * + * The CTRL message is finally handled in `process_cmd()`. + */ +struct VirtIOSound { VirtIODevice parent_obj; =20 VirtQueue *queues[VIRTIO_SND_VQ_MAX]; uint64_t features; + VirtIOSoundPCM *pcm; QEMUSoundCard card; VMChangeStateEntry *vmstate; virtio_snd_config snd_conf; -} VirtIOSound; + QemuMutex cmdq_mutex; + QTAILQ_HEAD(, virtio_snd_ctrl_command) cmdq; + bool processing_cmdq; +}; + +struct virtio_snd_ctrl_command { + VirtQueueElement *elem; + VirtQueue *vq; + virtio_snd_hdr ctrl; + virtio_snd_hdr resp; + QTAILQ_ENTRY(virtio_snd_ctrl_command) next; +}; #endif diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index 3a4b441c20..4eae76f638 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -32,6 +32,29 @@ #define VIRTIO_SOUND_CHMAP_DEFAULT 0 #define VIRTIO_SOUND_HDA_FN_NID 0 =20 +static uint32_t supported_formats =3D BIT(VIRTIO_SND_PCM_FMT_S8) + | BIT(VIRTIO_SND_PCM_FMT_U8) + | BIT(VIRTIO_SND_PCM_FMT_S16) + | BIT(VIRTIO_SND_PCM_FMT_U16) + | BIT(VIRTIO_SND_PCM_FMT_S32) + | BIT(VIRTIO_SND_PCM_FMT_U32) + | BIT(VIRTIO_SND_PCM_FMT_FLOAT); + +static uint32_t supported_rates =3D BIT(VIRTIO_SND_PCM_RATE_5512) + | BIT(VIRTIO_SND_PCM_RATE_8000) + | BIT(VIRTIO_SND_PCM_RATE_11025) + | BIT(VIRTIO_SND_PCM_RATE_16000) + | BIT(VIRTIO_SND_PCM_RATE_22050) + | BIT(VIRTIO_SND_PCM_RATE_32000) + | BIT(VIRTIO_SND_PCM_RATE_44100) + | BIT(VIRTIO_SND_PCM_RATE_48000) + | BIT(VIRTIO_SND_PCM_RATE_64000) + | BIT(VIRTIO_SND_PCM_RATE_88200) + | BIT(VIRTIO_SND_PCM_RATE_96000) + | BIT(VIRTIO_SND_PCM_RATE_176400) + | BIT(VIRTIO_SND_PCM_RATE_192000) + | BIT(VIRTIO_SND_PCM_RATE_384000); + static const VMStateDescription vmstate_virtio_snd_device =3D { .name =3D TYPE_VIRTIO_SND, .version_id =3D VIRTIO_SOUND_VM_VERSION, @@ -100,13 +123,397 @@ virtio_snd_set_config(VirtIODevice *vdev, const uint= 8_t *config) =20 } =20 +static void +virtio_snd_ctrl_cmd_free(virtio_snd_ctrl_command *cmd) +{ + g_free(cmd->elem); + g_free(cmd); +} + /* - * Queue handler stub. + * Get a specific stream from the virtio sound card device. + * Returns NULL if @stream_id is invalid or not allocated. + * + * @s: VirtIOSound device + * @stream_id: stream id + */ +static VirtIOSoundPCMStream *virtio_snd_pcm_get_stream(VirtIOSound *s, + uint32_t stream_id) +{ + return stream_id >=3D s->snd_conf.streams ? NULL : + s->pcm->streams[stream_id]; +} + +/* + * Get params for a specific stream. + * + * @s: VirtIOSound device + * @stream_id: stream id + */ +static virtio_snd_pcm_set_params *virtio_snd_pcm_get_params(VirtIOSound *s, + uint32_t strea= m_id) +{ + return stream_id >=3D s->snd_conf.streams ? NULL + : &s->pcm->pcm_params[stream_id]; +} + +/* + * Set the given stream params. + * Called by both virtio_snd_handle_pcm_set_params and during device + * initialization. + * Returns the response status code. (VIRTIO_SND_S_*). + * + * @s: VirtIOSound device + * @params: The PCM params as defined in the virtio specification + */ +static +uint32_t virtio_snd_set_pcm_params(VirtIOSound *s, + uint32_t stream_id, + virtio_snd_pcm_set_params *params) +{ + virtio_snd_pcm_set_params *st_params; + + if (stream_id >=3D s->snd_conf.streams || s->pcm->pcm_params =3D=3D NU= LL) { + /* + * TODO: do we need to set DEVICE_NEEDS_RESET? + */ + virtio_error(VIRTIO_DEVICE(s), "Streams have not been initialized.= \n"); + return cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + } + + st_params =3D virtio_snd_pcm_get_params(s, stream_id); + + if (params->channels < 1 || params->channels > AUDIO_MAX_CHANNELS) { + error_report("Number of channels is not supported."); + return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP); + } + if (!(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))) { + error_report("Stream rate is not supported."); + return cpu_to_le32(VIRTIO_SND_S_NOT_SUPP); + } + + st_params->buffer_bytes =3D le32_to_cpu(params->buffer_bytes); + st_params->period_bytes =3D le32_to_cpu(params->period_bytes); + st_params->features =3D le32_to_cpu(params->features); + /* the following are uint8_t, so there's no need to bswap the values. = */ + st_params->channels =3D params->channels; + st_params->format =3D params->format; + st_params->rate =3D params->rate; + + return cpu_to_le32(VIRTIO_SND_S_OK); +} + +/* + * Get a QEMU Audiosystem compatible format value from a VIRTIO_SND_PCM_FM= T_* + */ +static AudioFormat virtio_snd_get_qemu_format(uint32_t format) +{ + #define CASE(FMT) \ + case VIRTIO_SND_PCM_FMT_##FMT: \ + return AUDIO_FORMAT_##FMT; + + switch (format) { + CASE(U8) + CASE(S8) + CASE(U16) + CASE(S16) + CASE(U32) + CASE(S32) + case VIRTIO_SND_PCM_FMT_FLOAT: + return AUDIO_FORMAT_F32; + default: + g_assert_not_reached(); + } + + #undef CASE +} + +/* + * Get a QEMU Audiosystem compatible frequency value from a + * VIRTIO_SND_PCM_RATE_* + */ +static uint32_t virtio_snd_get_qemu_freq(uint32_t rate) +{ + #define CASE(RATE) \ + case VIRTIO_SND_PCM_RATE_##RATE: \ + return RATE; + + switch (rate) { + CASE(5512) + CASE(8000) + CASE(11025) + CASE(16000) + CASE(22050) + CASE(32000) + CASE(44100) + CASE(48000) + CASE(64000) + CASE(88200) + CASE(96000) + CASE(176400) + CASE(192000) + CASE(384000) + default: + g_assert_not_reached(); + } + + #undef CASE +} + +/* + * Get QEMU Audiosystem compatible audsettings from virtio based pcm stream + * params. + */ +static void virtio_snd_get_qemu_audsettings(audsettings *as, + virtio_snd_pcm_set_params *par= ams) +{ + as->nchannels =3D MIN(AUDIO_MAX_CHANNELS, params->channels); + as->fmt =3D virtio_snd_get_qemu_format(params->format); + as->freq =3D virtio_snd_get_qemu_freq(params->rate); + as->endianness =3D target_words_bigendian() ? 1 : 0; +} + +/* + * Close a stream and free all its resources. + * + * @stream: VirtIOSoundPCMStream *stream + */ +static void virtio_snd_pcm_close(VirtIOSoundPCMStream *stream) +{ +} + +/* + * Prepares a VirtIOSound card stream. + * Returns the response status code. (VIRTIO_SND_S_*). + * + * @s: VirtIOSound device + * @stream_id: stream id + */ +static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s, uint32_t stream_id) +{ + audsettings as; + virtio_snd_pcm_set_params *params; + VirtIOSoundPCMStream *stream; + + if (s->pcm->streams =3D=3D NULL || + s->pcm->pcm_params =3D=3D NULL || + stream_id >=3D s->snd_conf.streams) { + return cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + } + + params =3D virtio_snd_pcm_get_params(s, stream_id); + if (params =3D=3D NULL) { + return cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + } + + stream =3D virtio_snd_pcm_get_stream(s, stream_id); + if (stream =3D=3D NULL) { + stream =3D g_new0(VirtIOSoundPCMStream, 1); + stream->active =3D false; + stream->id =3D stream_id; + stream->pcm =3D s->pcm; + stream->s =3D s; + + /* + * stream_id >=3D s->snd_conf.streams was checked before so this is + * in-bounds + */ + s->pcm->streams[stream_id] =3D stream; + } + + virtio_snd_get_qemu_audsettings(&as, params); + stream->info.direction =3D stream_id < s->snd_conf.streams / 2 + + (s->snd_conf.streams & 1) ? VIRTIO_SND_D_OUTPUT : VIRTIO_SND_D_INP= UT; + stream->info.hdr.hda_fn_nid =3D VIRTIO_SOUND_HDA_FN_NID; + stream->info.features =3D 0; + stream->info.channels_min =3D 1; + stream->info.channels_max =3D as.nchannels; + stream->info.formats =3D supported_formats; + stream->info.rates =3D supported_rates; + stream->params =3D *params; + + stream->positions[0] =3D VIRTIO_SND_CHMAP_FL; + stream->positions[1] =3D VIRTIO_SND_CHMAP_FR; + stream->as =3D as; + + return cpu_to_le32(VIRTIO_SND_S_OK); +} + +static const char *print_code(uint32_t code) +{ + #define CASE(CODE) \ + case VIRTIO_SND_R_##CODE: \ + return "VIRTIO_SND_R_"#CODE + + switch (code) { + CASE(JACK_INFO); + CASE(JACK_REMAP); + CASE(PCM_INFO); + CASE(PCM_SET_PARAMS); + CASE(PCM_PREPARE); + CASE(PCM_RELEASE); + CASE(PCM_START); + CASE(PCM_STOP); + CASE(CHMAP_INFO); + default: + return "invalid code"; + } + + #undef CASE +}; + +/* + * The actual processing done in virtio_snd_process_cmdq(). + * + * @s: VirtIOSound device + * @cmd: control command request + */ +static inline void +process_cmd(VirtIOSound *s, virtio_snd_ctrl_command *cmd) +{ + uint32_t code; + size_t msg_sz =3D iov_to_buf(cmd->elem->out_sg, + cmd->elem->out_num, + 0, + &cmd->ctrl, + sizeof(virtio_snd_hdr)); + + if (msg_sz !=3D sizeof(virtio_snd_hdr)) { + /* + * TODO: do we need to set DEVICE_NEEDS_RESET? + */ + qemu_log_mask(LOG_GUEST_ERROR, + "%s: virtio-snd command size incorrect %zu vs \ + %zu\n", __func__, msg_sz, sizeof(virtio_snd_hdr)); + return; + } + + code =3D le32_to_cpu(cmd->ctrl.code); + + trace_virtio_snd_handle_code(code, print_code(code)); + + switch (code) { + case VIRTIO_SND_R_JACK_INFO: + case VIRTIO_SND_R_JACK_REMAP: + qemu_log_mask(LOG_UNIMP, + "virtio_snd: jack functionality is unimplemented.\n"); + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_NOT_SUPP); + break; + case VIRTIO_SND_R_PCM_INFO: + case VIRTIO_SND_R_PCM_SET_PARAMS: + case VIRTIO_SND_R_PCM_PREPARE: + case VIRTIO_SND_R_PCM_START: + case VIRTIO_SND_R_PCM_STOP: + case VIRTIO_SND_R_PCM_RELEASE: + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_NOT_SUPP); + break; + case VIRTIO_SND_R_CHMAP_INFO: + qemu_log_mask(LOG_UNIMP, + "virtio_snd: chmap info functionality is unimplemente= d.\n"); + trace_virtio_snd_handle_chmap_info(); + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_NOT_SUPP); + break; + default: + /* error */ + error_report("virtio snd header not recognized: %"PRIu32, code); + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + } + + iov_from_buf(cmd->elem->in_sg, + cmd->elem->in_num, + 0, + &cmd->resp, + sizeof(virtio_snd_hdr)); + virtqueue_push(cmd->vq, cmd->elem, sizeof(virtio_snd_hdr)); + virtio_notify(VIRTIO_DEVICE(s), cmd->vq); +} + +/* + * Consume all elements in command queue. + * + * @s: VirtIOSound device + */ +static void virtio_snd_process_cmdq(VirtIOSound *s) +{ + virtio_snd_ctrl_command *cmd; + + if (unlikely(qatomic_read(&s->processing_cmdq))) { + return; + } + + WITH_QEMU_LOCK_GUARD(&s->cmdq_mutex) { + qatomic_set(&s->processing_cmdq, true); + while (!QTAILQ_EMPTY(&s->cmdq)) { + cmd =3D QTAILQ_FIRST(&s->cmdq); + + /* process command */ + process_cmd(s, cmd); + + QTAILQ_REMOVE(&s->cmdq, cmd, next); + + virtio_snd_ctrl_cmd_free(cmd); + } + qatomic_set(&s->processing_cmdq, false); + } +} + +/* + * The control message handler. Pops an element from the control virtqueue, + * and stores them to VirtIOSound's cmdq queue and finally calls + * virtio_snd_process_cmdq() for processing. + * + * @vdev: VirtIOSound device + * @vq: Control virtqueue + */ +static void virtio_snd_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) +{ + VirtIOSound *s =3D VIRTIO_SND(vdev); + VirtQueueElement *elem; + virtio_snd_ctrl_command *cmd; + + trace_virtio_snd_handle_ctrl(vdev, vq); + + if (!virtio_queue_ready(vq)) { + return; + } + + elem =3D virtqueue_pop(vq, sizeof(VirtQueueElement)); + while (elem) { + cmd =3D g_new0(virtio_snd_ctrl_command, 1); + cmd->elem =3D elem; + cmd->vq =3D vq; + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_OK); + QTAILQ_INSERT_TAIL(&s->cmdq, cmd, next); + elem =3D virtqueue_pop(vq, sizeof(VirtQueueElement)); + } + + virtio_snd_process_cmdq(s); +} + +/* + * The event virtqueue handler. + * Not implemented yet. + * + * @vdev: VirtIOSound device + * @vq: event vq + */ +static void virtio_snd_handle_event(VirtIODevice *vdev, VirtQueue *vq) +{ + qemu_log_mask(LOG_UNIMP, "virtio_snd: event queue is unimplemented.\n"= ); + trace_virtio_snd_handle_event(); +} + +/* + * Stub buffer virtqueue handler. * * @vdev: VirtIOSound device * @vq: virtqueue */ -static void virtio_snd_handle_queue(VirtIODevice *vdev, VirtQueue *vq) {} +static void virtio_snd_handle_xfer(VirtIODevice *vdev, VirtQueue *vq) {} =20 static uint64_t get_features(VirtIODevice *vdev, uint64_t features, Error **errp) @@ -140,12 +547,22 @@ static void virtio_snd_realize(DeviceState *dev, Erro= r **errp) ERRP_GUARD(); VirtIOSound *vsnd =3D VIRTIO_SND(dev); VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + virtio_snd_pcm_set_params default_params =3D { 0 }; + uint32_t status; =20 + vsnd->pcm =3D NULL; vsnd->vmstate =3D qemu_add_vm_change_state_handler(virtio_snd_vm_state_change, vsnd); =20 trace_virtio_snd_realize(vsnd); =20 + vsnd->pcm =3D g_new0(VirtIOSoundPCM, 1); + vsnd->pcm->snd =3D vsnd; + vsnd->pcm->streams =3D + g_new0(VirtIOSoundPCMStream *, vsnd->snd_conf.streams); + vsnd->pcm->pcm_params =3D + g_new0(virtio_snd_pcm_set_params, vsnd->snd_conf.streams); + virtio_init(vdev, VIRTIO_ID_SOUND, sizeof(virtio_snd_config)); virtio_add_feature(&vsnd->features, VIRTIO_F_VERSION_1); =20 @@ -172,25 +589,69 @@ static void virtio_snd_realize(DeviceState *dev, Erro= r **errp) =20 AUD_register_card("virtio-sound", &vsnd->card, errp); =20 + /* set default params for all streams */ + default_params.features =3D 0; + default_params.buffer_bytes =3D cpu_to_le32(8192); + default_params.period_bytes =3D cpu_to_le32(2048); + default_params.channels =3D 2; + default_params.format =3D VIRTIO_SND_PCM_FMT_S16; + default_params.rate =3D VIRTIO_SND_PCM_RATE_48000; vsnd->queues[VIRTIO_SND_VQ_CONTROL] =3D - virtio_add_queue(vdev, 64, virtio_snd_handle_queue); + virtio_add_queue(vdev, 64, virtio_snd_handle_ctrl); vsnd->queues[VIRTIO_SND_VQ_EVENT] =3D - virtio_add_queue(vdev, 64, virtio_snd_handle_queue); + virtio_add_queue(vdev, 64, virtio_snd_handle_event); vsnd->queues[VIRTIO_SND_VQ_TX] =3D - virtio_add_queue(vdev, 64, virtio_snd_handle_queue); + virtio_add_queue(vdev, 64, virtio_snd_handle_xfer); vsnd->queues[VIRTIO_SND_VQ_RX] =3D - virtio_add_queue(vdev, 64, virtio_snd_handle_queue); + virtio_add_queue(vdev, 64, virtio_snd_handle_xfer); + qemu_mutex_init(&vsnd->cmdq_mutex); + QTAILQ_INIT(&vsnd->cmdq); + + for (uint32_t i =3D 0; i < vsnd->snd_conf.streams; i++) { + status =3D virtio_snd_set_pcm_params(vsnd, i, &default_params); + if (status !=3D cpu_to_le32(VIRTIO_SND_S_OK)) { + error_setg(errp, + "Can't initalize stream params, device responded wi= th %s.", + print_code(status)); + return; + } + status =3D virtio_snd_pcm_prepare(vsnd, i); + if (status !=3D cpu_to_le32(VIRTIO_SND_S_OK)) { + error_setg(errp, + "Can't prepare streams, device responded with %s.", + print_code(status)); + return; + } + } } =20 static void virtio_snd_unrealize(DeviceState *dev) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOSound *vsnd =3D VIRTIO_SND(dev); + VirtIOSoundPCMStream *stream; =20 qemu_del_vm_change_state_handler(vsnd->vmstate); trace_virtio_snd_unrealize(vsnd); =20 + if (vsnd->pcm) { + if (vsnd->pcm->streams) { + for (uint32_t i =3D 0; i < vsnd->snd_conf.streams; i++) { + stream =3D vsnd->pcm->streams[i]; + if (stream) { + virtio_snd_process_cmdq(stream->s); + virtio_snd_pcm_close(stream); + g_free(stream); + } + } + g_free(vsnd->pcm->streams); + } + g_free(vsnd->pcm->pcm_params); + g_free(vsnd->pcm); + vsnd->pcm =3D NULL; + } AUD_remove_card(&vsnd->card); + qemu_mutex_destroy(&vsnd->cmdq_mutex); virtio_delete_queue(vsnd->queues[VIRTIO_SND_VQ_CONTROL]); virtio_delete_queue(vsnd->queues[VIRTIO_SND_VQ_EVENT]); virtio_delete_queue(vsnd->queues[VIRTIO_SND_VQ_TX]); @@ -199,7 +660,19 @@ static void virtio_snd_unrealize(DeviceState *dev) } =20 =20 -static void virtio_snd_reset(VirtIODevice *vdev) {} +static void virtio_snd_reset(VirtIODevice *vdev) +{ + VirtIOSound *s =3D VIRTIO_SND(vdev); + virtio_snd_ctrl_command *cmd; + + WITH_QEMU_LOCK_GUARD(&s->cmdq_mutex) { + while (!QTAILQ_EMPTY(&s->cmdq)) { + cmd =3D QTAILQ_FIRST(&s->cmdq); + QTAILQ_REMOVE(&s->cmdq, cmd, next); + virtio_snd_ctrl_cmd_free(cmd); + } + } +} =20 static void virtio_snd_class_init(ObjectClass *klass, void *data) { diff --git a/hw/audio/trace-events b/hw/audio/trace-events index 525ced2b34..122d1403ef 100644 --- a/hw/audio/trace-events +++ b/hw/audio/trace-events @@ -47,3 +47,7 @@ virtio_snd_vm_state_running(void) "vm state running" virtio_snd_vm_state_stopped(void) "vm state stopped" virtio_snd_realize(void *snd) "snd %p: realize" virtio_snd_unrealize(void *snd) "snd %p: unrealize" +virtio_snd_handle_ctrl(void *vdev, void *vq) "snd %p: handle ctrl event fo= r queue %p" +virtio_snd_handle_code(uint32_t val, const char *code) "ctrl code msg val = =3D %"PRIu32" =3D=3D %s" +virtio_snd_handle_chmap_info(void) "VIRTIO_SND_CHMAP_INFO called" +virtio_snd_handle_event(void) "event queue callback called" --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351857; cv=none; d=zohomail.com; s=zohoarc; b=CJEDRW0MN631KTw+KiDFMHw3ipy1QZL8SwPRcYwJeahTVlmAnWTN46NTSno4wCPW8t3teTlVPiX3MhtSqlwywdhhMACE6y7G5a1bBNa4gPquYwrz7e2VQWaoUiJvkGVMeELHHbviqg02AWH3r30XqGR5j+dZLUCdfgmO/d11hUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351857; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vfauttJPTH7CDsS+NAXMawCTCDD51QjLsLHnUx3iJuI=; b=M1jbhByVFWhGnxkYF+wPL89DPmyA5KLjm3yc+8UK6fA7oQpNx4pT7GChimSYyMu0db0i7N5DxLZgGnjVEq5aBbb6NiQHZ9SeyeReBw+Dt7QQL2UlBkTlBmh6xRKwvfL0SqIUjy2F+TCMHZmSyim1pKafvQxihpNcl33Pq9CBVPY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699351857553845.3356389609551; Tue, 7 Nov 2023 02:10:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J2j-0002Bc-II; Tue, 07 Nov 2023 05:10:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2R-0001ZZ-M5 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2P-0002S9-Qs for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:27 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-202-LAb3jlnRP6iXm8Bz4TdWtQ-1; Tue, 07 Nov 2023 05:10:23 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4084e4ce543so34960775e9.3 for ; Tue, 07 Nov 2023 02:10:22 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id fl17-20020a05600c0b9100b004097881d5f0sm12440561wmb.29.2023.11.07.02.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:10:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351825; h=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=vfauttJPTH7CDsS+NAXMawCTCDD51QjLsLHnUx3iJuI=; b=YPakE+ncNHk0ltHar3jNnKO4175j7rzmDfaiVXhlY1R13EqNEgPOYCbGFJJM6wiIDLCUOe v/3z3PNEXESKV3YNm4ccMhqFoTPGdCtzM1JiOhAxsmPIMovnVpft8LimI4Ufy8X8LggbWl EDGr4CT7z3uel/Nm9/M0shA+xy8p07U= X-MC-Unique: LAb3jlnRP6iXm8Bz4TdWtQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351821; x=1699956621; 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=vfauttJPTH7CDsS+NAXMawCTCDD51QjLsLHnUx3iJuI=; b=DBeLaWkpMgH5DU+5S0OaGX9VZVaEf4aJnEVW4UQqCZhI4QD6PazE1lOg8MvcDt4a80 PCkmaCs8kmA/yHfhsWsDjVpCod1ryAPmk+xJtp8+eqg6R2M8ZaimzEIBR5SS0fNo8VPQ 7DBibhKmjg0jy9PX0lfESEWQjm+HACmtEVc8Gh/vWPoV/RFXFea6F6DUxGaRzqzqgBHr F6SAS2dIi7ZaVjj9de7EoCtkSHT9tQNaR8K+YnTpe9oxuonVAhJmPu+Ab2nOUVGsdnhB KFeNRYOl92QhHKXv4GhqFBiviI2IXcb3qBCWuxknwZ8R+axFBhO55vuTcRL/TeCrWE2J xvSA== X-Gm-Message-State: AOJu0YyA++PDx8jHpprVJz6PFjmRg6erksEAkCK1WOiNB/ols04xcu10 zTZunh9DjebtRq9EvppIybb/UvvP9kQyyjjSs5KOlWJyISZZ20Czcx/tk2v5rx3sgvmge0EMmlU dcjBTqJzW+bCsDPhhDkdtvZB9VnescD6JPfaxgReiZRXVjSzJqdHbifpwF+NOVblOPUHR X-Received: by 2002:a05:600c:3112:b0:408:575e:f24f with SMTP id g18-20020a05600c311200b00408575ef24fmr1890507wmo.28.1699351820959; Tue, 07 Nov 2023 02:10:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5Uw61O8rfpuU4IEFMR97wIED55tgJcYp6TK5WuxBE5rcwy+LZhLHEz1UJbloOwAWCmGpv9g== X-Received: by 2002:a05:600c:3112:b0:408:575e:f24f with SMTP id g18-20020a05600c311200b00408575ef24fmr1890483wmo.28.1699351820588; Tue, 07 Nov 2023 02:10:20 -0800 (PST) Date: Tue, 7 Nov 2023 05:10:16 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Igor Skalkin , Anton Yakovlev , Alex =?utf-8?Q?Benn=C3=A9e?= , Gerd Hoffmann Subject: [PULL 11/63] virtio-sound: handle VIRTIO_SND_R_PCM_INFO request Message-ID: <0ff05dd209f153f037a48e4039a033885b9ab5e3.1699351720.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351859643100003 From: Manos Pitsidianakis Respond to the VIRTIO_SND_R_PCM_INFO control request with the parameters of each requested PCM stream. Based-on: https://github.com/OpenSynergy/qemu/commit/5a2f350eec5d157b90d9c7= b40a8e603f4da92471 Signed-off-by: Igor Skalkin Signed-off-by: Anton Yakovlev Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Message-Id: <5ecea6ba2fb0e3957d7d90bc4dbac521a3d1f678.1698062525.git.manos.= pitsidianakis@linaro.org> Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/audio/virtio-snd.c | 82 +++++++++++++++++++++++++++++++++++++++++++ hw/audio/trace-events | 1 + 2 files changed, 83 insertions(+) diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index 4eae76f638..fd0c50de6e 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -157,6 +157,86 @@ static virtio_snd_pcm_set_params *virtio_snd_pcm_get_p= arams(VirtIOSound *s, : &s->pcm->pcm_params[stream_id]; } =20 +/* + * Handle the VIRTIO_SND_R_PCM_INFO request. + * The function writes the info structs to the request element. + * + * @s: VirtIOSound device + * @cmd: The request command queue element from VirtIOSound cmdq field + */ +static void virtio_snd_handle_pcm_info(VirtIOSound *s, + virtio_snd_ctrl_command *cmd) +{ + uint32_t stream_id, start_id, count, size; + virtio_snd_pcm_info val; + virtio_snd_query_info req; + VirtIOSoundPCMStream *stream =3D NULL; + g_autofree virtio_snd_pcm_info *pcm_info =3D NULL; + size_t msg_sz =3D iov_to_buf(cmd->elem->out_sg, + cmd->elem->out_num, + 0, + &req, + sizeof(virtio_snd_query_info)); + + if (msg_sz !=3D sizeof(virtio_snd_query_info)) { + /* + * TODO: do we need to set DEVICE_NEEDS_RESET? + */ + qemu_log_mask(LOG_GUEST_ERROR, + "%s: virtio-snd command size incorrect %zu vs \ + %zu\n", __func__, msg_sz, sizeof(virtio_snd_query_info)); + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + return; + } + + start_id =3D le32_to_cpu(req.start_id); + count =3D le32_to_cpu(req.count); + size =3D le32_to_cpu(req.size); + + if (iov_size(cmd->elem->in_sg, cmd->elem->in_num) < + sizeof(virtio_snd_hdr) + size * count) { + /* + * TODO: do we need to set DEVICE_NEEDS_RESET? + */ + error_report("pcm info: buffer too small, got: %zu, needed: %zu", + iov_size(cmd->elem->in_sg, cmd->elem->in_num), + sizeof(virtio_snd_pcm_info)); + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + return; + } + + pcm_info =3D g_new0(virtio_snd_pcm_info, count); + for (uint32_t i =3D 0; i < count; i++) { + stream_id =3D i + start_id; + trace_virtio_snd_handle_pcm_info(stream_id); + stream =3D virtio_snd_pcm_get_stream(s, stream_id); + if (!stream) { + error_report("Invalid stream id: %"PRIu32, stream_id); + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + return; + } + val =3D stream->info; + val.hdr.hda_fn_nid =3D cpu_to_le32(val.hdr.hda_fn_nid); + val.features =3D cpu_to_le32(val.features); + val.formats =3D cpu_to_le64(val.formats); + val.rates =3D cpu_to_le64(val.rates); + /* + * 5.14.6.6.2.1 Device Requirements: Stream Information The device= MUST + * NOT set undefined feature, format, rate and direction values. T= he + * device MUST initialize the padding bytes to 0. + */ + pcm_info[i] =3D val; + memset(&pcm_info[i].padding, 0, 5); + } + + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_OK); + iov_from_buf(cmd->elem->in_sg, + cmd->elem->in_num, + sizeof(virtio_snd_hdr), + pcm_info, + sizeof(virtio_snd_pcm_info) * count); +} + /* * Set the given stream params. * Called by both virtio_snd_handle_pcm_set_params and during device @@ -404,6 +484,8 @@ process_cmd(VirtIOSound *s, virtio_snd_ctrl_command *cm= d) cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_NOT_SUPP); break; case VIRTIO_SND_R_PCM_INFO: + virtio_snd_handle_pcm_info(s, cmd); + break; case VIRTIO_SND_R_PCM_SET_PARAMS: case VIRTIO_SND_R_PCM_PREPARE: case VIRTIO_SND_R_PCM_START: diff --git a/hw/audio/trace-events b/hw/audio/trace-events index 122d1403ef..6def414f96 100644 --- a/hw/audio/trace-events +++ b/hw/audio/trace-events @@ -48,6 +48,7 @@ virtio_snd_vm_state_stopped(void) "vm state stopped" virtio_snd_realize(void *snd) "snd %p: realize" virtio_snd_unrealize(void *snd) "snd %p: unrealize" virtio_snd_handle_ctrl(void *vdev, void *vq) "snd %p: handle ctrl event fo= r queue %p" +virtio_snd_handle_pcm_info(uint32_t stream) "VIRTIO_SND_R_PCM_INFO called = for stream %"PRIu32 virtio_snd_handle_code(uint32_t val, const char *code) "ctrl code msg val = =3D %"PRIu32" =3D=3D %s" virtio_snd_handle_chmap_info(void) "VIRTIO_SND_CHMAP_INFO called" virtio_snd_handle_event(void) "event queue callback called" --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351986; cv=none; d=zohomail.com; s=zohoarc; b=PdiWF+TWezE69b5xSfimInTr3EnLwhghwHph1lFbLpzaIsf9P8EPbVR1xXARzcbbCZNX2ARnnsjrQg0qGJCno6tglsfeGX3g0GA3birE2msZGrfEZg8VQWEtESOHPi5pUYzREoNgNCCLygom/BS/4z79KpKT0Em1G2/HO9vmII8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351986; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vvxEP4jiEV7WSUxXyqMVFGiE73KFR5mwnf3CNU3QYWg=; b=C4TMF5qsPeyOBTccHiDvVTHBr975Y4fLDGeLGgn1xILSK3rwdlrVfJBe12x6ZYCDxdjJfOMB8BgCfG8rpTGLmfGwHqdcwtilrcQkz/YCoet95IosvXay6XnQB1UvcceMM3IGjJKIgYL05P4DrWQRi3lFoDotZkBcj84GvWb62+M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699351986155577.7502912770135; Tue, 7 Nov 2023 02:13:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J2x-0002g1-TE; Tue, 07 Nov 2023 05:11:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2W-0001g6-B4 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2U-0002SW-EK for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:32 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-121-iXz2_lb3OuW_JIkKd1pGyw-1; Tue, 07 Nov 2023 05:10:27 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-408508aa81cso36211055e9.3 for ; Tue, 07 Nov 2023 02:10:27 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id c14-20020a05600c0a4e00b004030e8ff964sm15725829wmq.34.2023.11.07.02.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:10:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351829; h=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=vvxEP4jiEV7WSUxXyqMVFGiE73KFR5mwnf3CNU3QYWg=; b=RQNPgw8Y5Osna5HBR64wGg2AcyYcTjPMUqvZzT/7EZRtSyGXzXu3iFpcE2Wmd8wVJjVQWy f5/eCSwTLcXr9gKSVciD+b4V1B1shWL3hwcB2tbcmJ8dBFFCnI3Rme+XIgtn0jAy4oCPJ3 kkHUDF+tUaPMf6BTaFk/s7GmxU4xUWE= X-MC-Unique: iXz2_lb3OuW_JIkKd1pGyw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351826; x=1699956626; 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=vvxEP4jiEV7WSUxXyqMVFGiE73KFR5mwnf3CNU3QYWg=; b=keGcVTVag8G229c+LSorKRp0VUvlTQ75zHu1FSjaGPu+0vWm8H5sCoA2vzSc8n2egZ 0BUvTE1wg+B74CXvK/ojfeVpl1p3U8lSKuSYbUkwRHk0GG4Hh30u/19AZ8GJRyHvpeUS qBQEX31ElBI1Pw/CMohBCD0LvZ0isHU1rDrvrw6vjdTodQpKkBrOtfmGW5rNREpnDbA8 sre9IF0fuyNY5A6K7ewoHpAs39YRSHTSb0bxWngUW0YP9xYII9RzLD/TjKdmFPIaO+I0 m04UuMt5ZpMQUPqDLT1DrjnJZ9kXPdZo3FiFCTLtS5x72cEjZsYpq7kfsSWx+XOfoMB1 ftWw== X-Gm-Message-State: AOJu0YzYV5xflIH8IlkHhXPiLnUhQVPgBMi1Z/S7axoedebCovl8OZze ZHe7B6cViNNZRhLugHDxVbaW4Tdbacdqwr2z7qppioSh8MAYTxuo0q/Cf8KfBbaBpX+v2kOqCwK 1IW0tDqytZuOqvNFeqyqf3Sw7utnegESPVqBIvazGwGGF/1i6MCLRWCsge4KjDhnVl3ea X-Received: by 2002:a1c:6a17:0:b0:405:3955:5872 with SMTP id f23-20020a1c6a17000000b0040539555872mr1747344wmc.18.1699351826017; Tue, 07 Nov 2023 02:10:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEm13nbVnSFztb+F11kuXqCoJtyrEnpRPJ8MonH620o5B0P2TnbQT8iZ9v/UnvxXhtiuT3d6w== X-Received: by 2002:a1c:6a17:0:b0:405:3955:5872 with SMTP id f23-20020a1c6a17000000b0040539555872mr1747320wmc.18.1699351825585; Tue, 07 Nov 2023 02:10:25 -0800 (PST) Date: Tue, 7 Nov 2023 05:10:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Igor Skalkin , Anton Yakovlev , Alex =?utf-8?Q?Benn=C3=A9e?= , Gerd Hoffmann Subject: [PULL 12/63] virtio-sound: handle VIRTIO_SND_R_PCM_{START,STOP} Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351988066100006 From: Manos Pitsidianakis Handle the start and stop control messages for a stream_id. This request does nothing at the moment except for replying to it. Audio playback or capture will be started/stopped here in follow-up commits. Based-on: https://github.com/OpenSynergy/qemu/commit/5a2f350eec5d157b90d9c7= b40a8e603f4da92471 Signed-off-by: Igor Skalkin Signed-off-by: Anton Yakovlev Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Message-Id: <9657dbfe3cb4a48ceb033ceb5977dc08669dfefd.1698062525.git.manos.= pitsidianakis@linaro.org> Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/audio/virtio-snd.c | 49 +++++++++++++++++++++++++++++++++++++++++-- hw/audio/trace-events | 1 + 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index fd0c50de6e..e6791de6c6 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -446,6 +446,47 @@ static const char *print_code(uint32_t code) #undef CASE }; =20 +/* + * Handles VIRTIO_SND_R_PCM_START. + * + * @s: VirtIOSound device + * @cmd: The request command queue element from VirtIOSound cmdq field + * @start: whether to start or stop the device + */ +static void virtio_snd_handle_pcm_start_stop(VirtIOSound *s, + virtio_snd_ctrl_command *cmd, + bool start) +{ + VirtIOSoundPCMStream *stream; + virtio_snd_pcm_hdr req; + uint32_t stream_id; + size_t msg_sz =3D iov_to_buf(cmd->elem->out_sg, + cmd->elem->out_num, + 0, + &req, + sizeof(virtio_snd_pcm_hdr)); + + if (msg_sz !=3D sizeof(virtio_snd_pcm_hdr)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: virtio-snd command size incorrect %zu vs \ + %zu\n", __func__, msg_sz, sizeof(virtio_snd_pcm_hdr)); + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + return; + } + + stream_id =3D le32_to_cpu(req.stream_id); + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_OK); + trace_virtio_snd_handle_pcm_start_stop(start ? "VIRTIO_SND_R_PCM_START= " : + "VIRTIO_SND_R_PCM_STOP", stream_id); + stream =3D virtio_snd_pcm_get_stream(s, stream_id); + if (stream =3D=3D NULL) { + error_report("Invalid stream id: %"PRIu32, req.stream_id); + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + return; + } + stream->active =3D start; +} + /* * The actual processing done in virtio_snd_process_cmdq(). * @@ -486,10 +527,14 @@ process_cmd(VirtIOSound *s, virtio_snd_ctrl_command *= cmd) case VIRTIO_SND_R_PCM_INFO: virtio_snd_handle_pcm_info(s, cmd); break; + case VIRTIO_SND_R_PCM_START: + virtio_snd_handle_pcm_start_stop(s, cmd, true); + break; + case VIRTIO_SND_R_PCM_STOP: + virtio_snd_handle_pcm_start_stop(s, cmd, false); + break; case VIRTIO_SND_R_PCM_SET_PARAMS: case VIRTIO_SND_R_PCM_PREPARE: - case VIRTIO_SND_R_PCM_START: - case VIRTIO_SND_R_PCM_STOP: case VIRTIO_SND_R_PCM_RELEASE: cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_NOT_SUPP); break; diff --git a/hw/audio/trace-events b/hw/audio/trace-events index 6def414f96..db48ff04fe 100644 --- a/hw/audio/trace-events +++ b/hw/audio/trace-events @@ -49,6 +49,7 @@ virtio_snd_realize(void *snd) "snd %p: realize" virtio_snd_unrealize(void *snd) "snd %p: unrealize" virtio_snd_handle_ctrl(void *vdev, void *vq) "snd %p: handle ctrl event fo= r queue %p" virtio_snd_handle_pcm_info(uint32_t stream) "VIRTIO_SND_R_PCM_INFO called = for stream %"PRIu32 +virtio_snd_handle_pcm_start_stop(const char *code, uint32_t stream) "%s ca= lled for stream %"PRIu32 virtio_snd_handle_code(uint32_t val, const char *code) "ctrl code msg val = =3D %"PRIu32" =3D=3D %s" virtio_snd_handle_chmap_info(void) "VIRTIO_SND_CHMAP_INFO called" virtio_snd_handle_event(void) "event queue callback called" --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352211; cv=none; d=zohomail.com; s=zohoarc; b=U1TvoiqZ9+sDg2vQvs//OpRCEoyARtxQ9JNG1ELGVvDAFs8iHk6b61mlpYXeUDYDgI381m6cxQqLtZI8S2+B/MTe55/dwZ0CfD11RViAK/T1KvAzFLQXK1xDldkKKpcRQFK7LqYx2WB8WTbAZkVJoY+IizOF8EZzwwtJGrombpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352211; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5krSj5ww4PPaYbWf+2x/83yOHdPFHALqGPbTo+C3zcI=; b=alHkmW5UnuRotMsQaguPbEQVyf8Tor08CaYC/8Fd18KnUQw3wJU461nQSSuEz24Rj0xAu3cm79DFjfjpmN6+RkprrRKKPqa6NodG63GSUX/DfZwt8+rHVbRBQlYe8BZOs2iiHd2R4j0xBKStkX9ry3d5tlgMq3hKe7O8EXRMKuA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352211055318.3926457527997; Tue, 7 Nov 2023 02:16:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J34-00037F-4B; Tue, 07 Nov 2023 05:11:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2a-0001ow-EU for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2Y-0002Ss-Lb for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:36 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-583-s7pqoJyOPTSI7nU3GM7ImQ-1; Tue, 07 Nov 2023 05:10:32 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4092164ed09so32748055e9.2 for ; Tue, 07 Nov 2023 02:10:32 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id p6-20020a05600c358600b004053a6b8c41sm14891490wmq.12.2023.11.07.02.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:10:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351833; h=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=5krSj5ww4PPaYbWf+2x/83yOHdPFHALqGPbTo+C3zcI=; b=RfYUksef+mDFawM2SJoZtHZ02gIe13sLE6N8+IcYvydqLEz/NuAXT7htoGwT48fAUN8bww B22lSP7nAvqnULLlH5mmD/2KxaE3rHAzB6PLQk/4nZo3uO9b7GhVxsP7fJF16t3ep7ZQGh dhyDIPNKIwd9H+VwEBlIrLBPWPoZzYM= X-MC-Unique: s7pqoJyOPTSI7nU3GM7ImQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351831; x=1699956631; 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=5krSj5ww4PPaYbWf+2x/83yOHdPFHALqGPbTo+C3zcI=; b=NgL3ON1ANebVQb/Od3WtiNA+ct/fVtuJ4GwnVXRCX9e/tW4xQOvUUQ4jSKHmvBWqur 4CzBNAtk9+kyVfc5tIMRXrsLFUTQbUynKCAE4PlAGGS/f4h2WpF7VfhU2+nrZx/OfSqh J6Zdp/mIcBMz20NDTF/PI7yRmjGOuPLMTEzUXmQLHuipL8gq++GWziXY8kixBVTnEVwP jCcFbCTy5K2awxEyUlPtz1ZviwRrz0NdLgRaB42WDqrhfchUPTnUvdPtIsWBLDiAM4ZV Bw0IL0uMq6CQyH6QG3+IiVTovXa3AQNn5rWO5xhmi+GaOYOuoIJjJ0fVhSGyPp7ITdhc h5ew== X-Gm-Message-State: AOJu0YypHlt/Vslu202Oy/SPRxCNu00USrGffhb3Pz7naiv2joefnT7B BBnQr1fyMJTZnUKt+SQxDRzKixARl3p/XSicf4xcKpgEyxtc4NBRH/OJYP0dbH+QcYaVXdDnknU 9g4Lopdtw3oI85H/10Usb0+3B/PBdi/m5P1y+rTaVy78Y3FJKBUS3jZnyNgk+HfFCi94H X-Received: by 2002:a05:600c:3b0c:b0:405:36d7:4579 with SMTP id m12-20020a05600c3b0c00b0040536d74579mr1789549wms.28.1699351830773; Tue, 07 Nov 2023 02:10:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzZWVZlv7KRbcYmr0khXER3w18YmFC9cbiHf9oXxzUb+V5HyuZsBHdg/mn9/kGht05Unp2gg== X-Received: by 2002:a05:600c:3b0c:b0:405:36d7:4579 with SMTP id m12-20020a05600c3b0c00b0040536d74579mr1789508wms.28.1699351829907; Tue, 07 Nov 2023 02:10:29 -0800 (PST) Date: Tue, 7 Nov 2023 05:10:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Igor Skalkin , Anton Yakovlev , Alex =?utf-8?Q?Benn=C3=A9e?= , Gerd Hoffmann Subject: [PULL 13/63] virtio-sound: handle VIRTIO_SND_R_PCM_SET_PARAMS Message-ID: <64704ce04b0a62184d49f899e7f300f67480a2a6.1699351720.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352212454100002 From: Manos Pitsidianakis Handle the set parameters control request. It reconfigures a stream based on a guest's preference if the values are valid and supported. Based-on: https://github.com/OpenSynergy/qemu/commit/5a2f350eec5d157b90d9c7= b40a8e603f4da92471 Signed-off-by: Igor Skalkin Signed-off-by: Anton Yakovlev Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Message-Id: Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/audio/virtio-snd.c | 34 ++++++++++++++++++++++++++++++++++ hw/audio/trace-events | 1 + 2 files changed, 35 insertions(+) diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index e6791de6c6..084890e52b 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -287,6 +287,38 @@ uint32_t virtio_snd_set_pcm_params(VirtIOSound *s, return cpu_to_le32(VIRTIO_SND_S_OK); } =20 +/* + * Handles the VIRTIO_SND_R_PCM_SET_PARAMS request. + * + * @s: VirtIOSound device + * @cmd: The request command queue element from VirtIOSound cmdq field + */ +static void virtio_snd_handle_pcm_set_params(VirtIOSound *s, + virtio_snd_ctrl_command *cmd) +{ + virtio_snd_pcm_set_params req =3D { 0 }; + uint32_t stream_id; + size_t msg_sz =3D iov_to_buf(cmd->elem->out_sg, + cmd->elem->out_num, + 0, + &req, + sizeof(virtio_snd_pcm_set_params)); + + if (msg_sz !=3D sizeof(virtio_snd_pcm_set_params)) { + /* + * TODO: do we need to set DEVICE_NEEDS_RESET? + */ + qemu_log_mask(LOG_GUEST_ERROR, + "%s: virtio-snd command size incorrect %zu vs \ + %zu\n", __func__, msg_sz, sizeof(virtio_snd_pcm_set_params= )); + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + return; + } + stream_id =3D le32_to_cpu(req.hdr.stream_id); + trace_virtio_snd_handle_pcm_set_params(stream_id); + cmd->resp.code =3D virtio_snd_set_pcm_params(s, stream_id, &req); +} + /* * Get a QEMU Audiosystem compatible format value from a VIRTIO_SND_PCM_FM= T_* */ @@ -534,6 +566,8 @@ process_cmd(VirtIOSound *s, virtio_snd_ctrl_command *cm= d) virtio_snd_handle_pcm_start_stop(s, cmd, false); break; case VIRTIO_SND_R_PCM_SET_PARAMS: + virtio_snd_handle_pcm_set_params(s, cmd); + break; case VIRTIO_SND_R_PCM_PREPARE: case VIRTIO_SND_R_PCM_RELEASE: cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_NOT_SUPP); diff --git a/hw/audio/trace-events b/hw/audio/trace-events index db48ff04fe..3badcab2e8 100644 --- a/hw/audio/trace-events +++ b/hw/audio/trace-events @@ -47,6 +47,7 @@ virtio_snd_vm_state_running(void) "vm state running" virtio_snd_vm_state_stopped(void) "vm state stopped" virtio_snd_realize(void *snd) "snd %p: realize" virtio_snd_unrealize(void *snd) "snd %p: unrealize" +virtio_snd_handle_pcm_set_params(uint32_t stream) "VIRTIO_SND_PCM_SET_PARA= MS called for stream %"PRIu32 virtio_snd_handle_ctrl(void *vdev, void *vq) "snd %p: handle ctrl event fo= r queue %p" virtio_snd_handle_pcm_info(uint32_t stream) "VIRTIO_SND_R_PCM_INFO called = for stream %"PRIu32 virtio_snd_handle_pcm_start_stop(const char *code, uint32_t stream) "%s ca= lled for stream %"PRIu32 --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352199; cv=none; d=zohomail.com; s=zohoarc; b=gP3ZBfuJxKVg4udNqQt8S4K5VU9Ah0RGWy07rLi0jdWY/nOHns57d+ueAnw7lP3diCZiPNGnFgp6SdamDyXYid7mn02gkT6GX7fE+BIR972syalr2tIsSjurXiuLgPseY45tDsGz4nnBV9c49eLNXLhDGuNRbjHRZZfQ2XQstIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352199; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=N2OemcVYSlI5Erb95YCn87opEKILgO1gPwKsg30RdW0=; b=mlbq+3DzEYAJSOULfnC8+bNFuLaRAcd4/Gy9MIU22fpoM/p5urqznAtNpb+kSYlxmvxAnZRZ7hEaW+FAxeioghBFLlZ5PrNrg6j4wkaEPhVBEafPgQd2lfwahffCVfOcWc4LB9QtsEhp8IIkaeCq3RB/g2i+naD7fXr7hweDHJM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352199358534.1130699396167; Tue, 7 Nov 2023 02:16:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J35-0003Dp-Gh; Tue, 07 Nov 2023 05:11:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2g-00020G-0y for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2e-0002T9-4B for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:41 -0500 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-433-Yrt-evhrOEWRlXaNUYsB1g-1; Tue, 07 Nov 2023 05:10:37 -0500 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-5091368e043so6170687e87.2 for ; Tue, 07 Nov 2023 02:10:37 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id b3-20020a5d5503000000b003233b554e6esm1902622wrv.85.2023.11.07.02.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:10:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351838; h=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=N2OemcVYSlI5Erb95YCn87opEKILgO1gPwKsg30RdW0=; b=IL8wQoZYIMcDyPaCBBW5sUpQx4hEUac7dukCnTj7HQrbqS78t1iNeMZuvPRmdKxVMpszgi qH+Uli+uJ1sBcs7t7rUFg4eo2Gc8db1SKVKgzz4CiTCZz7SSobKHt7X0MykTqk/aAXZHjh Liqlm6EmWQkaNN5ETnqP0xNjCC8+tlU= X-MC-Unique: Yrt-evhrOEWRlXaNUYsB1g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351835; x=1699956635; 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=N2OemcVYSlI5Erb95YCn87opEKILgO1gPwKsg30RdW0=; b=JbprlFiR+4loIJIgaZp5EsXmjKFj4Wd6hNJvQ3Po4wozEKCgsyW4AgSXQXwOJfF3/C YavVjVplX0nIO36tBvBb7ZRGX6IY5oT47gXWkqXzDlnQeuPgM+vu5mn4vC6w7r4zl4Nh Gqc/Be2xzYyJLZ7H1Tu9FyCO3OQXhTrjws8OgO/Nbx54y/WAwTc9+t0js8mjjxydjStl mQDnLAuxsiwmlrOOWyt3Gv0WV25BYCNaqMhDoDKWvLr2OpVtAEZq5SdkwnUK7om/m3kQ TKeUicLssGx94xqxHSol77dP6nL4hX8DJ1b1UsiLcN9mk3i2RxQjvOZOT1EEA73rWTJq inzg== X-Gm-Message-State: AOJu0Yx1ogFexSU99rEhXtREi1lbQiaXUYnQKsRHBvYmYehhvxeIAOpj jUadbjFs2rE2+vbS1e0ikFGxiYBEA0sbhmZlzttCsCilmJnwYDn1XXguVdkgWP3vdsVjMkMk1NO /l/XuCTavntuMSizuMYu5k0S4yLeXg5rA9U5233Gm9gh/aly2YLa1pwLIZHlreRqD7Qqy X-Received: by 2002:a19:ca49:0:b0:507:c9d5:39a9 with SMTP id h9-20020a19ca49000000b00507c9d539a9mr22125487lfj.52.1699351835016; Tue, 07 Nov 2023 02:10:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4jLFGfoCiHifo0fv/LeBNTNe3GY+UGilDrY57nOBnP9mwntU/3M5nErHlX6Z9QcK2AwdwnQ== X-Received: by 2002:a19:ca49:0:b0:507:c9d5:39a9 with SMTP id h9-20020a19ca49000000b00507c9d539a9mr22125464lfj.52.1699351834571; Tue, 07 Nov 2023 02:10:34 -0800 (PST) Date: Tue, 7 Nov 2023 05:10:30 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Igor Skalkin , Anton Yakovlev , Alex =?utf-8?Q?Benn=C3=A9e?= , Gerd Hoffmann Subject: [PULL 14/63] virtio-sound: handle VIRTIO_SND_R_PCM_PREPARE Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352200591100001 From: Manos Pitsidianakis Handles the PCM prepare control request. It initializes a PCM stream when the guests asks for it. Based-on: https://github.com/OpenSynergy/qemu/commit/5a2f350eec5d157b90d9c7= b40a8e603f4da92471 Signed-off-by: Igor Skalkin Signed-off-by: Anton Yakovlev Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Message-Id: Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/audio/virtio-snd.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index 084890e52b..31a1942754 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -478,6 +478,28 @@ static const char *print_code(uint32_t code) #undef CASE }; =20 +/* + * Handles VIRTIO_SND_R_PCM_PREPARE. + * + * @s: VirtIOSound device + * @cmd: The request command queue element from VirtIOSound cmdq field + */ +static void virtio_snd_handle_pcm_prepare(VirtIOSound *s, + virtio_snd_ctrl_command *cmd) +{ + uint32_t stream_id; + size_t msg_sz =3D iov_to_buf(cmd->elem->out_sg, + cmd->elem->out_num, + sizeof(virtio_snd_hdr), + &stream_id, + sizeof(stream_id)); + + stream_id =3D le32_to_cpu(stream_id); + cmd->resp.code =3D msg_sz =3D=3D sizeof(stream_id) + ? virtio_snd_pcm_prepare(s, stream_id) + : cpu_to_le32(VIRTIO_SND_S_BAD_MSG); +} + /* * Handles VIRTIO_SND_R_PCM_START. * @@ -569,6 +591,8 @@ process_cmd(VirtIOSound *s, virtio_snd_ctrl_command *cm= d) virtio_snd_handle_pcm_set_params(s, cmd); break; case VIRTIO_SND_R_PCM_PREPARE: + virtio_snd_handle_pcm_prepare(s, cmd); + break; case VIRTIO_SND_R_PCM_RELEASE: cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_NOT_SUPP); break; --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351942; cv=none; d=zohomail.com; s=zohoarc; b=BIR3BQvNbPi8wGp5zsG5peGB7WEIkFRSlAzqyidCmB5RgQot6P0R3t7y07WTTu100FCZRhc8j4wwhanTIe7NuSw/pOQ8rNTuJkGyYMzDesnU8Vc1rvh7c+BEH6O4cMOvw1FXXmWLUjm93/nYr1ylAMqRkMFQ43ouIcUQZhOt6Gs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351942; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gnuv7Z17pTs9Ku5fIWHLu61w17iNT9D7kiH/z0kMDjY=; b=ZTj7+oQDT9gwZeWh0eoLd5Z0TZM9NB0uhfNqe2Q7T/MTaU27wAEO2vkUwu0MQ3cH2Sla7X3uMSrJYG5s4wTbt9zyxe0G/LoiK4lK3JIcnNwxdW3hGA2gonVZZEizsvgSIq4m3bOaig1nITgfOprvKIXogZYG69++VD1I6qUi06U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699351942082202.67685126022013; Tue, 7 Nov 2023 02:12:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J34-00037Z-6B; Tue, 07 Nov 2023 05:11:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2t-0002UN-MU for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2r-0002Ts-32 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:55 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-511-PmJSd1aoPxKuiRwWNSb-VA-1; Tue, 07 Nov 2023 05:10:41 -0500 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4090181eec2so35022705e9.1 for ; Tue, 07 Nov 2023 02:10:40 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id t14-20020a05600c198e00b00405d9a950a2sm15315278wmq.28.2023.11.07.02.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:10:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351852; h=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=gnuv7Z17pTs9Ku5fIWHLu61w17iNT9D7kiH/z0kMDjY=; b=c+RW535PPygmFVHvBiPZQ2/CxfNVJDLkmGSlcDLLv/o9CFqg6t1K+jiDd0cxXanLq9MQEi yAGafK/XgWBLt3lu4GcITJg5KX7/SuN8RXRkCMQ3R02JBAXn9nywfmtHxFDrjMtQa4dd6T KoivyxHzcffWcken3BENyc/XYu1zNXQ= X-MC-Unique: PmJSd1aoPxKuiRwWNSb-VA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351839; x=1699956639; 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=gnuv7Z17pTs9Ku5fIWHLu61w17iNT9D7kiH/z0kMDjY=; b=gcfaj6Nkgvpg5b1EwN/MFeLRtGg/90jTVZzlJBvn2CF1KVOZ+MoNFSBW+JZZUtFo47 J1+mH1H3kdXRd2is0f/8+Nsv07zzjWhDda15vyPq2JkjS2CkyKxiN23d1kNymqok0byX 8om9FWa/WibINvpJGnAp8ddX46CitiYn4t3+laGdrBUDZGWwh1w5jzMpazPY87FJVrY9 QqTbbpzG8ncuL4rhl4xexR4Z8ysrZMiUAGmPoO8hYwOOIGgN1u2u/6ckdxs4/McqcGD2 hPZi2jfHm56RySXWMjZixbYhhQlO/vAwT4XF7sheKF5hE8cLUZyqbno8L5LhZTBCQwQc z8bw== X-Gm-Message-State: AOJu0YwQ2kdZW3XpLVPQfItr1QmWrMxYs4vlb2ufryCDNiimnYGNU7Mb lnodyuUzebsa9bRRl9jAHFTlHb/fBcf3qBHelX14xBBqWKdc+LrTQu93MNoXSWJlVhdC/QR/MJf 3AqZuAryBQFPDgF216xOqxDsMqQXzKGWu028DcziyzIgRx6+Giza5cQgs9JdZGdWlrcId X-Received: by 2002:a05:600c:a02:b0:408:3bbd:4a82 with SMTP id z2-20020a05600c0a0200b004083bbd4a82mr1950203wmp.15.1699351839621; Tue, 07 Nov 2023 02:10:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1RWMxg7k40Tp03Cg6votMuDi1EU+mybc/J+Rq3fygeV0/nSbACRPZZpRhStwecLL3sUdyBQ== X-Received: by 2002:a05:600c:a02:b0:408:3bbd:4a82 with SMTP id z2-20020a05600c0a0200b004083bbd4a82mr1950185wmp.15.1699351839312; Tue, 07 Nov 2023 02:10:39 -0800 (PST) Date: Tue, 7 Nov 2023 05:10:35 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Igor Skalkin , Anton Yakovlev , Alex =?utf-8?Q?Benn=C3=A9e?= , Gerd Hoffmann Subject: [PULL 15/63] virtio-sound: handle VIRTIO_SND_R_PCM_RELEASE Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351943407100002 From: Manos Pitsidianakis Handle the PCM release control request, which is necessary for flushing pending sound IO. No IO is handled yet so currently it only replies to the request. Based-on: https://github.com/OpenSynergy/qemu/commit/5a2f350eec5d157b90d9c7= b40a8e603f4da92471 Signed-off-by: Igor Skalkin Signed-off-by: Anton Yakovlev Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Message-Id: Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/audio/virtio-snd.c | 48 ++++++++++++++++++++++++++++++++++++++++++- hw/audio/trace-events | 1 + 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index 31a1942754..9cff724f62 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -541,6 +541,52 @@ static void virtio_snd_handle_pcm_start_stop(VirtIOSou= nd *s, stream->active =3D start; } =20 +/* + * Handles VIRTIO_SND_R_PCM_RELEASE. Releases the buffer resources allocat= ed to + * a stream. + * + * @s: VirtIOSound device + * @cmd: The request command queue element from VirtIOSound cmdq field + */ +static void virtio_snd_handle_pcm_release(VirtIOSound *s, + virtio_snd_ctrl_command *cmd) +{ + uint32_t stream_id; + VirtIOSoundPCMStream *stream; + size_t msg_sz =3D iov_to_buf(cmd->elem->out_sg, + cmd->elem->out_num, + sizeof(virtio_snd_hdr), + &stream_id, + sizeof(stream_id)); + + if (msg_sz !=3D sizeof(stream_id)) { + /* + * TODO: do we need to set DEVICE_NEEDS_RESET? + */ + qemu_log_mask(LOG_GUEST_ERROR, + "%s: virtio-snd command size incorrect %zu vs \ + %zu\n", __func__, msg_sz, sizeof(stream_id)); + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + return; + } + + stream_id =3D le32_to_cpu(stream_id); + trace_virtio_snd_handle_pcm_release(stream_id); + stream =3D virtio_snd_pcm_get_stream(s, stream_id); + if (stream =3D=3D NULL) { + /* + * TODO: do we need to set DEVICE_NEEDS_RESET? + */ + error_report("already released stream %"PRIu32, stream_id); + virtio_error(VIRTIO_DEVICE(s), + "already released stream %"PRIu32, + stream_id); + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + return; + } + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_OK); +} + /* * The actual processing done in virtio_snd_process_cmdq(). * @@ -594,7 +640,7 @@ process_cmd(VirtIOSound *s, virtio_snd_ctrl_command *cm= d) virtio_snd_handle_pcm_prepare(s, cmd); break; case VIRTIO_SND_R_PCM_RELEASE: - cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_NOT_SUPP); + virtio_snd_handle_pcm_release(s, cmd); break; case VIRTIO_SND_R_CHMAP_INFO: qemu_log_mask(LOG_UNIMP, diff --git a/hw/audio/trace-events b/hw/audio/trace-events index 3badcab2e8..33e24d0011 100644 --- a/hw/audio/trace-events +++ b/hw/audio/trace-events @@ -51,6 +51,7 @@ virtio_snd_handle_pcm_set_params(uint32_t stream) "VIRTIO= _SND_PCM_SET_PARAMS cal virtio_snd_handle_ctrl(void *vdev, void *vq) "snd %p: handle ctrl event fo= r queue %p" virtio_snd_handle_pcm_info(uint32_t stream) "VIRTIO_SND_R_PCM_INFO called = for stream %"PRIu32 virtio_snd_handle_pcm_start_stop(const char *code, uint32_t stream) "%s ca= lled for stream %"PRIu32 +virtio_snd_handle_pcm_release(uint32_t stream) "VIRTIO_SND_PCM_RELEASE cal= led for stream %"PRIu32 virtio_snd_handle_code(uint32_t val, const char *code) "ctrl code msg val = =3D %"PRIu32" =3D=3D %s" virtio_snd_handle_chmap_info(void) "VIRTIO_SND_CHMAP_INFO called" virtio_snd_handle_event(void) "event queue callback called" --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352213; cv=none; d=zohomail.com; s=zohoarc; b=T9y3i1Oif7NZ5iIpRf8ydYNHTdlepLRLZHPAF/nqeqTAENFf8eoWnNOMGvo7sKjAKX1ozePDZi1Cbr58jRnzaqkfFfh/UO67zoVR7e9YYW7IC3rG3lh1PLwOKl1ebUKm+PoxAknu8qPC4B/IYBI3TNsrt5p8cwMdih189XKyYGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352213; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Vt80n1+Opr+IW9tphohbn1/TaDU5wnsYwOizNcxhtsw=; b=dg0ZErKPepnAzN76lMsG4N3OB9mhAu9I8wHl0TIj5z9r3bWWRXPR97e1rmICF/3jpvnW2j2uu6k74HTH6w0TJ8GveGXVToSksuDOtZ90d7W69ImR8BCJERdpiMDcEYt4KLi8ohwB5JIhnWR5E+qVzP8Kg3PE2AvLlIN9ZQaPrw0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169935221333220.902822859147363; Tue, 7 Nov 2023 02:16:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J36-0003SF-DZ; Tue, 07 Nov 2023 05:11:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2x-0002hs-0I for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2u-0002UE-9C for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:58 -0500 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-83-gg7Nqm3YOwy8q6iqraW0PA-1; Tue, 07 Nov 2023 05:10:47 -0500 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-5079fe7cc7cso6344798e87.2 for ; Tue, 07 Nov 2023 02:10:46 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id k4-20020a5d6d44000000b0032dc1fc84f2sm1926292wri.46.2023.11.07.02.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:10:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351855; h=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=Vt80n1+Opr+IW9tphohbn1/TaDU5wnsYwOizNcxhtsw=; b=M/nPoV3jvchp65aTmvDIc97sjQNgEos8tCKLXZmIv02niTh694Lk5Y39rMSFCEcLfivBZo aakXMrt9KdakhLQfI5lbgYIBe2f9XIXE7+d8FcHJ/Bk29UDCKIChInAqz84Mh0j9OHQQcF xYMzh06MvbCkAGrTlOXsp1nGWDYGNk0= X-MC-Unique: gg7Nqm3YOwy8q6iqraW0PA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351845; x=1699956645; 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=Vt80n1+Opr+IW9tphohbn1/TaDU5wnsYwOizNcxhtsw=; b=qkCgBdMbWqfBgOqbApptIXl450EZnvF1rc3lKbnwtdy+E4CleOjxFV7kQ+Qk4ZnQ3I pgQsbqEDpLHrpsQ0dJpjpl04IuwQru9V/dmj4k9iGeimvZ7VzzOKFRKi1uRP6OjgUwP4 U6DPfUNaZ+a+eJ+Qo4n5UVZNAm/o5kkiRFTodu54hJ9lBfihqfrbyEmajEA6vTvpKDSZ uq3yH6bmKLGsIUIqweuoOHzEJu8WFo3InYZP7mgTytSaIT7LWfIhIi25kEG2pfAHRLYq C5gDsvvGwCdtnLlfbn1ahi67j74jItiLyL1SOlLPac1/c6ALu4goGoRxuDKzi0ZXuwaw XppA== X-Gm-Message-State: AOJu0YwIeaMkepTXG0bLbPN13r7fgccpuQ7jN4XI8GLnA/pN8YCIEBh3 FHmNyxodzPOCNCQomYraFLTWmsKFfu1ZYOup+t9ZPsyWP8EG4qlXZ4tAG2eW99ESJFi8F7ko11Z cRMUqQ5C6rZslICqamGwO7fAx1bnQ+wku8m3ISPTi2Bi5zoqkxBTLmg8UgK4vTOqBdu/0 X-Received: by 2002:a19:4344:0:b0:507:a0d6:f178 with SMTP id m4-20020a194344000000b00507a0d6f178mr22631266lfj.35.1699351844748; Tue, 07 Nov 2023 02:10:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHK3SBCie4N83C8eBbjfv+X5tSGk50EdtT5Dpngl5/byk4spmZQwTlFkvkIga9GHr27fVoanw== X-Received: by 2002:a19:4344:0:b0:507:a0d6:f178 with SMTP id m4-20020a194344000000b00507a0d6f178mr22631243lfj.35.1699351844343; Tue, 07 Nov 2023 02:10:44 -0800 (PST) Date: Tue, 7 Nov 2023 05:10:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Igor Skalkin , Anton Yakovlev , Alex =?utf-8?Q?Benn=C3=A9e?= , Gerd Hoffmann Subject: [PULL 16/63] virtio-sound: implement audio output (TX) Message-ID: <18a752810f04e3f1933682addd0a6c978efc5cdf.1699351720.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352214491100017 From: Manos Pitsidianakis Handle output IO messages in the transmit (TX) virtqueue. It allocates a VirtIOSoundPCMBuffer for each IO message and copies the data buffer to it. When the IO buffer is written to the host's sound card, the guest will be notified that it has been consumed. The lifetime of an IO message is: 1. Guest sends IO message to TX virtqueue. 2. QEMU adds it to the appropriate stream's IO buffer queue. 3. Sometime later, the host audio backend calls the output callback, virtio_snd_pcm_out_cb(), which is defined with an AUD_open_out() call. The callback gets an available number of bytes the backend can receive. Then it writes data from the IO buffer queue to the backend. If at any time a buffer is exhausted, it is returned to the guest as completed. 4. If the guest releases the stream, its buffer queue is flushed by attempting to write any leftover data to the audio backend and releasing all IO messages back to the guest. This is how according to the spec the guest knows the release was successful. Based-on: https://github.com/OpenSynergy/qemu/commit/5a2f350eec5d157b90d9c7= b40a8e603f4da92471 Signed-off-by: Igor Skalkin Signed-off-by: Anton Yakovlev Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Message-Id: Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/audio/virtio-snd.h | 47 ++++++ hw/audio/virtio-snd.c | 288 +++++++++++++++++++++++++++++++++- hw/audio/trace-events | 2 + 3 files changed, 332 insertions(+), 5 deletions(-) diff --git a/include/hw/audio/virtio-snd.h b/include/hw/audio/virtio-snd.h index cc14c875ed..c3767f442b 100644 --- a/include/hw/audio/virtio-snd.h +++ b/include/hw/audio/virtio-snd.h @@ -77,6 +77,50 @@ typedef struct virtio_snd_ctrl_command virtio_snd_ctrl_c= ommand; =20 typedef struct VirtIOSoundPCM VirtIOSoundPCM; =20 +typedef struct VirtIOSoundPCMBuffer VirtIOSoundPCMBuffer; + +/* + * The VirtIO sound spec reuses layouts and values from the High Definition + * Audio spec (virtio/v1.2: 5.14 Sound Device). This struct handles each I= /O + * message's buffer (virtio/v1.2: 5.14.6.8 PCM I/O Messages). + * + * In the case of TX (i.e. playback) buffers, we defer reading the raw PCM= data + * from the virtqueue until QEMU's sound backsystem calls the output callb= ack. + * This is tracked by the `bool populated;` field, which is set to true wh= en + * data has been read into our own buffer for consumption. + * + * VirtIOSoundPCMBuffer has a dynamic size since it includes the raw PCM d= ata + * in its allocation. It must be initialized and destroyed as follows: + * + * size_t size =3D [[derived from owned VQ element descriptor sizes]]; + * buffer =3D g_malloc0(sizeof(VirtIOSoundPCMBuffer) + size); + * buffer->elem =3D [[owned VQ element]]; + * + * [..] + * + * g_free(buffer->elem); + * g_free(buffer); + */ +struct VirtIOSoundPCMBuffer { + QSIMPLEQ_ENTRY(VirtIOSoundPCMBuffer) entry; + VirtQueueElement *elem; + VirtQueue *vq; + size_t size; + /* + * In TX / Plaback, `offset` represents the first unused position insi= de + * `data`. If `offset =3D=3D size` then there are no unused data left. + */ + uint64_t offset; + /* Used for the TX queue for lazy I/O copy from `elem` */ + bool populated; + /* + * VirtIOSoundPCMBuffer is an unsized type because it ends with an arr= ay of + * bytes. The size of `data` is determined from the I/O message's read= -only + * or write-only size when allocating VirtIOSoundPCMBuffer. + */ + uint8_t data[]; +}; + struct VirtIOSoundPCM { VirtIOSound *snd; /* @@ -104,7 +148,10 @@ struct VirtIOSoundPCMStream { SWVoiceIn *in; SWVoiceOut *out; } voice; + QemuMutex queue_mutex; bool active; + QSIMPLEQ_HEAD(, VirtIOSoundPCMBuffer) queue; + QSIMPLEQ_HEAD(, VirtIOSoundPCMBuffer) invalid; }; =20 /* diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index 9cff724f62..6c91d0a740 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -32,6 +32,10 @@ #define VIRTIO_SOUND_CHMAP_DEFAULT 0 #define VIRTIO_SOUND_HDA_FN_NID 0 =20 +static void virtio_snd_pcm_out_cb(void *data, int available); +static void virtio_snd_process_cmdq(VirtIOSound *s); +static void virtio_snd_pcm_flush(VirtIOSoundPCMStream *stream); + static uint32_t supported_formats =3D BIT(VIRTIO_SND_PCM_FMT_S8) | BIT(VIRTIO_SND_PCM_FMT_U8) | BIT(VIRTIO_SND_PCM_FMT_S16) @@ -123,6 +127,13 @@ virtio_snd_set_config(VirtIODevice *vdev, const uint8_= t *config) =20 } =20 +static void +virtio_snd_pcm_buffer_free(VirtIOSoundPCMBuffer *buffer) +{ + g_free(buffer->elem); + g_free(buffer); +} + static void virtio_snd_ctrl_cmd_free(virtio_snd_ctrl_command *cmd) { @@ -396,6 +407,13 @@ static void virtio_snd_get_qemu_audsettings(audsetting= s *as, */ static void virtio_snd_pcm_close(VirtIOSoundPCMStream *stream) { + if (stream) { + if (stream->info.direction =3D=3D VIRTIO_SND_D_OUTPUT) { + virtio_snd_pcm_flush(stream); + AUD_close_out(&stream->pcm->snd->card, stream->voice.out); + stream->voice.out =3D NULL; + } + } } =20 /* @@ -429,6 +447,9 @@ static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s, = uint32_t stream_id) stream->id =3D stream_id; stream->pcm =3D s->pcm; stream->s =3D s; + qemu_mutex_init(&stream->queue_mutex); + QSIMPLEQ_INIT(&stream->queue); + QSIMPLEQ_INIT(&stream->invalid); =20 /* * stream_id >=3D s->snd_conf.streams was checked before so this is @@ -452,6 +473,18 @@ static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s,= uint32_t stream_id) stream->positions[1] =3D VIRTIO_SND_CHMAP_FR; stream->as =3D as; =20 + if (stream->info.direction =3D=3D VIRTIO_SND_D_OUTPUT) { + stream->voice.out =3D AUD_open_out(&s->card, + stream->voice.out, + "virtio-sound.out", + stream, + virtio_snd_pcm_out_cb, + &as); + AUD_set_volume_out(stream->voice.out, 0, 255, 255); + } else { + qemu_log_mask(LOG_UNIMP, "virtio_snd: input/capture is unimplement= ed."); + } + return cpu_to_le32(VIRTIO_SND_S_OK); } =20 @@ -532,9 +565,17 @@ static void virtio_snd_handle_pcm_start_stop(VirtIOSou= nd *s, cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_OK); trace_virtio_snd_handle_pcm_start_stop(start ? "VIRTIO_SND_R_PCM_START= " : "VIRTIO_SND_R_PCM_STOP", stream_id); + stream =3D virtio_snd_pcm_get_stream(s, stream_id); - if (stream =3D=3D NULL) { - error_report("Invalid stream id: %"PRIu32, req.stream_id); + if (stream) { + WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { + stream->active =3D start; + } + if (stream->info.direction =3D=3D VIRTIO_SND_D_OUTPUT) { + AUD_set_active_out(stream->voice.out, start); + } + } else { + error_report("Invalid stream id: %"PRIu32, stream_id); cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); return; } @@ -542,8 +583,28 @@ static void virtio_snd_handle_pcm_start_stop(VirtIOSou= nd *s, } =20 /* - * Handles VIRTIO_SND_R_PCM_RELEASE. Releases the buffer resources allocat= ed to - * a stream. + * Returns the number of I/O messages that are being processed. + * + * @stream: VirtIOSoundPCMStream + */ +static size_t virtio_snd_pcm_get_io_msgs_count(VirtIOSoundPCMStream *strea= m) +{ + VirtIOSoundPCMBuffer *buffer, *next; + size_t count =3D 0; + + WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { + QSIMPLEQ_FOREACH_SAFE(buffer, &stream->queue, entry, next) { + count +=3D 1; + } + QSIMPLEQ_FOREACH_SAFE(buffer, &stream->invalid, entry, next) { + count +=3D 1; + } + } + return count; +} + +/* + * Handles VIRTIO_SND_R_PCM_RELEASE. * * @s: VirtIOSound device * @cmd: The request command queue element from VirtIOSound cmdq field @@ -584,6 +645,21 @@ static void virtio_snd_handle_pcm_release(VirtIOSound = *s, cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); return; } + + if (virtio_snd_pcm_get_io_msgs_count(stream)) { + /* + * virtio-v1.2-csd01, 5.14.6.6.5.1, + * Device Requirements: Stream Release + * + * - The device MUST complete all pending I/O messages for the + * specified stream ID. + * - The device MUST NOT complete the control request while there + * are pending I/O messages for the specified stream ID. + */ + trace_virtio_snd_pcm_stream_flush(stream_id); + virtio_snd_pcm_flush(stream); + } + cmd->resp.code =3D cpu_to_le32(VIRTIO_SND_S_OK); } =20 @@ -738,6 +814,108 @@ static void virtio_snd_handle_event(VirtIODevice *vde= v, VirtQueue *vq) trace_virtio_snd_handle_event(); } =20 +/* + * The tx virtqueue handler. Makes the buffers available to their respecti= ve + * streams for consumption. + * + * @vdev: VirtIOSound device + * @vq: tx virtqueue + */ +static void virtio_snd_handle_tx(VirtIODevice *vdev, VirtQueue *vq) +{ + VirtIOSound *s =3D VIRTIO_SND(vdev); + VirtIOSoundPCMStream *stream =3D NULL; + VirtIOSoundPCMBuffer *buffer; + VirtQueueElement *elem; + size_t msg_sz, size; + virtio_snd_pcm_xfer hdr; + virtio_snd_pcm_status resp =3D { 0 }; + uint32_t stream_id; + /* + * If any of the I/O messages are invalid, put them in stream->invalid= and + * return them after the for loop. + */ + bool must_empty_invalid_queue =3D false; + + if (!virtio_queue_ready(vq)) { + return; + } + trace_virtio_snd_handle_xfer(); + + for (;;) { + elem =3D virtqueue_pop(vq, sizeof(VirtQueueElement)); + if (!elem) { + break; + } + /* get the message hdr object */ + msg_sz =3D iov_to_buf(elem->out_sg, + elem->out_num, + 0, + &hdr, + sizeof(virtio_snd_pcm_xfer)); + if (msg_sz !=3D sizeof(virtio_snd_pcm_xfer)) { + goto tx_err; + } + stream_id =3D le32_to_cpu(hdr.stream_id); + + if (stream_id >=3D s->snd_conf.streams + || s->pcm->streams[stream_id] =3D=3D NULL) { + goto tx_err; + } + + stream =3D s->pcm->streams[stream_id]; + if (stream->info.direction !=3D VIRTIO_SND_D_OUTPUT) { + goto tx_err; + } + + WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { + size =3D iov_size(elem->out_sg, elem->out_num) - msg_sz; + + buffer =3D g_malloc0(sizeof(VirtIOSoundPCMBuffer) + size); + buffer->elem =3D elem; + buffer->populated =3D false; + buffer->vq =3D vq; + buffer->size =3D size; + buffer->offset =3D 0; + + QSIMPLEQ_INSERT_TAIL(&stream->queue, buffer, entry); + } + continue; + +tx_err: + WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { + must_empty_invalid_queue =3D true; + buffer =3D g_malloc0(sizeof(VirtIOSoundPCMBuffer)); + buffer->elem =3D elem; + buffer->vq =3D vq; + QSIMPLEQ_INSERT_TAIL(&stream->invalid, buffer, entry); + } + } + + if (must_empty_invalid_queue) { + WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { + while (!QSIMPLEQ_EMPTY(&stream->invalid)) { + buffer =3D QSIMPLEQ_FIRST(&stream->invalid); + + resp.status =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + iov_from_buf(buffer->elem->in_sg, + buffer->elem->in_num, + 0, + &resp, + sizeof(virtio_snd_pcm_status)); + virtqueue_push(vq, buffer->elem, sizeof(virtio_snd_pcm_sta= tus)); + QSIMPLEQ_REMOVE_HEAD(&stream->invalid, entry); + virtio_snd_pcm_buffer_free(buffer); + } + /* + * Notify vq about virtio_snd_pcm_status responses. + * Buffer responses must be notified separately later. + */ + virtio_notify(vdev, vq); + } + } +} + /* * Stub buffer virtqueue handler. * @@ -832,7 +1010,7 @@ static void virtio_snd_realize(DeviceState *dev, Error= **errp) vsnd->queues[VIRTIO_SND_VQ_EVENT] =3D virtio_add_queue(vdev, 64, virtio_snd_handle_event); vsnd->queues[VIRTIO_SND_VQ_TX] =3D - virtio_add_queue(vdev, 64, virtio_snd_handle_xfer); + virtio_add_queue(vdev, 64, virtio_snd_handle_tx); vsnd->queues[VIRTIO_SND_VQ_RX] =3D virtio_add_queue(vdev, 64, virtio_snd_handle_xfer); qemu_mutex_init(&vsnd->cmdq_mutex); @@ -856,6 +1034,105 @@ static void virtio_snd_realize(DeviceState *dev, Err= or **errp) } } =20 +static inline void return_tx_buffer(VirtIOSoundPCMStream *stream, + VirtIOSoundPCMBuffer *buffer) +{ + virtio_snd_pcm_status resp =3D { 0 }; + resp.status =3D cpu_to_le32(VIRTIO_SND_S_OK); + resp.latency_bytes =3D cpu_to_le32((uint32_t)buffer->size); + iov_from_buf(buffer->elem->in_sg, + buffer->elem->in_num, + 0, + &resp, + sizeof(virtio_snd_pcm_status)); + virtqueue_push(buffer->vq, + buffer->elem, + sizeof(virtio_snd_pcm_status)); + virtio_notify(VIRTIO_DEVICE(stream->s), buffer->vq); + QSIMPLEQ_REMOVE(&stream->queue, + buffer, + VirtIOSoundPCMBuffer, + entry); + virtio_snd_pcm_buffer_free(buffer); +} + +/* + * AUD_* output callback. + * + * @data: VirtIOSoundPCMStream stream + * @available: number of bytes that can be written with AUD_write() + */ +static void virtio_snd_pcm_out_cb(void *data, int available) +{ + VirtIOSoundPCMStream *stream =3D data; + VirtIOSoundPCMBuffer *buffer; + size_t size; + + WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { + while (!QSIMPLEQ_EMPTY(&stream->queue)) { + buffer =3D QSIMPLEQ_FIRST(&stream->queue); + if (!virtio_queue_ready(buffer->vq)) { + return; + } + if (!stream->active) { + /* Stream has stopped, so do not perform AUD_write. */ + return_tx_buffer(stream, buffer); + continue; + } + if (!buffer->populated) { + iov_to_buf(buffer->elem->out_sg, + buffer->elem->out_num, + sizeof(virtio_snd_pcm_xfer), + buffer->data, + buffer->size); + buffer->populated =3D true; + } + for (;;) { + size =3D AUD_write(stream->voice.out, + buffer->data + buffer->offset, + MIN(buffer->size, available)); + assert(size <=3D MIN(buffer->size, available)); + if (size =3D=3D 0) { + /* break out of both loops */ + available =3D 0; + break; + } + buffer->size -=3D size; + buffer->offset +=3D size; + available -=3D size; + if (buffer->size < 1) { + return_tx_buffer(stream, buffer); + break; + } + if (!available) { + break; + } + } + if (!available) { + break; + } + } + } +} + +/* + * Flush all buffer data from this stream's queue into the driver's virtual + * queue. + * + * @stream: VirtIOSoundPCMStream *stream + */ +static inline void virtio_snd_pcm_flush(VirtIOSoundPCMStream *stream) +{ + VirtIOSoundPCMBuffer *buffer; + + WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { + while (!QSIMPLEQ_EMPTY(&stream->queue)) { + buffer =3D QSIMPLEQ_FIRST(&stream->queue); + return_tx_buffer(stream, buffer); + } + } +} + static void virtio_snd_unrealize(DeviceState *dev) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -872,6 +1149,7 @@ static void virtio_snd_unrealize(DeviceState *dev) if (stream) { virtio_snd_process_cmdq(stream->s); virtio_snd_pcm_close(stream); + qemu_mutex_destroy(&stream->queue_mutex); g_free(stream); } } diff --git a/hw/audio/trace-events b/hw/audio/trace-events index 33e24d0011..884108129b 100644 --- a/hw/audio/trace-events +++ b/hw/audio/trace-events @@ -55,3 +55,5 @@ virtio_snd_handle_pcm_release(uint32_t stream) "VIRTIO_SN= D_PCM_RELEASE called fo virtio_snd_handle_code(uint32_t val, const char *code) "ctrl code msg val = =3D %"PRIu32" =3D=3D %s" virtio_snd_handle_chmap_info(void) "VIRTIO_SND_CHMAP_INFO called" virtio_snd_handle_event(void) "event queue callback called" +virtio_snd_pcm_stream_flush(uint32_t stream) "flushing stream %"PRIu32 +virtio_snd_handle_xfer(void) "tx/rx queue callback called" --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352306; cv=none; d=zohomail.com; s=zohoarc; b=l2PC5WSpsTsz4Vv/FK5F/2lUeehg/aLqcVPnELFIHzvFQaaGMRXuysXu4UJbFaTCw8ruQWPe6Y1eIjKk53NsnIa1GpF1ijhZaG2yC2ezDU4bzzpY/NczU1bl1g0MFGngTa0pRKRoOKYofwFiPJ8yIbiOGsl5kN5MDAsVRMnefm0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352306; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=x7k04BtIMbJcMeHwiSPKgGrolXanjKZR9xU+A1o+1Wc=; b=AueRHguKm3m/DchZWSxebS9gW1Ikn6iMI6zWuslbwumIB9LXLwpYV5oqFgyJKCdFIUtgVrQSZO+B/Sl4z7Gk105s5fyzvkn9WiPoIOar+hfRE066n9cmYNOjiCjh/Rn1atAGyxix790PiVLAjPV8bHHNo/UxiQIb5kOjUTkppsI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352306550640.6377212264913; Tue, 7 Nov 2023 02:18:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J36-0003SO-De; Tue, 07 Nov 2023 05:11:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2u-0002Zj-SE for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2q-0002Tp-MU for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:56 -0500 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-404-Rc9jXf0iPhaW1aFZOEOV7w-1; Tue, 07 Nov 2023 05:10:50 -0500 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9d25d0788b8so375472266b.1 for ; Tue, 07 Nov 2023 02:10:50 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id h22-20020a05600c351600b004094c5d929asm15082065wmq.10.2023.11.07.02.10.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:10:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351852; h=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=x7k04BtIMbJcMeHwiSPKgGrolXanjKZR9xU+A1o+1Wc=; b=aIxQVVWnWCcbN+IvKTrPsrIYpHekwVg7JFHuBaRgXRgZspF1vczyGLJKCLqIpi5dtmS9pW NbNc/s1bm/T0AzrWplE7FFDOl5Wuxxd+S9plqbtcYsP/sOEQ28aidFvCNcQp0X451Qv2jK GuTgdZ0ZLqbFLqFbTgHKLzHcDRfy7So= X-MC-Unique: Rc9jXf0iPhaW1aFZOEOV7w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351849; x=1699956649; 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=x7k04BtIMbJcMeHwiSPKgGrolXanjKZR9xU+A1o+1Wc=; b=PB0H2pp1hDrJGWCUc1lPDlXWltbStOEIEYZTIq22GFob6krAlbMrkTa9zGtd5RC78F ixKt14liPh7s/aXPhGDPYPAAofNO/hZ4wu9l+BiGvzo96+aUGMqk+mjfvVp6C8LNSY3W OWv1ZVnvd0dt1DxxLd5/UeBH2ngqXhbVU3E6QkDBAVlxQlfXcD2oDhQsbNuX79W5BwwT 7zEW/8c51Y6KafVOQ54JdN7zX/FCVaqsaeN5oFOnt60btvCtOYtjFxaIJGN93B0FsNp6 y2jwlbFIIO4syGIPWymburDThnvRZJpNDifSWn4iP4h0MXZ/zgoMrV0VlBADt732czR6 6gwQ== X-Gm-Message-State: AOJu0YwuQhXMBFzk71zjZ2npZrRaelqk6Vhfk8Pu6k2QrNacI+4kNtj5 MMmj/aH1LfpXSchZrlwbIfo8+UYIyVRi7eSXsEXtiUFFKYWZ9hJk+7Ul3/0FjsY3hg7deOjhVAA vBGUV1+56CqGVs5ayEL6geJPsy+yJsAXjUTCBKoQ++EDmVXPJPBWIUu3Sgd8TETR8UgeM X-Received: by 2002:a17:906:c7d8:b0:9da:f85a:233f with SMTP id dc24-20020a170906c7d800b009daf85a233fmr10951956ejb.28.1699351849107; Tue, 07 Nov 2023 02:10:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFraU5mPUAEBw0M1zbMP5GtrTI+OPHh6L/aDH1tkNT0Ml2efn66JzrE9c2yQ1Aczjm0Z/0PSA== X-Received: by 2002:a17:906:c7d8:b0:9da:f85a:233f with SMTP id dc24-20020a170906c7d800b009daf85a233fmr10951931ejb.28.1699351848661; Tue, 07 Nov 2023 02:10:48 -0800 (PST) Date: Tue, 7 Nov 2023 05:10:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Alex =?utf-8?Q?Benn=C3=A9e?= , Gerd Hoffmann Subject: [PULL 17/63] virtio-sound: implement audio capture (RX) Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352308538100007 From: Manos Pitsidianakis To perform audio capture we duplicate the TX logic of the previous commit with the following difference: we receive data from the QEMU audio backend and write it in the virt queue IO buffers the guest sends to QEMU. When they are full (i.e. they have `period_bytes` amount of data) or when recording stops in QEMU's audio backend, the buffer is returned to the guest by notifying it. Signed-off-by: Manos Pitsidianakis Tested-by: Alex Benn=C3=A9e Reviewed-by: Alex Benn=C3=A9e Message-Id: Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/audio/virtio-snd.c | 262 ++++++++++++++++++++++++++++++++++++------ hw/audio/trace-events | 3 +- 2 files changed, 230 insertions(+), 35 deletions(-) diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index 6c91d0a740..a18a9949a7 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -28,13 +28,14 @@ =20 #define VIRTIO_SOUND_VM_VERSION 1 #define VIRTIO_SOUND_JACK_DEFAULT 0 -#define VIRTIO_SOUND_STREAM_DEFAULT 1 +#define VIRTIO_SOUND_STREAM_DEFAULT 2 #define VIRTIO_SOUND_CHMAP_DEFAULT 0 #define VIRTIO_SOUND_HDA_FN_NID 0 =20 static void virtio_snd_pcm_out_cb(void *data, int available); static void virtio_snd_process_cmdq(VirtIOSound *s); static void virtio_snd_pcm_flush(VirtIOSoundPCMStream *stream); +static void virtio_snd_pcm_in_cb(void *data, int available); =20 static uint32_t supported_formats =3D BIT(VIRTIO_SND_PCM_FMT_S8) | BIT(VIRTIO_SND_PCM_FMT_U8) @@ -408,10 +409,13 @@ static void virtio_snd_get_qemu_audsettings(audsettin= gs *as, static void virtio_snd_pcm_close(VirtIOSoundPCMStream *stream) { if (stream) { + virtio_snd_pcm_flush(stream); if (stream->info.direction =3D=3D VIRTIO_SND_D_OUTPUT) { - virtio_snd_pcm_flush(stream); AUD_close_out(&stream->pcm->snd->card, stream->voice.out); stream->voice.out =3D NULL; + } else if (stream->info.direction =3D=3D VIRTIO_SND_D_INPUT) { + AUD_close_in(&stream->pcm->snd->card, stream->voice.in); + stream->voice.in =3D NULL; } } } @@ -482,7 +486,13 @@ static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s,= uint32_t stream_id) &as); AUD_set_volume_out(stream->voice.out, 0, 255, 255); } else { - qemu_log_mask(LOG_UNIMP, "virtio_snd: input/capture is unimplement= ed."); + stream->voice.in =3D AUD_open_in(&s->card, + stream->voice.in, + "virtio-sound.in", + stream, + virtio_snd_pcm_in_cb, + &as); + AUD_set_volume_in(stream->voice.in, 0, 255, 255); } =20 return cpu_to_le32(VIRTIO_SND_S_OK); @@ -573,6 +583,8 @@ static void virtio_snd_handle_pcm_start_stop(VirtIOSoun= d *s, } if (stream->info.direction =3D=3D VIRTIO_SND_D_OUTPUT) { AUD_set_active_out(stream->voice.out, start); + } else { + AUD_set_active_in(stream->voice.in, start); } } else { error_report("Invalid stream id: %"PRIu32, stream_id); @@ -814,6 +826,49 @@ static void virtio_snd_handle_event(VirtIODevice *vdev= , VirtQueue *vq) trace_virtio_snd_handle_event(); } =20 +static inline void empty_invalid_queue(VirtIODevice *vdev, VirtQueue *vq) +{ + VirtIOSoundPCMBuffer *buffer =3D NULL; + VirtIOSoundPCMStream *stream =3D NULL; + virtio_snd_pcm_status resp =3D { 0 }; + VirtIOSound *vsnd =3D VIRTIO_SND(vdev); + bool any =3D false; + + for (uint32_t i =3D 0; i < vsnd->snd_conf.streams; i++) { + stream =3D vsnd->pcm->streams[i]; + if (stream) { + any =3D false; + WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { + while (!QSIMPLEQ_EMPTY(&stream->invalid)) { + buffer =3D QSIMPLEQ_FIRST(&stream->invalid); + if (buffer->vq !=3D vq) { + break; + } + any =3D true; + resp.status =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); + iov_from_buf(buffer->elem->in_sg, + buffer->elem->in_num, + 0, + &resp, + sizeof(virtio_snd_pcm_status)); + virtqueue_push(vq, + buffer->elem, + sizeof(virtio_snd_pcm_status)); + QSIMPLEQ_REMOVE_HEAD(&stream->invalid, entry); + virtio_snd_pcm_buffer_free(buffer); + } + if (any) { + /* + * Notify vq about virtio_snd_pcm_status responses. + * Buffer responses must be notified separately later. + */ + virtio_notify(vdev, vq); + } + } + } + } +} + /* * The tx virtqueue handler. Makes the buffers available to their respecti= ve * streams for consumption. @@ -821,7 +876,7 @@ static void virtio_snd_handle_event(VirtIODevice *vdev,= VirtQueue *vq) * @vdev: VirtIOSound device * @vq: tx virtqueue */ -static void virtio_snd_handle_tx(VirtIODevice *vdev, VirtQueue *vq) +static void virtio_snd_handle_tx_xfer(VirtIODevice *vdev, VirtQueue *vq) { VirtIOSound *s =3D VIRTIO_SND(vdev); VirtIOSoundPCMStream *stream =3D NULL; @@ -829,7 +884,6 @@ static void virtio_snd_handle_tx(VirtIODevice *vdev, Vi= rtQueue *vq) VirtQueueElement *elem; size_t msg_sz, size; virtio_snd_pcm_xfer hdr; - virtio_snd_pcm_status resp =3D { 0 }; uint32_t stream_id; /* * If any of the I/O messages are invalid, put them in stream->invalid= and @@ -840,7 +894,7 @@ static void virtio_snd_handle_tx(VirtIODevice *vdev, Vi= rtQueue *vq) if (!virtio_queue_ready(vq)) { return; } - trace_virtio_snd_handle_xfer(); + trace_virtio_snd_handle_tx_xfer(); =20 for (;;) { elem =3D virtqueue_pop(vq, sizeof(VirtQueueElement)); @@ -893,36 +947,88 @@ tx_err: } =20 if (must_empty_invalid_queue) { - WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { - while (!QSIMPLEQ_EMPTY(&stream->invalid)) { - buffer =3D QSIMPLEQ_FIRST(&stream->invalid); - - resp.status =3D cpu_to_le32(VIRTIO_SND_S_BAD_MSG); - iov_from_buf(buffer->elem->in_sg, - buffer->elem->in_num, - 0, - &resp, - sizeof(virtio_snd_pcm_status)); - virtqueue_push(vq, buffer->elem, sizeof(virtio_snd_pcm_sta= tus)); - QSIMPLEQ_REMOVE_HEAD(&stream->invalid, entry); - virtio_snd_pcm_buffer_free(buffer); - } - /* - * Notify vq about virtio_snd_pcm_status responses. - * Buffer responses must be notified separately later. - */ - virtio_notify(vdev, vq); - } + empty_invalid_queue(vdev, vq); } } =20 /* - * Stub buffer virtqueue handler. + * The rx virtqueue handler. Makes the buffers available to their respecti= ve + * streams for consumption. * * @vdev: VirtIOSound device - * @vq: virtqueue + * @vq: rx virtqueue */ -static void virtio_snd_handle_xfer(VirtIODevice *vdev, VirtQueue *vq) {} +static void virtio_snd_handle_rx_xfer(VirtIODevice *vdev, VirtQueue *vq) +{ + VirtIOSound *s =3D VIRTIO_SND(vdev); + VirtIOSoundPCMStream *stream =3D NULL; + VirtIOSoundPCMBuffer *buffer; + VirtQueueElement *elem; + size_t msg_sz, size; + virtio_snd_pcm_xfer hdr; + uint32_t stream_id; + /* + * if any of the I/O messages are invalid, put them in stream->invalid= and + * return them after the for loop. + */ + bool must_empty_invalid_queue =3D false; + + if (!virtio_queue_ready(vq)) { + return; + } + trace_virtio_snd_handle_rx_xfer(); + + for (;;) { + elem =3D virtqueue_pop(vq, sizeof(VirtQueueElement)); + if (!elem) { + break; + } + /* get the message hdr object */ + msg_sz =3D iov_to_buf(elem->out_sg, + elem->out_num, + 0, + &hdr, + sizeof(virtio_snd_pcm_xfer)); + if (msg_sz !=3D sizeof(virtio_snd_pcm_xfer)) { + goto rx_err; + } + stream_id =3D le32_to_cpu(hdr.stream_id); + + if (stream_id >=3D s->snd_conf.streams + || !s->pcm->streams[stream_id]) { + goto rx_err; + } + + stream =3D s->pcm->streams[stream_id]; + if (stream =3D=3D NULL || stream->info.direction !=3D VIRTIO_SND_D= _INPUT) { + goto rx_err; + } + WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { + size =3D iov_size(elem->in_sg, elem->in_num) - + sizeof(virtio_snd_pcm_status); + buffer =3D g_malloc0(sizeof(VirtIOSoundPCMBuffer) + size); + buffer->elem =3D elem; + buffer->vq =3D vq; + buffer->size =3D 0; + buffer->offset =3D 0; + QSIMPLEQ_INSERT_TAIL(&stream->queue, buffer, entry); + } + continue; + +rx_err: + WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { + must_empty_invalid_queue =3D true; + buffer =3D g_malloc0(sizeof(VirtIOSoundPCMBuffer)); + buffer->elem =3D elem; + buffer->vq =3D vq; + QSIMPLEQ_INSERT_TAIL(&stream->invalid, buffer, entry); + } + } + + if (must_empty_invalid_queue) { + empty_invalid_queue(vdev, vq); + } +} =20 static uint64_t get_features(VirtIODevice *vdev, uint64_t features, Error **errp) @@ -1010,9 +1116,9 @@ static void virtio_snd_realize(DeviceState *dev, Erro= r **errp) vsnd->queues[VIRTIO_SND_VQ_EVENT] =3D virtio_add_queue(vdev, 64, virtio_snd_handle_event); vsnd->queues[VIRTIO_SND_VQ_TX] =3D - virtio_add_queue(vdev, 64, virtio_snd_handle_tx); + virtio_add_queue(vdev, 64, virtio_snd_handle_tx_xfer); vsnd->queues[VIRTIO_SND_VQ_RX] =3D - virtio_add_queue(vdev, 64, virtio_snd_handle_xfer); + virtio_add_queue(vdev, 64, virtio_snd_handle_rx_xfer); qemu_mutex_init(&vsnd->cmdq_mutex); QTAILQ_INIT(&vsnd->cmdq); =20 @@ -1116,19 +1222,107 @@ static void virtio_snd_pcm_out_cb(void *data, int = available) } =20 /* - * Flush all buffer data from this stream's queue into the driver's virtual - * queue. + * Flush all buffer data from this input stream's queue into the driver's + * virtual queue. + * + * @stream: VirtIOSoundPCMStream *stream + */ +static inline void return_rx_buffer(VirtIOSoundPCMStream *stream, + VirtIOSoundPCMBuffer *buffer) +{ + virtio_snd_pcm_status resp =3D { 0 }; + resp.status =3D cpu_to_le32(VIRTIO_SND_S_OK); + resp.latency_bytes =3D 0; + /* Copy data -if any- to guest */ + iov_from_buf(buffer->elem->in_sg, + buffer->elem->in_num, + 0, + buffer->data, + buffer->size); + iov_from_buf(buffer->elem->in_sg, + buffer->elem->in_num, + buffer->size, + &resp, + sizeof(virtio_snd_pcm_status)); + virtqueue_push(buffer->vq, + buffer->elem, + sizeof(virtio_snd_pcm_status) + buffer->size); + virtio_notify(VIRTIO_DEVICE(stream->s), buffer->vq); + QSIMPLEQ_REMOVE(&stream->queue, + buffer, + VirtIOSoundPCMBuffer, + entry); + virtio_snd_pcm_buffer_free(buffer); +} + + +/* + * AUD_* input callback. + * + * @data: VirtIOSoundPCMStream stream + * @available: number of bytes that can be read with AUD_read() + */ +static void virtio_snd_pcm_in_cb(void *data, int available) +{ + VirtIOSoundPCMStream *stream =3D data; + VirtIOSoundPCMBuffer *buffer; + size_t size; + + WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { + while (!QSIMPLEQ_EMPTY(&stream->queue)) { + buffer =3D QSIMPLEQ_FIRST(&stream->queue); + if (!virtio_queue_ready(buffer->vq)) { + return; + } + if (!stream->active) { + /* Stream has stopped, so do not perform AUD_read. */ + return_rx_buffer(stream, buffer); + continue; + } + + for (;;) { + size =3D AUD_read(stream->voice.in, + buffer->data + buffer->size, + MIN(available, (stream->params.period_bytes - + buffer->size))); + if (!size) { + available =3D 0; + break; + } + buffer->size +=3D size; + available -=3D size; + if (buffer->size >=3D stream->params.period_bytes) { + return_rx_buffer(stream, buffer); + break; + } + if (!available) { + break; + } + } + if (!available) { + break; + } + } + } +} + +/* + * Flush all buffer data from this output stream's queue into the driver's + * virtual queue. * * @stream: VirtIOSoundPCMStream *stream */ static inline void virtio_snd_pcm_flush(VirtIOSoundPCMStream *stream) { VirtIOSoundPCMBuffer *buffer; + void (*cb)(VirtIOSoundPCMStream *, VirtIOSoundPCMBuffer *) =3D + (stream->info.direction =3D=3D VIRTIO_SND_D_OUTPUT) ? return_tx_bu= ffer : + return_rx_buffer; =20 WITH_QEMU_LOCK_GUARD(&stream->queue_mutex) { while (!QSIMPLEQ_EMPTY(&stream->queue)) { buffer =3D QSIMPLEQ_FIRST(&stream->queue); - return_tx_buffer(stream, buffer); + cb(stream, buffer); } } } diff --git a/hw/audio/trace-events b/hw/audio/trace-events index 884108129b..b1870ff224 100644 --- a/hw/audio/trace-events +++ b/hw/audio/trace-events @@ -56,4 +56,5 @@ virtio_snd_handle_code(uint32_t val, const char *code) "c= trl code msg val =3D %"PR virtio_snd_handle_chmap_info(void) "VIRTIO_SND_CHMAP_INFO called" virtio_snd_handle_event(void) "event queue callback called" virtio_snd_pcm_stream_flush(uint32_t stream) "flushing stream %"PRIu32 -virtio_snd_handle_xfer(void) "tx/rx queue callback called" +virtio_snd_handle_tx_xfer(void) "tx queue callback called" +virtio_snd_handle_rx_xfer(void) "rx queue callback called" --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351986; cv=none; d=zohomail.com; s=zohoarc; b=CshyMe9NzXVLT2szqesLIPCC3v5fpGSPFAj8QKaHwdH0CXYf32xPWkEnNmfTlt3yoeeDivsyLiMzqI5A2oxobQzHW1CNgU63tub7ivk9YcA3QDU8qCFes0Q7cKxguHibMhzwPrMSzusy1PY6jhcseR/s8dyCDs/Bo6Q3VfV3/Oo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351986; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=exRXQxzSkBuHePlXjstPNpQJEvpRz38bCMREMqF6jhg=; b=iA9wLMuneF5OgJaf7iygpHnyecHGDVtcTlthqa6zdLUCxNG/q/XCRcR0NCitw+eAs1s/wsVJJZplEitAZsIc6BFtY7uP/ugMZ7dVoY0CT1wrjs9MCOiWDaEHtwSMfNqi2nppmwge3G1zJ9D/cYqTQ+yL78d7w2THCHBaJMK9TFA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699351986252613.6867606061419; Tue, 7 Nov 2023 02:13:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J37-0003bc-Eg; Tue, 07 Nov 2023 05:11:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2w-0002hn-N4 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2v-0002UQ-03 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:10:58 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-124-_MT13OMtP1G6yQEGGvFC4A-1; Tue, 07 Nov 2023 05:10:54 -0500 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4084e4ce543so34963025e9.3 for ; Tue, 07 Nov 2023 02:10:54 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id h21-20020a05600c499500b0040586360a36sm14743133wmp.17.2023.11.07.02.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:10:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351856; h=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=exRXQxzSkBuHePlXjstPNpQJEvpRz38bCMREMqF6jhg=; b=KTq5TesSPrxwEQMVLMchMZsTHGBgfY+0KWwvPoBcuqwxOkspxzmyAFTvCUKLM/tETtJrN2 Y/uTdeiemCveuK1JXuvT0suxeb5+3gZsk3MJbXG5EDPFhBRTn0XNoQsFIhYGAEGwgLlqm8 GHzgaVQY7CtQEzJ51tLumjgwWoRk+iw= X-MC-Unique: _MT13OMtP1G6yQEGGvFC4A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351853; x=1699956653; 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=exRXQxzSkBuHePlXjstPNpQJEvpRz38bCMREMqF6jhg=; b=cYBgNp4jKE+tjNuNcKT0ObyDe6Gcxv5efy9pFBDqXATq70FmWIdjFJ29VZSqL1rfyr Ny4WfIDq6791fSauHdNsobYW702TLSz4OmuX/DIV4FL5rjbUJkmtuhbPGFVHCoyTj37O mST4EpbkL3cTJCWv+Ob8hUVf+0TC4SG8PQQdKhxkIohkJ0QoFJgGowYcUGH86D4xNFBc kXnfzM426+/MLoN1wod+zZqG21HyueTNzlHa4ElMiy/s1qph1DovC5k1XZI7SQRTIOkb JGUhtTp1hBRQBSGHYdMtWbirqw8Ej87WILAjsqwzocL7aqMVZo4zVzk8wXCnUbyfkdY0 45bw== X-Gm-Message-State: AOJu0YwejGK3PIOCE3xLfB5iqIRjmGnvpZu5PsYE4w90QtaH5FHfqeYo mAXuELXKHnfZbLE6VsvghJdV3tdHCvn3Qa/i0fZ81HAHmrv92KpNDV7B7R5QrTa47aRm0440J89 aOV06dPkZdE9VKJGQXvJGUpc9k7GAe34+fY5twfGze2+0oqbwl/IZxHgi72q91hCYa0JF X-Received: by 2002:a05:600c:35ce:b0:402:8896:bb7b with SMTP id r14-20020a05600c35ce00b004028896bb7bmr1628320wmq.6.1699351853076; Tue, 07 Nov 2023 02:10:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRw/GRG5qMCCwJmW/BIDMwgC0hRVYveijdIafuP9NS8vyYMUiEFdn/vaVjgH3xhtTSJp0D7A== X-Received: by 2002:a05:600c:35ce:b0:402:8896:bb7b with SMTP id r14-20020a05600c35ce00b004028896bb7bmr1628299wmq.6.1699351852599; Tue, 07 Nov 2023 02:10:52 -0800 (PST) Date: Tue, 7 Nov 2023 05:10:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Alex =?utf-8?Q?Benn=C3=A9e?= , Gerd Hoffmann Subject: [PULL 18/63] docs/system: add basic virtio-snd documentation Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351988048100005 From: Manos Pitsidianakis This commit adds basic documentation for using virtio-snd. Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e Tested-by: Alex Benn=C3=A9e Message-Id: Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- MAINTAINERS | 1 + docs/system/device-emulation.rst | 1 + docs/system/devices/virtio-snd.rst | 49 ++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 docs/system/devices/virtio-snd.rst diff --git a/MAINTAINERS b/MAINTAINERS index c09bb8cf41..4fad272d73 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2317,6 +2317,7 @@ S: Supported F: hw/audio/virtio-snd.c F: hw/audio/virtio-snd-pci.c F: include/hw/audio/virtio-snd.h +F: docs/system/devices/virtio-snd.rst =20 nvme M: Keith Busch diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulatio= n.rst index 1167f3a9f2..d1f3277cb0 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -93,6 +93,7 @@ Emulated Devices devices/vhost-user.rst devices/virtio-gpu.rst devices/virtio-pmem.rst + devices/virtio-snd.rst devices/vhost-user-rng.rst devices/canokey.rst devices/usb-u2f.rst diff --git a/docs/system/devices/virtio-snd.rst b/docs/system/devices/virti= o-snd.rst new file mode 100644 index 0000000000..2a9187fd70 --- /dev/null +++ b/docs/system/devices/virtio-snd.rst @@ -0,0 +1,49 @@ +virtio sound +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +This document explains the setup and usage of the Virtio sound device. +The Virtio sound device is a paravirtualized sound card device. + +Linux kernel support +-------------------- + +Virtio sound requires a guest Linux kernel built with the +``CONFIG_SND_VIRTIO`` option. + +Description +----------- + +Virtio sound implements capture and playback from inside a guest using the +configured audio backend of the host machine. + +Device properties +----------------- + +The Virtio sound device can be configured with the following properties: + + * ``jacks`` number of physical jacks (Unimplemented). + * ``streams`` number of PCM streams. At the moment, no stream configurati= on is supported: the first one will always be a playback stream, an optiona= l second will always be a capture stream. Adding more will cycle stream dir= ections from playback to capture. + * ``chmaps`` number of channel maps (Unimplemented). + +All streams are stereo and have the default channel positions ``Front left= , right``. + +Examples +-------- + +Add an audio device and an audio backend at once with ``-audio`` and ``mod= el=3Dvirtio``: + + * pulseaudio: ``-audio driver=3Dpa,model=3Dvirtio`` + or ``-audio driver=3Dpa,model=3Dvirtio,server=3D/run/user/1000/pulse/na= tive`` + * sdl: ``-audio driver=3Dsdl,model=3Dvirtio`` + * coreaudio: ``-audio driver=3Dcoreaudio,model=3Dvirtio`` + +etc. + +To specifically add virtualized sound devices, you have to specify a PCI d= evice +and an audio backend listed with ``-audio driver=3Dhelp`` that works on yo= ur host +machine, e.g.: + +:: + + -device virtio-sound-pci,audiodev=3Dmy_audiodev \ + -audiodev alsa,id=3Dmy_audiodev --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352576; cv=none; d=zohomail.com; s=zohoarc; b=GJPJ4GXd2actzPxS3rIr63QHxc36BGlFGNn6hPGRYCrkEma27kZT4zFf1MCSqqL2vMHjrcCtRSBW2y0CKzq3u8uY3w7PPq057gWx71dHabzb4gXfL3dL4KI3NteWwkdI3F2Yqn077cWrBe4eSiKOaWYaxOLwzan0SsLSwu/jrR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352576; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lwNZq3J0BZTlZC7w878PfX1koj5w7HE98022Wpi/7iY=; b=gUF16WUQEnzypu/VxBoikJf/iBjthkt0UrOxnFnOgWBOI3gcL85SXNLkbq2bQYiUnhVIGF2kGrvtNcKoeATXc+OwZQTlS162gXJccnXggm9w92ftC3zJvNY+3bjRzgfJRuaJkW5MEJyiIGGzD0c7e9kpQQi1OM31TRYt/qATAxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352576034207.98737157091648; Tue, 7 Nov 2023 02:22:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J37-0003be-Eo; Tue, 07 Nov 2023 05:11:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J30-0002xz-GE for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J2y-0002Up-NT for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:02 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-phf6HhaNPEG0S310GYf6pg-1; Tue, 07 Nov 2023 05:10:58 -0500 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4083c9b426fso34438755e9.2 for ; Tue, 07 Nov 2023 02:10:58 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id j6-20020a5d6046000000b0032fc5f5abafsm1895042wrt.96.2023.11.07.02.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:10:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351860; h=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=lwNZq3J0BZTlZC7w878PfX1koj5w7HE98022Wpi/7iY=; b=QQA1sLCztCuSVTnd4h7kUvFZupcfvtjiRisKzYOD6ym/E7kuMc2F4yUPIwJ5DJYxjw0Sj2 zFSaVZPf7N0QnNnP087KIwNfCQmJk+3KVShRFv+E16uUJHIB3ZkfnizgaySihZ2SzuqhEt wBRzPrUEFsVk32faw7tvCAVl2xVdO0o= X-MC-Unique: phf6HhaNPEG0S310GYf6pg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351857; x=1699956657; 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=lwNZq3J0BZTlZC7w878PfX1koj5w7HE98022Wpi/7iY=; b=OsSEsPGWsNzfEA09LqwtpuyNDDs8y4kJIWi1ji9AzqqRF6E5de9qOndDmzqk2AIAWa iZZs/Kw2FQL0Hl7Xbu/y16M24vgfDUIvKf0orbOXyqDkbovCEPcMZZzV6tg3RoBxV9N+ bCWF1cBqioPU5qlYaOadJ7eyKMIecWChgTTeXDdvoNc+lmEsjotoZEQhVR7BwID38Amx vMo483oLlN017efaBxZAYjG4OdS3A93xvB8RwpwgWpgP97eJz+/pieKiZD23iTdk8HUe KtfKHAhJTq7Ke+LeNM9v+gBBdpUGu8CwK/85nP9EELJB9qessFvvSDksO+tCOMhBIJw8 j6xw== X-Gm-Message-State: AOJu0Yw/zzDD5ji6NerIeOblx8UROuwGJ930slFMqg/bybI9YKKh4TJH Yyd/mTEg1OV3OmpfUfE6veeY2ssfZcRsM2V2HTgIaD51xIaP/1Dnzup433vp6ZrYN6U1b9ZLOiv ee7ukgcMpVlTVoNZjrijjcZPH09OzfCsmppUXTUeVtqw65oeHRIJaQ31jCdMEv2eW/AEU X-Received: by 2002:a5d:6dae:0:b0:32f:7c01:5376 with SMTP id u14-20020a5d6dae000000b0032f7c015376mr25404268wrs.31.1699351857155; Tue, 07 Nov 2023 02:10:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/52wyFaN00HbAl/jur4LC2XEZNyP0vxTVUylcplucZEswlKSNWJDVwB90FmzERzO/dglitA== X-Received: by 2002:a5d:6dae:0:b0:32f:7c01:5376 with SMTP id u14-20020a5d6dae000000b0032f7c015376mr25404248wrs.31.1699351856778; Tue, 07 Nov 2023 02:10:56 -0800 (PST) Date: Tue, 7 Nov 2023 05:10:53 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Eugenio =?utf-8?B?UMOpcmV6?= , Jason Wang Subject: [PULL 19/63] vdpa: Restore hash calculation state Message-ID: <8b98c15f22fca34f23846e70752a70e4a2469317.1699351720.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352576392100001 From: Hawkins Jiawei This patch introduces vhost_vdpa_net_load_rss() to restore the hash calculation state at device's startup. Signed-off-by: Hawkins Jiawei Message-Id: Acked-by: Eugenio P=C3=A9rez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 7a226c93bc..e59d40b8ae 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -818,6 +818,88 @@ static int vhost_vdpa_net_load_mac(VhostVDPAState *s, = const VirtIONet *n, return 0; } =20 +static int vhost_vdpa_net_load_rss(VhostVDPAState *s, const VirtIONet *n, + struct iovec *out_cursor, + struct iovec *in_cursor) +{ + struct virtio_net_rss_config cfg =3D {}; + ssize_t r; + g_autofree uint16_t *table =3D NULL; + + /* + * According to VirtIO standard, "Initially the device has all hash + * types disabled and reports only VIRTIO_NET_HASH_REPORT_NONE.". + * + * Therefore, there is no need to send this CVQ command if the + * driver disables the all hash types, which aligns with + * the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + if (!n->rss_data.enabled || + n->rss_data.hash_types =3D=3D VIRTIO_NET_HASH_REPORT_NONE) { + return 0; + } + + table =3D g_malloc_n(n->rss_data.indirections_len, + sizeof(n->rss_data.indirections_table[0])); + cfg.hash_types =3D cpu_to_le32(n->rss_data.hash_types); + + /* + * According to VirtIO standard, "Field reserved MUST contain zeroes. + * It is defined to make the structure to match the layout of + * virtio_net_rss_config structure, defined in 5.1.6.5.7.". + * + * Therefore, we need to zero the fields in + * struct virtio_net_rss_config, which corresponds to the + * `reserved` field in struct virtio_net_hash_config. + * + * Note that all other fields are zeroed at their definitions, + * except for the `indirection_table` field, where the actual data + * is stored in the `table` variable to ensure compatibility + * with RSS case. Therefore, we need to zero the `table` variable here. + */ + table[0] =3D 0; + + /* + * Considering that virtio_net_handle_rss() currently does not restore + * the hash key length parsed from the CVQ command sent from the guest + * into n->rss_data and uses the maximum key length in other code, so + * we also employ the maximum key length here. + */ + cfg.hash_key_length =3D sizeof(n->rss_data.key); + + const struct iovec data[] =3D { + { + .iov_base =3D &cfg, + .iov_len =3D offsetof(struct virtio_net_rss_config, + indirection_table), + }, { + .iov_base =3D table, + .iov_len =3D n->rss_data.indirections_len * + sizeof(n->rss_data.indirections_table[0]), + }, { + .iov_base =3D &cfg.max_tx_vq, + .iov_len =3D offsetof(struct virtio_net_rss_config, hash_key_d= ata) - + offsetof(struct virtio_net_rss_config, max_tx_vq), + }, { + .iov_base =3D (void *)n->rss_data.key, + .iov_len =3D sizeof(n->rss_data.key), + } + }; + + r =3D vhost_vdpa_net_load_cmd(s, out_cursor, in_cursor, + VIRTIO_NET_CTRL_MQ, + VIRTIO_NET_CTRL_MQ_HASH_CONFIG, + data, ARRAY_SIZE(data)); + if (unlikely(r < 0)) { + return r; + } + + return 0; +} + static int vhost_vdpa_net_load_mq(VhostVDPAState *s, const VirtIONet *n, struct iovec *out_cursor, @@ -843,6 +925,15 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s, return r; } =20 + if (!virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_HASH_REPORT)= ) { + return 0; + } + + r =3D vhost_vdpa_net_load_rss(s, n, out_cursor, in_cursor); + if (unlikely(r < 0)) { + return r; + } + return 0; } =20 --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351911; cv=none; d=zohomail.com; s=zohoarc; b=WuFeAOSBHLsQbVpPvDAJoLGh8i+myQVUOgNFn34qLgQn+0/jTUQZLlPsP40fjc68ovo0OFsgNHjQZrv1JazFBxJdIFdyFqp89jyrPp1V1JmWtwmz1t6HaFZsVowzYT7If9AiNcWX5sXpwjLPUm0/kF/IpOwQ1d/+1UCm/R0bDFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351911; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Fk18UFl3gvhVFvUPc8Rke7I/hKZLNs+l/lUgUAmltCE=; b=aaOpN9/69SGLtw3S2kW475Y7p9HOjHtDfvJIpAqyuev86tPt4areRXgUSp2lwmlslekkPsH2QwS3DDgpacdGPCd38WP5jQXN6QS8EJxcJpRXSMOZVTmqlN2pKq+XYRdKz9NZOB1xbi3ALGayqxxI9u2x4qCl2lwPHxEX95ODBDU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699351911720841.8969963184878; Tue, 7 Nov 2023 02:11:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J38-0003qd-DY; Tue, 07 Nov 2023 05:11:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J34-0003AU-Nx for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J33-0002VB-1t for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:06 -0500 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-596-_Fp8CfstOm2eafQoP-7JmQ-1; Tue, 07 Nov 2023 05:11:03 -0500 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-50911cc75adso5930542e87.1 for ; Tue, 07 Nov 2023 02:11:03 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id t11-20020a5d49cb000000b003248a490e3asm1903339wrs.39.2023.11.07.02.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351864; h=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=Fk18UFl3gvhVFvUPc8Rke7I/hKZLNs+l/lUgUAmltCE=; b=O06KqB7DZJzxUeZOy9DMCHRntf4JKMTvB9y7h2INS5MokLK9PK0MLKSNVgjXmjbZyberwD dH1wXs1TV8y1viCzysm7f4wxW3ZyYBQGCSQhSF/1gaDrcSx2NUpFhZlmsQ0dO0iIh9c6Hu 9ZlX1vYsviYiF2fjH8JgR9YzfK2E/zE= X-MC-Unique: _Fp8CfstOm2eafQoP-7JmQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351861; x=1699956661; 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=Fk18UFl3gvhVFvUPc8Rke7I/hKZLNs+l/lUgUAmltCE=; b=pZM9BPuOf74LVqPGEq2nykM4fN+BPq+W54tZh3Y5Oq6ld5D8pw/XvLA07MJY+21QY2 G85t2f31RAd4nO+d7FSQsPeU/WeImEPDtmShffhICi5YA445Nh4DFi5LBl8Hy/TVc8If XcygefGA0Zy6Wez8yeYuUeUrYyoUgc/eWIZc8RJbwMyRov0LtAs/g1AIaMQ1eg1W9BBd J/Hbn+Xmg3Mr9Nn4Hot1kPltYTQWiIqCuxKzvT6VZs/kFGJNaUuaCk3dnPou2tkNHgiU pk/YYc3aAo0UG8tP8nSM5F8DJ+5C+Og+Nm69N0wXabKmhGIxcP0B4y5EprdSTsxWpV15 TBEQ== X-Gm-Message-State: AOJu0YzSm5Ujr3ikX7vUl2WUarv0u69e2Uzv18jq8pmMxfPbrXwKkTn2 HFuOuApL3ICuQn9WM2NM75FhdHtlnGKyXUqcaP5/6x+A84ox15U/aBv6s/hK52qa2aezlxCD0/J d5rWFb/SuMCm6edTtEnw+HnFHul2OWBI4OM1m+7OjBBWysJ3qYO54o5Vfi1dwB8XqzveG X-Received: by 2002:a19:5f50:0:b0:509:31e6:1de5 with SMTP id a16-20020a195f50000000b0050931e61de5mr12992025lfj.47.1699351861152; Tue, 07 Nov 2023 02:11:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IERbotreMh5K4WhsdOjBYGvmUrAemMBxp0MEtAxkvZgQSsZlinmB6D5CIqHsQQqwi8FdqZwgQ== X-Received: by 2002:a19:5f50:0:b0:509:31e6:1de5 with SMTP id a16-20020a195f50000000b0050931e61de5mr12992014lfj.47.1699351860866; Tue, 07 Nov 2023 02:11:00 -0800 (PST) Date: Tue, 7 Nov 2023 05:10:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Eugenio =?utf-8?B?UMOpcmV6?= , Jason Wang Subject: [PULL 20/63] vdpa: Allow VIRTIO_NET_F_HASH_REPORT in SVQ Message-ID: <556b67d413a699431eadb71642033864649ea934.1699351720.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351912725100005 From: Hawkins Jiawei Enable SVQ with VIRTIO_NET_F_HASH_REPORT feature. Signed-off-by: Hawkins Jiawei Message-Id: Acked-by: Eugenio P=C3=A9rez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e59d40b8ae..54f748d49d 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -121,6 +121,7 @@ static const uint64_t vdpa_svq_device_features =3D BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) | /* VHOST_F_LOG_ALL is exposed by SVQ */ BIT_ULL(VHOST_F_LOG_ALL) | + BIT_ULL(VIRTIO_NET_F_HASH_REPORT) | BIT_ULL(VIRTIO_NET_F_RSC_EXT) | BIT_ULL(VIRTIO_NET_F_STANDBY) | BIT_ULL(VIRTIO_NET_F_SPEED_DUPLEX); --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352743; cv=none; d=zohomail.com; s=zohoarc; b=Rbw2rdBWULQLGUp4a/3C629bhzeb0u7Wk34hXWzDTuoJzu1WEuAimMJ+lVKjJxWl1EuemvaH8d2uBu1rTP23aNUz5h/+4TP+eUtGOYztpRwcT7AwqnBhjVFZvw7miLUfwJuW/fyYr9ehtBbkgLHIE78lNqwkzWEfN2eA2vCLvyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352743; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Bpj29tXiqgLNxsD0wsJlUZ9eT5lcs0B4elp4WPlk0FM=; b=Ys2EENM8ODXy0Nsb5GScMO4Mzb3QX3XS+cFfUtkHWu3w+F6j+l0da7V1QgrsbUFDjGsJJeLcI28eV1zA5WhMZDBmKgSK2Mlrph+JCMI6+2fwry82UKkrCuRRYVE8vwtQQuK/ejoX1YHSVZrcRgwvfwfwU+Z+8BXSTI8/ILSnPCQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352743473228.0579697086547; Tue, 7 Nov 2023 02:25:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J3I-00057k-J6; Tue, 07 Nov 2023 05:11:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3F-0004kF-H9 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3D-0002Vx-Px for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:17 -0500 Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-60-wXL2WF9UMM-iZVzF8vUhJQ-1; Tue, 07 Nov 2023 05:11:07 -0500 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2c50bebd8dfso53492471fa.3 for ; Tue, 07 Nov 2023 02:11:07 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id l3-20020a05600c4f0300b003fc0505be19sm15233367wmq.37.2023.11.07.02.11.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351875; h=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=Bpj29tXiqgLNxsD0wsJlUZ9eT5lcs0B4elp4WPlk0FM=; b=bag04e9Nu1VlbCffCFypqK+dj/T/K6iPGxjujrcM4v1b1edFIRc5lPWNuwki/okfSZXski VUNNdJUavYnUxLOvG0YHHtgiB4y71WpD3hAb6ROHmdWp1In11Qa6Yl9sSFN9c18mPc0Lxa Lqe068flOEYXOHwv+TcdcsrWV7UkM/o= X-MC-Unique: wXL2WF9UMM-iZVzF8vUhJQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351865; x=1699956665; 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=Bpj29tXiqgLNxsD0wsJlUZ9eT5lcs0B4elp4WPlk0FM=; b=mx4kp/PBoKrB0AjXKZgzsbyuS38ngsMThj+BfIY4OemcbNS1zVnXeBvdTUvfzlrKCx Wy61xgXUgVDY3vyTWkV664887+Emm8VVFXgRwgmjxlqHj32U8N042FyeoWo+k1FWRWG4 jxQ31WmE+YGgHYv+/Q/nZAO0ne/nhQ9mkjNYCUimVh0TntBdHhf9cCpsFoYy3AOlynIq xoIBqcUqp87+y2ETiXMDNLZzZ7titD54iREbIDPEGnTSKrT/2AOfK24L67OWCMpUn29g DQzN6D9oHomufHYX5Pf98p3zASW5R4fMHBKYjwcRjk3owTzZ7FKQKjqmK6RglsK3Ntb+ cOpw== X-Gm-Message-State: AOJu0Yy32e/8NNzKbRJzYOOB3lN4SKZC6VClSPXwOVeg6MpZL0NR9UOq 57HWVXW03bIJjfzE6E6Vf9NE1szquArWjiuSl5eGtGOZ20pFcfQgyPPLzpKgP0svM7UbsUM0fl+ fyTVUczq07elfWvDDqfLzM4xblGl8gw/lUkr2DyRd6r9grLdRuwmfH0LBCsl3UnI4E/l+ X-Received: by 2002:a05:651c:3cf:b0:2c5:1f30:ebfc with SMTP id f15-20020a05651c03cf00b002c51f30ebfcmr23050911ljp.38.1699351865385; Tue, 07 Nov 2023 02:11:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHCUPlFMIO3qEUQ/ZSpq2ok2/OqNQOmKDBFrq3mrkbzCDuOR3Db6sa/FNZl25b6gW/wkw2pSg== X-Received: by 2002:a05:651c:3cf:b0:2c5:1f30:ebfc with SMTP id f15-20020a05651c03cf00b002c51f30ebfcmr23050894ljp.38.1699351864967; Tue, 07 Nov 2023 02:11:04 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Eugenio =?utf-8?B?UMOpcmV6?= , Jason Wang Subject: [PULL 21/63] vdpa: Add SetSteeringEBPF method for NetClientState Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352745648100005 From: Hawkins Jiawei At present, to enable the VIRTIO_NET_F_RSS feature, eBPF must be loaded for the vhost backend. Given that vhost-vdpa is one of the vhost backend, we need to implement the SetSteeringEBPF method to support RSS for vhost-vdpa, even if vhost-vdpa calculates the rss hash in the hardware device instead of in the kernel by eBPF. Although this requires QEMU to be compiled with `--enable-bpf` configuration even if the vdpa device does not use eBPF to calculate the rss hash, this can avoid adding the specific conditional statements for vDPA case to enable the VIRTIO_NET_F_RSS feature, which reduces code maintainbility. Suggested-by: Eugenio P=C3=A9rez Signed-off-by: Hawkins Jiawei Message-Id: <280e20ddce55b6de60f1552ba0865bffffe909b2.1698195059.git.yin311= 49@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 54f748d49d..3466936b87 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -241,6 +241,12 @@ static void vhost_vdpa_cleanup(NetClientState *nc) } } =20 +/** Dummy SetSteeringEBPF to support RSS for vhost-vdpa backend */ +static bool vhost_vdpa_set_steering_ebpf(NetClientState *nc, int prog_fd) +{ + return true; +} + static bool vhost_vdpa_has_vnet_hdr(NetClientState *nc) { assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); @@ -423,6 +429,7 @@ static NetClientInfo net_vhost_vdpa_info =3D { .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, .has_ufo =3D vhost_vdpa_has_ufo, .check_peer_type =3D vhost_vdpa_check_peer_type, + .set_steering_ebpf =3D vhost_vdpa_set_steering_ebpf, }; =20 static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index, @@ -1258,6 +1265,7 @@ static NetClientInfo net_vhost_vdpa_cvq_info =3D { .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, .has_ufo =3D vhost_vdpa_has_ufo, .check_peer_type =3D vhost_vdpa_check_peer_type, + .set_steering_ebpf =3D vhost_vdpa_set_steering_ebpf, }; =20 /* --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351903; cv=none; d=zohomail.com; s=zohoarc; b=RS5xnFOerYSrXMBmBf8JjAKZ/QfRBuVP4GEsmhm+82Le6thV97jlX8qg6xcQkuE0Vw7XaTdktaUVfGDxd7fhh3MvG7OxSu9I7f4hb4Xy40Nn6yfGblA3cPQE7wSEiaFwZQ4abZM4hJ2N8SlQbyrlqEQJRNAVschYN0h5S8n2/po= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351903; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yu/DRCnQglYDbBr20d7/0QO5BSMWBIDRPcuYSsahgjo=; b=b7BlJw5dlH4gIvSRtU/Ipzvms6Enrra+dTteqLZvQfsOUNmOK3a2oZQrzTVhE8alMdKq42orX+TH1yIrUfamZxoGHClJWpnk04aowqbbSVdfY9KxJ6gOrYd7WnHZLnrShLR+Hrgj6uR6xdzNA9tYE9RwEE7h26PzesNFsM/Wbr0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699351903140570.0118726885498; Tue, 7 Nov 2023 02:11:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J3G-0004na-0E; Tue, 07 Nov 2023 05:11:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3E-0004a6-4h for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3C-0002Vp-3C for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:15 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-22-ea6yjPneOE-LUlvY9M4c1A-1; Tue, 07 Nov 2023 05:11:12 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-408f9e9e9b0so35068355e9.2 for ; Tue, 07 Nov 2023 02:11:12 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id x17-20020a05600c2d1100b004077219aed5sm14821417wmf.6.2023.11.07.02.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351873; h=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=yu/DRCnQglYDbBr20d7/0QO5BSMWBIDRPcuYSsahgjo=; b=NG2CqMr4KtgUiFrw33JeY86JUv/8adK+NoLHCScphhszi/qLpfLFFomgLdDdBgqczqrELe BTX6l/dGVgqKvvfvGoVYho4auUu2o40r6XYKw9UVipUU4ejKU+iVUX8n6PDvYnniTDvVa6 jck3DmGHa0FoODaKwjJKZu59Q69j/TE= X-MC-Unique: ea6yjPneOE-LUlvY9M4c1A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351870; x=1699956670; 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=yu/DRCnQglYDbBr20d7/0QO5BSMWBIDRPcuYSsahgjo=; b=pAZnYaR9vMoDB9Y9XM2R3UIu4tvwmgrTDmzKDPze0jav3qgfHUvaJbWKLYE0DHXyLb pcaupcuPFHvEOkc9oPPPInlHl3BY7e2D+a+Gn1FTGmP0HAYyOffQ0nwJVDugkQbcC0Af ouAPcXmkEaFVU2qpVfPjdDi6Ahb+LSibNym8274Jy+csCDWuriphVzs0e9JW2FdKjEXq R5QD45VaNCce1Z/hQ5+49UBoD16UVer9ukEqA511/0wmV8kB2QhzwQ8Wd3OPDuX0ll6g +P4QS00IUhzuUzhQUtIt8rBXSkBT/eDQOj9g27+gxT5S6ahODAEli74bkeZh4X6OiOtm a0JA== X-Gm-Message-State: AOJu0Yzsa5x0OUXHC1C9a5NNSogRUaoxR3J9LFNhdYwcTKOBTjg73tFn F2eTY1AbyvefC5F/ndEyKRdd/iS2eGkhT9gtwaXFTQMTTz+kjKo2j5s3AxneIAI8bLslcQBTMz2 BDuiAU8sGvFwKem9NsTCmdUeds4CXUvWSnv/w8tE7iZzKO5wkINEOLoRwNPyZ6u9mbNMy X-Received: by 2002:a05:600c:46d2:b0:40a:20f3:d126 with SMTP id q18-20020a05600c46d200b0040a20f3d126mr1619831wmo.6.1699351870105; Tue, 07 Nov 2023 02:11:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0iCW89dy7j421OF1kO6UGKYYzsLhdDOndmiRs6IJHOCEg6vdf7O8f3h+Xo5aG9qBzP6z9yQ== X-Received: by 2002:a05:600c:46d2:b0:40a:20f3:d126 with SMTP id q18-20020a05600c46d200b0040a20f3d126mr1619812wmo.6.1699351869717; Tue, 07 Nov 2023 02:11:09 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Eugenio =?utf-8?B?UMOpcmV6?= , Jason Wang Subject: [PULL 22/63] vdpa: Restore receive-side scaling state Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351904295100001 From: Hawkins Jiawei This patch reuses vhost_vdpa_net_load_rss() with some refactorings to restore the receive-side scaling state at device's startup. Signed-off-by: Hawkins Jiawei Message-Id: Acked-by: Eugenio P=C3=A9rez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 67 +++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 3466936b87..a4cc1381fc 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -828,7 +828,7 @@ static int vhost_vdpa_net_load_mac(VhostVDPAState *s, c= onst VirtIONet *n, =20 static int vhost_vdpa_net_load_rss(VhostVDPAState *s, const VirtIONet *n, struct iovec *out_cursor, - struct iovec *in_cursor) + struct iovec *in_cursor, bool do_rss) { struct virtio_net_rss_config cfg =3D {}; ssize_t r; @@ -854,21 +854,35 @@ static int vhost_vdpa_net_load_rss(VhostVDPAState *s,= const VirtIONet *n, sizeof(n->rss_data.indirections_table[0])); cfg.hash_types =3D cpu_to_le32(n->rss_data.hash_types); =20 - /* - * According to VirtIO standard, "Field reserved MUST contain zeroes. - * It is defined to make the structure to match the layout of - * virtio_net_rss_config structure, defined in 5.1.6.5.7.". - * - * Therefore, we need to zero the fields in - * struct virtio_net_rss_config, which corresponds to the - * `reserved` field in struct virtio_net_hash_config. - * - * Note that all other fields are zeroed at their definitions, - * except for the `indirection_table` field, where the actual data - * is stored in the `table` variable to ensure compatibility - * with RSS case. Therefore, we need to zero the `table` variable here. - */ - table[0] =3D 0; + if (do_rss) { + /* + * According to VirtIO standard, "Number of entries in indirection= _table + * is (indirection_table_mask + 1)". + */ + cfg.indirection_table_mask =3D cpu_to_le16(n->rss_data.indirection= s_len - + 1); + cfg.unclassified_queue =3D cpu_to_le16(n->rss_data.default_queue); + for (int i =3D 0; i < n->rss_data.indirections_len; ++i) { + table[i] =3D cpu_to_le16(n->rss_data.indirections_table[i]); + } + cfg.max_tx_vq =3D cpu_to_le16(n->curr_queue_pairs); + } else { + /* + * According to VirtIO standard, "Field reserved MUST contain zero= es. + * It is defined to make the structure to match the layout of + * virtio_net_rss_config structure, defined in 5.1.6.5.7.". + * + * Therefore, we need to zero the fields in + * struct virtio_net_rss_config, which corresponds to the + * `reserved` field in struct virtio_net_hash_config. + * + * Note that all other fields are zeroed at their definitions, + * except for the `indirection_table` field, where the actual data + * is stored in the `table` variable to ensure compatibility + * with RSS case. Therefore, we need to zero the `table` variable = here. + */ + table[0] =3D 0; + } =20 /* * Considering that virtio_net_handle_rss() currently does not restore @@ -899,6 +913,7 @@ static int vhost_vdpa_net_load_rss(VhostVDPAState *s, c= onst VirtIONet *n, =20 r =3D vhost_vdpa_net_load_cmd(s, out_cursor, in_cursor, VIRTIO_NET_CTRL_MQ, + do_rss ? VIRTIO_NET_CTRL_MQ_RSS_CONFIG : VIRTIO_NET_CTRL_MQ_HASH_CONFIG, data, ARRAY_SIZE(data)); if (unlikely(r < 0)) { @@ -933,13 +948,19 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s, return r; } =20 - if (!virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_HASH_REPORT)= ) { - return 0; - } - - r =3D vhost_vdpa_net_load_rss(s, n, out_cursor, in_cursor); - if (unlikely(r < 0)) { - return r; + if (virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_RSS)) { + /* load the receive-side scaling state */ + r =3D vhost_vdpa_net_load_rss(s, n, out_cursor, in_cursor, true); + if (unlikely(r < 0)) { + return r; + } + } else if (virtio_vdev_has_feature(&n->parent_obj, + VIRTIO_NET_F_HASH_REPORT)) { + /* load the hash calculation state */ + r =3D vhost_vdpa_net_load_rss(s, n, out_cursor, in_cursor, false); + if (unlikely(r < 0)) { + return r; + } } =20 return 0; --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352668; cv=none; d=zohomail.com; s=zohoarc; b=Z6Wu90/vnwMj/b+jk1ksILudhm9YqoZ4pwdvnl7hog7CMXghFRIUNswrEHlqVseY0y/EWfSpL2tBja4x3rzY785WtqvcrXzinygEkHAvtwmJPNTdMys9iQPZcS/7pNOytREqUXPcLBfRiaxbV/BJNeRCzCE6jsQv1GAG1beHySs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352668; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UNKgVV/wXkTDvg8p/RE2Zx3f5TGpx7KpGUcSvb+K8Qk=; b=iGk4MMWVdXN6MBudJxgnmwX/ef71prg+Fz2NFzt8pRzLmmQPTghwBYg3atkHPkRFzt3Hol/lXo16sm3qEq0wTfKEzLj8bEK4p2ml43voAP9ujDjuaBvMEkFzaN4yjwCUY4JZyibEzrES6qtX+PblXVvzX/jnu0gH4p3Zzn52f1Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352668444821.2098705690349; Tue, 7 Nov 2023 02:24:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J8Z-0000us-IF; Tue, 07 Nov 2023 05:16:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J8X-0000hC-Sv for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:16:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J8T-0003dr-8W for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:16:45 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-CG696xNKMR-u9EvhZXrAKA-1; Tue, 07 Nov 2023 05:16:20 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-408f9cee5e8so35155275e9.0 for ; Tue, 07 Nov 2023 02:16:20 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id fc13-20020a05600c524d00b004068de50c64sm15358374wmb.46.2023.11.07.02.11.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352200; h=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=UNKgVV/wXkTDvg8p/RE2Zx3f5TGpx7KpGUcSvb+K8Qk=; b=J0G9547spEgzqRdGmszhrKd1Ugec7KhJiyL8Tf4+1we0kjZ3ip6fhqZct8BrwqmI+zK8zj BeM1TjRGjypOhFWBxeBpgk9kxz+f2MYXE3dwiVhjCSXX9sDbZ6X/QEebpD6wR9hsUW5TNF 3XtAD+SU++LCTXuKm2Yu2Bg6jqI+PkA= X-MC-Unique: CG696xNKMR-u9EvhZXrAKA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351874; x=1699956674; 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=UNKgVV/wXkTDvg8p/RE2Zx3f5TGpx7KpGUcSvb+K8Qk=; b=fNcVNNrsqy8SlUafb1MPhw2DxpElIHZ4WSSM5jR880SYMDWsR94+QbhBoRlLakdugz zsDzQZE6u2oQcOjrS4wKI0NprGcDNybRCxCA+5wF7Gghj/xEiTBcC95Gi2LYDRFiqmhI JHLXXzlY4ySPyQ8GV2SgaKsGmOuLw3XbYVEWNZ6SVsWt4Oncxownhrxah3ydhIv+deBt dpkZkkmG4njLi605BrSeB0M8S9HZo5Akn7UkP3MAZCw/rgZhzLUHrJUtwrgIyen74JlQ w8k7lMnajht6+ZiO8Hcv9qeR3ZfjDuHg44VDSwZeXDv9FwMk+X0Q4YXeVwGvHKCC3xtm 87Bw== X-Gm-Message-State: AOJu0YzVEJLJyWl4eFo5S7PHd2nwb+hshwhQXoPgZ1sIeumMVfTEbfsN gQs4ulbpHhjb1HycumDbKyIZQsWKXW2fYMyHoKaDdTZajonhF/79xcQFFYLYi4aJUnnxiWgC0Ad I1xPhRPMZn3HmaIcURWu9glgKAibuOSUZTpRojoCHriWRxZmfeBBkPPMrx8wv6fbhazcr X-Received: by 2002:a05:600c:1c81:b0:405:37bb:d942 with SMTP id k1-20020a05600c1c8100b0040537bbd942mr1893411wms.4.1699351874242; Tue, 07 Nov 2023 02:11:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEh1DBQy7P1tILj5m5O3Ch3CInT8NzIJfYCOvQgWZSkGu5SCXFXrTlvzZaSJ0PvRZ/85xHSYQ== X-Received: by 2002:a05:600c:1c81:b0:405:37bb:d942 with SMTP id k1-20020a05600c1c8100b0040537bbd942mr1893394wms.4.1699351873954; Tue, 07 Nov 2023 02:11:13 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:10 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Eugenio =?utf-8?B?UMOpcmV6?= , Jason Wang Subject: [PULL 23/63] vdpa: Allow VIRTIO_NET_F_RSS in SVQ Message-ID: <07eba9493d14b3ba371e64392effc384246892ea.1699351720.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352670096100011 From: Hawkins Jiawei Enable SVQ with VIRTIO_NET_F_RSS feature. Signed-off-by: Hawkins Jiawei Message-Id: <626449eb303207de408126b3dc7c155cd72b028b.1698195059.git.yin311= 49@gmail.com> Acked-by: Eugenio P=C3=A9rez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index a4cc1381fc..d0614d7954 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -122,6 +122,7 @@ static const uint64_t vdpa_svq_device_features =3D /* VHOST_F_LOG_ALL is exposed by SVQ */ BIT_ULL(VHOST_F_LOG_ALL) | BIT_ULL(VIRTIO_NET_F_HASH_REPORT) | + BIT_ULL(VIRTIO_NET_F_RSS) | BIT_ULL(VIRTIO_NET_F_RSC_EXT) | BIT_ULL(VIRTIO_NET_F_STANDBY) | BIT_ULL(VIRTIO_NET_F_SPEED_DUPLEX); --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351899; cv=none; d=zohomail.com; s=zohoarc; b=cY62Ub7Q/qBdfkcep0Sno9MzZFn9eqV3D5xU2nfD1+C4UWnG95XeQMrdivapC8zWIvr5ASNaoaD1u/YZo+FgyUWJg1Iee/w7sph6yXwNhJ4iKhsTHUuW75gvgJuOx5Kh8zHJUTsj/bjMnBKel9pODC8z35RemlmrKeZNORB7ipk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351899; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Qifpv3aNAIEISwFz81bmMK6pnQ3IauyLXcDLRV+33ZY=; b=Ax7ZyHqh/VjckRQ9Rr40rOHC/xyq6cO/j3/dKN+rI3x51FyC7gY3a3WENy2hPim9LVtP6JVBxZg2ZnfUig/I8Du1kFuAErxv8WDsxdCHTAyrjx6T5SmIWM1y/ATykiokyS0/NlEfG2pSEaZksFWxFpNaxw9FQgv4LNRpsChcxQk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699351899323951.5418354804921; Tue, 7 Nov 2023 02:11:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J3P-0005n9-Ff; Tue, 07 Nov 2023 05:11:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3N-0005gl-PY for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3L-0002YT-Px for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:25 -0500 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-185-J603MWHLN_eUFY9kNcdLSg-1; Tue, 07 Nov 2023 05:11:21 -0500 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-5079fe7cc7cso6345354e87.2 for ; Tue, 07 Nov 2023 02:11:21 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id y11-20020adff6cb000000b0032fc609c118sm1903923wrp.66.2023.11.07.02.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351883; h=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=Qifpv3aNAIEISwFz81bmMK6pnQ3IauyLXcDLRV+33ZY=; b=ZqQzk+0yphGquV04jz+Yy+Gbz49oWai1W3Rac7EhliSyE89TawJP4FWToy7bzLd2SZzK7t 9Xz6onJtwojcYZSV+ZjlKLp1yoHJWDAs5K49MsIn+C/o0CVtHCD4Im5Ty6NSDuzp/A/+LQ uu7tmwwP2ougpa071Sfn2kek3zZY9yk= X-MC-Unique: J603MWHLN_eUFY9kNcdLSg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351880; x=1699956680; 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=Qifpv3aNAIEISwFz81bmMK6pnQ3IauyLXcDLRV+33ZY=; b=wIfGX3a0v8LEdqgxYHMq7UrvPYrGCqaNl0cIMyLHBf+iy/VnnHeOWQXhgMie/1tIuf eTQsgxm7MPTDm9u9VkZB64Aor/6kvslhy/YgXt8tIqs/uulUzmidp0azcI1YH38NyBYQ H3x95zsRiOSUtiNc7vk9et8RQUdmVipVa7tbYVWwzMBbxDWyo2NOzJjit88tekw+sSai iF66jXXWvgZVfMcA38mAJP6m0OR613qjqepMq3fE9pWtGnRIp8Xa9+zVX4oJ53d3pdtk hz9bw0PW+Fot4aGJ86C//1TUH9+eSBQ2SqdRzq055ZCCSH2CK9yQDDxXzb095S6mYYxc m91w== X-Gm-Message-State: AOJu0Yz3kZcHZe4iCZQz+jFPdSWHf/OxqixnYhR+rTpIIpJj4l8mZm+h a7N86GCl0WzDvKFc1abG0hRYHojcckFUcl2IR+RbAjdccgjV+P1L0TAYHmYuRH0eaddcnzW1QA+ 3YbPfZtoJxJs4HkOhuHxwRokZRhi+3lD8lh437i4YZ4juHnrwoJ/KsSDVUQUWa17xs7TO X-Received: by 2002:a05:6512:10cb:b0:507:aaa9:b080 with SMTP id k11-20020a05651210cb00b00507aaa9b080mr29451571lfg.33.1699351879780; Tue, 07 Nov 2023 02:11:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSElT1kUkwKGt/kI8dyERyAqtlAgTjfSVgxPFPgtIPbAkSwBdEENHz1nGQUqDAv+gzMIDhkg== X-Received: by 2002:a05:6512:10cb:b0:507:aaa9:b080 with SMTP id k11-20020a05651210cb00b00507aaa9b080mr29451542lfg.33.1699351879472; Tue, 07 Nov 2023 02:11:19 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:14 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Eduardo Habkost , Marcel Apfelbaum , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Yanan Wang Subject: [PULL 24/63] tests: test-smp-parse: Add the test for cores/threads per socket helpers Message-ID: <7d5936791ea349d9cef856babcce28470966bfa4.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351900240100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu Use the different ways to calculate cores/threads per socket, so that the new CPU topology levels won't be missed in these 2 helpes: * machine_topo_get_cores_per_socket() * machine_topo_get_threads_per_socket() Test the commit a1d027be95bc3 ("machine: Add helpers to get cores/ threads per socket"). Suggested-by: Igor Mammedov Signed-off-by: Zhao Liu Acked-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-2-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/unit/test-smp-parse.c | 67 ++++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/tests/unit/test-smp-parse.c b/tests/unit/test-smp-parse.c index fdc39a846c..24972666a7 100644 --- a/tests/unit/test-smp-parse.c +++ b/tests/unit/test-smp-parse.c @@ -394,20 +394,47 @@ static char *smp_config_to_string(const SMPConfigurat= ion *config) config->has_maxcpus ? "true" : "false", config->maxcpus); } =20 -static char *cpu_topology_to_string(const CpuTopology *topo) +/* Use the different calculation than machine_topo_get_threads_per_socket(= ). */ +static unsigned int cpu_topology_get_threads_per_socket(const CpuTopology = *topo) +{ + /* Check the divisor to avoid invalid topology examples causing SIGFPE= . */ + if (!topo->sockets) { + return 0; + } else { + return topo->max_cpus / topo->sockets; + } +} + +/* Use the different calculation than machine_topo_get_cores_per_socket().= */ +static unsigned int cpu_topology_get_cores_per_socket(const CpuTopology *t= opo) +{ + /* Check the divisor to avoid invalid topology examples causing SIGFPE= . */ + if (!topo->threads) { + return 0; + } else { + return cpu_topology_get_threads_per_socket(topo) / topo->threads; + } +} + +static char *cpu_topology_to_string(const CpuTopology *topo, + unsigned int threads_per_socket, + unsigned int cores_per_socket) { return g_strdup_printf( "(CpuTopology) {\n" - " .cpus =3D %u,\n" - " .sockets =3D %u,\n" - " .dies =3D %u,\n" - " .clusters =3D %u,\n" - " .cores =3D %u,\n" - " .threads =3D %u,\n" - " .max_cpus =3D %u,\n" + " .cpus =3D %u,\n" + " .sockets =3D %u,\n" + " .dies =3D %u,\n" + " .clusters =3D %u,\n" + " .cores =3D %u,\n" + " .threads =3D %u,\n" + " .max_cpus =3D %u,\n" + " .threads_per_socket =3D %u,\n" + " .cores_per_socket =3D %u,\n" "}", topo->cpus, topo->sockets, topo->dies, topo->clusters, - topo->cores, topo->threads, topo->max_cpus); + topo->cores, topo->threads, topo->max_cpus, + threads_per_socket, cores_per_socket); } =20 static void check_parse(MachineState *ms, const SMPConfiguration *config, @@ -415,14 +442,26 @@ static void check_parse(MachineState *ms, const SMPCo= nfiguration *config, bool is_valid) { g_autofree char *config_str =3D smp_config_to_string(config); - g_autofree char *expect_topo_str =3D cpu_topology_to_string(expect_top= o); - g_autofree char *output_topo_str =3D NULL; + g_autofree char *expect_topo_str =3D NULL, *output_topo_str =3D NULL; + unsigned int expect_threads_per_socket, expect_cores_per_socket; + unsigned int ms_threads_per_socket, ms_cores_per_socket; Error *err =3D NULL; =20 + expect_threads_per_socket =3D + cpu_topology_get_threads_per_socket(expect_topo); + expect_cores_per_socket =3D + cpu_topology_get_cores_per_socket(expect_topo); + expect_topo_str =3D cpu_topology_to_string(expect_topo, + expect_threads_per_socket, + expect_cores_per_socket); + /* call the generic parser */ machine_parse_smp_config(ms, config, &err); =20 - output_topo_str =3D cpu_topology_to_string(&ms->smp); + ms_threads_per_socket =3D machine_topo_get_threads_per_socket(ms); + ms_cores_per_socket =3D machine_topo_get_cores_per_socket(ms); + output_topo_str =3D cpu_topology_to_string(&ms->smp, ms_threads_per_so= cket, + ms_cores_per_socket); =20 /* when the configuration is supposed to be valid */ if (is_valid) { @@ -433,7 +472,9 @@ static void check_parse(MachineState *ms, const SMPConf= iguration *config, (ms->smp.clusters =3D=3D expect_topo->clusters) && (ms->smp.cores =3D=3D expect_topo->cores) && (ms->smp.threads =3D=3D expect_topo->threads) && - (ms->smp.max_cpus =3D=3D expect_topo->max_cpus)) { + (ms->smp.max_cpus =3D=3D expect_topo->max_cpus) && + (ms_threads_per_socket =3D=3D expect_threads_per_socket) && + (ms_cores_per_socket =3D=3D expect_cores_per_socket)) { return; } =20 --=20 MST From nobody Fri May 17 12:13:02 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352211; cv=none; d=zohomail.com; s=zohoarc; b=DHG+0dqPPrfAabX94ype8YfWjpb9fP1jsCyDW57NXbjm+LEqOq0gBKs6FODLKY/o+hua2t3nwJT8km4+l+s3hZnFzKuUjpIlqBhNeZVZ28Ho0a10nviyygw0QAqS7jy/xLXXfGKEfmfTBE1OLL3/JG2POkQIsrfuKPbVHJ3Lu6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352211; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PBJ1uvthAaidklul8YgcRjJtzKSz6MO46xKoN4oXPb0=; b=K26vn7yUzpQFwtUOy7Y0YIoQv6EVyixwvJd+4apjtL3B9HCRvX+NEqJS0bQAlsSztIqrrKfaAn0g+dKsqsT8Unc95XM+o5Qsx+kBPLp0XsGTkF9+1tW7aCUeUrJhdBTRPDcZ+9eL9dG26jDR5c361QZVTcUkmC9s+P60UPO1DJQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169935221180224.214978693352464; Tue, 7 Nov 2023 02:16:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J3i-0006ha-S0; Tue, 07 Nov 2023 05:11:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3e-0006Ts-Nh for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3c-0002aQ-Hz for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:42 -0500 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-642-WpNppxxkMiqzUJj9mOUDRg-1; Tue, 07 Nov 2023 05:11:26 -0500 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2c6f3cd892cso55321961fa.3 for ; Tue, 07 Nov 2023 02:11:26 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id o25-20020a1c7519000000b003fe1c332810sm14788257wmc.33.2023.11.07.02.11.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351899; h=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=PBJ1uvthAaidklul8YgcRjJtzKSz6MO46xKoN4oXPb0=; b=TQFIvvYncfZwsl1PBa5ymPPcpEZI3WP3zGcaigxKAKXubRYoCKg/RRsq17UhiBK0v1pB+C yBGryrM70ha4g2anl+LN9XvAhHcfEGek8Q+eSW5nuloXNl6zLxYL3P8yd/FnVP9svY7qfG wG9XQwOsatLPoXace31A1uOMxyOiD6E= X-MC-Unique: WpNppxxkMiqzUJj9mOUDRg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351884; x=1699956684; 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=PBJ1uvthAaidklul8YgcRjJtzKSz6MO46xKoN4oXPb0=; b=S8h72Epcew9PKnexq246OS5Omov0PMCMwCuWmY7gUARWToUYGk25RqH365H/J9UaWq wuVamJZxaApCxeAELcSYkiasjVDz+R78Na0EokoHaU1nEibud+LW7eimPSz4DkdLJd7c 2wOm720IyVH/C4vuH+fEQYDHBcYet2ASY+nQv8s3wDKWdpAZx1RacU4O7FI20E2td2Au 8Xs0uLKKsaWaNLN66xU7fiCLwWW4T6UmtgsCujyJt6/uswhmU3OveUDl0eeU4zl0oaOq sJpEAgu/9mdBL665X61P54k2nnRqTfOrMNo1zR7H/bByca0Z55nvObBB+G4WxbImMZ7h jtWw== X-Gm-Message-State: AOJu0Yw6LwhsRX0YKAOSJtpwiOF8gh4UsLYC+ouAyAlSqvRZc+ap+/tj xrKGI9t1jkPHiDAu9eUcPgYiuRpbAu//058EJGom1CCzP/vWHGDDiTIXl4/VNiBiVEBHbSw8oPA ttGd0UuH79Tc2ZgPY8KFSdoqyKClRZNe/ObNXglKWupjj21NLtzfWEboRB6z9hD9RkaEZ X-Received: by 2002:a2e:9f08:0:b0:2bc:dab2:c7dc with SMTP id u8-20020a2e9f08000000b002bcdab2c7dcmr25059254ljk.47.1699351884732; Tue, 07 Nov 2023 02:11:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjw9m3AgwD6wZwF8oH05VhBUEFtHKe7rSQmmq+vlleANiygt3MkLv5AskmeU2LkcdPgNGTog== X-Received: by 2002:a2e:9f08:0:b0:2bc:dab2:c7dc with SMTP id u8-20020a2e9f08000000b002bcdab2c7dcmr25059220ljk.47.1699351884081; Tue, 07 Nov 2023 02:11:24 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:20 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 25/63] tests: bios-tables-test: Prepare the ACPI table change for smbios type4 count test Message-ID: <6c7937ece909d3df0d2b4e94909f57388f5ed666.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352212443100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu Following the guidelines in tests/qtest/bios-tables-test.c, this is step 1 - 3. List the ACPI tables that will be added to test the type 4 count. Signed-off-by: Zhao Liu Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-3-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 3 +++ tests/data/acpi/q35/APIC.type4-count | 0 tests/data/acpi/q35/DSDT.type4-count | 0 tests/data/acpi/q35/FACP.type4-count | 0 4 files changed, 3 insertions(+) create mode 100644 tests/data/acpi/q35/APIC.type4-count create mode 100644 tests/data/acpi/q35/DSDT.type4-count create mode 100644 tests/data/acpi/q35/FACP.type4-count diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..0ce6f8fc72 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,4 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/APIC.type4-count", +"tests/data/acpi/q35/DSDT.type4-count", +"tests/data/acpi/q35/FACP.type4-count", diff --git a/tests/data/acpi/q35/APIC.type4-count b/tests/data/acpi/q35/API= C.type4-count new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/DSDT.type4-count b/tests/data/acpi/q35/DSD= T.type4-count new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/FACP.type4-count b/tests/data/acpi/q35/FAC= P.type4-count new file mode 100644 index 0000000000..e69de29bb2 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352482; cv=none; d=zohomail.com; s=zohoarc; b=JQaxFFM5dKiLRCl5cExeRkXsE4tv+pJBRDNIjodXnN5SOX3pvWNwtblUc1gXT1IxenbzFqU+sz95l2VEBEXpTNoCacco9+q6E82jLK1a4XuKqpX4ZbUF6kqJZTsOIlx6DpLR9/bwlgp6+t7EnHlchuuXF68bbrYc1WH9cxAskPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352482; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CRVMMBpST4bseQtoU4pWaih3l68nE594eAbjKTnyT28=; b=TTGH55J3KmRm0NlGW1cJMVU/gAqtBftwj5a+fElPOytY2gvp/uzo8jS/Ol5RVG8vX5EmJl4i9k3g48ZRdnZ7weWtKbxM7utbW9MUaZq34v3geQd0G8lRAz7XwL6Ft0TLhv9cQ59HLJ6RYTHO+v8Jy+lWUPH9AL244uuJJaozAZ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169935248266738.34483501293846; Tue, 7 Nov 2023 02:21:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J3Y-0005uj-4O; Tue, 07 Nov 2023 05:11:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3X-0005uR-Fx for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3V-0002ZU-5M for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:35 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-152-FiIzqPeEMz-3ZVZ03_Ff5A-1; Tue, 07 Nov 2023 05:11:30 -0500 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-53e26bbbc63so4058441a12.3 for ; Tue, 07 Nov 2023 02:11:30 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id c12-20020a05600c0a4c00b0040775501256sm15419124wmq.16.2023.11.07.02.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351892; h=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=CRVMMBpST4bseQtoU4pWaih3l68nE594eAbjKTnyT28=; b=F/Z55H1LZlWkJw8e3AYFoa2oKJd7ahDRxXzEMzw1AIBvzCiflce4MhHqE1ocSyU2qsezBJ xg2Q5Q1BWTEZymrEvZ1TXezXKbKwzGXd4bI5SbY71IoZD2RsCx5dAnVBpt5fvv0jqYV1ZN PPZRZbhSf4vGhpFQ4aSknJu7wtl0LQE= X-MC-Unique: FiIzqPeEMz-3ZVZ03_Ff5A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351888; x=1699956688; 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=CRVMMBpST4bseQtoU4pWaih3l68nE594eAbjKTnyT28=; b=a41fr6JOZiN+7pbDKAB55u0VmG/MiCgi1Syg73gRuQGftep07pIhgckg6duVCurI1J a0IqIjANmuoO8TqUG1BdOpmVkTRK2UL+3HBRZ3gKG5cNee+9J1kaoSrP5fhLPSy2SooR 7P4Gfv+oidV81picZ6l5/1wsWcjSGRqg7+XkamUTmv1O9NRd7lraa4wcu/AI5FNZWjlD FNnZX4IYfSt8Lufjy0HG1XfaU8k5XT9EQchkrbLrGAO3ecFUazJM4pxhnZEC8GNGAFaj WrjLOdyQ9VwwtaliqysVWh7uQSLvKOidbbUtebHmA+dnAgQhECh5i0CsXxN/qbieBGrW +sWg== X-Gm-Message-State: AOJu0YxlhPij0/p2eHo9+du/C5wxU3LN82wPT9VT+pjwT6NCu1oqrDte 5aMnvF1hGwugsVedaDKWOWyKgD9/lF1S0/hVEFjBefyCKtluRUGw7pKngCC586xeQx7JbyCGcEp u0qhfTdLN0d24PHr5Dw9Nx4RZvMEzLNishsUcdHWcv06bPftlNQBP3OaB8QGZPdtdaBC3 X-Received: by 2002:a17:906:db01:b0:9b2:a96c:9290 with SMTP id xj1-20020a170906db0100b009b2a96c9290mr13620548ejb.33.1699351888118; Tue, 07 Nov 2023 02:11:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEvjHJCLuFVxx+/iMtwTma9hBIDlqqCIkO3OUcajw7LY+3vjakpl5vz5MLpJg+SkZGaTYapBA== X-Received: by 2002:a17:906:db01:b0:9b2:a96c:9290 with SMTP id xj1-20020a170906db0100b009b2a96c9290mr13620533ejb.33.1699351887813; Tue, 07 Nov 2023 02:11:27 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:24 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 26/63] tests: bios-tables-test: Add test for smbios type4 count 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352484392100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu This tests the commit d79a284a44bb7 ("hw/smbios: Fix smbios_smp_sockets calculation"). In smbios_get_tables() (hw/smbios/smbios.c), smbios type4 table is built for each socket, so the count of type4 tables should be equal to the number of sockets. Thus for the topology in this case, there're the following considerations: 1. The topology should include multiple sockets to ensure smbios could create type4 tables for each socket. 2. In addition to sockets, for the more general topology, we should also configure as many topology levels as possible (multiple dies, no module since x86 hasn't supported it), to ensure that smbios is able to exclude the effect of other topology levels to create the type4 tables only for sockets. 3. The original miscalculation bug also misused "smp.cpus", so it's necessary to configure "cpus" (presented threads for machine) and "maxcpus" (total threads for machine) as well to make sure that configuring unpluged CPUs in smp (cpus < maxcpus) does not affect the correctness of the count of type4 tables. Based on these considerations, select the topology as the follow: -smp cpus=3D100,maxcpus=3D120,sockets=3D5,dies=3D2,cores=3D4,threads=3D3 The expected count of type4 tables =3D sockets (5). Suggested-by: Igor Mammedov Signed-off-by: Zhao Liu Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-4-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index 9f4bc15aab..cdbfb51559 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -97,6 +97,7 @@ typedef struct { uint16_t smbios_core_count2; uint8_t *required_struct_types; int required_struct_types_len; + int type4_count; QTestState *qts; } test_data; =20 @@ -673,12 +674,21 @@ static void smbios_cpu_test(test_data *data, uint32_t= addr, } } =20 +static void smbios_type4_count_test(test_data *data, int type4_count) +{ + int expected_type4_count =3D data->type4_count; + + if (expected_type4_count) { + g_assert_cmpuint(type4_count, =3D=3D, expected_type4_count); + } +} + static void test_smbios_structs(test_data *data, SmbiosEntryPointType ep_t= ype) { DECLARE_BITMAP(struct_bitmap, SMBIOS_MAX_TYPE+1) =3D { 0 }; =20 SmbiosEntryPoint *ep_table =3D &data->smbios_ep_table; - int i =3D 0, len, max_len =3D 0; + int i =3D 0, len, max_len =3D 0, type4_count =3D 0; uint8_t type, prv, crt; uint64_t addr; =20 @@ -704,6 +714,7 @@ static void test_smbios_structs(test_data *data, Smbios= EntryPointType ep_type) =20 if (type =3D=3D 4) { smbios_cpu_test(data, addr, ep_type); + type4_count++; } =20 /* seek to end of unformatted string area of this struct ("\0\0") = */ @@ -747,6 +758,8 @@ static void test_smbios_structs(test_data *data, Smbios= EntryPointType ep_type) for (i =3D 0; i < data->required_struct_types_len; i++) { g_assert(test_bit(data->required_struct_types[i], struct_bitmap)); } + + smbios_type4_count_test(data, type4_count); } =20 static void test_acpi_load_tables(test_data *data) @@ -970,6 +983,22 @@ static void test_acpi_q35_tcg(void) free_test_data(&data); } =20 +static void test_acpi_q35_tcg_type4_count(void) +{ + test_data data =3D { + .machine =3D MACHINE_Q35, + .variant =3D ".type4-count", + .required_struct_types =3D base_required_struct_types, + .required_struct_types_len =3D ARRAY_SIZE(base_required_struct_typ= es), + .type4_count =3D 5, + }; + + test_acpi_one("-machine smbios-entry-point-type=3D64 " + "-smp cpus=3D100,maxcpus=3D120,sockets=3D5," + "dies=3D2,cores=3D4,threads=3D3", &data); + free_test_data(&data); +} + static void test_acpi_q35_tcg_core_count2(void) { test_data data =3D { @@ -2147,6 +2176,8 @@ int main(int argc, char *argv[]) if (has_kvm) { qtest_add_func("acpi/q35/kvm/xapic", test_acpi_q35_kvm_xap= ic); qtest_add_func("acpi/q35/kvm/dmar", test_acpi_q35_kvm_dmar= ); + qtest_add_func("acpi/q35/type4-count", + test_acpi_q35_tcg_type4_count); qtest_add_func("acpi/q35/core-count2", test_acpi_q35_tcg_core_count2); } --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699351941; cv=none; d=zohomail.com; s=zohoarc; b=Da3NLRdMietLBa+xmEB6X3AGJcDpxY2oZeIW8XPMxpD7p/XkZKLoHFygNVhQNAvj9HzNWza+/6NTZ5OrdBb/WdOhHJDGXIGz+KLtkFaStAcwinQCj3UIP/H96HAknE6uABB4P3HcCGqDj52VioMMHSjyKkRXyfj1MeQUGddtFq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699351941; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZA8HxfNJ/qF8EPsW/eamPz9nmKDmKxImdkjGTeQ8Jzg=; b=f2tlhMcgZBUZToW5dJ8/yvh7Amtu/ol0krJrzOtdN0BzSJ+eJDZ8T9BvocAYGagdT+15umW0uQ0nRrcGNkvHR+G7Z1TSohga366HOHZ6TKBpiHRi5be1GWZv9BSUcC0rxgJSo6wlz6iUgvMYCu67q3sSF/AOT7nmG+eKVRcOg9A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699351941323531.2607602382635; Tue, 7 Nov 2023 02:12:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J3g-0006Z8-9b; Tue, 07 Nov 2023 05:11:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3c-0006Ne-NU for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3Z-0002aB-4Q for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:40 -0500 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-75-FLCBMPCbNUOvaNLfdXef3g-1; Tue, 07 Nov 2023 05:11:35 -0500 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2c131ddfcfaso53403291fa.1 for ; Tue, 07 Nov 2023 02:11:34 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id 10-20020a05600c230a00b004068495910csm15227196wmo.23.2023.11.07.02.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351896; h=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=ZA8HxfNJ/qF8EPsW/eamPz9nmKDmKxImdkjGTeQ8Jzg=; b=UIS3bElEtTWKGoDBdDFdchQtBidgfmKMh5e8N4Bm1njNMjqCfh6pm2V++8bjrPyQr09kXd YctjItva4KXv5cId1YLs/XHiP2ALVjYsebALmWwxfm+QXy7woPHRVqokchQjxk7HPMlSN2 ICS2eo+VBXbfWHFAYm/Zg3r/lDng4C4= X-MC-Unique: FLCBMPCbNUOvaNLfdXef3g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351893; x=1699956693; 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=ZA8HxfNJ/qF8EPsW/eamPz9nmKDmKxImdkjGTeQ8Jzg=; b=HFwbraI075F0wqR1FC30t+0Myd6jFu/G+SdcYT2iHpkkNWYkI/osKASo3yUjNL7tiz a2X81GQFqOha4j6iANxyUYRZtWEbbGQ70g1zG24g8908hqgYDhMK2OxIkSoi4/gLXakw 2Rdf/XfWSWWVaZm5pA1/NdmSHhiAGM2mRTtelkGUw3Dixd2pyCGGFRcCfTydRKYIaaRB nOK6D2z0wJCyes2mS98N5S14u8E9U74oHmJ83FZwXdvmlkPslN/MUHzlIvIctoFeT0ka JH3LU6EhVCeaVXQ7DsWODdqxaYYsib44zl83ZRxdgbAzxMKZ38vZaM4WirUD6jRwP8sq TESw== X-Gm-Message-State: AOJu0YwLhmCk2DsGFC6T2GD/BnVDbI/hRkjMOFv8ueJY/fbZI8BJ3V4e cJRDykoUZ3KJQpCB9IHez3VQ2U9vK7aK0dtgyfFE3WMVVtUsxwS6zFFORGhbOAJJRSvK8bd7USJ n4ME21wsmMJe2+t1sDz1W/H8DqDx8k02CTFuwy2gcVPkkt4gs5nTURYX9V+6pasY3kOA6 X-Received: by 2002:a05:651c:221c:b0:2bc:dcdb:b5dc with SMTP id y28-20020a05651c221c00b002bcdcdbb5dcmr30513091ljq.39.1699351892558; Tue, 07 Nov 2023 02:11:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5G1YfgMDZa35MUsL6kFGBui62qFFj2JlLM8rDA+LjUzFovCBFLhl3qnXi1FYM74t3GLEtfA== X-Received: by 2002:a05:651c:221c:b0:2bc:dcdb:b5dc with SMTP id y28-20020a05651c221c00b002bcdcdbb5dcmr30513062ljq.39.1699351892002; Tue, 07 Nov 2023 02:11:32 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 27/63] tests: bios-tables-test: Add ACPI table binaries for smbios type4 count test 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699351943433100004 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu Following the guidelines in tests/qtest/bios-tables-test.c, this is step 5 and 6. Changes in the tables: FACP: +/* + * Intel ACPI Component Architecture + * AML/ASL+ Disassembler version 20200925 (64-bit version) + * Copyright (c) 2000 - 2020 Intel Corporation + * + * Disassembly of /tmp/aml-W37791, Wed Aug 23 10:36:32 2023 + * + * ACPI Data Table [FACP] + * + * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue + */ + +[000h 0000 4] Signature : "FACP" [Fixed ACPI Descr= iption Table (FADT)] +[004h 0004 4] Table Length : 000000F4 +[008h 0008 1] Revision : 03 +[009h 0009 1] Checksum : B3 +[00Ah 0010 6] Oem ID : "BOCHS " +[010h 0016 8] Oem Table ID : "BXPC " +[018h 0024 4] Oem Revision : 00000001 +[01Ch 0028 4] Asl Compiler ID : "BXPC" +[020h 0032 4] Asl Compiler Revision : 00000001 + +[024h 0036 4] FACS Address : 00000000 +[028h 0040 4] DSDT Address : 00000000 +[02Ch 0044 1] Model : 01 +[02Dh 0045 1] PM Profile : 00 [Unspecified] +[02Eh 0046 2] SCI Interrupt : 0009 +[030h 0048 4] SMI Command Port : 000000B2 +[034h 0052 1] ACPI Enable Value : 02 +[035h 0053 1] ACPI Disable Value : 03 +[036h 0054 1] S4BIOS Command : 00 +[037h 0055 1] P-State Control : 00 +[038h 0056 4] PM1A Event Block Address : 00000600 +[03Ch 0060 4] PM1B Event Block Address : 00000000 +[040h 0064 4] PM1A Control Block Address : 00000604 +[044h 0068 4] PM1B Control Block Address : 00000000 +[048h 0072 4] PM2 Control Block Address : 00000000 +[04Ch 0076 4] PM Timer Block Address : 00000608 +[050h 0080 4] GPE0 Block Address : 00000620 +[054h 0084 4] GPE1 Block Address : 00000000 +[058h 0088 1] PM1 Event Block Length : 04 +[059h 0089 1] PM1 Control Block Length : 02 +[05Ah 0090 1] PM2 Control Block Length : 00 +[05Bh 0091 1] PM Timer Block Length : 04 +[05Ch 0092 1] GPE0 Block Length : 10 +[05Dh 0093 1] GPE1 Block Length : 00 +[05Eh 0094 1] GPE1 Base Offset : 00 +[05Fh 0095 1] _CST Support : 00 +[060h 0096 2] C2 Latency : 0FFF +[062h 0098 2] C3 Latency : 0FFF +[064h 0100 2] CPU Cache Size : 0000 +[066h 0102 2] Cache Flush Stride : 0000 +[068h 0104 1] Duty Cycle Offset : 00 +[069h 0105 1] Duty Cycle Width : 00 +[06Ah 0106 1] RTC Day Alarm Index : 00 +[06Bh 0107 1] RTC Month Alarm Index : 00 +[06Ch 0108 1] RTC Century Index : 32 +[06Dh 0109 2] Boot Flags (decoded below) : 0002 + Legacy Devices Supported (V2) : 0 + 8042 Present on ports 60/64 (V2) : 1 + VGA Not Present (V4) : 0 + MSI Not Supported (V4) : 0 + PCIe ASPM Not Supported (V4) : 0 + CMOS RTC Not Present (V5) : 0 +[06Fh 0111 1] Reserved : 00 +[070h 0112 4] Flags (decoded below) : 000484A5 + WBINVD instruction is operational (V1) : 1 + WBINVD flushes all caches (V1) : 0 + All CPUs support C1 (V1) : 1 + C2 works on MP system (V1) : 0 + Control Method Power Button (V1) : 0 + Control Method Sleep Button (V1) : 1 + RTC wake not in fixed reg space (V1) : 0 + RTC can wake system from S4 (V1) : 1 + 32-bit PM Timer (V1) : 0 + Docking Supported (V1) : 0 + Reset Register Supported (V2) : 1 + Sealed Case (V3) : 0 + Headless - No Video (V3) : 0 + Use native instr after SLP_TYPx (V3) : 0 + PCIEXP_WAK Bits Supported (V4) : 0 + Use Platform Timer (V4) : 1 + RTC_STS valid on S4 wake (V4) : 0 + Remote Power-on capable (V4) : 0 + Use APIC Cluster Model (V4) : 1 + Use APIC Physical Destination Mode (V4) : 0 + Hardware Reduced (V5) : 0 + Low Power S0 Idle (V5) : 0 + +[074h 0116 12] Reset Register : [Generic Address Structure] +[074h 0116 1] Space ID : 01 [SystemIO] +[075h 0117 1] Bit Width : 08 +[076h 0118 1] Bit Offset : 00 +[077h 0119 1] Encoded Access Width : 00 [Undefined/Legacy] +[078h 0120 8] Address : 0000000000000CF9 + +[080h 0128 1] Value to cause reset : 0F +[081h 0129 2] ARM Flags (decoded below) : 0000 + PSCI Compliant : 0 + Must use HVC for PSCI : 0 + +[083h 0131 1] FADT Minor Revision : 00 +[084h 0132 8] FACS Address : 0000000000000000 +[08Ch 0140 8] DSDT Address : 0000000000000000 +[094h 0148 12] PM1A Event Block : [Generic Address Structure] +[094h 0148 1] Space ID : 01 [SystemIO] +[095h 0149 1] Bit Width : 20 +[096h 0150 1] Bit Offset : 00 +[097h 0151 1] Encoded Access Width : 00 [Undefined/Legacy] +[098h 0152 8] Address : 0000000000000600 + +[0A0h 0160 12] PM1B Event Block : [Generic Address Structure] +[0A0h 0160 1] Space ID : 00 [SystemMemory] +[0A1h 0161 1] Bit Width : 00 +[0A2h 0162 1] Bit Offset : 00 +[0A3h 0163 1] Encoded Access Width : 00 [Undefined/Legacy] +[0A4h 0164 8] Address : 0000000000000000 + +[0ACh 0172 12] PM1A Control Block : [Generic Address Structure] +[0ACh 0172 1] Space ID : 01 [SystemIO] +[0ADh 0173 1] Bit Width : 10 +[0AEh 0174 1] Bit Offset : 00 +[0AFh 0175 1] Encoded Access Width : 00 [Undefined/Legacy] +[0B0h 0176 8] Address : 0000000000000604 + +[0B8h 0184 12] PM1B Control Block : [Generic Address Structure] +[0B8h 0184 1] Space ID : 00 [SystemMemory] +[0B9h 0185 1] Bit Width : 00 +[0BAh 0186 1] Bit Offset : 00 +[0BBh 0187 1] Encoded Access Width : 00 [Undefined/Legacy] +[0BCh 0188 8] Address : 0000000000000000 + +[0C4h 0196 12] PM2 Control Block : [Generic Address Structure] +[0C4h 0196 1] Space ID : 00 [SystemMemory] +[0C5h 0197 1] Bit Width : 00 +[0C6h 0198 1] Bit Offset : 00 +[0C7h 0199 1] Encoded Access Width : 00 [Undefined/Legacy] +[0C8h 0200 8] Address : 0000000000000000 + +[0D0h 0208 12] PM Timer Block : [Generic Address Structure] +[0D0h 0208 1] Space ID : 01 [SystemIO] +[0D1h 0209 1] Bit Width : 20 +[0D2h 0210 1] Bit Offset : 00 +[0D3h 0211 1] Encoded Access Width : 00 [Undefined/Legacy] +[0D4h 0212 8] Address : 0000000000000608 + +[0DCh 0220 12] GPE0 Block : [Generic Address Structure] +[0DCh 0220 1] Space ID : 01 [SystemIO] +[0DDh 0221 1] Bit Width : 80 +[0DEh 0222 1] Bit Offset : 00 +[0DFh 0223 1] Encoded Access Width : 00 [Undefined/Legacy] +[0E0h 0224 8] Address : 0000000000000620 + +[0E8h 0232 12] GPE1 Block : [Generic Address Structure] +[0E8h 0232 1] Space ID : 00 [SystemMemory] +[0E9h 0233 1] Bit Width : 00 +[0EAh 0234 1] Bit Offset : 00 +[0EBh 0235 1] Encoded Access Width : 00 [Undefined/Legacy] +[0ECh 0236 8] Address : 0000000000000000 + ... APIC: +/* + * Intel ACPI Component Architecture + * AML/ASL+ Disassembler version 20200925 (64-bit version) + * Copyright (c) 2000 - 2020 Intel Corporation + * + * Disassembly of /tmp/aml-687791, Wed Aug 23 10:36:32 2023 + * + * ACPI Data Table [APIC] + * + * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue + */ + +[000h 0000 4] Signature : "APIC" [Multiple APIC De= scription Table (MADT)] +[004h 0004 4] Table Length : 00000430 +[008h 0008 1] Revision : 03 +[009h 0009 1] Checksum : C5 +[00Ah 0010 6] Oem ID : "BOCHS " +[010h 0016 8] Oem Table ID : "BXPC " +[018h 0024 4] Oem Revision : 00000001 +[01Ch 0028 4] Asl Compiler ID : "BXPC" +[020h 0032 4] Asl Compiler Revision : 00000001 + +[024h 0036 4] Local Apic Address : FEE00000 +[028h 0040 4] Flags (decoded below) : 00000001 + PC-AT Compatibility : 1 + +[02Ch 0044 1] Subtable Type : 00 [Processor Local APIC] +[02Dh 0045 1] Length : 08 +[02Eh 0046 1] Processor ID : 00 +[02Fh 0047 1] Local Apic ID : 00 +[030h 0048 4] Flags (decoded below) : 00000001 + Processor Enabled : 1 + Runtime Online Capable : 0 + +[034h 0052 1] Subtable Type : 00 [Processor Local APIC] +[035h 0053 1] Length : 08 +[036h 0054 1] Processor ID : 01 +[037h 0055 1] Local Apic ID : 01 +[038h 0056 4] Flags (decoded below) : 00000001 + Processor Enabled : 1 + Runtime Online Capable : 0 [snip] +[3E4h 0996 1] Subtable Type : 00 [Processor Local APIC] +[3E5h 0997 1] Length : 08 +[3E6h 0998 1] Processor ID : 77 +[3E7h 0999 1] Local Apic ID : 9E +[3E8h 1000 4] Flags (decoded below) : 00000000 + Processor Enabled : 0 + Runtime Online Capable : 0 + +[3ECh 1004 1] Subtable Type : 01 [I/O APIC] +[3EDh 1005 1] Length : 0C +[3EEh 1006 1] I/O Apic ID : 00 +[3EFh 1007 1] Reserved : 00 +[3F0h 1008 4] Address : FEC00000 +[3F4h 1012 4] Interrupt : 00000000 + +[3F8h 1016 1] Subtable Type : 02 [Interrupt Source Overri= de] +[3F9h 1017 1] Length : 0A +[3FAh 1018 1] Bus : 00 +[3FBh 1019 1] Source : 00 +[3FCh 1020 4] Interrupt : 00000002 +[400h 1024 2] Flags (decoded below) : 0000 + Polarity : 0 + Trigger Mode : 0 + +[402h 1026 1] Subtable Type : 02 [Interrupt Source Overri= de] +[403h 1027 1] Length : 0A +[404h 1028 1] Bus : 00 +[405h 1029 1] Source : 05 +[406h 1030 4] Interrupt : 00000005 +[40Ah 1034 2] Flags (decoded below) : 000D + Polarity : 1 + Trigger Mode : 3 + +[40Ch 1036 1] Subtable Type : 02 [Interrupt Source Overri= de] +[40Dh 1037 1] Length : 0A +[40Eh 1038 1] Bus : 00 +[40Fh 1039 1] Source : 09 +[410h 1040 4] Interrupt : 00000009 +[414h 1044 2] Flags (decoded below) : 000D + Polarity : 1 + Trigger Mode : 3 + +[416h 1046 1] Subtable Type : 02 [Interrupt Source Overri= de] +[417h 1047 1] Length : 0A +[418h 1048 1] Bus : 00 +[419h 1049 1] Source : 0A +[41Ah 1050 4] Interrupt : 0000000A +[41Eh 1054 2] Flags (decoded below) : 000D + Polarity : 1 + Trigger Mode : 3 + +[420h 1056 1] Subtable Type : 02 [Interrupt Source Overri= de] +[421h 1057 1] Length : 0A +[422h 1058 1] Bus : 00 +[423h 1059 1] Source : 0B +[424h 1060 4] Interrupt : 0000000B +[428h 1064 2] Flags (decoded below) : 000D + Polarity : 1 + Trigger Mode : 3 + +[42Ah 1066 1] Subtable Type : 04 [Local APIC NMI] +[42Bh 1067 1] Length : 06 +[42Ch 1068 1] Processor ID : FF +[42Dh 1069 2] Flags (decoded below) : 0000 + Polarity : 0 + Trigger Mode : 0 +[42Fh 1071 1] Interrupt Input LINT : 01 + ... DSDT: +/* + * Intel ACPI Component Architecture + * AML/ASL+ Disassembler version 20200925 (64-bit version) + * Copyright (c) 2000 - 2020 Intel Corporation + * + * Disassembling to symbolic ASL+ operators + * + * Disassembly of /tmp/aml-8G8791, Wed Aug 23 10:36:32 2023 + * + * Original Table Header: + * Signature "DSDT" + * Length 0x0000489D (18589) + * Revision 0x01 **** 32-bit table (V1), no 64-bit math support + * Checksum 0xDB + * OEM ID "BOCHS " + * OEM Table ID "BXPC " + * OEM Revision 0x00000001 (1) + * Compiler ID "BXPC" + * Compiler Version 0x00000001 (1) + */ +DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001) +{ + Scope (\) + { + OperationRegion (DBG, SystemIO, 0x0402, One) + Field (DBG, ByteAcc, NoLock, Preserve) + { + DBGB, 8 + } + + Method (DBUG, 1, NotSerialized) + { + ToHexString (Arg0, Local0) + ToBuffer (Local0, Local0) + Local1 =3D (SizeOf (Local0) - One) + Local2 =3D Zero + While ((Local2 < Local1)) + { + DBGB =3D DerefOf (Local0 [Local2]) + Local2++ + } + + DBGB =3D 0x0A + } + } + [snip] + + Processor (C000, 0x00, 0x00000000, 0x00) + { + Method (_STA, 0, Serialized) // _STA: Status + { + Return (CSTA (Zero)) + } + + Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + { + 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 // .= ....... + }) + Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion + { + COST (Zero, Arg0, Arg1, Arg2) + } + } + + Processor (C001, 0x01, 0x00000000, 0x00) + { + Method (_STA, 0, Serialized) // _STA: Status + { + Return (CSTA (One)) + } + + Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + { + 0x00, 0x08, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00 // .= ....... + }) + Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device, x= =3D0-9 + { + CEJ0 (One) + } + + Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion + { + COST (One, Arg0, Arg1, Arg2) + } + } [snip] + Processor (C077, 0x77, 0x00000000, 0x00) + { + Method (_STA, 0, Serialized) // _STA: Status + { + Return (CSTA (0x77)) + } + + Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + { + 0x00, 0x08, 0x77, 0x9E, 0x01, 0x00, 0x00, 0x00 // .= .w..... + }) + Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device, x= =3D0-9 + { + CEJ0 (0x77) + } + + Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion + { + COST (0x77, Arg0, Arg1, Arg2) + } + } + } + } + ... Signed-off-by: Zhao Liu Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-5-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 3 --- tests/data/acpi/q35/APIC.type4-count | Bin 0 -> 1072 bytes tests/data/acpi/q35/DSDT.type4-count | Bin 0 -> 18589 bytes tests/data/acpi/q35/FACP.type4-count | Bin 0 -> 244 bytes 4 files changed, 3 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index 0ce6f8fc72..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,4 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/APIC.type4-count", -"tests/data/acpi/q35/DSDT.type4-count", -"tests/data/acpi/q35/FACP.type4-count", diff --git a/tests/data/acpi/q35/APIC.type4-count b/tests/data/acpi/q35/API= C.type4-count index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ab60a6ef065d8ce53ae93d311d3= 777d2d4afb9f6 100644 GIT binary patch literal 1072 zcmXxjX)mKu7{>9_YU}A{8~a-OZpzsAwwBgf>(n~-!C>rL5ClOG1VQjwyzxDJ5_Ev|p!(#Wi9Ts`1gb+$r6yp8Et0V-fRH#;?j|Meb z)apP55|BH3=3DGAfaQqR0!I2mejiE6Z7K`EDe+elf zo_%BjMkQf%GRCA}Y#PR;qa_35voIkW6LT=3DhipjZ{l834Jm{x%4g_u!{nI)K2irM9u zQ-MD#(OQkUHq5i*uNus+#ezC4bYhVUiyN?{2}_%?tOd*6SkZ=3D+?O4@`)m>=3DoM!N?c zJy_F=3Dwf$H(fc1mu975MHHjH577&eV#^8~g`V(S#Tr?G7Y+h?(34m;8of!Q`;?#f0%hq@0RR91 literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/DSDT.type4-count b/tests/data/acpi/q35/DSD= T.type4-count index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..edc23198cdb47a981bcbc82bc8e= 392b815abb554 100644 GIT binary patch literal 18589 zcmb81No*V0c804+N}`ICL`n1{%eE}fGfB;!$s#FI5@m{%JW)2O!M5a)9%Q$>+4U|Byj2$2yloJ?UOnfWdvDb}b*~J>UQquj zp7Wh^io+pqT{B%yPyZ%o80PO%m+V}*Cv~-G_rO2XFbvfAHnGGDhW6p``HYB^P{ ztmfN_c0LxY=3DJM%q@<%HetlC`pgVmXQ+K5gxRWFt8z}tIc6)auroFKdPY2fEkpT21wi2A|Pl)Zi@KH;lRZ9KW-&I-D*gZPs~9 zak3b*V{rqzFO}Q(Slz$aW*A{S<@oO(-@kwVuUs0DmquhFdJ<0_p18{EqFtUgL+`>? zu<|B?h7HGOdf+DAQ+Zv^jKM?o?_nzdj};nrDwY|8J5rN{k{SAuhoNDoCT9vg#eDi| zPsL14*yBd@K+(>O`6~O+djGz@gdX*m=3DCXl|${{?wVMLE5A!ai#WYzJeCVXqrRCAG? z&vfHQolrPyn1r1`xG{}+co<%-%^Pd;VK_JMjaPH#+^e~lrqv`*@cIGI*;fGddHyg2 zi+MY1M8j41Yu1<0imYBX@%%>Y-?Qgtu{2%m7=3DQY@BNPZhu8GOA3oNB)GCjFfr1}5@3-|1pyZ6xCVHnQ#_co&jwGQ4J^`eZQzkk@nF(E z8$EqCvPj3Z(c34Ow9h6_pG}@Vo4kF3N&5_X`V4yd40`(nllIx{>9g6>XS26YFlnEb zr%%h%r{(PvOxkD2(`U%jXUN+pn6%HZr_Zpb&#<>oFlnDHo<3VVeYSY}1e5mJ>glu9 z(`T!pc6j>i z@b(EN?X%O2s^M zPcUhpFvj?M7JFCP=3DIL{rw@)x>pW8isZuj)L-P;N> zr1KuXn?*YB@w<7X^TrJ(Mmm#Zk0<9IPtHBwoM7^tK^UM(GC)Vmc}UHMsRxi5=3D^0ZLqPfO1zBi31c&r%xE5+?Ped041(CK)EZ6!~qJX(eOV+7P~wUMl)JJ>9H3x2eZm0czAO?3C~?IB%3WC`4p1vWsxvIi7O6J?#d!@fP(4t2?Lb-vPc-9#1#i9cV&?{ zK*4nSgaOKZStJZl;)(;5yRt|epkO+E!T{yIED{DNam4}3U0Ea!P%xc7VSsX976}8C zxZ(iit}GGBn(gzi35~G z;s7O)FhEHp3{Vn@1C&JK040$yKuIJFP!fp)ltkhHC6O>d!Ezp57@%OmBgRf94p1=3DR zVQ@^0bj~ddP_UeH3j-7^=3DiK4|1=3DBgVI6%RKHIS|BoisMEgkotb z8Evno^JU`|YU?#S(uNBf=3DwX+by{%d>?x8x#j>ZMKAJrh z-8_4$vRc62`C1IDLW$lj-$$gkNqU>5x0Uqv2h!UjeOhVWf)%j;_qk7#^l6qpt)x$X zAbnb-%GACW#o(q~xujFLX{f%F-XKC7m0_=3Dxmbl0M7QXO;BX52VkE^rLF}#*aup zO45(A^rK4p(GR2_73p(o`lgRapCjpWEPYN%pZh@i9HbB6+mV_+!qYo%9`MlsUhaHx z(t9l0$X@dB2Vd6$r@oA>b}tS-FK9S^Y*U=3D}y6o`c;6sFlczna6Aj0YZHm*Lr`x{?ZNvxEZYARw!)P+ zhtWtHJ$5lOY1;Y8vT2tJmrYoDkKs+$H2k(*NW=3D1e2YUMLa%Q3j+|$YF9$2@|Pv(Pl z0}obKzxXHLEW0!S74a%XKk*pW!7r>dL^Idz>FhP%y0x}sd|^Yk%P38h@#Xc<+LGl% zo#5J!x{vDs>VB>pP!Dk3h1m-HdvKYYTOf>k#S`*J0E)*Da{iT(_dm zaNUMF%XI{F9LmR<+fj@9J5Y=3DIJ5h`Jqo_swTTqMox1tvHZ$mBW-;P?;zXP?XzYDdf zeZAT|1Q*`{@tiW{d-W0`g=3DepME!eFi~4&}i~9GW7WMB(E$TmjTGW3KwW$9P zYEl1T)S~_)s73upQH%PIp%(QYM=3Dk0 z??)}_A3!bYA4DzcA3`naA4Vs6T^R)SpEy>K{cd>d&DT_2*HG`o~a<`o~d=3D`X^9}`U|K< z{gbFg{g+US`ir0kMEz5!Mg1kzqW&^!QU5e*QU45TQU7JsqW&wWMg3P%i~6sj7WH38 zE$XkJ7WL1f7WLmiE$Y9CTGU@fE$Xj<9u)P@p%(SeqZaiqpceHnq89bvLM`gQjat-y z2eqhw3ALzy8MUbYE^1N#J=3DCK9`=3D~|z4^WHxAEFlZKSC|)uY(>E^*=3D@}>VJY-)c+K< zsQ(#iQU3~RQU7z)qW%}ChnAzcM!1-pY_9B^Jr$tS2d4^Nja3iB1gPWn=3D{5BZoGW#! z4X(m!_e_j$)S`t3oHZYp$W&24*pwd~-D;QZ$>0at2-=3DgGD;>V~bz`A!F8+||SX(sf z#$w&9)s49y3gKU_)y!`ftWTh``huF1b*vtQQMtbDTlFXm%Z1;rH?PfE?;+1`>zm!b zzF#|aIF0KIUt*DS#>yO&_5INLfab>LHH_2+%U{>d4BQEED+{MEZP z!_bc5hb{vzw!;%UxPeb^_*ha%PPd1wpaJX2xJnUih5a7WA#BE2TE1KPJQIM>I9tH* zgu>#08)}*?G*lHInqnrwm<*FcOad+lV2&190e;JOIX)lbgk6s1gRfFfJ(f?B`rrz? zN`g&te4639?N@|p(A-KSxlHkj&OKM_EQ}C2<9yzOtlA0uG7@i<13APKlq@bnN z6r`k}B#p37|K4XoGa)szoj0_mW=3Dd+7q$DneDQDawB&$WO$)Y4nl2W*&rjSB}6lzsT zAxa8Kk_}&*R8p9b!V#4erlhbWrQrgGN@^jbmUflYLP;%>lz|HxDyfx_T02xyD6cVg)xTI*8 zN{UiaRFVd8p+X_S@`g*=3D(yfxVP|_Aj8pJgUg#;@bE@|s7m9&+Two1|vE>9>VSk!Py z+jgs@ZIrZ4l7``ei%Qx~NZZ*~O8Ty{oszao(g<9DQAs-pX~$l*rX7^DLz0rPqd_Hg z5mHyLO6sDdE=3Dfwk1savKlaO}qS4lf5X{RLFaKT0;brVwe0hQEEN!^l^h6^|l+-IpefxCMK0?}eQYG!9qFn2-(+sHDS`bXbx`j_9N#gmh$3B^{xpBa)Ons*{cq($Qg+ zbd-{gN>b{WPC7n z*K3LsQaq`W;*=3DDZq(nj|B?u{zQb`F)N=3DQ;)pHAu{q`tID>Z7DSN$T&{N&SS>pHWHu zl+-Ut0|Po~fRF~@S^<2NA>XA2C}}{F1_yQ0AR!IrRMH?N4NB6`kWLyRq@lb@8lt2j zNg5v3NyCIRJf@O{DQQ@eMn-hf2qBG3sH71}8j+;rX`OVMkWLp=3D(rHRMElH^}I_V4{ zotacgXDI26B-v+m(pf?}TU1GBDe0^vrO)Z4bA)tmN+q46q;ry#Ij@t>6VmyTN;*$T z=3DOrn7K_^`xqzlt3=3D>jEPa7q2Ki#q8dAzhqNNf#;Uq9nzWItebByYF<#%PJ{JNl8gc zq;wKoEq6(&t11aMvAF9`DM{+HbrM`CcS-g&m4y3IT#_wG{b`*9*T`K``npQOttBog zElC3zodlOvT~cONCE+d+mz0sD!K_Y#E8{LHdqXARh7XsNm879jodg%fUDD`Hm4tgY zT+*l{4d-+cTn~3ixtdDCZ5S>oCrKlDos=3Dh}{G3Y4Q&L`%l4Ck)jF86WRnizGjY(2! zTqlha()glE8mFXjNwOz&(gYz*+)_yslr$kp>4HvzjRWo(FWgp11xhMNQf5*oO%l@N zl1iGSq)AE2UeZaI2V7 zlr$wtiIPq#5mM=3DaN-9xONs{`?ItjKUxQ|`=3Dp-L)KQdyGvr*#tS7;#C{b(J(tNz;-v zFr$-Z2x;cAN}8dh8A%$vtdlMi(&Z;A=3D`tlx6Xu6P0wGlCDcqs-lxBgj9K{k}8x` zktBOoC(RPl?58SemXc;ADSbmH-5{hJf1;9ZP|^)a%G}gRHwo$HE0uJUl5R>;wyKk=3D zgjD@gl~kpqs!JM-)pSygkZP}0QjL;ok`$lQNpplW_eLenQPP|wCFXU~JR!}ms-$^J znwO-$1)a1&NDF_ak`^dwL6Z6xbF!^uq`Q=3DKSCUfqbkaRSy7yNq=3D^iEBlO+4TPP$J>_kXF9?o-lz zNlHJ^Ne>9=3D!PhG30VO?WnB|V{}Cz90nR3|+pq^Eza zlAco1Q%UN7rjwo#(zCx&NzW+hnIsLY=3D%f`wTKQX*v_eTMk~H{SCp{;m=3Df6=3D&&nfA- zBn`dLNiPWL#owu<7nJk@NYS0JX%;pBS2MAMA-4MB23p*=3D6e(=3DsJ8Ic4L9p$^V~pTH z+5zYj7HQ$vR@iTjBw?d7-@}Z@$>wF)o;{tkU;_efm}Z-odm4KhP5AYZ%Ia94m@C4! z0v!S;X_Jl6I_q8dUD(_X8?TSdLi%!FwWBd$LhYdYs~y3B<+EU;4p;+t54I6GBOiv! z>dEXC8Jj26h%D&|9fE(hzCD?beaZ&RN_*7b$e%qgYuDm18mZOq5KQpqr!R z*f2NX5i0p@7b#<*anxgB!W?r753Pv%(QOz>-wnoId5pH0X)< zn)v^l;QwMxrSQhan{?2CZR}GS)LFb4#hYBPvf4kMN<%UH$8h|xp9p(`?G5-SY`3#&E4 z_(rUjQS%f3C;nit_cbFY>`MhVrUAS+kNMgEv)>5zMp(>&(zNYX6M{TgJVV!wx?u); k4HL_0D`%79y!#9|m3SZ}4*20fB#f^~_-_Ll_+6a;1CLN!@c;k- literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/FACP.type4-count b/tests/data/acpi/q35/FAC= P.type4-count index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..31fa5dd19c213034eef4eeefa6a= 04e61dadd8a2a 100644 GIT binary patch literal 244 zcmZ>BbPo8!z`($~*~#D8BUr&HBEVSz2pEB4AU24G0Y(N+hD|^Y6El!tgNU*~X%LSC z$X0-fGcm9T0LA|E|L2FOWMD92VqjR>!otAF!NBm72Obk1 YBHITON2VDSAnpK(F*YFF1LDH~0O^Si0RR91 literal 0 HcmV?d00001 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352448; cv=none; d=zohomail.com; s=zohoarc; b=ScHgpB3SvSnC5/t4mA0mj5CC3gNBE199TwFXMldqcfjgxxW0eetLi2Lht4LCKj7pp79h3P2FGABu4MInUzZsotQLZFKsqW34tkz0qWKe3uNnZVKfzg/5GlA1nbWKKaoNxiY2y3HY6tIeTysseeS6fYUXGHfDZzWSBoennviVqZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352448; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CzJ70v10uwjo0/ajo+23xOd4j1emTdpwZ/Zn3TXa4uw=; b=JGkNrZJTiFnQsJH58QlAnT+v7hdsiuYmx5X8YnirFcNkEFcnbiV2cMWd2CeSKFepIE7fh/uAe/woPQuZE7c5NdcNsuCKNCvN0Jqf9gAkYNFQreKkyGICP7OUxv05l06NZPy5gXjb1KIO65PJrSAPym13t1oCzYLkvwHOl7x6qgw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352448658515.8734889016215; Tue, 7 Nov 2023 02:20:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J3m-0006tM-8J; Tue, 07 Nov 2023 05:11:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3e-0006OY-3e for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3b-0002aL-Pf for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:41 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-418-9uxGWroMP86r-6kNUGfq_w-1; Tue, 07 Nov 2023 05:11:38 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4092164ed09so32755285e9.2 for ; Tue, 07 Nov 2023 02:11:37 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id f13-20020a05600c4e8d00b0040596352951sm14884901wmq.5.2023.11.07.02.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351899; h=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=CzJ70v10uwjo0/ajo+23xOd4j1emTdpwZ/Zn3TXa4uw=; b=fGl3OXo26c36yfc69R9SoPq5lT8uSNyxOpD7owSu9F6BR4G22/cEzI+OF2/RjiyusRaze3 FO+93XmuauiC1ksTDTuDAe3hzqDhqq0vBlcBevyu+56U4wZGe3rmfu6vR0He3hD3nZmab3 fURjCzw5TFmSKYVkgKT8L9/0vncLWl4= X-MC-Unique: 9uxGWroMP86r-6kNUGfq_w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351896; x=1699956696; 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=CzJ70v10uwjo0/ajo+23xOd4j1emTdpwZ/Zn3TXa4uw=; b=oKVzhXyYc9wzm+tEx7mhf5qFmABmgUAVL7c2UBsPNHb4+pTyF4C+PFFWb8NmJ70MD+ 4/oaE5jZnkd4DQVCMl1Ao8r+sqo0Ez16z5jyjNnc2ZxQJrzA+PDu+J5JAXnuzzcGRJij wQSKWksY8BNZsRjOl3/O8W3jtX8tgYsDiidbWAph2vbih5bCvSNOv9z3fm9Ms/oePTp/ LhqmEROq3AxFeiNpm9XXMFXdrmCcjCwFbt4AosQTbJlqUga8w7g0uhi3FTnTmbZyimfI Mc7z7bcRg04SmtuzvhGdjdfwpRyXDM6xf5PpY8vGs5aH1JFGm35L3rbJlP2V8byjwy3g /OdA== X-Gm-Message-State: AOJu0YyGk2K0/+aE6Q9Ao+vwKl0VKsbYb6Hxi2hwEfWaMs+S8qZ2iPdO ivnyYtj2kH/cpcGQtfo4y3YAMmyjsYWU2EVg6YErl436+po0pfuGR8k43+4yojiQy2hqlNujVFY iVfPhtu3CEpCEiGov1bBOzZy8Kq78LIPV+P31Vfiyr2BceKbZB/1QdgCCxpKU0fJZSV+R X-Received: by 2002:a05:600c:5489:b0:409:404e:5ba6 with SMTP id iv9-20020a05600c548900b00409404e5ba6mr1652204wmb.35.1699351896398; Tue, 07 Nov 2023 02:11:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHR1/9hgPMHiEoVd5VNIHKyVgQafPFQy4IQbqZ6ehEWtP88k/gZ8xm6Req1SKgJMS+qxhKTmw== X-Received: by 2002:a05:600c:5489:b0:409:404e:5ba6 with SMTP id iv9-20020a05600c548900b00409404e5ba6mr1652187wmb.35.1699351896072; Tue, 07 Nov 2023 02:11:36 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:32 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 28/63] tests: bios-tables-test: Prepare the ACPI table change for smbios type4 core count test Message-ID: <623d26ad9affaeca03633880623961434e60e77b.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352449564100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu Following the guidelines in tests/qtest/bios-tables-test.c, this is step 1 - 3. List the ACPI tables that will be added to test the type 4 core count field. Signed-off-by: Zhao Liu Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-6-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 3 +++ tests/data/acpi/q35/APIC.core-count | 0 tests/data/acpi/q35/DSDT.core-count | 0 tests/data/acpi/q35/FACP.core-count | 0 4 files changed, 3 insertions(+) create mode 100644 tests/data/acpi/q35/APIC.core-count create mode 100644 tests/data/acpi/q35/DSDT.core-count create mode 100644 tests/data/acpi/q35/FACP.core-count diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..b9bc196130 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,4 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/APIC.core-count", +"tests/data/acpi/q35/DSDT.core-count", +"tests/data/acpi/q35/FACP.core-count", diff --git a/tests/data/acpi/q35/APIC.core-count b/tests/data/acpi/q35/APIC= .core-count new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/DSDT.core-count b/tests/data/acpi/q35/DSDT= .core-count new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/FACP.core-count b/tests/data/acpi/q35/FACP= .core-count new file mode 100644 index 0000000000..e69de29bb2 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352301; cv=none; d=zohomail.com; s=zohoarc; b=d+YbpnK3NexSAgzEAm+jgd2nPcLQquJ0nS2w8RHd3lNpdt2DaCean2onI6lTcXjeVJQ8DmGvPt0qS6IKjYTympdupLS+n+4UX7O8wZ87E+GJtl3l4tkkE2+EYdAabJ/U1MfyCgDkATzrwrv5X5gOn6KJSCtEjU4KUcnVTVMtLy8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352301; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=f1qL4Gjf5dDJMPYrCrv2bEV2a6+bVH8Xfdo7bHqZQA0=; b=JWNnB5W41DHAOVCBOBKBXC2C178Oo/JNdZGk8bmR3NFucRJY7IEJtl7dRTZ9l9YQSfYUuWQaDVfAho6LYdyaMvxZtHdZCzkFuScy5w+aNG9qUiak4HsRgFnO4QjmQJ9wkMWRa0BgDFyc1mOWlAh42/1RKe1DnVWi3nehLaVUR2U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352301952187.59079465659465; Tue, 7 Nov 2023 02:18:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J3v-0007Z5-HE; Tue, 07 Nov 2023 05:11:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3q-0007IT-7y for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3h-0002bH-O6 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:53 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-PYcy4sBWNQCFvUBEGgC2AA-1; Tue, 07 Nov 2023 05:11:43 -0500 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-32fa25668acso2831208f8f.1 for ; Tue, 07 Nov 2023 02:11:43 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id a4-20020a5d53c4000000b0032f7d7ec4adsm1927005wrw.92.2023.11.07.02.11.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351905; h=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=f1qL4Gjf5dDJMPYrCrv2bEV2a6+bVH8Xfdo7bHqZQA0=; b=PpyBIa5LE3pBjETDLB91js5bKirhGvKpHo9sN5NpW7KJVa4NiO+hpGpL2Wtp2WEnjs6c7+ fsbupYitZZ5nyRFSPuhgbSJiOwHtTPRdtLXUOGjJYGm0FuphUVv22D+AMgpfq9N6vtRxd7 LjE7ysO3H6FTUQTY50bVxBdj3Tuc6Ec= X-MC-Unique: PYcy4sBWNQCFvUBEGgC2AA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351902; x=1699956702; 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=f1qL4Gjf5dDJMPYrCrv2bEV2a6+bVH8Xfdo7bHqZQA0=; b=iIVs7sTgnS2/tNYJQMuoKgCDLggg/u4QxI3qWCQLvauBOAfjLTcieuwi335rRGcPmd KoZqsIcIh3pDr55tXMb53ZNd9M83A21ISYBIw+02jn5nbDT8Cbr/X1Agd/v75txzGuC+ ft5Uihvww9daaLrj6ZhxIhwZX98bySqmcxI5+x7/hVs0XHPvJzuQj1j11JlXWNZYBaBW LM0tVsUZ9tuQLQoIpSFlazjykux4FU7BvjSeopr9MDkuZrabahsiD24annL2+w53juWi vy3GtDprgQ4CMaCwdyPz9otZvg0pPxGAcC+QILWjj/s0QclfAfc5pZnhzAyxkPmVlzWg eMzg== X-Gm-Message-State: AOJu0YwvThQCxHYPDFqzVxuQlSal3LQHoZbmS82A+bWCkf8fKFNEDVnt SQjEvkvnXnvBh7vEnZHyEhPuIxwvWo0tebTkloi3sGsuq2CZvlNUpvYaS2De8TJ7HibnvwZKmmf LU5gTHppuxRWZOdNJtp1LXBD806DG+xglAiUQcCD8GQgDVXmI3l6WoBEXUBHR3xJR09nY X-Received: by 2002:adf:f08f:0:b0:32d:8872:aac8 with SMTP id n15-20020adff08f000000b0032d8872aac8mr23765246wro.31.1699351901803; Tue, 07 Nov 2023 02:11:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgQRMWJi47Ehcf2w6FB+4kaMFVkia6IbaQRChxS6ngxFEjSRlS3F2+L2hirXSXoy24VCrHRQ== X-Received: by 2002:adf:f08f:0:b0:32d:8872:aac8 with SMTP id n15-20020adff08f000000b0032d8872aac8mr23765228wro.31.1699351901390; Tue, 07 Nov 2023 02:11:41 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:36 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 29/63] tests: bios-tables-test: Add test for smbios type4 core count Message-ID: <148a8a1d5fdbdb0ba2a9883c6182e3135cb417b2.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352302408100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu This tests the commit 196ea60a734c3 ("hw/smbios: Fix core count in type4"). In smbios_build_type_4_table() (hw/smbios/smbios.c), if the number of cores in the socket is not more than 255, then smbios type4 table encodes cores per socket into the core count field. So for the topology in this case, there're the following considerations: 1. cores per socket should be not more than 255 to ensure we could cover the core count field. 2. The original bug was that cores per socket was miscalculated, so now we should include as many topology levels as possible (mutiple sockets & dies, no module since x86 hasn't supported it) to cover more general topology scenarios, to ensure that the cores per socket encoded in the core count field is correct. Based on these considerations, select the topology with multiple sockets and dies: -smp 54,sockets=3D2,dies=3D3,cores=3D3,threads=3D3 The expected core count =3D cores per socket =3D cores (3) * dies (3) =3D 9. Suggested-by: Igor Mammedov Signed-off-by: Zhao Liu Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-7-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index cdbfb51559..c20f6f73d0 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -999,6 +999,23 @@ static void test_acpi_q35_tcg_type4_count(void) free_test_data(&data); } =20 +static void test_acpi_q35_tcg_core_count(void) +{ + test_data data =3D { + .machine =3D MACHINE_Q35, + .variant =3D ".core-count", + .required_struct_types =3D base_required_struct_types, + .required_struct_types_len =3D ARRAY_SIZE(base_required_struct_typ= es), + .smbios_core_count =3D 9, + .smbios_core_count2 =3D 9, + }; + + test_acpi_one("-machine smbios-entry-point-type=3D64 " + "-smp 54,sockets=3D2,dies=3D3,cores=3D3,threads=3D3", + &data); + free_test_data(&data); +} + static void test_acpi_q35_tcg_core_count2(void) { test_data data =3D { @@ -2178,6 +2195,8 @@ int main(int argc, char *argv[]) qtest_add_func("acpi/q35/kvm/dmar", test_acpi_q35_kvm_dmar= ); qtest_add_func("acpi/q35/type4-count", test_acpi_q35_tcg_type4_count); + qtest_add_func("acpi/q35/core-count", + test_acpi_q35_tcg_core_count); qtest_add_func("acpi/q35/core-count2", test_acpi_q35_tcg_core_count2); } --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352315; cv=none; d=zohomail.com; s=zohoarc; b=FfKtBU0yWIZhLiCg4OZbBg2TPfs9bxBA1vy6Qcn3YoPPQAo9vTFclY1gdTe1W6d5QbJF652y/VUkM6Uu8FeRBcL2KWWsjVDUjGzQm6SKOV5p5Nru93E4Gu55J3eU+0tdB3d/psvtGsbJhj4KIH4aQ6zAGodh5I1wx0jtS2uJKJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352315; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=V+OH4T+y2ku9GD/QgSTPhTXa7OqHvrqkrTzXUvKsq04=; b=CJrEpugen1a6ijJvEzWsoD9UIGIbrz3Jt8bUIiMrtN9R8o3L0UVm7J6ypaMRa7x0kCXF88RfUBPXO9bb+W3Mm9s9LzsA7cxGkE/G7NkMEwSBVkTTDVx9HdW/FOSSvtOysRZR5sAKUfVsuAsTJCh8tYW6rSAyCv8/vx9PKbn4fwo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352315591750.7154557647231; Tue, 7 Nov 2023 02:18:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J49-00085c-AR; Tue, 07 Nov 2023 05:12:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3x-0007oz-A5 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3u-0002dC-85 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:01 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-hLD4OZoeMxClYNH26UdrTQ-1; Tue, 07 Nov 2023 05:11:49 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4092164ee4eso34588485e9.3 for ; Tue, 07 Nov 2023 02:11:49 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id z6-20020a5d4406000000b003196b1bb528sm1899307wrq.64.2023.11.07.02.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351917; h=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=V+OH4T+y2ku9GD/QgSTPhTXa7OqHvrqkrTzXUvKsq04=; b=JdwFG8zuTCc7/asVrY0q8EsYDLdR/elsxtBiwUmTUGVWI9HnQTExyicrrXUiDEQ0SrQEV4 bg98Zy9ZCyy+7UVM+QxEiXl82zUN6RCXnuimhoueF9DI2hg9HYMip8qeCNu1drZyMn3mHq q/Y4HXFV8RoPnRdJVOKV7RobIW8UjkY= X-MC-Unique: hLD4OZoeMxClYNH26UdrTQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351907; x=1699956707; 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=V+OH4T+y2ku9GD/QgSTPhTXa7OqHvrqkrTzXUvKsq04=; b=POmMbuM+Jv11juF4Y8/BTjn/yaA6rFZE2180uPin9xQ4Ur1SGkWAVbQMPxvxcR9A3k 0KzdNBo0WZIUqTJ/5wArngEjlaZh7Vrc8BRBnRHLMrXMutAoZKr8yGefiAbVqQ1zljDX q7tIVNRMIwXQirnkdOyVrULl4P4lYaWl1d9mIjKVWceYZbedFxjKUvBS8CPoW7F9LqxX 8ohQY65tyq/HpkIMZ/lVnytFxDnLILTHVgHo3kKW5pKCijYfXjro7dUefJnPpHMfcrAc 8WcvpV0xXv2BLJSJJFACY3MrPFDNvLqvEmU6lfCa47rKra7Bwjwl1ELHvn3rE7ndRIbr XA6Q== X-Gm-Message-State: AOJu0Yzlb7mTzLZjc3vYoa99qR2iqWpet5jo/f8YNl2zKPkKr+K7lFMs t/n7a4BJh85KQs/3S4lKc3uuXIYoww5gANuUM7y9zDhredQOfnQMiAVbq2nJrs7LYIVquEDQN9p WOzAId/XQpDJWeSs++ARSFecPp4Ig4iF7rvmTm2sw6h19aSidjcHeomCFpRBuo5cxF1kY X-Received: by 2002:a05:600c:1551:b0:408:364e:34a2 with SMTP id f17-20020a05600c155100b00408364e34a2mr1858154wmg.10.1699351906767; Tue, 07 Nov 2023 02:11:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQo3w2lepKuux2k52bFPITIFVYCMd5sIAjEGDBP+5aZJISuWpKhyR3bZId5s4XcWk4pEI/6A== X-Received: by 2002:a05:600c:1551:b0:408:364e:34a2 with SMTP id f17-20020a05600c155100b00408364e34a2mr1858129wmg.10.1699351906155; Tue, 07 Nov 2023 02:11:46 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:41 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 30/63] tests: bios-tables-test: Add ACPI table binaries for smbios type4 core count test Message-ID: <61ace1d77280b26f0d6ed32b27a1f532f85af9f5.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352316670100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu Following the guidelines in tests/qtest/bios-tables-test.c, this is step 5 and 6. Changes in the tables: FACP: +/* + * Intel ACPI Component Architecture + * AML/ASL+ Disassembler version 20200925 (64-bit version) + * Copyright (c) 2000 - 2020 Intel Corporation + * + * Disassembly of /tmp/aml-Y6WW91, Wed Aug 23 15:43:43 2023 + * + * ACPI Data Table [FACP] + * + * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue + */ + +[000h 0000 4] Signature : "FACP" [Fixed ACPI Descr= iption Table (FADT)] +[004h 0004 4] Table Length : 000000F4 +[008h 0008 1] Revision : 03 +[009h 0009 1] Checksum : B3 +[00Ah 0010 6] Oem ID : "BOCHS " +[010h 0016 8] Oem Table ID : "BXPC " +[018h 0024 4] Oem Revision : 00000001 +[01Ch 0028 4] Asl Compiler ID : "BXPC" +[020h 0032 4] Asl Compiler Revision : 00000001 + +[024h 0036 4] FACS Address : 00000000 +[028h 0040 4] DSDT Address : 00000000 +[02Ch 0044 1] Model : 01 +[02Dh 0045 1] PM Profile : 00 [Unspecified] +[02Eh 0046 2] SCI Interrupt : 0009 +[030h 0048 4] SMI Command Port : 000000B2 +[034h 0052 1] ACPI Enable Value : 02 +[035h 0053 1] ACPI Disable Value : 03 +[036h 0054 1] S4BIOS Command : 00 +[037h 0055 1] P-State Control : 00 +[038h 0056 4] PM1A Event Block Address : 00000600 +[03Ch 0060 4] PM1B Event Block Address : 00000000 +[040h 0064 4] PM1A Control Block Address : 00000604 +[044h 0068 4] PM1B Control Block Address : 00000000 +[048h 0072 4] PM2 Control Block Address : 00000000 +[04Ch 0076 4] PM Timer Block Address : 00000608 +[050h 0080 4] GPE0 Block Address : 00000620 +[054h 0084 4] GPE1 Block Address : 00000000 +[058h 0088 1] PM1 Event Block Length : 04 +[059h 0089 1] PM1 Control Block Length : 02 +[05Ah 0090 1] PM2 Control Block Length : 00 +[05Bh 0091 1] PM Timer Block Length : 04 +[05Ch 0092 1] GPE0 Block Length : 10 +[05Dh 0093 1] GPE1 Block Length : 00 +[05Eh 0094 1] GPE1 Base Offset : 00 +[05Fh 0095 1] _CST Support : 00 +[060h 0096 2] C2 Latency : 0FFF +[062h 0098 2] C3 Latency : 0FFF +[064h 0100 2] CPU Cache Size : 0000 +[066h 0102 2] Cache Flush Stride : 0000 +[068h 0104 1] Duty Cycle Offset : 00 +[069h 0105 1] Duty Cycle Width : 00 +[06Ah 0106 1] RTC Day Alarm Index : 00 +[06Bh 0107 1] RTC Month Alarm Index : 00 +[06Ch 0108 1] RTC Century Index : 32 +[06Dh 0109 2] Boot Flags (decoded below) : 0002 + Legacy Devices Supported (V2) : 0 + 8042 Present on ports 60/64 (V2) : 1 + VGA Not Present (V4) : 0 + MSI Not Supported (V4) : 0 + PCIe ASPM Not Supported (V4) : 0 + CMOS RTC Not Present (V5) : 0 +[06Fh 0111 1] Reserved : 00 +[070h 0112 4] Flags (decoded below) : 000484A5 + WBINVD instruction is operational (V1) : 1 + WBINVD flushes all caches (V1) : 0 + All CPUs support C1 (V1) : 1 + C2 works on MP system (V1) : 0 + Control Method Power Button (V1) : 0 + Control Method Sleep Button (V1) : 1 + RTC wake not in fixed reg space (V1) : 0 + RTC can wake system from S4 (V1) : 1 + 32-bit PM Timer (V1) : 0 + Docking Supported (V1) : 0 + Reset Register Supported (V2) : 1 + Sealed Case (V3) : 0 + Headless - No Video (V3) : 0 + Use native instr after SLP_TYPx (V3) : 0 + PCIEXP_WAK Bits Supported (V4) : 0 + Use Platform Timer (V4) : 1 + RTC_STS valid on S4 wake (V4) : 0 + Remote Power-on capable (V4) : 0 + Use APIC Cluster Model (V4) : 1 + Use APIC Physical Destination Mode (V4) : 0 + Hardware Reduced (V5) : 0 + Low Power S0 Idle (V5) : 0 + +[074h 0116 12] Reset Register : [Generic Address Structure] +[074h 0116 1] Space ID : 01 [SystemIO] +[075h 0117 1] Bit Width : 08 +[076h 0118 1] Bit Offset : 00 +[077h 0119 1] Encoded Access Width : 00 [Undefined/Legacy] +[078h 0120 8] Address : 0000000000000CF9 + +[080h 0128 1] Value to cause reset : 0F +[081h 0129 2] ARM Flags (decoded below) : 0000 + PSCI Compliant : 0 + Must use HVC for PSCI : 0 + +[083h 0131 1] FADT Minor Revision : 00 +[084h 0132 8] FACS Address : 0000000000000000 +[08Ch 0140 8] DSDT Address : 0000000000000000 +[094h 0148 12] PM1A Event Block : [Generic Address Structure] +[094h 0148 1] Space ID : 01 [SystemIO] +[095h 0149 1] Bit Width : 20 +[096h 0150 1] Bit Offset : 00 +[097h 0151 1] Encoded Access Width : 00 [Undefined/Legacy] +[098h 0152 8] Address : 0000000000000600 + +[0A0h 0160 12] PM1B Event Block : [Generic Address Structure] +[0A0h 0160 1] Space ID : 00 [SystemMemory] +[0A1h 0161 1] Bit Width : 00 +[0A2h 0162 1] Bit Offset : 00 +[0A3h 0163 1] Encoded Access Width : 00 [Undefined/Legacy] +[0A4h 0164 8] Address : 0000000000000000 + +[0ACh 0172 12] PM1A Control Block : [Generic Address Structure] +[0ACh 0172 1] Space ID : 01 [SystemIO] +[0ADh 0173 1] Bit Width : 10 +[0AEh 0174 1] Bit Offset : 00 +[0AFh 0175 1] Encoded Access Width : 00 [Undefined/Legacy] +[0B0h 0176 8] Address : 0000000000000604 + +[0B8h 0184 12] PM1B Control Block : [Generic Address Structure] +[0B8h 0184 1] Space ID : 00 [SystemMemory] +[0B9h 0185 1] Bit Width : 00 +[0BAh 0186 1] Bit Offset : 00 +[0BBh 0187 1] Encoded Access Width : 00 [Undefined/Legacy] +[0BCh 0188 8] Address : 0000000000000000 + +[0C4h 0196 12] PM2 Control Block : [Generic Address Structure] +[0C4h 0196 1] Space ID : 00 [SystemMemory] +[0C5h 0197 1] Bit Width : 00 +[0C6h 0198 1] Bit Offset : 00 +[0C7h 0199 1] Encoded Access Width : 00 [Undefined/Legacy] +[0C8h 0200 8] Address : 0000000000000000 + +[0D0h 0208 12] PM Timer Block : [Generic Address Structure] +[0D0h 0208 1] Space ID : 01 [SystemIO] +[0D1h 0209 1] Bit Width : 20 +[0D2h 0210 1] Bit Offset : 00 +[0D3h 0211 1] Encoded Access Width : 00 [Undefined/Legacy] +[0D4h 0212 8] Address : 0000000000000608 + +[0DCh 0220 12] GPE0 Block : [Generic Address Structure] +[0DCh 0220 1] Space ID : 01 [SystemIO] +[0DDh 0221 1] Bit Width : 80 +[0DEh 0222 1] Bit Offset : 00 +[0DFh 0223 1] Encoded Access Width : 00 [Undefined/Legacy] +[0E0h 0224 8] Address : 0000000000000620 + +[0E8h 0232 12] GPE1 Block : [Generic Address Structure] +[0E8h 0232 1] Space ID : 00 [SystemMemory] +[0E9h 0233 1] Bit Width : 00 +[0EAh 0234 1] Bit Offset : 00 +[0EBh 0235 1] Encoded Access Width : 00 [Undefined/Legacy] +[0ECh 0236 8] Address : 0000000000000000 ... APIC: +/* + * Intel ACPI Component Architecture + * AML/ASL+ Disassembler version 20200925 (64-bit version) + * Copyright (c) 2000 - 2020 Intel Corporation + * + * Disassembly of /tmp/aml-FFXW91, Wed Aug 23 15:43:43 2023 + * + * ACPI Data Table [APIC] + * + * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue + */ + +[000h 0000 4] Signature : "APIC" [Multiple APIC De= scription Table (MADT)] +[004h 0004 4] Table Length : 00000220 +[008h 0008 1] Revision : 03 +[009h 0009 1] Checksum : 3C +[00Ah 0010 6] Oem ID : "BOCHS " +[010h 0016 8] Oem Table ID : "BXPC " +[018h 0024 4] Oem Revision : 00000001 +[01Ch 0028 4] Asl Compiler ID : "BXPC" +[020h 0032 4] Asl Compiler Revision : 00000001 + +[024h 0036 4] Local Apic Address : FEE00000 +[028h 0040 4] Flags (decoded below) : 00000001 + PC-AT Compatibility : 1 + +[02Ch 0044 1] Subtable Type : 00 [Processor Local APIC] +[02Dh 0045 1] Length : 08 +[02Eh 0046 1] Processor ID : 00 +[02Fh 0047 1] Local Apic ID : 00 +[030h 0048 4] Flags (decoded below) : 00000001 + Processor Enabled : 1 + Runtime Online Capable : 0 [snip] +[1D4h 0468 1] Subtable Type : 00 [Processor Local APIC] +[1D5h 0469 1] Length : 08 +[1D6h 0470 1] Processor ID : 35 +[1D7h 0471 1] Local Apic ID : 6A +[1D8h 0472 4] Flags (decoded below) : 00000001 + Processor Enabled : 1 + Runtime Online Capable : 0 + +[1DCh 0476 1] Subtable Type : 01 [I/O APIC] +[1DDh 0477 1] Length : 0C +[1DEh 0478 1] I/O Apic ID : 00 +[1DFh 0479 1] Reserved : 00 +[1E0h 0480 4] Address : FEC00000 +[1E4h 0484 4] Interrupt : 00000000 + +[1E8h 0488 1] Subtable Type : 02 [Interrupt Source Overri= de] +[1E9h 0489 1] Length : 0A +[1EAh 0490 1] Bus : 00 +[1EBh 0491 1] Source : 00 +[1ECh 0492 4] Interrupt : 00000002 +[1F0h 0496 2] Flags (decoded below) : 0000 + Polarity : 0 + Trigger Mode : 0 + +[1F2h 0498 1] Subtable Type : 02 [Interrupt Source Overri= de] +[1F3h 0499 1] Length : 0A +[1F4h 0500 1] Bus : 00 +[1F5h 0501 1] Source : 05 +[1F6h 0502 4] Interrupt : 00000005 +[1FAh 0506 2] Flags (decoded below) : 000D + Polarity : 1 + Trigger Mode : 3 + +[1FCh 0508 1] Subtable Type : 02 [Interrupt Source Overri= de] +[1FDh 0509 1] Length : 0A +[1FEh 0510 1] Bus : 00 +[1FFh 0511 1] Source : 09 +[200h 0512 4] Interrupt : 00000009 +[204h 0516 2] Flags (decoded below) : 000D + Polarity : 1 + Trigger Mode : 3 + +[206h 0518 1] Subtable Type : 02 [Interrupt Source Overri= de] +[207h 0519 1] Length : 0A +[208h 0520 1] Bus : 00 +[209h 0521 1] Source : 0A +[20Ah 0522 4] Interrupt : 0000000A +[20Eh 0526 2] Flags (decoded below) : 000D + Polarity : 1 + Trigger Mode : 3 + +[210h 0528 1] Subtable Type : 02 [Interrupt Source Overri= de] +[211h 0529 1] Length : 0A +[212h 0530 1] Bus : 00 +[213h 0531 1] Source : 0B +[214h 0532 4] Interrupt : 0000000B +[218h 0536 2] Flags (decoded below) : 000D + Polarity : 1 + Trigger Mode : 3 + +[21Ah 0538 1] Subtable Type : 04 [Local APIC NMI] +[21Bh 0539 1] Length : 06 +[21Ch 0540 1] Processor ID : FF +[21Dh 0541 2] Flags (decoded below) : 0000 + Polarity : 0 + Trigger Mode : 0 +[21Fh 0543 1] Interrupt Input LINT : 01 ... DSDT: +/* + * Intel ACPI Component Architecture + * AML/ASL+ Disassembler version 20200925 (64-bit version) + * Copyright (c) 2000 - 2020 Intel Corporation + * + * Disassembling to symbolic ASL+ operators + * + * Disassembly of /tmp/aml-9ZXW91, Wed Aug 23 15:43:43 2023 + * + * Original Table Header: + * Signature "DSDT" + * Length 0x00003271 (12913) + * Revision 0x01 **** 32-bit table (V1), no 64-bit math support + * Checksum 0xAF + * OEM ID "BOCHS " + * OEM Table ID "BXPC " + * OEM Revision 0x00000001 (1) + * Compiler ID "BXPC" + * Compiler Version 0x00000001 (1) + */ +DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001) +{ + Scope (\) + { + OperationRegion (DBG, SystemIO, 0x0402, One) + Field (DBG, ByteAcc, NoLock, Preserve) + { + DBGB, 8 + } + + Method (DBUG, 1, NotSerialized) + { + ToHexString (Arg0, Local0) + ToBuffer (Local0, Local0) + Local1 =3D (SizeOf (Local0) - One) + Local2 =3D Zero + While ((Local2 < Local1)) + { + DBGB =3D DerefOf (Local0 [Local2]) + Local2++ + } + + DBGB =3D 0x0A + } + } [snip] + Device (\_SB.CPUS) + { + Name (_HID, "ACPI0010" /* Processor Container Device */) // _= HID: Hardware ID + Name (_CID, EisaId ("PNP0A05") /* Generic Container Device */)= // _CID: Compatible ID + Method (CTFY, 2, NotSerialized) + { + If ((Arg0 =3D=3D Zero)) + { + Notify (C000, Arg1) + } + + If ((Arg0 =3D=3D One)) + { + Notify (C001, Arg1) + } [snip] + If ((Arg0 =3D=3D 0x35)) + { + Notify (C035, Arg1) + } + } [snip] + Processor (C000, 0x00, 0x00000000, 0x00) + { + Method (_STA, 0, Serialized) // _STA: Status + { + Return (CSTA (Zero)) + } + + Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + { + 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 // .= ....... + }) + Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion + { + COST (Zero, Arg0, Arg1, Arg2) + } + } + + Processor (C001, 0x01, 0x00000000, 0x00) + { + Method (_STA, 0, Serialized) // _STA: Status + { + Return (CSTA (One)) + } + + Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + { + 0x00, 0x08, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00 // .= ....... + }) + Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device, x= =3D0-9 + { + CEJ0 (One) + } + + Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion + { + COST (One, Arg0, Arg1, Arg2) + } + } [snip] + Processor (C035, 0x35, 0x00000000, 0x00) + { + Method (_STA, 0, Serialized) // _STA: Status + { + Return (CSTA (0x35)) + } + + Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + { + 0x00, 0x08, 0x35, 0x6A, 0x01, 0x00, 0x00, 0x00 // .= .5j.... + }) + Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device, x= =3D0-9 + { + CEJ0 (0x35) + } + + Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion + { + COST (0x35, Arg0, Arg1, Arg2) + } + } ... Signed-off-by: Zhao Liu Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-8-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 3 --- tests/data/acpi/q35/APIC.core-count | Bin 0 -> 544 bytes tests/data/acpi/q35/DSDT.core-count | Bin 0 -> 12913 bytes tests/data/acpi/q35/FACP.core-count | Bin 0 -> 244 bytes 4 files changed, 3 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index b9bc196130..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,4 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/APIC.core-count", -"tests/data/acpi/q35/DSDT.core-count", -"tests/data/acpi/q35/FACP.core-count", diff --git a/tests/data/acpi/q35/APIC.core-count b/tests/data/acpi/q35/APIC= .core-count index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d9d7ca9a896159791f6e74842d0= 2786dc2608cb3 100644 GIT binary patch literal 544 zcmXxh*-pYh7(n5_rLA2+0RaKGf`EYgcISn(YQP%{EZ zC}OsRxiZdIaG{F%8W!qUO#f5d#RmIQ6U!~Ev~j6})h^b0SnuQV8LkX)HNv%XT))8Z z5*tHoj&S1&TM4$u*qPwwEq3p)caQxkZav`kBknxm?lbPa;QlKfyy4+H9(~~PC!Tz1 jjjVpV@0ngrUrimlY+ISr<$3?*s{?!sg0w8>S6%T3A7&l_ literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/DSDT.core-count b/tests/data/acpi/q35/DSDT= .core-count index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a24b04cbdbf09383b933a42a2a1= 5182545543a87 100644 GIT binary patch literal 12913 zcmb80O>A4)b;s}HheSP+5=3DBwpvPH|1Eq{unB-_)XMaV}|k}b+KDbGww1EeHRDtQ8g z&5VIK0|T}ONG1jfbVi+^OU*z5x=3DUBx)<8GyZgw4@t1i09HVEQXl>fQ+J-&1AlY!U^ z>YT@Oe&?J=3D^8I=3D5qsz_m_CFMauzp**@2oeor4Q>)7XK_E1ljaAwGnwFS})3_wYC)x zMXc7#xU}(5ie;{sOAptqf7$Q+y3_gemmO=3DTD|Ww4eZ9NW{rrp0uArc&yItERBXw`2 z-7K|RhZ{q6XCoJDuWytS#qaD`tnDZ(9BV(^D2vQyfBSyZiM;w)IOPxW$6L{({oxTi z)vEpP@*ihse(>uLJ}tifoB#RItB>sn0t)yW!{6mDJ#;?n*ylUPsjrR>tml+2pUWSQ ze03zBR>xBGOt(WvzDcMF^{sl&$>jy6Z#0Kz?U`SW3z48xPXGSx^z`&UlqpirL~1j0lTIF;xYmoh)7-Y=3D zuM>8x^)f|{gX0ggcqnIEFPfFRc&Yv?VMp*iwdmAiPNv{h?Z@$Xa`IZkQoVJ%zV zD1Vr3S*1mqrlr`>&u=3DsvR!1Tk8d>F|ljTq`2ytSDl2>7nDsb~2@b zx;&rdzIQsIIBQfyo)Nkm(Lm3=3D8S7|#`QVj@;MXQoC$5tggz%+K4(&!GpWs))aQiD=3DN#1L9Mt9<)aQiD z=3DN!`J9Ma|-(&vQB=3DS*pHrnEUz`kZk2oWt6j!`hs~`kZk2oM~;&v^Hm2pA#;hb3~hS zM4NL&pA#;hGo#I!(dNwPbHe3wj%ss`YIBb2bHe3wj%jm_X>*S0bHe3wLdMiJOJ0@6 zwK>Q2IpOj-C$u>yv^gjAIpOj-CuL^Qy%J8!%#wStn^c*O?^0&jjh)gmr?ku|Jrgd^ zoYpd@wajTf6E4r3(K2VW%o#lsF3&utWuDVA&*_0RT`%S`VYe_myJ7jC$e z=3D_$#qR&!RXIjh%%t7^s|phYI2Yt0RmmSSqbMqyV#;h?N?!f?Ez5Kt8--$a(6EU!Nc zMOA1|K;e3$K|ockC!j2p1XP9g1Qag1@dQ-Gx*pX8)l*E$^v)OwC|q`2TvL*>ATyIVYsEU=3DD z5KtCM0;)n~CJ889Z%zoPij|oVP!>u8szPNZ2`F6e^@M<`SeXd{WuYXXDpY2YfWr0W zgn+78nF#@9p(LOxRA!QZ!u95afT~!T2?1rHB%mr(W|Dxy_2z_ts#uu`0cD{ipej^m zl7PbX=3D7fN%SeXd{WuYXXDpY2YfWr0Wgn+78nF#@9p(LOxRA!QZ!u95afT~!T2?1rH zB%mr(W|Dxy_2z_ts#uu`0cD{ipej^ml7PbX=3D7fN%SeXd{WuYXXDpY2YfWr0Wgn+78 znF#@9p(LOxRA!QZ!u95afT~!T2?1rHB%mr(W|Dxy_2z_ts#uu`0cD{ipej^ml7PbX z=3D7fN%SeXd{WuYXXDpY2YfWr0Wgn+78nF#@9p(LOxRA!QZ!u95afT~!T2?1rHB%mr( zW|Dxy_2z_ts#uu`0cD{ipej^ml7PbX=3D7fO4V*(0~3n*MJpm3RhvP=3Djl%OnA1nIxbr z69URIA)qXi1e9fxfU-;oD9eO^vP=3D?CmPrE2G9jQW69URINkCa92`I~ifWq@$T?i;V zykhcXl7Pa+%iy_`>782$C_L}nLO|hp=3DavK%u6J%pK;dE!WU37b6~~DqxmZ1+1?e|^ z^rx5^*?55U|M9?Q_KSUSVh^0y@yyD`1E(b-39NoiBPjF^M6y{}My#=3DJ1$3@~c5H5QahtT!RI!rsA2%47HovMR7tc z)Ef_qnc;SMqbZ(~ZNHF5hG;{BBAkZw$J@e!jMz~^j4$Kjhr z0H=3D`YwXb1VC3k^ahwJvErLec*UT;*IUb{9f5@WZzbHjO;tg9w7TYW!q#Il^rL$r0fLQj3;iWV`)OknQ$A zNw(Yn6xnY7(`38-&yel*e~xUo|MO(K{m+u^_Me4aaQnYNw%h+4*>3+A$#(mnC)@3R zfo!+`OJuwKUnbk_f01mr|0`s>{a+>9?f)9tZvWTGcKg3Uw%h+rvfcid$aeeB!CrRz z&y(%;Um)A!YN zeSW(35bibwp4q&2(#h1K^qG3MLY9dF;Y@yJZOmypTd}u{5p%XGAEZO4U9s1-9)DX& zA3e6Z;&IpNbj8lMwZuOib*!)V>|28?bzLki&?MuL2 zu}7DiJrro=3D&mJzoLO)M;&pyw!0q1^mJMotDeD>QVz{kn!9-MJ*x^~DsN}*58gE-A+ zcGvp+4lYhP5*I-?74gQ7ozUAGm)}}(dpK^#1oq8nHI^B~eeLZy4I}msp0qx%M39=3D7 z3pFhji=3DbYrWy#cd+ZBhL#W0q{tP`eyjZdnP^gE!{Opg-^Nlv22u|xRE=3D=3DEcVe9|)R zB$_0sbdMB{n4~Z#g?-WrwALhHjnN}Tq9!TANfDp4O3P4VIxH7@q-dW>igHraC*8uv zsY!yU_egy)lhnsaeLm?nHd0LzzQp%P{c;J8w}kh~+5Mc<@00G}4Puh;vxpukW}7|5 zI4S0n-jm;Q^moAkBMqcX(f}t7_@p8&`i(PgGm<@Ql59@0eNu_G4h&M9k>Y8S6z8P4 zPjc|}&?F@oDUmTr2~JA*q%t;YO;VDPlA|Um$w^6{RKdorNg8CN!7-CG$Vr1fsfvwU zlZ5ZDy?4RTgh?9Wq@f-upQF{AamKN}>yc8ECMm^9DW8<5MVdjv(ym7uo-#?poHXo{ z3bZ~mNLbbNNNM@ABmQYgb5hzTEz{D>AYnn*BaK`zdm7=3DS5uda|t1^RxwOo&snKMZl zPRjVCRa%f4BrM~4q|tekG|EY%KIs;%#S9Wwa6Qu4f=3DL?Vq%og#o0ee)35&NLY5bB& z8t0^OpL7Qs%O+`pktP;R(gY_>_@wu+(QJ|?8ENv0Nt)!ONuN~2om-PM#Yj_EP0|!6 zP5Gn}Hlj_^G$T#_z$8s`(zH)D&(?3QkIdjSOMdW%ak+ANm-wi zzYru{V5AG{Cg}nvUGPbTxgcqdk>)l`(i|tv`K0BGLDEG=3Dx_H+lUF4*TK51n>NSbG) z`MOD(=3DcIX`w7L)^Eilr;1CzACNee#d)}(I>rkB}lr$NLSuBNmn@OicczD4U(=3Dh($x=3D5(p65n>XS;> zf~0GVbnS;G=3D^7_p^GVM2An7_IUH?0ibe)r~`=3Ds)XAn67p-RPL48=3DQ2*Csl3+NjDkk z=3D8j3a$w@bTQgtavT4JQ7U6ZuLNlQJ_vb&tq)>8Pva!)yPk4;jJlX5;OpAYtwXQcc` zCMnNJd7o4$1W5%(D*VVK6*#Hjla`l*q-920-Zx3hoV4tdR#t+f6-HV)Fi9(%wBnOi zSA(QgMp}Jhl2$os6{O5GHbSwf+pgpa!ri{5O;OsTN!3QxE~)%=3DuiO&88@K=3Dci=3D+st zCB-R~x7MsTi8l!=3DhT~R3u7dxFr{5%ceiAviIF z!kWNl`jtm0-&}5|`y#Yk0ehvLjz#Q{jZF!7tMm+wk@{=3D@WoRAVtbX9An;*#smD)q> zq7*3F=3Dr|QkMQIB?RhfPyf1_QSqF1qX7;ols?O3~5ZeW_L&D?%F1(ZhPIb+~e`R7NxEKRAT3cS19{w<0F&(KV|hI>N%+?Xh@_zjGn^s?OK$ zKkQ`BbPo8!z`($~*~#D8BUr&HBEVSz2pEB4AU24G0Y(N+hD|^Y6El!tgNU*~X%LSC z$X0-fGcm9T0LA|E|L2FOWMD92VqjR>!otAF!NBm72Obk1 YBHITON2VDSAnpK(F*YFF1LDH~0O^Si0RR91 literal 0 HcmV?d00001 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352692; cv=none; d=zohomail.com; s=zohoarc; b=HLoBzyat1vT1GzMrBMqCeDVwqBv4IKvMEGkhijsfPh90YTHDn8AUeV7jXsu6aq2GZauPvLAHoRous+3zY0Yjbe8KsKJ/QbRGiuXMNU+eQKm58XyeHejeV4VsGkhsJ9cT9B1q9xpOBvnphLGUPKJl6uyS68k79y1Cgdl9NxtuJGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352692; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=K0kx8qJ2YzraSWvCM5ZZfa/pcBINgphK8RV/OZhF/o4=; b=hqnzb3iimPwTML1nIks3EVFjn98M1Da9sKbMfmrWETXrM4J2Jww5FVToaRPK+C7WojZs5oLJb7ZNDrrE1Xt1njVSBJ/3x89g4rpqVGZbF67hNdZKTU2Jg595yfRDp8mEC7CoKgGoWJ3IqUTLmLr0Pe1aIlhZzOXG3QbNRdY+DCM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352692262839.8174585262016; Tue, 7 Nov 2023 02:24:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J43-0007uo-Dg; Tue, 07 Nov 2023 05:12:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3r-0007So-Uf for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3q-0002cI-9N for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:11:55 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-117-oGuFOoAFPUW2m7R98_QNhQ-1; Tue, 07 Nov 2023 05:11:52 -0500 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-32cef5f8af5so3907824f8f.1 for ; Tue, 07 Nov 2023 02:11:52 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id j19-20020a05600c1c1300b004060f0a0fd5sm15235837wms.13.2023.11.07.02.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351913; h=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=K0kx8qJ2YzraSWvCM5ZZfa/pcBINgphK8RV/OZhF/o4=; b=X+sPFjTFhyKg/54O4SUbJzQ5aSAB0arUlWO5zF4Sc1qqEH2mztyhhSWyv66VzlWTwNl1cv HwnBIPnLsaxiejyNp4wGBBdGkuGTH3mevPWMJva5pv3sfC4HXJ26w+T0zwbtbqx/qXC6ZL DOtUNgt4C7KflSw3Zg4TA6iY884tzo4= X-MC-Unique: oGuFOoAFPUW2m7R98_QNhQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351910; x=1699956710; 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=K0kx8qJ2YzraSWvCM5ZZfa/pcBINgphK8RV/OZhF/o4=; b=RyldPwMm8NsGfjf1UDdcM1QKIirKFMsON8Tve7cti9inbUDTnYUCEjxNqyM/D7Wc1s /pxyGIO35JztShYkDaoV1sC3OKABd9IWYH7bvm1ZfRWbRZcmxt9ktsRWkfjRuAqUveZO Iz1qLwt8MIIKW3Y6ta3fqUU4R8VQhHhW0Ajk+07jtivzGYudiGwbWgDfbIs1nEXGMazB fQjYRnVtQoIixhlxLc/TAkfqFz1GtfLrUTDB4y7zH8dvwuYtDjy8KJPCRJphF/Adu6OP 6Hn7+z1ecNfSyVtfvspwqjQ6FSkWZ5F1RxqWtf3H3qD0lLLARrG1SbmqYwtCoCy21ggK pcCQ== X-Gm-Message-State: AOJu0Yyz2ayFJSb48AVW3OSYtQltsVgOR0gm5/lnnx87raPEam5NZq5B 2pjfHKrAIw6CY6SL+bog3LB4wxo/Wd4yHNrCPjUuijR1gktOUGwmiPYlOXhpMzBSzMyqfCXrTqK GE2MV39QzDJhVPR/cD8Xi0RcjaAViKy8XE4jRynxuHkrob7RgaV5B1/MJM3O9+46BqDID X-Received: by 2002:a5d:588f:0:b0:32f:b47c:f1f6 with SMTP id n15-20020a5d588f000000b0032fb47cf1f6mr2520113wrf.32.1699351910620; Tue, 07 Nov 2023 02:11:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrRjU3YZYrAMXwTtPZeHTNhPaxifl5jEe3PT+G4DOJ2UiFjfImPq6t0aowIi9Qkx8BeR8CiA== X-Received: by 2002:a5d:588f:0:b0:32f:b47c:f1f6 with SMTP id n15-20020a5d588f000000b0032fb47cf1f6mr2520083wrf.32.1699351910345; Tue, 07 Nov 2023 02:11:50 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 31/63] tests: bios-tables-test: Prepare the ACPI table change for smbios type4 core count2 test 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352694438100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu Following the guidelines in tests/qtest/bios-tables-test.c, this is step 1 - 3. List the ACPI tables that will be changed about the type 4 core count2 test case. Signed-off-by: Zhao Liu Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-9-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..0f95d1344b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,3 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/APIC.core-count2", +"tests/data/acpi/q35/DSDT.core-count2", --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352455; cv=none; d=zohomail.com; s=zohoarc; b=b/gvoXrPxXfjlriXswZru6fIJmZrPWm2tZOppT2lCO8aoKbN6Ir/tGruM1S2eRO5HRZlqRPJD6/gC3FbCUtTDMvegQ4Uo+U3LUqUnZEDXTVWTzdYSPgNhavt5/Cs0HVBMaiAZL7494w/RcDJyl8o6ZuRw/7VF3ACkfpPRgFJOvE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352455; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ACyePYuwAqhNiNSLL7HwFgNEUdgIfSbmJfWFYv0Xilc=; b=ko0ZZC2bu392nirdeuuziWVKg+XwyoYqaYEPWjcbAdsp5A048ralVH5fzGPKZcHRDKdK3ifRA92iS0gDKf+azn9X958J+vMzEWAyWyA+9ogb+FyTkzRn8vP5fONcRaY3QT2kNZ852jOLle1BHdaV32zVkYuN73biS5JkO+csCww= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352455332436.016268042148; Tue, 7 Nov 2023 02:20:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4E-0000Ga-QT; Tue, 07 Nov 2023 05:12:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J46-00085d-Kz for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J44-0002fK-UN for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:10 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-RH1CEjd1ObKc1P5n61UUZQ-1; Tue, 07 Nov 2023 05:11:57 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-408524e2368so32854285e9.0 for ; Tue, 07 Nov 2023 02:11:57 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id j8-20020a05600c1c0800b004063977eccesm15365868wms.42.2023.11.07.02.11.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351928; h=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=ACyePYuwAqhNiNSLL7HwFgNEUdgIfSbmJfWFYv0Xilc=; b=aRgG2dJ/9pPPAZItMw5QTX9bRH6eFclBKJB+hkh/1XaluuGqAgV6kis2eH27uSQTz1/2Mo MAh0cUXhsoQo2v9YuTIxrAYzLqgsaNGZxQj1v0qgUtW+GZ+NDH+YfAdJmPS2F5cRnFmi6B u7S8Dpy8fFyQFjY6PaR3QFwyxLsGMM0= X-MC-Unique: RH1CEjd1ObKc1P5n61UUZQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351915; x=1699956715; 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=ACyePYuwAqhNiNSLL7HwFgNEUdgIfSbmJfWFYv0Xilc=; b=ejc7kJrfv/c6YmuEVQGaNIiXc+L9p2jww0cmR6pLyWleUinM6/jCYZxRRQxy9fq6db OdQoa1ZfH5NSUcHvpAI03Aspel9zQUKc6WGJNDdQ2eyvcuioLyzZme7pgobYriAlfkZV Ixks+tVLxDl1P7zjl1Bnod+/sbbpOJdRy0LRPShHP699t5zRy7trIHl+kxOOi1sQIinI BZJVH4tGHvfda1BjLKyqTWLvG0VsC6xXFiQ1JUdhgOV45JPrIb7b9X8qSIFwMGyPBNFO f3tMDf+n1FnFIrSi4BNGcsK6+9Y6ZXv3NOYWpbQwuf/kZ/fxljiHTiX52V0mA6C/kpbh rbDg== X-Gm-Message-State: AOJu0YwX72F1Bm2URH3PoG2NVk9zRquj6OzOY9TwkoJui2Po1r08TE0K aKNc7aYDE/o4vRFZC0GT2DJMPOKoSrAdgnjT7YngProfUYtLW517uiu7eOqktdb342hI1k8en2E rOZxxswoM9aIdcecaOmyob0NpczCMiCFFbksWehk/QH0GoHrM+v1IMf6kjziTGDpOsupw X-Received: by 2002:a05:600c:2d48:b0:406:84b2:67f with SMTP id a8-20020a05600c2d4800b0040684b2067fmr1886906wmg.20.1699351915302; Tue, 07 Nov 2023 02:11:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IEvqmB7XloJac9+m8GkRrbHaCsFZGW4NOFSCcWoWXlfM4jwApS0WpWp+VcRxXF9Kj5tuVZqCw== X-Received: by 2002:a05:600c:2d48:b0:406:84b2:67f with SMTP id a8-20020a05600c2d4800b0040684b2067fmr1886886wmg.20.1699351914949; Tue, 07 Nov 2023 02:11:54 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:50 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 32/63] tests: bios-tables-test: Extend smbios core count2 test to cover general topology Message-ID: <6dc82e32226dd3455a1b82bb2ef37d938570084f.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352455705100004 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu The commit 196ea60a734c3 ("hw/smbios: Fix core count in type4") fixed the miscalculation of cores per socket. The original core count2 test (with the topology configured by "-smp 275") didn't recognize that topology-related but because it just created a special topology with only one socket and one die by default, ignoring the effect of more topology levels (between socket and core) on the cores per socket calculation. So for the topology in this case, there're the following considerations: 1. cores per socket should be more than 255 to ensure we could cover the core count2 field. 2. The original bug was that cores per socket was miscalculated, so now we should include as many topology levels as possible (multiple sockets or dies, no module since x86 hasn't supported it) to cover more general topology scenarios, to ensure that the cores per socket encoded in the core count2 field is correct. Based on these considerations, select the topology with multiple dies: -smp 260,dies=3D2,cores=3D130,threads=3D1 Note, here we doesn't configure multiple sockets to avoid the error ("kvm_init_vcpu: kvm_get_vcpu failed (*): Too many open files") if user uses the default ulimit seeting on his machine. And the cores per socket calculation for multiple sockets has already been covered by the core count test case, so that only multiple dies configuration is enough. The expected core count2 =3D cores per socket =3D cores (130) * dies (2) = =3D 260. Suggested-by: Igor Mammedov Signed-off-by: Zhao Liu Acked-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-10-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index c20f6f73d0..f3af20cf2c 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -1024,10 +1024,12 @@ static void test_acpi_q35_tcg_core_count2(void) .required_struct_types =3D base_required_struct_types, .required_struct_types_len =3D ARRAY_SIZE(base_required_struct_typ= es), .smbios_core_count =3D 0xFF, - .smbios_core_count2 =3D 275, + .smbios_core_count2 =3D 260, }; =20 - test_acpi_one("-machine smbios-entry-point-type=3D64 -smp 275", &data); + test_acpi_one("-machine smbios-entry-point-type=3D64 " + "-smp 260,dies=3D2,cores=3D130,threads=3D1", + &data); free_test_data(&data); } =20 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352468; cv=none; d=zohomail.com; s=zohoarc; b=m630wH9o4E41ngfjv1XmUyTe6WQSou8muC3VbbVLw1VqBcQ6QfCUZPfKwr9UsQgFIu/4Wwx/Pu+KWE8vewq44rHXHojt7WKaByEuBDUL5V1anzsXokRCTxaLRGz8b2nYnbZ57aHFcH1Qb8yjhvye94FL0V2BeOlbNmQhtvgiDy8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352468; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=og4TVCko7gAafnR/H/nic0nJI4rsMQ+uiUj7Weg7xqI=; b=ZIDN9DvNrLVKJn+Oht9nWjgUjf4BsnKWlp73E7y0C4V2+P0rmpevLsourZXLiwA0AVx6hMsm9Vd2sExINn1Jd8UoZblNJwyAewpAilsi2s7KViL3D0ZKvVzKkzQdw2WS+a5Ia7OhBFmNTNrDQw3itJ8BavV4hSE4jC7QSDYv/BE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352468636858.5906907692834; Tue, 7 Nov 2023 02:21:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4C-0008Hg-Fx; Tue, 07 Nov 2023 05:12:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J42-000838-Vz for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J3z-0002dq-Mw for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:06 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-QJ6w-lA3N2mnqizNiHrYfA-1; Tue, 07 Nov 2023 05:12:01 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4092164eceeso34961025e9.2 for ; Tue, 07 Nov 2023 02:12:01 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id l7-20020a05600c1d0700b00405bbfd5d16sm15291749wms.7.2023.11.07.02.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:11:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351922; h=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=og4TVCko7gAafnR/H/nic0nJI4rsMQ+uiUj7Weg7xqI=; b=OPGWXLdxDrgwdydWJXAOQehz5tC2l9QRnftSpX8RwsiwGPln7hSdYTRo+k3v35s3mn5Adl KZ3xX2/DjT6Oj26WCrdg3H3ZKNkzqM2F10GCBt0QDdmXh/1XXzdZlluXKLq5VJhWGd25T/ BIFRYvisdRUWExmC9JzvbVyalm9B55s= X-MC-Unique: QJ6w-lA3N2mnqizNiHrYfA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351920; x=1699956720; 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=og4TVCko7gAafnR/H/nic0nJI4rsMQ+uiUj7Weg7xqI=; b=mQ7WgH9hJA21efottOt0kQGGlSjdF1NiGKHyyMDsIU/koXAtmqd4hnBCfsMHSRUlby 6zW2qnWu8wRt0cbWVNYxX6573LbQZoagPmd3KBM2FUUpXtGPb/gPTo1f2eGNG0tu2X6G s9WQOthYdsU/GmNCr71kTlUy9SnANLbTspf4uaLLumXlcY9tslTxpeihZG0zOACZYOPu f4h8O4mi7FlcephS6gaP1aF4S6wwRON9GjrdNTxYCrMW5BSuA5PjcyuzbiHBshzJqH2e iRccoL7hfX7kwfJQCcDdfm4U5A6v3C8dEC3mG05bAirQl5VCwXYH+mFcMNwbyA9xgB41 cyJA== X-Gm-Message-State: AOJu0YzE91Vuhc22/cYLk05lfBOy3pa9JzaPmPvGp7lUTC69R51/P7S6 ykHjSH5YaGaza3cgE7vqWDHRou1FCrGEhcouBfjRwNIGsGJG1hL850mKoX6rPQA+kWNFBYOnetX ig8IHOyhAa0btuPTL0Je5QiNPsd48t4/nsdC3sJHwy9o2d/BalMD4rCjxIuGYrVe1jOya X-Received: by 2002:a05:600c:3b84:b0:408:37aa:4766 with SMTP id n4-20020a05600c3b8400b0040837aa4766mr1713523wms.5.1699351919819; Tue, 07 Nov 2023 02:11:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdAjmKo7hIXXe7otsZ/Rc028vACuDEzkB/Eu9lHtXkboQTWbmucH3k/cJtWT1scAw1qxvVgQ== X-Received: by 2002:a05:600c:3b84:b0:408:37aa:4766 with SMTP id n4-20020a05600c3b8400b0040837aa4766mr1713497wms.5.1699351919198; Tue, 07 Nov 2023 02:11:59 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 33/63] tests: bios-tables-test: Update ACPI table binaries for smbios core count2 test 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352470066100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu Change the core count2 from 275 to 260. Following the guidelines in tests/qtest/bios-tables-test.c, this is step 5 and 6. Changes in the tables: APIC: /* * Intel ACPI Component Architecture * AML/ASL+ Disassembler version 20200925 (64-bit version) * Copyright (c) 2000 - 2020 Intel Corporation * - * Disassembly of tests/data/acpi/q35/APIC.core-count2, Wed Aug 23 16:29:5= 1 2023 + * Disassembly of /tmp/aml-KQDX91, Wed Aug 23 16:29:51 2023 * * ACPI Data Table [APIC] * * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue */ [000h 0000 4] Signature : "APIC" [Multiple APIC De= scription Table (MADT)] -[004h 0004 4] Table Length : 000009AE +[004h 0004 4] Table Length : 00000CA6 [008h 0008 1] Revision : 03 -[009h 0009 1] Checksum : CE +[009h 0009 1] Checksum : FA [00Ah 0010 6] Oem ID : "BOCHS " [010h 0016 8] Oem Table ID : "BXPC " [018h 0024 4] Oem Revision : 00000001 [01Ch 0028 4] Asl Compiler ID : "BXPC" [020h 0032 4] Asl Compiler Revision : 00000001 [024h 0036 4] Local Apic Address : FEE00000 [028h 0040 4] Flags (decoded below) : 00000001 PC-AT Compatibility : 1 [02Ch 0044 1] Subtable Type : 00 [Processor Local APIC] [02Dh 0045 1] Length : 08 [02Eh 0046 1] Processor ID : 00 [02Fh 0047 1] Local Apic ID : 00 [030h 0048 4] Flags (decoded below) : 00000001 Processor Enabled : 1 @@ -1051,1256 +1051,1136 @@ [42Ch 1068 1] Subtable Type : 00 [Processor Local APIC] [42Dh 1069 1] Length : 08 [42Eh 1070 1] Processor ID : 80 [42Fh 1071 1] Local Apic ID : 80 [430h 1072 4] Flags (decoded below) : 00000001 Processor Enabled : 1 Runtime Online Capable : 0 [434h 1076 1] Subtable Type : 00 [Processor Local APIC] [435h 1077 1] Length : 08 [436h 1078 1] Processor ID : 81 [437h 1079 1] Local Apic ID : 81 [438h 1080 4] Flags (decoded below) : 00000001 Processor Enabled : 1 Runtime Online Capable : 0 -[43Ch 1084 1] Subtable Type : 00 [Processor Local APIC] -[43Dh 1085 1] Length : 08 -[43Eh 1086 1] Processor ID : 82 -[43Fh 1087 1] Local Apic ID : 82 -[440h 1088 4] Flags (decoded below) : 00000001 - Processor Enabled : 1 - Runtime Online Capable : 0 - -[444h 1092 1] Subtable Type : 00 [Processor Local APIC] -[445h 1093 1] Length : 08 -[446h 1094 1] Processor ID : 83 -[447h 1095 1] Local Apic ID : 83 -[448h 1096 4] Flags (decoded below) : 00000001 - Processor Enabled : 1 - Runtime Online Capable : 0 [snip] - -[964h 2404 1] Subtable Type : 01 [I/O APIC] -[965h 2405 1] Length : 0C -[966h 2406 1] I/O Apic ID : 00 -[967h 2407 1] Reserved : 00 -[968h 2408 4] Address : FEC00000 -[96Ch 2412 4] Interrupt : 00000000 - -[970h 2416 1] Subtable Type : 02 [Interrupt Source Overri= de] -[971h 2417 1] Length : 0A -[972h 2418 1] Bus : 00 -[973h 2419 1] Source : 00 -[974h 2420 4] Interrupt : 00000002 -[978h 2424 2] Flags (decoded below) : 0000 +[43Ch 1084 1] Subtable Type : 09 [Processor Local x2APIC] +[43Dh 1085 1] Length : 10 +[43Eh 1086 2] Reserved : 0000 +[440h 1088 4] Processor x2Apic ID : 00000100 +[444h 1092 4] Flags (decoded below) : 00000001 + Processor Enabled : 1 +[448h 1096 4] Processor UID : 00000082 + +[44Ch 1100 1] Subtable Type : 09 [Processor Local x2APIC] +[44Dh 1101 1] Length : 10 +[44Eh 1102 2] Reserved : 0000 +[450h 1104 4] Processor x2Apic ID : 00000101 +[454h 1108 4] Flags (decoded below) : 00000001 + Processor Enabled : 1 +[458h 1112 4] Processor UID : 00000083 + [snip] + +[C68h 3176 1] Subtable Type : 02 [Interrupt Source Overri= de] +[C69h 3177 1] Length : 0A +[C6Ah 3178 1] Bus : 00 +[C6Bh 3179 1] Source : 00 +[C6Ch 3180 4] Interrupt : 00000002 +[C70h 3184 2] Flags (decoded below) : 0000 Polarity : 0 Trigger Mode : 0 -[97Ah 2426 1] Subtable Type : 02 [Interrupt Source Overri= de] -[97Bh 2427 1] Length : 0A -[97Ch 2428 1] Bus : 00 -[97Dh 2429 1] Source : 05 -[97Eh 2430 4] Interrupt : 00000005 -[982h 2434 2] Flags (decoded below) : 000D +[C72h 3186 1] Subtable Type : 02 [Interrupt Source Overri= de] +[C73h 3187 1] Length : 0A +[C74h 3188 1] Bus : 00 +[C75h 3189 1] Source : 05 +[C76h 3190 4] Interrupt : 00000005 +[C7Ah 3194 2] Flags (decoded below) : 000D Polarity : 1 Trigger Mode : 3 -[984h 2436 1] Subtable Type : 02 [Interrupt Source Overri= de] -[985h 2437 1] Length : 0A -[986h 2438 1] Bus : 00 -[987h 2439 1] Source : 09 -[988h 2440 4] Interrupt : 00000009 -[98Ch 2444 2] Flags (decoded below) : 000D +[C7Ch 3196 1] Subtable Type : 02 [Interrupt Source Overri= de] +[C7Dh 3197 1] Length : 0A +[C7Eh 3198 1] Bus : 00 +[C7Fh 3199 1] Source : 09 +[C80h 3200 4] Interrupt : 00000009 +[C84h 3204 2] Flags (decoded below) : 000D Polarity : 1 Trigger Mode : 3 -[98Eh 2446 1] Subtable Type : 02 [Interrupt Source Overri= de] -[98Fh 2447 1] Length : 0A -[990h 2448 1] Bus : 00 -[991h 2449 1] Source : 0A -[992h 2450 4] Interrupt : 0000000A -[996h 2454 2] Flags (decoded below) : 000D +[C86h 3206 1] Subtable Type : 02 [Interrupt Source Overri= de] +[C87h 3207 1] Length : 0A +[C88h 3208 1] Bus : 00 +[C89h 3209 1] Source : 0A +[C8Ah 3210 4] Interrupt : 0000000A +[C8Eh 3214 2] Flags (decoded below) : 000D Polarity : 1 Trigger Mode : 3 -[998h 2456 1] Subtable Type : 02 [Interrupt Source Overri= de] -[999h 2457 1] Length : 0A -[99Ah 2458 1] Bus : 00 -[99Bh 2459 1] Source : 0B -[99Ch 2460 4] Interrupt : 0000000B -[9A0h 2464 2] Flags (decoded below) : 000D +[C90h 3216 1] Subtable Type : 02 [Interrupt Source Overri= de] +[C91h 3217 1] Length : 0A +[C92h 3218 1] Bus : 00 +[C93h 3219 1] Source : 0B +[C94h 3220 4] Interrupt : 0000000B +[C98h 3224 2] Flags (decoded below) : 000D Polarity : 1 Trigger Mode : 3 -[9A2h 2466 1] Subtable Type : 0A [Local x2APIC NMI] -[9A3h 2467 1] Length : 0C -[9A4h 2468 2] Flags (decoded below) : 0000 +[C9Ah 3226 1] Subtable Type : 0A [Local x2APIC NMI] +[C9Bh 3227 1] Length : 0C +[C9Ch 3228 2] Flags (decoded below) : 0000 Polarity : 0 Trigger Mode : 0 -[9A6h 2470 4] Processor UID : FFFFFFFF -[9AAh 2474 1] Interrupt Input LINT : 01 -[9ABh 2475 3] Reserved : 000000 +[C9Eh 3230 4] Processor UID : FFFFFFFF +[CA2h 3234 1] Interrupt Input LINT : 01 +[CA3h 3235 3] Reserved : 000000 ... DSDT: /* * Intel ACPI Component Architecture * AML/ASL+ Disassembler version 20200925 (64-bit version) * Copyright (c) 2000 - 2020 Intel Corporation * * Disassembling to symbolic ASL+ operators * - * Disassembly of tests/data/acpi/q35/DSDT.core-count2, Wed Aug 23 16:29:5= 1 2023 + * Disassembly of /tmp/aml-6DDX91, Wed Aug 23 16:29:51 2023 * * Original Table Header: * Signature "DSDT" - * Length 0x00007EEF (32495) + * Length 0x000083EA (33770) * Revision 0x01 **** 32-bit table (V1), no 64-bit math support - * Checksum 0x52 + * Checksum 0x01 * OEM ID "BOCHS " * OEM Table ID "BXPC " * OEM Revision 0x00000001 (1) * Compiler ID "BXPC" * Compiler Version 0x00000001 (1) */ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001) { Scope (\) { OperationRegion (DBG, SystemIO, 0x0402, One) Field (DBG, ByteAcc, NoLock, Preserve) { DBGB, 8 } @@ -4196,107 +4196,32 @@ } If ((Arg0 =3D=3D 0x0101)) { Notify (C101, Arg1) } If ((Arg0 =3D=3D 0x0102)) { Notify (C102, Arg1) } If ((Arg0 =3D=3D 0x0103)) { Notify (C103, Arg1) } - - If ((Arg0 =3D=3D 0x0104)) - { - Notify (C104, Arg1) - } - - If ((Arg0 =3D=3D 0x0105)) - { - Notify (C105, Arg1) - } - - If ((Arg0 =3D=3D 0x0106)) - { - Notify (C106, Arg1) - } - [snip] - If ((Arg0 =3D=3D 0x0112)) - { - Notify (C112, Arg1) - } } Method (CSTA, 1, Serialized) { Acquire (\_SB.PCI0.PRES.CPLK, 0xFFFF) \_SB.PCI0.PRES.CSEL =3D Arg0 Local0 =3D Zero If ((\_SB.PCI0.PRES.CPEN =3D=3D One)) { Local0 =3D 0x0F } Release (\_SB.PCI0.PRES.CPLK) Return (Local0) } @@ -4306,33 +4231,33 @@ \_SB.PCI0.PRES.CSEL =3D Arg0 \_SB.PCI0.PRES.CEJ0 =3D One Release (\_SB.PCI0.PRES.CPLK) } Method (CSCN, 0, Serialized) { Acquire (\_SB.PCI0.PRES.CPLK, 0xFFFF) Name (CNEW, Package (0xFF) {}) Local3 =3D Zero Local4 =3D One While ((Local4 =3D=3D One)) { Local4 =3D Zero Local0 =3D One Local1 =3D Zero - While (((Local0 =3D=3D One) && (Local3 < 0x0113))) + While (((Local0 =3D=3D One) && (Local3 < 0x0104))) { Local0 =3D Zero \_SB.PCI0.PRES.CSEL =3D Local3 \_SB.PCI0.PRES.CCMD =3D Zero If ((\_SB.PCI0.PRES.CDAT < Local3)) { Break } If ((Local1 =3D=3D 0xFF)) { Local4 =3D One Break } Local3 =3D \_SB.PCI0.PRES.CDAT @@ -7220,3281 +7145,3281 @@ Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try { 0x00, 0x08, 0x81, 0x81, 0x01, 0x00, 0x00, 0x00 // .= ....... }) Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device, x= =3D0-9 { CEJ0 (0x81) } Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion { COST (0x81, Arg0, Arg1, Arg2) } } - Processor (C082, 0x82, 0x00000000, 0x00) + Device (C082) { + Name (_HID, "ACPI0007" /* Processor Device */) // _HID: H= ardware ID + Name (_UID, 0x82) // _UID: Unique ID Method (_STA, 0, Serialized) // _STA: Status { Return (CSTA (0x82)) } - Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + Name (_MAT, Buffer (0x10) // _MAT: Multiple APIC Table En= try { - 0x00, 0x08, 0x82, 0x82, 0x01, 0x00, 0x00, 0x00 // .= ....... + /* 0000 */ 0x09, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, = 0x00, // ........ + /* 0008 */ 0x01, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, = 0x00 // ........ }) Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device, x= =3D0-9 { CEJ0 (0x82) } Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion { COST (0x82, Arg0, Arg1, Arg2) } } - Processor (C083, 0x83, 0x00000000, 0x00) + Device (C083) { + Name (_HID, "ACPI0007" /* Processor Device */) // _HID: H= ardware ID + Name (_UID, 0x83) // _UID: Unique ID Method (_STA, 0, Serialized) // _STA: Status { Return (CSTA (0x83)) } - Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + Name (_MAT, Buffer (0x10) // _MAT: Multiple APIC Table En= try { - 0x00, 0x08, 0x83, 0x83, 0x01, 0x00, 0x00, 0x00 // .= ....... + /* 0000 */ 0x09, 0x10, 0x00, 0x00, 0x01, 0x01, 0x00, = 0x00, // ........ + /* 0008 */ 0x01, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, = 0x00 // ........ }) Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device, x= =3D0-9 { CEJ0 (0x83) } Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion { COST (0x83, Arg0, Arg1, Arg2) } } - Processor (C084, 0x84, 0x00000000, 0x00) + Device (C084) { + Name (_HID, "ACPI0007" /* Processor Device */) // _HID: H= ardware ID + Name (_UID, 0x84) // _UID: Unique ID Method (_STA, 0, Serialized) // _STA: Status { Return (CSTA (0x84)) } - Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + Name (_MAT, Buffer (0x10) // _MAT: Multiple APIC Table En= try { - 0x00, 0x08, 0x84, 0x84, 0x01, 0x00, 0x00, 0x00 // .= ....... + /* 0000 */ 0x09, 0x10, 0x00, 0x00, 0x02, 0x01, 0x00, = 0x00, // ........ + /* 0008 */ 0x01, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, = 0x00 // ........ }) Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device, x= =3D0-9 { CEJ0 (0x84) } Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion { COST (0x84, Arg0, Arg1, Arg2) } } [snip] - Processor (C0FE, 0xFE, 0x00000000, 0x00) + Device (C0FE) { + Name (_HID, "ACPI0007" /* Processor Device */) // _HID: H= ardware ID + Name (_UID, 0xFE) // _UID: Unique ID Method (_STA, 0, Serialized) // _STA: Status { Return (CSTA (0xFE)) } - Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + Name (_MAT, Buffer (0x10) // _MAT: Multiple APIC Table En= try { - 0x00, 0x08, 0xFE, 0xFE, 0x01, 0x00, 0x00, 0x00 // .= ....... + /* 0000 */ 0x09, 0x10, 0x00, 0x00, 0x7C, 0x01, 0x00, = 0x00, // ....|... + /* 0008 */ 0x01, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, = 0x00 // ........ }) Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device, x= =3D0-9 { CEJ0 (0xFE) } Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion { COST (0xFE, Arg0, Arg1, Arg2) } } ... Signed-off-by: Zhao Liu Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-11-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 2 -- tests/data/acpi/q35/APIC.core-count2 | Bin 2478 -> 3238 bytes tests/data/acpi/q35/DSDT.core-count2 | Bin 32495 -> 33770 bytes 3 files changed, 2 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index 0f95d1344b..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,3 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/APIC.core-count2", -"tests/data/acpi/q35/DSDT.core-count2", diff --git a/tests/data/acpi/q35/APIC.core-count2 b/tests/data/acpi/q35/API= C.core-count2 index f5da2eb1e8a93d961b39f665f2e8b02acf1aeb3c..4f2428443430b7da8321e9edd81= 6219deb7929a2 100644 GIT binary patch literal 3238 zcmXxmby$@L7>4l=3D5IyGriroq-c6Un%f(43!4Ju%FCoFWS>+W#f-LAWJ9j?3EZMyH~ zdB%0*{(jUSTwd=3D(R#8FDzT_ZCIGkOWlV6;cT~d^j7QV#=3DLBKN&f4Y) zR}&J{TD8=3D~M74HpwN4#15>ca3H5OBolGNm6H6=3Dx@TUV`DPfbl#>(^HsG*BBhR2wx? z8#h*)G*O#2RhuSZmv`|~NR9m%DTenu*v{Bo(RrPxbBI)UJyLM{(_G*U?YDR|I zv7_3lliInn+NF!ywX52#o7%m*+M|csv!~jtm)g6x+NY1&x3Ai-pW45_I$(f0aG*M9 zkUDsRrAyUi z%hct|)fFq$l`GX%tJKx2)irC>wQJRN>(uq@)eRfejT_ZXo7Byl)h%1pty|S?+tlsb z)g3$3ojcX4Dz&EHirqHX>*|PSvH3X zpKWun@HsYz3!iIq!0>rChYX)@bI|YwHir#gXmjB3MK*^HUu<*m@Fg~f4_|6?0P$ru zhY(+Gr`cE7>GqX22QqvGSJ@m&e6`KN#QW?F`x=3D`A%IB}OIi&bHn}dq4w>hl%2Aczm zZ?rkI_$Hf!i*L3$y!aNI1B`FAImGxjn}dvRw>ixC4x0mw@3cA8_%54+jqkQO-1r`w z1CH;tIpp|0n}d$;w>j+i0hL z0};N0Cv1iSKWQ@<_$fQre%j8npRpMdzW!O8LBY@23=3D4kVW?=3D9OHbaA7v>6=3DylFjho zmu&_JzhW~)_*I)h!mrs36Mo%hpzr~kp~44k1`EGoGhFyhn*qab*$f$e+h)-4J2u0H z-?bSy{GQFw;rDF@4}V}YeE36~0mO%Fh7f;bm)alOW%egF0~x-8Pi=3D-0e`Yh7_;b75 z{=3D%-XzqBjuuWSZ2d<9?I3@iS|W?=3DERHbaZQvl(3cz0L6AA8ZB~|7bJB_$Qk|#y{H( zGycV9pz*IZLydp48EpK!&2ZyCYz7?vX*1;bFPlNfhi!%(|7|ny_#d00$N$<4K0abI z{P?KN9{`wl>^*-7V0Io?+3Y;7wrh4inQz?Bj}GEv;XfXDN=3Dyu!!c#Q*|5Ggd0(~qg Qspcsbe)rMvE&PGOe_jvc0RR91 literal 2478 zcmXZeWl$DT6oBC+KKO#RP*m&=3D4D137us{*TMz9O9Td}*lI}y7Jv9Q1{3{VuiJJ3D6 zcW3rK=3DbgE`Kkn?0^$7~_i#2JQO`>n0pMP*Z-_RhxeEMajX`0NUrln+LYSc8evO;TX zw6Q^3TQnHZ&JOME(P%`I3C(7-SkS=3D%9Ualh37wtM#RXkm(ajCBWWlUiFfD+ZQ7vv0p!oio*W=3Dalil^I1mR7!oh=3Da z$PgSl6o(DN;lpvn2pl;QM~%YKqjAg_96J`HqjB6g96uf>Ou&f~andB5JQ=3D48~5zNy?b%rKHR?_4;;XQ2l3D$JbW0B9KoYU@z^muejHDnz>_C2E)Gwf!uWVR zeHzc4!Lw)a+&Mgd9upGq!Ueo|5iecB%a`%W6--RTq$Iq06|Y^x>(}wd4ZL|1Z{5P% zxAD#$yn7e#-NXC$F*z9@Jivz!@zEoE{1{VGFf|pQJi(_=3DF)awzkI>3U-8>F{Qez({J@_-@z*c>{Tu)M z!M}eoBSSQ~XxcwrnMG-d%su)dZKYb2wpJ}l+o%?$ZB>iX2GydpooZ3qUbQG~R4q!I zREyGP)uOaTwJ7bNT9kHFElNA77Nwn4i_$KtMQK;nqO_apOda&|(&92?wKnUw3^ExE cx{flL^j|P0v%Z1JV#%D$`qTgPOMjvEANV#K5C8xG diff --git a/tests/data/acpi/q35/DSDT.core-count2 b/tests/data/acpi/q35/DSD= T.core-count2 index b47891ec10be131a59bf404242241c054ac902f8..3a0cb8c581c8cc630a2ec21712b= 7f8b75fcad1c8 100644 GIT binary patch delta 7005 zcmZA0cUaYR6vuHcmD)`M6Dpcop=3D68FRGPxQSQ+I2Hwg|D$rMA)wuyop<*2xEptuoH zapMFxZrr$095})Kguios=3DlOl^^YGliczw_J`#aCOJ%_q}6KALiUeBHm>ly%joe&wv9npJESpSH!iMaFibUbVckJpBA>RUFW;g2TVT zClndy?K{A$NU%Zdp_&wR(`he=3DQe;Mo750h$58R0;z8L& z#nU`hbqzHT)Id<~q6X4!Ri7Ga5U4?*o)R^PzG`aTu-+5pkpL=3Dz`uFj+CD35~uli5^ zD0Se@J~r_bQL)|$z@eZ)>S3xssd<3T=3D}X-QPWV})$?-1DC!<6ZwmO>c++SYJQ@aj zh#F1HRdH9zpprp(ib_rnGe>b&1c(4t6-3ln6=3DyXD)EH1Nh#EsWyrgN&e zvnimafO=3DKb6#B50`7Wa~->IOcf_hEVRO;7Cx(lEu-K7Fb1@yY0RF~bQT6dSKy9?y* zrqT6Qy1O^zh-p;0wcIw4yPFP!r^DbkMNOxcs<^uupk{!oE@}o%Q^n!U1T_;>4N)_x zSQUqt1}Y8ITcXmaZX5Gm9NsKYvp~HqY8L&Yio=3D@?YBs2MM9rqHsyMuKQ0bt2MWwqe zFWtJlbj$LL@a9m%wz|BUa>N`8Z)-l1!P=3D?FyGOWAH(A@=3Dbc#CONxbE&lIbty_2$wGt#NlPa;7l0&k*G{6RmI^g z0ks5_zo;eD@F#N?hnEE^3)IJ=3DvS_F(4sR)_rJz0$wUiF1;_#M%S_Z0)sAcpwf=3D;#9<<*lTR?tHo%;Bws!7E{K zeNii^QH1$O4sR8xRiGM(T1BH&ad@jitp*h!YBe2I#o?_1wFcB@qSnwmk>(9KytSa# zg8E$4TI!*S!&?Vx9jGrvt)mr@5?+uIUJjrfKwk>VaoJstb$2B9ad832F+W><%z~HY%ZJ=3D?gIJ}LZHiBv>Y9pOe#o=3DuNwFy+9s7+M6qj^IPZ!@UP zpn^ngrrxSJye*)%fO3f1LhDpQ1etb;kcZ7_Hn4E{#cHoBmS!`lvOJE(6(Z72WE<|8@09iVoA`cBji z`a>0mw-eM(P>n_Hq|K^0yj`Gnf%;z5E_y!7ydj6T8`N%4A)nI7&VT6|tC?C)d zg7RH~2DcJ*gc4M7 zct=3D4U1=3DU*AQQD)5!#f7*7^pU)j?pXK%o}oe$3Yzj)mGGT>a2>xI|1qhsCJ@G&>~eF z-bqj=3DL4}JtNq4(Rcupg{LO_LpeiBsZvb#d-?h18x!5rQxijC3TwU;AK(eN1gGQk|) zX&8JO21kfGO@~x*cxOPJ0Tn6g3|0TxoWLltsJyylxT>y0fRA*5a=3D-ck*yEwceP(`4kL>0L#ugJQ*BFplO@GjE&?z+4# za>PYCu7f$eOECBn4DKrG64m_0ye@}V45}DZw5Vc=3DRmI_526Y)!H&K^ql`0PJ3aBff zVnkh`r+b(;{jqpkUl>quhP>IX#O02sp z(cLxT@UD|*Pu*P)IpR9K-&5Y$h{L-9gKxm#o}zA0UsW95O;9&M#frK~>s4`hw?N$j z)l1YZvd5Y?(_VCF(IX ph->5iw~Z*SqwOCmjf=3DAVOX0nvZ2f6t`R{+^*Qa(?$e%Nx`XBpVSA+ln delta 7056 zcmZYDc~DjN6~J*03Oso1!Zc1N({Y@{rcS5tJ(l<0bUK~4HeDh`u|}<1j8RN%v^J(T zMiWs%al_-jf}p5~im0f#;l3m8yW+kf?mMP;`~7mRhd;P;=3D6&w>{_gqn-pLJZY=3DS6% z2Y*)M@Q@H_UlA42GBm$6wrE)qn)e>=3DZuvpz-)buxS~{ag6h>n|YjYUmv)fX$wINI! z()1x*8`AY5LK~d=3DV9^GbK16DRTOXpd!J`jWZSd+tv^MzkAx0hA+5GwxtNj$vhd6Br z>O;Ib*lqfdpbd6?NYn;LcGAb;z7AQQ$gZu?^XnG4?8Eo4^M|LQMWv&Sw@pmW$IX2< zmt$mz`iBMWk}TFJONeFUNWiu2T79JdoRXvcoD|bT30X?iTvU#w$0wew1Wo7U0RAFF z=3D+seMk0N^1D8Qjor;X-%G|{6+1D=3DyQeGJ!Qh#oTr@DG0%CvoO-olA6XF5m*GU3pyR z5uKL@2$`bo9?SJuqQ{N}?48-lSg>cDrm-l~Sn#-UfV*VOo6lqUB$l5K*rvUBv~N7u zy+BB}G5j|}h;A^SVr*l1>=3D;_k|yZu9)#5sfO8AQ*R0k~Ca*G#Tw58!0R&Rox@{uNNmm=3Dz(0K|9_^dU^<1Lo&IMd5 zwSOMh^N5}|5763Kv;*_Go=3D^1r`G5nY4ldw&0nrN<0M-iau@!P%NOWN#puLN65|6!z z>ms6yiU6^Tv0#s5p{B8}i?QH^3jv?XSV}RE6_Z$TF<_^z;?b!kT$d1CQUbU^>a;~% zFCu!;BEVn%Q?%0;bG?}8#ft&Im)cp%bt%!MrGS^Db}iw03DHZI0D8KKlem|1y_D#s zO96|!i3NL>X&URh84F&v3^1&_hnH_RaOFiD|PA`uGbK~W)0vOsngbSy_V>;YXN`% znK()MI1=3DgJgJ>kTvriYRR#Ey)UNehuP1u_dca=3D2#Yx;7xZXhYh7Eu_dW!{n zHfkE-b7R39Hv)d}xrlkId90ems;dEWrS@&&dK1x`HUZw2+P|6W%|vhB4EWbR;v|7B zTyG(I%ND?Lse@a&-b(b=3Dt$=3DY~7;T?z8`s;2-nI>Jkks}Xu4{;{sR2Cpg|T3tW4op? zp|7#v?b`v<`ie)V?BKB-B(`G*;0&o#cXGXx=3D$$(OUrL>}i|buP@7e{}wVyai`fjdw z6TN#k;AW|vd$`_1^qxI{zseSE*Iuso61{gX;Ez(f_i??C=3DzaSDuV#w{d-iJ@TlF^< zynjDnpuc#u_W+L_Ah81n086Fz9pw5T(FYF#Mt&*U{zF_JBKpuFz%Qi^9On8k(T5KM z9+Em(%XKZ$wY7l1`^q?p-*$xSBSarL0$3omy^iZTqU-7aAAe;m*zY*1X|xY87JT$5 zV8;RC(J9Ax>=3D=3Dn1I|f)Kb?R}hj}v|TIAF_viFVovu1^qs;soG#Qm3Ef`XtdOPXb<$ z+IfoWQ$(LS1^CCW#YtSJxjs$w>C=3DEkQoGM^eTL{WX8@ZG6bts8)iinr8Vf#q7O>Ai z@o4Wk9y>>3=3DgtA{k=3Dl2j>+?jPKM(lPAkp?;;Q9j57cKziOC7k#^+lpDUIc8AI(Uie zOGIC~1eoz}<0JvwWv(w1efctAh1B+XuIq`euLo=3D~*jRADaYfUZIoMe6l`DYX3>J@0 zxyoZ#N$l!Xz*ADEUgP>2(buj4y8k2EY1g^FPW1KbfODiyzrpnlqHo*)Y?9h}lk1yA z-@FOf;~Q}j*DbDZ5q;|xV2#x7+g#r!`u1(W)nB7%c>>t^f1;iClVEp_@cuAdS8>>1$u--)*KIoHpLe*PSA zgw(DVT)!at#S6fCsogKReo6Gpmw>)uV!@tQn#Lc884G^(3UJXdaZvAT9(zqH31%wI`Ee3w?w~v3;5gNokM>L!Mx$0;qrDCd^Ef} z#%5UX(-GYv6stz`foAyr55KW=3D9qA8OKSN_tMpCBoO*$#|=3DZ~?^cady3$vX9HggF~w&PEtn^-8nKT_hVpvMx27XtkKL z7Uc_OW^!B0I~hfhjD=3D*}dM47GiBvvqwoh&w`A$YrBoj$89{nYw%$X?jOGX(lsb1+z zDtD1=3D6v=3Dw^tks;gnzL3Tt6phVxr=3D12B^cadx~$@=3Dwdj5!-) z&c+y7^-8nKT_hVrvH?9CYtF`+v#~~2z0$057sx --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352426; cv=none; d=zohomail.com; s=zohoarc; b=MmFTaobT85rIs4P7UJpMq4uZ1tFBQ3eqSqtN/x5+YsKCrbFYjJgd4QO+3ii4Ghjr4neHMcqFZqZmXyBKWbiJHH80p4M4kdGSEHM+RmK9kC0TuQM+R9zjfik93QbumZK4nk3T7LBE4FtHjoYr3lO3dXbQuj+HEBI5um6XyHTl/Ws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352426; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LcAijS7Yd/T++Hyga8YX5w8OlX23Y/cXaSYo0SnpUO8=; b=RuZcai3XWTnx9Sa9jcyCORd5su7EDMD9TyUQYO11A4dcX0jPUwswwy6Noejk/FWOAMMCqzjBT7pCTU3BXGGMv/Y8rLUclpRX0bBoec5Pe6SZHmNHv7Um1ZDjU66+h7SXUN4L32ZqENalrRYzxZSJHZjBdDkaTHYWUJFAYQQPSCA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16993524259901020.5686038387872; Tue, 7 Nov 2023 02:20:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4D-0008Oh-D8; Tue, 07 Nov 2023 05:12:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J44-00083v-Uk for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J43-0002el-Du for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:08 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-231-dkgkyXkwNtCQIu_nfOfujA-1; Tue, 07 Nov 2023 05:12:05 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-408f9e9e9b0so35072045e9.2 for ; Tue, 07 Nov 2023 02:12:05 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id n30-20020a05600c501e00b00405442edc69sm15255050wmr.14.2023.11.07.02.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:12:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351926; h=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=LcAijS7Yd/T++Hyga8YX5w8OlX23Y/cXaSYo0SnpUO8=; b=fFI8Ll1CrCiWx/N93q8AdAyCPBDuMsSq7LRQpz4dx6Jm+O1vIb2Xru5DDAFcCdbwxGALTq ujSMucabq6OsPhl7laGGxMeJtD84Vl+JoR1XjNUkrZYfDbOkO6kf48n7SeX60j4gU7Ou6P nxpdNLjsCUhnl1b/vNhvioGwOmPUIBY= X-MC-Unique: dkgkyXkwNtCQIu_nfOfujA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351923; x=1699956723; 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=LcAijS7Yd/T++Hyga8YX5w8OlX23Y/cXaSYo0SnpUO8=; b=M/b6ifjbIjxMOzpR0b1odeNxnLtZsag0t8gpzQ+aDKJyB93v1JFA33605TGOv3CBN4 ehWiDjnW0fFAwGNDbhohaSpmTeRx6qS1iEVZ8FAvCldQ0JTXBbS4BOA3mItdOhEUbbCw /ADjAkzuaEOPskVb1B4hp2Fz4oDMgcaHpi2zpOGM0DaAn6b0+utmSLbWPixKrAAmLEh4 084aHAGTZU4NMMR385kSXBL06X2pP1qovayXqBcWZt8Es4ngYXqR/d0Si4EZSapGmwgF 3HJTpjenr+s44rC5ezVojzYXAHV3h16WK+7zQKDPznvJr41z19bHQePXSotshqwopZvk nsjw== X-Gm-Message-State: AOJu0Yzj096Xv2w1N6sCxWY+dIGV7TpSFDE3aEOVVMhW65IjvN0SLo7c DGYwzj1ORol0qQnVoaKGakZCQdMk3aaGgynGWkWfqyynSi/n8UhUJxwF5bV+SYAo847DC3NylPY n1YNGLqkJT5UzJA5RvBDlk0IEysKv1UUxPFonxk2LnNuG7ZBaHJc/ztGtfFAWSo30iMjR X-Received: by 2002:a05:600c:4f16:b0:405:3885:490a with SMTP id l22-20020a05600c4f1600b004053885490amr1834949wmq.0.1699351923575; Tue, 07 Nov 2023 02:12:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGrW1+FTPOBRL7MRccwZW7EiKBMquD8iF2AiFs0ovUGbznxpUmzYINmxmNWCegt2AegHIQwcQ== X-Received: by 2002:a05:600c:4f16:b0:405:3885:490a with SMTP id l22-20020a05600c4f1600b004053885490amr1834929wmq.0.1699351923280; Tue, 07 Nov 2023 02:12:03 -0800 (PST) Date: Tue, 7 Nov 2023 05:11:59 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 34/63] tests: bios-tables-test: Prepare the ACPI table change for smbios type4 thread count test Message-ID: <85ccbe1275b58efe9e30d229c942d33144b5ef6f.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352427043100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu Following the guidelines in tests/qtest/bios-tables-test.c, this is step 1 - 3. List the ACPI tables that will be added to test the thread count field of smbios type4 table. Signed-off-by: Zhao Liu Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-12-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 3 +++ tests/data/acpi/q35/APIC.thread-count | 0 tests/data/acpi/q35/DSDT.thread-count | 0 tests/data/acpi/q35/FACP.thread-count | 0 4 files changed, 3 insertions(+) create mode 100644 tests/data/acpi/q35/APIC.thread-count create mode 100644 tests/data/acpi/q35/DSDT.thread-count create mode 100644 tests/data/acpi/q35/FACP.thread-count diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..4d139d7f6b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,4 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/APIC.thread-count", +"tests/data/acpi/q35/DSDT.thread-count", +"tests/data/acpi/q35/FACP.thread-count", diff --git a/tests/data/acpi/q35/APIC.thread-count b/tests/data/acpi/q35/AP= IC.thread-count new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/DSDT.thread-count b/tests/data/acpi/q35/DS= DT.thread-count new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/FACP.thread-count b/tests/data/acpi/q35/FA= CP.thread-count new file mode 100644 index 0000000000..e69de29bb2 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352376; cv=none; d=zohomail.com; s=zohoarc; b=oFL7UZA6GfNzlR8jO0uoJtx3ir/i+dc5aQdkb6kLNsyKqeJscixvWoLU9LfhxcPB2jUveQdvYe8fGvAoYj4qCgKhjkvCR3NwBo+w2r+1clmyKKNBuGBBtim6kir8HZ442wAIrbuFjy9lZAX7tFdMypcJoe0X41nVRV/8dSmTWpQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352376; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kvKinPzzhIdC86ZBf7W/UsCNgZ8n3aoFrJd6rA7avKY=; b=BCtlaQK/Eb/OOQx35a6P8U1mT7bv5m1CW3+rRJs7/H29ltkoQ5Ot7XCkseTQ5zhvZQaxP9JDoocMkaAolG/R89QXTKZbQUW9DThgI1LZdhQc7tA9IMgvq9rUdPMspbGziJQvyW3BnjJNpt7heJQa6fLsrRMdW91PkMULxpiIM9U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352376134385.6709267243756; Tue, 7 Nov 2023 02:19:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4D-0008Sk-Q5; Tue, 07 Nov 2023 05:12:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4B-0008CM-IE for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J49-0002g3-6A for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:15 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-56-ZSbS4c5ONE6Fgqkv48QXYQ-1; Tue, 07 Nov 2023 05:12:09 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4094158c899so34463545e9.3 for ; Tue, 07 Nov 2023 02:12:09 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id u6-20020a05600c210600b003fe23b10fdfsm14728677wml.36.2023.11.07.02.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:12:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351931; h=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=kvKinPzzhIdC86ZBf7W/UsCNgZ8n3aoFrJd6rA7avKY=; b=LP15Y/LUcLkKV8YGwBojX2ub4ALKHxNvx4QJxrdWWqFR9QwcbmZ7v569Ljos4eIZrXgMRf YQk/myxXY8c1QAC78LjlPnutPQv9ssQ5BGyxyPHgMX3wTmDdrswEm9x0V9ajXch+ORDbj0 WdlTpiilmH+HJQWiYoVKOdn202q64RU= X-MC-Unique: ZSbS4c5ONE6Fgqkv48QXYQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351928; x=1699956728; 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=kvKinPzzhIdC86ZBf7W/UsCNgZ8n3aoFrJd6rA7avKY=; b=kH6S5Ludc6QxFE09TxPhh9mfo3P5ryO7NIpPTFqNvb5is58mkX0UzUBoSg3vC14hJO oou0avKID77TUEOEN2tooDWPBCFpWfi0Ld2x+YPnKzOx85975bMOjC0pq+tV7RiYoEa6 ycEJ1BaS8DStPAy7biDtXR1n78k1cbAs7zWWnKVtIsgMWRWaNZUyX3VRTkH5BizdBJ5T ixr/WP2m/QvKih9tZknO70oQQRrYpaMLfas7cH4V0/mRn+hUUULneHZicvFhXk/XiHpK 6buKIaWam7EEGTtUdX2iU2MPFdkKRekkHCUYBjvmrqU2cvEXdOsQPEyupASbczXlklkV hQdA== X-Gm-Message-State: AOJu0YxGCKsJBb5a58PNqE2D16tjY7K5qrzMehBtHCksK+4Wb1JBMXgl 4EOV4CQ9y3n5lhBWZ/AVs/IXNs/INjYl6FyTgfx28fAB+9HOI07pZPLS5YMKKkT26FRhxDMqFEF z4inT7dQ7Od2LvyJeHxVXq0u7A3SVMvYD7LOYxrdgyO4VnJrAc1LKil5kNP+LD4qr0cCo X-Received: by 2002:a05:600c:4fc7:b0:405:95ae:4a94 with SMTP id o7-20020a05600c4fc700b0040595ae4a94mr1685748wmq.5.1699351928085; Tue, 07 Nov 2023 02:12:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFxBk6qfHpx20Nxu9TGshHZFipEP6RPVbHpjECWRYRlUPGZpnrEopnwQidsqrRfZtZBxDqQg== X-Received: by 2002:a05:600c:4fc7:b0:405:95ae:4a94 with SMTP id o7-20020a05600c4fc700b0040595ae4a94mr1685734wmq.5.1699351927758; Tue, 07 Nov 2023 02:12:07 -0800 (PST) Date: Tue, 7 Nov 2023 05:12:04 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 35/63] tests: bios-tables-test: Add test for smbios type4 thread count Message-ID: <7ee18dcef14540c79892381d7af0a2c54ec11484.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352378211100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu This tests the commit 7298fd7de5551 ("hw/smbios: Fix thread count in type4"). In smbios_build_type_4_table() (hw/smbios/smbios.c), if the number of threads in the socket is not more than 255, then smbios type4 table encodes threads per socket into the thread count field. So for the topology in this case, there're the following considerations: 1. threads per socket should be not more than 255 to ensure we could cover the thread count field. 2. The original bug was that threads per socket was miscalculated, so now we should configure as many topology levels as possible (multiple sockets & dies, no module since x86 hasn't supported it) to cover more general topology scenarios, to ensure that the threads per socket encoded in the thread count field is correct. 3. For the more general topology, we should also add "cpus" (presented threads for machine) and "maxcpus" (total threads for machine) to make sure that configuring unpluged CPUs in smp (cpus < maxcpus) does not affect the correctness of threads per socket for thread count field. Based on these considerations, select the topology as the follow: -smp cpus=3D15,maxcpus=3D54,sockets=3D2,dies=3D3,cores=3D3,threads=3D3 The expected thread count =3D threads per socket =3D threads (3) * cores (3) * dies (3) =3D 27. Suggested-by: Igor Mammedov Signed-off-by: Zhao Liu Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-13-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index f3af20cf2c..395ed7f9ff 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -95,6 +95,7 @@ typedef struct { uint16_t smbios_cpu_curr_speed; uint8_t smbios_core_count; uint16_t smbios_core_count2; + uint8_t smbios_thread_count; uint8_t *required_struct_types; int required_struct_types_len; int type4_count; @@ -640,6 +641,7 @@ static void smbios_cpu_test(test_data *data, uint32_t a= ddr, SmbiosEntryPointType ep_type) { uint8_t core_count, expected_core_count =3D data->smbios_core_count; + uint8_t thread_count, expected_thread_count =3D data->smbios_thread_co= unt; uint16_t speed, expected_speed[2]; uint16_t core_count2, expected_core_count2 =3D data->smbios_core_count= 2; int offset[2]; @@ -663,6 +665,13 @@ static void smbios_cpu_test(test_data *data, uint32_t = addr, g_assert_cmpuint(core_count, =3D=3D, expected_core_count); } =20 + thread_count =3D qtest_readb(data->qts, + addr + offsetof(struct smbios_type_4, thread_count)= ); + + if (expected_thread_count) { + g_assert_cmpuint(thread_count, =3D=3D, expected_thread_count); + } + if (ep_type =3D=3D SMBIOS_ENTRY_POINT_TYPE_64) { core_count2 =3D qtest_readw(data->qts, addr + offsetof(struct smbios_type_4, core_count= 2)); @@ -1033,6 +1042,22 @@ static void test_acpi_q35_tcg_core_count2(void) free_test_data(&data); } =20 +static void test_acpi_q35_tcg_thread_count(void) +{ + test_data data =3D { + .machine =3D MACHINE_Q35, + .variant =3D ".thread-count", + .required_struct_types =3D base_required_struct_types, + .required_struct_types_len =3D ARRAY_SIZE(base_required_struct_typ= es), + .smbios_thread_count =3D 27, + }; + + test_acpi_one("-machine smbios-entry-point-type=3D64 " + "-smp cpus=3D15,maxcpus=3D54,sockets=3D2,dies=3D3,cores= =3D3,threads=3D3", + &data); + free_test_data(&data); +} + static void test_acpi_q35_tcg_bridge(void) { test_data data =3D {}; @@ -2201,6 +2226,8 @@ int main(int argc, char *argv[]) test_acpi_q35_tcg_core_count); qtest_add_func("acpi/q35/core-count2", test_acpi_q35_tcg_core_count2); + qtest_add_func("acpi/q35/thread-count", + test_acpi_q35_tcg_thread_count); } if (qtest_has_device("virtio-iommu-pci")) { qtest_add_func("acpi/q35/viot", test_acpi_q35_viot); --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352202; cv=none; d=zohomail.com; s=zohoarc; b=F0M5q+oY7mW0dh0Y0dn8pIkwMDrHR7yJeYNiK9ZPtmB70Qtag24YCMstFazcsZcQJE3tyEjvZ1dCaT90fxkYHz6HJsLEV4JvH9aNETK7oB4e7rTjUe5hotbUubPN95QZLcG6PPlV6LTq+j1IeOvPbp3uGocuzygH+mczPBZvBuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352202; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AUutUF/PrSlFu7yDRlyVmJDAS8y0Qix7Q3WanV8uYcI=; b=kkm7zYLYjI1IWcNcrKnHrBeeWygh5/eX/7+uqR13KR02et9hUU5hAqE0gQSF2HntZyQUnykKM5oWCLBBHKzPZnF4jhABwYsxbyJ09kec2AynJkjprbLTWf97Y07Z2BhX/bOrZVGZ7vFZEUkxH3pZ0M0UcZ9AYdR8UzBOt8QKcHY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169935220296946.528722745919254; Tue, 7 Nov 2023 02:16:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4L-0001QJ-Fa; Tue, 07 Nov 2023 05:12:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4J-00014A-GN for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4F-0002gr-T4 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:23 -0500 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-185-xT-mRVx3OjSjxsShtHZe-Q-1; Tue, 07 Nov 2023 05:12:15 -0500 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2c5073588cbso45812341fa.3 for ; Tue, 07 Nov 2023 02:12:15 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id r13-20020a05600c458d00b00406443c8b4fsm14975679wmo.19.2023.11.07.02.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:12:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351939; h=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=AUutUF/PrSlFu7yDRlyVmJDAS8y0Qix7Q3WanV8uYcI=; b=h/TVYbf06k+FnWmoWrTu3vWl9yhbEUIWvgsNf1exXoo87DdvwCug5w9vlr9e0Cqp4P69DQ mJy9nEm2Ih98xtuuRSbcoienuwPdYJGRLBDVQ7EwOQRbEvk/xayzHqYuzJ3nTg1qk+oXaY R7/vKSDidmqaYZpN/RqAAa/W6ImI2Lc= X-MC-Unique: xT-mRVx3OjSjxsShtHZe-Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351933; x=1699956733; 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=AUutUF/PrSlFu7yDRlyVmJDAS8y0Qix7Q3WanV8uYcI=; b=wBKcxe0xHslFzDuAdSx3/OiP/bBv8uQFrDoDNDlieQV6IoGIZ7aNe21iUfMrvCVLW5 LTh81LZSyBPmgbcfvqSuiEqy7KpLcFYjaiKWv0InwtmeoVtJi2yBCTaXE7Xrj4vKwXR3 wjjbPdXQUL5kUtAkbbDg4C2Y/aopZyWyKsY7s33JlkuTA4yhrWkmGZgahT1XF1MFqeLW cOxt3mACo6S4E1BG3o4TlxBM5M971j88i7VH4lcWMGm3ZkZcuY+7Ahvu4PzCKgNYioLz gT2JntFIHpRGJ0x06pVJtCLCIe3BRUnM5xHSloyXpBu2tHv7C35Iej/EGuD+4j3Q7BlN DGuw== X-Gm-Message-State: AOJu0YwbaTM0o+lkY4yVpgnncRHzLEeyzLw78Ntmcwc5QQ3T7VLbqvjQ kbg7rnKIqhEOzPWHu/g3f+xhGQqTwgNe35512P+vGbw0vQpdx18hJKzlaPuHd+kyCsuNFPSaqCn E/aQHx6a77+QcP2uPp/RWfKT+IjYHPVRXVaNII/Ws8i79quGh0+1bAr+U7ydMaHyRuSua X-Received: by 2002:a2e:8919:0:b0:2c5:18ed:1809 with SMTP id d25-20020a2e8919000000b002c518ed1809mr28908512lji.34.1699351933124; Tue, 07 Nov 2023 02:12:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvmnNv6gDnMD+wmZkXcLAEn015pYfrEonIvBwzv4BAd0xiy6scPci1df0EKdMoga1IUpaFdg== X-Received: by 2002:a2e:8919:0:b0:2c5:18ed:1809 with SMTP id d25-20020a2e8919000000b002c518ed1809mr28908482lji.34.1699351932487; Tue, 07 Nov 2023 02:12:12 -0800 (PST) Date: Tue, 7 Nov 2023 05:12:08 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 36/63] tests: bios-tables-test: Add ACPI table binaries for smbios type4 thread count test 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352204420100013 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu Following the guidelines in tests/qtest/bios-tables-test.c, this is step 5 and 6. Changes in the tables: FACP: +/* + * Intel ACPI Component Architecture + * AML/ASL+ Disassembler version 20200925 (64-bit version) + * Copyright (c) 2000 - 2020 Intel Corporation + * + * Disassembly of /tmp/aml-1NP791, Wed Aug 23 21:51:31 2023 + * + * ACPI Data Table [FACP] + * + * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue + */ + +[000h 0000 4] Signature : "FACP" [Fixed ACPI Descr= iption Table (FADT)] +[004h 0004 4] Table Length : 000000F4 +[008h 0008 1] Revision : 03 +[009h 0009 1] Checksum : B3 +[00Ah 0010 6] Oem ID : "BOCHS " +[010h 0016 8] Oem Table ID : "BXPC " +[018h 0024 4] Oem Revision : 00000001 +[01Ch 0028 4] Asl Compiler ID : "BXPC" +[020h 0032 4] Asl Compiler Revision : 00000001 + +[024h 0036 4] FACS Address : 00000000 +[028h 0040 4] DSDT Address : 00000000 +[02Ch 0044 1] Model : 01 +[02Dh 0045 1] PM Profile : 00 [Unspecified] +[02Eh 0046 2] SCI Interrupt : 0009 +[030h 0048 4] SMI Command Port : 000000B2 +[034h 0052 1] ACPI Enable Value : 02 +[035h 0053 1] ACPI Disable Value : 03 +[036h 0054 1] S4BIOS Command : 00 +[037h 0055 1] P-State Control : 00 +[038h 0056 4] PM1A Event Block Address : 00000600 +[03Ch 0060 4] PM1B Event Block Address : 00000000 +[040h 0064 4] PM1A Control Block Address : 00000604 +[044h 0068 4] PM1B Control Block Address : 00000000 +[048h 0072 4] PM2 Control Block Address : 00000000 +[04Ch 0076 4] PM Timer Block Address : 00000608 +[050h 0080 4] GPE0 Block Address : 00000620 +[054h 0084 4] GPE1 Block Address : 00000000 +[058h 0088 1] PM1 Event Block Length : 04 +[059h 0089 1] PM1 Control Block Length : 02 +[05Ah 0090 1] PM2 Control Block Length : 00 +[05Bh 0091 1] PM Timer Block Length : 04 +[05Ch 0092 1] GPE0 Block Length : 10 +[05Dh 0093 1] GPE1 Block Length : 00 +[05Eh 0094 1] GPE1 Base Offset : 00 +[05Fh 0095 1] _CST Support : 00 +[060h 0096 2] C2 Latency : 0FFF +[062h 0098 2] C3 Latency : 0FFF +[064h 0100 2] CPU Cache Size : 0000 +[066h 0102 2] Cache Flush Stride : 0000 +[068h 0104 1] Duty Cycle Offset : 00 +[069h 0105 1] Duty Cycle Width : 00 +[06Ah 0106 1] RTC Day Alarm Index : 00 +[06Bh 0107 1] RTC Month Alarm Index : 00 +[06Ch 0108 1] RTC Century Index : 32 +[06Dh 0109 2] Boot Flags (decoded below) : 0002 + Legacy Devices Supported (V2) : 0 + 8042 Present on ports 60/64 (V2) : 1 + VGA Not Present (V4) : 0 + MSI Not Supported (V4) : 0 + PCIe ASPM Not Supported (V4) : 0 + CMOS RTC Not Present (V5) : 0 +[06Fh 0111 1] Reserved : 00 +[070h 0112 4] Flags (decoded below) : 000484A5 + WBINVD instruction is operational (V1) : 1 + WBINVD flushes all caches (V1) : 0 + All CPUs support C1 (V1) : 1 + C2 works on MP system (V1) : 0 + Control Method Power Button (V1) : 0 + Control Method Sleep Button (V1) : 1 + RTC wake not in fixed reg space (V1) : 0 + RTC can wake system from S4 (V1) : 1 + 32-bit PM Timer (V1) : 0 + Docking Supported (V1) : 0 + Reset Register Supported (V2) : 1 + Sealed Case (V3) : 0 + Headless - No Video (V3) : 0 + Use native instr after SLP_TYPx (V3) : 0 + PCIEXP_WAK Bits Supported (V4) : 0 + Use Platform Timer (V4) : 1 + RTC_STS valid on S4 wake (V4) : 0 + Remote Power-on capable (V4) : 0 + Use APIC Cluster Model (V4) : 1 + Use APIC Physical Destination Mode (V4) : 0 + Hardware Reduced (V5) : 0 + Low Power S0 Idle (V5) : 0 + +[074h 0116 12] Reset Register : [Generic Address Structure] +[074h 0116 1] Space ID : 01 [SystemIO] +[075h 0117 1] Bit Width : 08 +[076h 0118 1] Bit Offset : 00 +[077h 0119 1] Encoded Access Width : 00 [Undefined/Legacy] +[078h 0120 8] Address : 0000000000000CF9 + +[080h 0128 1] Value to cause reset : 0F +[081h 0129 2] ARM Flags (decoded below) : 0000 + PSCI Compliant : 0 + Must use HVC for PSCI : 0 + +[083h 0131 1] FADT Minor Revision : 00 +[084h 0132 8] FACS Address : 0000000000000000 +[08Ch 0140 8] DSDT Address : 0000000000000000 +[094h 0148 12] PM1A Event Block : [Generic Address Structure] +[094h 0148 1] Space ID : 01 [SystemIO] +[095h 0149 1] Bit Width : 20 +[096h 0150 1] Bit Offset : 00 +[097h 0151 1] Encoded Access Width : 00 [Undefined/Legacy] +[098h 0152 8] Address : 0000000000000600 + +[0A0h 0160 12] PM1B Event Block : [Generic Address Structure] +[0A0h 0160 1] Space ID : 00 [SystemMemory] +[0A1h 0161 1] Bit Width : 00 +[0A2h 0162 1] Bit Offset : 00 +[0A3h 0163 1] Encoded Access Width : 00 [Undefined/Legacy] +[0A4h 0164 8] Address : 0000000000000000 + +[0ACh 0172 12] PM1A Control Block : [Generic Address Structure] +[0ACh 0172 1] Space ID : 01 [SystemIO] +[0ADh 0173 1] Bit Width : 10 +[0AEh 0174 1] Bit Offset : 00 +[0AFh 0175 1] Encoded Access Width : 00 [Undefined/Legacy] +[0B0h 0176 8] Address : 0000000000000604 + +[0B8h 0184 12] PM1B Control Block : [Generic Address Structure] +[0B8h 0184 1] Space ID : 00 [SystemMemory] +[0B9h 0185 1] Bit Width : 00 +[0BAh 0186 1] Bit Offset : 00 +[0BBh 0187 1] Encoded Access Width : 00 [Undefined/Legacy] +[0BCh 0188 8] Address : 0000000000000000 + +[0C4h 0196 12] PM2 Control Block : [Generic Address Structure] +[0C4h 0196 1] Space ID : 00 [SystemMemory] +[0C5h 0197 1] Bit Width : 00 +[0C6h 0198 1] Bit Offset : 00 +[0C7h 0199 1] Encoded Access Width : 00 [Undefined/Legacy] +[0C8h 0200 8] Address : 0000000000000000 + +[0D0h 0208 12] PM Timer Block : [Generic Address Structure] +[0D0h 0208 1] Space ID : 01 [SystemIO] +[0D1h 0209 1] Bit Width : 20 +[0D2h 0210 1] Bit Offset : 00 +[0D3h 0211 1] Encoded Access Width : 00 [Undefined/Legacy] +[0D4h 0212 8] Address : 0000000000000608 + +[0DCh 0220 12] GPE0 Block : [Generic Address Structure] +[0DCh 0220 1] Space ID : 01 [SystemIO] +[0DDh 0221 1] Bit Width : 80 +[0DEh 0222 1] Bit Offset : 00 +[0DFh 0223 1] Encoded Access Width : 00 [Undefined/Legacy] +[0E0h 0224 8] Address : 0000000000000620 + +[0E8h 0232 12] GPE1 Block : [Generic Address Structure] +[0E8h 0232 1] Space ID : 00 [SystemMemory] +[0E9h 0233 1] Bit Width : 00 +[0EAh 0234 1] Bit Offset : 00 +[0EBh 0235 1] Encoded Access Width : 00 [Undefined/Legacy] +[0ECh 0236 8] Address : 0000000000000000 ... APIC: +/* + * Intel ACPI Component Architecture + * AML/ASL+ Disassembler version 20200925 (64-bit version) + * Copyright (c) 2000 - 2020 Intel Corporation + * + * Disassembly of /tmp/aml-2JP791, Wed Aug 23 21:51:31 2023 + * + * ACPI Data Table [APIC] + * + * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue + */ + +[000h 0000 4] Signature : "APIC" [Multiple APIC De= scription Table (MADT)] +[004h 0004 4] Table Length : 00000220 +[008h 0008 1] Revision : 03 +[009h 0009 1] Checksum : 63 +[00Ah 0010 6] Oem ID : "BOCHS " +[010h 0016 8] Oem Table ID : "BXPC " +[018h 0024 4] Oem Revision : 00000001 +[01Ch 0028 4] Asl Compiler ID : "BXPC" +[020h 0032 4] Asl Compiler Revision : 00000001 + +[024h 0036 4] Local Apic Address : FEE00000 +[028h 0040 4] Flags (decoded below) : 00000001 + PC-AT Compatibility : 1 + +[02Ch 0044 1] Subtable Type : 00 [Processor Local APIC] +[02Dh 0045 1] Length : 08 +[02Eh 0046 1] Processor ID : 00 +[02Fh 0047 1] Local Apic ID : 00 +[030h 0048 4] Flags (decoded below) : 00000001 + Processor Enabled : 1 + Runtime Online Capable : 0 + +[034h 0052 1] Subtable Type : 00 [Processor Local APIC] +[035h 0053 1] Length : 08 +[036h 0054 1] Processor ID : 01 +[037h 0055 1] Local Apic ID : 01 +[038h 0056 4] Flags (decoded below) : 00000001 + Processor Enabled : 1 + Runtime Online Capable : 0 [snip] +[1D4h 0468 1] Subtable Type : 00 [Processor Local APIC] +[1D5h 0469 1] Length : 08 +[1D6h 0470 1] Processor ID : 35 +[1D7h 0471 1] Local Apic ID : 6A +[1D8h 0472 4] Flags (decoded below) : 00000000 + Processor Enabled : 0 + Runtime Online Capable : 0 + +[1DCh 0476 1] Subtable Type : 01 [I/O APIC] +[1DDh 0477 1] Length : 0C +[1DEh 0478 1] I/O Apic ID : 00 +[1DFh 0479 1] Reserved : 00 +[1E0h 0480 4] Address : FEC00000 +[1E4h 0484 4] Interrupt : 00000000 + +[1E8h 0488 1] Subtable Type : 02 [Interrupt Source Overri= de] +[1E9h 0489 1] Length : 0A +[1EAh 0490 1] Bus : 00 +[1EBh 0491 1] Source : 00 +[1ECh 0492 4] Interrupt : 00000002 +[1F0h 0496 2] Flags (decoded below) : 0000 + Polarity : 0 + Trigger Mode : 0 + +[1F2h 0498 1] Subtable Type : 02 [Interrupt Source Overri= de] +[1F3h 0499 1] Length : 0A +[1F4h 0500 1] Bus : 00 +[1F5h 0501 1] Source : 05 +[1F6h 0502 4] Interrupt : 00000005 +[1FAh 0506 2] Flags (decoded below) : 000D + Polarity : 1 + Trigger Mode : 3 + +[1FCh 0508 1] Subtable Type : 02 [Interrupt Source Overri= de] +[1FDh 0509 1] Length : 0A +[1FEh 0510 1] Bus : 00 +[1FFh 0511 1] Source : 09 +[200h 0512 4] Interrupt : 00000009 +[204h 0516 2] Flags (decoded below) : 000D + Polarity : 1 + Trigger Mode : 3 + +[206h 0518 1] Subtable Type : 02 [Interrupt Source Overri= de] +[207h 0519 1] Length : 0A +[208h 0520 1] Bus : 00 +[209h 0521 1] Source : 0A +[20Ah 0522 4] Interrupt : 0000000A +[20Eh 0526 2] Flags (decoded below) : 000D + Polarity : 1 + Trigger Mode : 3 + +[210h 0528 1] Subtable Type : 02 [Interrupt Source Overri= de] +[211h 0529 1] Length : 0A +[212h 0530 1] Bus : 00 +[213h 0531 1] Source : 0B +[214h 0532 4] Interrupt : 0000000B +[218h 0536 2] Flags (decoded below) : 000D + Polarity : 1 + Trigger Mode : 3 + +[21Ah 0538 1] Subtable Type : 04 [Local APIC NMI] +[21Bh 0539 1] Length : 06 +[21Ch 0540 1] Processor ID : FF +[21Dh 0541 2] Flags (decoded below) : 0000 + Polarity : 0 + Trigger Mode : 0 +[21Fh 0543 1] Interrupt Input LINT : 01 ... DSDT: +/* + * Intel ACPI Component Architecture + * AML/ASL+ Disassembler version 20200925 (64-bit version) + * Copyright (c) 2000 - 2020 Intel Corporation + * + * Disassembling to symbolic ASL+ operators + * + * Disassembly of /tmp/aml-00O791, Wed Aug 23 21:51:31 2023 + * + * Original Table Header: + * Signature "DSDT" + * Length 0x00003271 (12913) + * Revision 0x01 **** 32-bit table (V1), no 64-bit math support + * Checksum 0xAF + * OEM ID "BOCHS " + * OEM Table ID "BXPC " + * OEM Revision 0x00000001 (1) + * Compiler ID "BXPC" + * Compiler Version 0x00000001 (1) + */ +DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001) +{ + Scope (\) + { + OperationRegion (DBG, SystemIO, 0x0402, One) + Field (DBG, ByteAcc, NoLock, Preserve) + { + DBGB, 8 + } + + Method (DBUG, 1, NotSerialized) + { + ToHexString (Arg0, Local0) + ToBuffer (Local0, Local0) + Local1 =3D (SizeOf (Local0) - One) + Local2 =3D Zero + While ((Local2 < Local1)) + { + DBGB =3D DerefOf (Local0 [Local2]) + Local2++ + } + + DBGB =3D 0x0A + } + } [snip] + Processor (C000, 0x00, 0x00000000, 0x00) + { + Method (_STA, 0, Serialized) // _STA: Status + { + Return (CSTA (Zero)) + } + + Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + { + 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 // .= ....... + }) + Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion + { + COST (Zero, Arg0, Arg1, Arg2) + } + } + + Processor (C001, 0x01, 0x00000000, 0x00) + { + Method (_STA, 0, Serialized) // _STA: Status + { + Return (CSTA (One)) + } + + Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + { + 0x00, 0x08, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00 // .= ....... + }) + Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device, x= =3D0-9 + { + CEJ0 (One) + } + + Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion + { + COST (One, Arg0, Arg1, Arg2) + } + } [snip] + Processor (C035, 0x35, 0x00000000, 0x00) + { + Method (_STA, 0, Serialized) // _STA: Status + { + Return (CSTA (0x35)) + } + + Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + { + 0x00, 0x08, 0x35, 0x6A, 0x01, 0x00, 0x00, 0x00 // .= .5j.... + }) + Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device, x= =3D0-9 + { + CEJ0 (0x35) + } + + Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion + { + COST (0x35, Arg0, Arg1, Arg2) + } + } ... Signed-off-by: Zhao Liu Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-14-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 3 --- tests/data/acpi/q35/APIC.thread-count | Bin 0 -> 544 bytes tests/data/acpi/q35/DSDT.thread-count | Bin 0 -> 12913 bytes tests/data/acpi/q35/FACP.thread-count | Bin 0 -> 244 bytes 4 files changed, 3 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index 4d139d7f6b..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,4 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/APIC.thread-count", -"tests/data/acpi/q35/DSDT.thread-count", -"tests/data/acpi/q35/FACP.thread-count", diff --git a/tests/data/acpi/q35/APIC.thread-count b/tests/data/acpi/q35/AP= IC.thread-count index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c27e87fcf1c04a2e75f9a20f2bc= 6a28f19aadf66 100644 GIT binary patch literal 544 zcmXxe*-pYh7(n4^X=3D@iyb^*5m0Ri{zURpKajdcxrrJx3VN*;wLL1%j6B=3DdhKlgVWI z@i3C65UELc8x0<0IEo{wmLY`DtrcRvNOXlj!$8x-l!ca!wu6p~OCGvDdRg>y800Zs z#7qg7%eYcWzTsx8n5$u4Vxf-329}ywZsBShD;=3DzMvDU-23taExMu?l2xOIi{8tVgW z3~~Dgn=3D!WTuzim^kJx#_?lbmAxch>8uekq)2k&?|#-k5B{=3D}0nJe}g%H=3Dh4!jkKP# eg`TFbwhmpkt<321y#Mmm1A4)b;s}HheSP+5=3DBwpvPH|1Eq{unB-_)XMaV}|k}b+KDbGww1EeHRDtQ8g z&5VIK0|T}ONG1jfbVi+^OU*z5x=3DUBx)<8GyZgw4@t1i09HVEQXl>fQ+J-&1AlY!U^ z>YT@Oe&?J=3D^8I=3D5qsz_m_CFMauzp**@2oeor4Q>)7XK_E1ljaAwGnwFS})3_wYC)x zMXc7#xU}(5ie;{sOAptqf7$Q+y3_gemmO=3DTD|Ww4eZ9NW{rrp0uArc&yItERBXw`2 z-7K|RhZ{q6XCoJDuWytS#qaD`tnDZ(9BV(^D2vQyfBSyZiM;w)IOPxW$6L{({oxTi z)vEpP@*ihse(>uLJ}tifoB#RItB>sn0t)yW!{6mDJ#;?n*ylUPsjrR>tml+2pUWSQ ze03zBR>xBGOt(WvzDcMF^{sl&$>jy6Z#0Kz?U`SW3z48xPXGSx^z`&UlqpirL~1j0lTIF;xYmoh)7-Y=3D zuM>8x^)f|{gX0ggcqnIEFPfFRc&Yv?VMp*iwdmAiPNv{h?Z@$Xa`IZkQoVJ%zV zD1Vr3S*1mqrlr`>&u=3DsvR!1Tk8d>F|ljTq`2ytSDl2>7nDsb~2@b zx;&rdzIQsIIBQfyo)Nkm(Lm3=3D8S7|#`QVj@;MXQoC$5tggz%+K4(&!GpWs))aQiD=3DN#1L9Mt9<)aQiD z=3DN!`J9Ma|-(&vQB=3DS*pHrnEUz`kZk2oWt6j!`hs~`kZk2oM~;&v^Hm2pA#;hb3~hS zM4NL&pA#;hGo#I!(dNwPbHe3wj%ss`YIBb2bHe3wj%jm_X>*S0bHe3wLdMiJOJ0@6 zwK>Q2IpOj-C$u>yv^gjAIpOj-CuL^Qy%J8!%#wStn^c*O?^0&jjh)gmr?ku|Jrgd^ zoYpd@wajTf6E4r3(K2VW%o#lsF3&utWuDVA&*_0RT`%S`VYe_myJ7jC$e z=3D_$#qR&!RXIjh%%t7^s|phYI2Yt0RmmSSqbMqyV#;h?N?!f?Ez5Kt8--$a(6EU!Nc zMOA1|K;e3$K|ockC!j2p1XP9g1Qag1@dQ-Gx*pX8)l*E$^v)OwC|q`2TvL*>ATyIVYsEU=3DD z5KtCM0;)n~CJ889Z%zoPij|oVP!>u8szPNZ2`F6e^@M<`SeXd{WuYXXDpY2YfWr0W zgn+78nF#@9p(LOxRA!QZ!u95afT~!T2?1rHB%mr(W|Dxy_2z_ts#uu`0cD{ipej^m zl7PbX=3D7fN%SeXd{WuYXXDpY2YfWr0Wgn+78nF#@9p(LOxRA!QZ!u95afT~!T2?1rH zB%mr(W|Dxy_2z_ts#uu`0cD{ipej^ml7PbX=3D7fN%SeXd{WuYXXDpY2YfWr0Wgn+78 znF#@9p(LOxRA!QZ!u95afT~!T2?1rHB%mr(W|Dxy_2z_ts#uu`0cD{ipej^ml7PbX z=3D7fN%SeXd{WuYXXDpY2YfWr0Wgn+78nF#@9p(LOxRA!QZ!u95afT~!T2?1rHB%mr( zW|Dxy_2z_ts#uu`0cD{ipej^ml7PbX=3D7fO4V*(0~3n*MJpm3RhvP=3Djl%OnA1nIxbr z69URIA)qXi1e9fxfU-;oD9eO^vP=3D?CmPrE2G9jQW69URINkCa92`I~ifWq@$T?i;V zykhcXl7Pa+%iy_`>782$C_L}nLO|hp=3DavK%u6J%pK;dE!WU37b6~~DqxmZ1+1?e|^ z^rx5^*?55U|M9?Q_KSUSVh^0y@yyD`1E(b-39NoiBPjF^M6y{}My#=3DJ1$3@~c5H5QahtT!RI!rsA2%47HovMR7tc z)Ef_qnc;SMqbZ(~ZNHF5hG;{BBAkZw$J@e!jMz~^j4$Kjhr z0H=3D`YwXb1VC3k^ahwJvErLec*UT;*IUb{9f5@WZzbHjO;tg9w7TYW!q#Il^rL$r0fLQj3;iWV`)OknQ$A zNw(Yn6xnY7(`38-&yel*e~xUo|MO(K{m+u^_Me4aaQnYNw%h+4*>3+A$#(mnC)@3R zfo!+`OJuwKUnbk_f01mr|0`s>{a+>9?f)9tZvWTGcKg3Uw%h+rvfcid$aeeB!CrRz z&y(%;Um)A!YN zeSW(35bibwp4q&2(#h1K^qG3MLY9dF;Y@yJZOmypTd}u{5p%XGAEZO4U9s1-9)DX& zA3e6Z;&IpNbj8lMwZuOib*!)V>|28?bzLki&?MuL2 zu}7DiJrro=3D&mJzoLO)M;&pyw!0q1^mJMotDeD>QVz{kn!9-MJ*x^~DsN}*58gE-A+ zcGvp+4lYhP5*I-?74gQ7ozUAGm)}}(dpK^#1oq8nHI^B~eeLZy4I}msp0qx%M39=3D7 z3pFhji=3DbYrWy#cd+ZBhL#W0q{tP`eyjZdnP^gE!{Opg-^Nlv22u|xRE=3D=3DEcVe9|)R zB$_0sbdMB{n4~Z#g?-WrwALhHjnN}Tq9!TANfDp4O3P4VIxH7@q-dW>igHraC*8uv zsY!yU_egy)lhnsaeLm?nHd0LzzQp%P{c;J8w}kh~+5Mc<@00G}4Puh;vxpukW}7|5 zI4S0n-jm;Q^moAkBMqcX(f}t7_@p8&`i(PgGm<@Ql59@0eNu_G4h&M9k>Y8S6z8P4 zPjc|}&?F@oDUmTr2~JA*q%t;YO;VDPlA|Um$w^6{RKdorNg8CN!7-CG$Vr1fsfvwU zlZ5ZDy?4RTgh?9Wq@f-upQF{AamKN}>yc8ECMm^9DW8<5MVdjv(ym7uo-#?poHXo{ z3bZ~mNLbbNNNM@ABmQYgb5hzTEz{D>AYnn*BaK`zdm7=3DS5uda|t1^RxwOo&snKMZl zPRjVCRa%f4BrM~4q|tekG|EY%KIs;%#S9Wwa6Qu4f=3DL?Vq%og#o0ee)35&NLY5bB& z8t0^OpL7Qs%O+`pktP;R(gY_>_@wu+(QJ|?8ENv0Nt)!ONuN~2om-PM#Yj_EP0|!6 zP5Gn}Hlj_^G$T#_z$8s`(zH)D&(?3QkIdjSOMdW%ak+ANm-wi zzYru{V5AG{Cg}nvUGPbTxgcqdk>)l`(i|tv`K0BGLDEG=3Dx_H+lUF4*TK51n>NSbG) z`MOD(=3DcIX`w7L)^Eilr;1CzACNee#d)}(I>rkB}lr$NLSuBNmn@OicczD4U(=3Dh($x=3D5(p65n>XS;> zf~0GVbnS;G=3D^7_p^GVM2An7_IUH?0ibe)r~`=3Ds)XAn67p-RPL48=3DQ2*Csl3+NjDkk z=3D8j3a$w@bTQgtavT4JQ7U6ZuLNlQJ_vb&tq)>8Pva!)yPk4;jJlX5;OpAYtwXQcc` zCMnNJd7o4$1W5%(D*VVK6*#Hjla`l*q-920-Zx3hoV4tdR#t+f6-HV)Fi9(%wBnOi zSA(QgMp}Jhl2$os6{O5GHbSwf+pgpa!ri{5O;OsTN!3QxE~)%=3DuiO&88@K=3Dci=3D+st zCB-R~x7MsTi8l!=3DhT~R3u7dxFr{5%ceiAviIF z!kWNl`jtm0-&}5|`y#Yk0ehvLjz#Q{jZF!7tMm+wk@{=3D@WoRAVtbX9An;*#smD)q> zq7*3F=3Dr|QkMQIB?RhfPyf1_QSqF1qX7;ols?O3~5ZeW_L&D?%F1(ZhPIb+~e`R7NxEKRAT3cS19{w<0F&(KV|hI>N%+?Xh@_zjGn^s?OK$ zKkQ`BbPo8!z`($~*~#D8BUr&HBEVSz2pEB4AU24G0Y(N+hD|^Y6El!tgNU*~X%LSC z$X0-fGcm9T0LA|E|L2FOWMD92VqjR>!otAF!NBm72Obk1 YBHITON2VDSAnpK(F*YFF1LDH~0O^Si0RR91 literal 0 HcmV?d00001 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352359; cv=none; d=zohomail.com; s=zohoarc; b=ejjnfVZOtDgP4WY7llG9Oz/FI/lS0rBnsC1Y0tLJ/aycSyXEv6c+MUp2XGTWkhO70wqXIl0OER803fyU4h5F9sZNMCbmtU1I/PJ3RLZy0TceSEX6G3nwUH07VgtZ86gJbLS+LBpXrPdKlK6QjNq3edIII2PxKWOEg4L44lEw9q4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352359; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JzjRcIcLJXTDDXAO5KcivGNPGYfMjX9ytJMlSvUQwkY=; b=JZyClAJBho+ZsxrefjppZ1CdiIxu81Cati2kZSczV6S+i2lMI+h/XyDug7W4EzjrJbRBjXZ4tDStmqarpC1X7e+ZkV3DpMzGOtjuMtnnxj/gzADNmUat2qxK6CuknbRtGNg0+BQ0r0Lp7bRLQB0alOAxIIV9OhntGJPAdqy3OaU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352359419980.5702051584576; Tue, 7 Nov 2023 02:19:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4K-0001Ds-Cj; Tue, 07 Nov 2023 05:12:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4J-00014O-GN for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4G-0002h3-Uq for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:23 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-341-GjNmOPogP_qzwEDAQyliyg-1; Tue, 07 Nov 2023 05:12:19 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4083a670d25so36283085e9.0 for ; Tue, 07 Nov 2023 02:12:18 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id f9-20020a0560001b0900b0032db430fb9bsm1910650wrz.68.2023.11.07.02.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:12:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351940; h=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=JzjRcIcLJXTDDXAO5KcivGNPGYfMjX9ytJMlSvUQwkY=; b=DOJaZ8eFJmcqH9LQtbb/zNYepNc/FOIniWhup7fD/1o7cxXPLF+6H+NvMiHKimuljRmPsC b5IEUT8LCG+E8Gr5UCWfffcO8Lgn0zb5fP44PINuoxgKDLsbgnZcSODUF3lY/vLwVEGVVN 7NNGnZKVrDTQOVxOfgcgf+Wo3+z8hVs= X-MC-Unique: GjNmOPogP_qzwEDAQyliyg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351937; x=1699956737; 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=JzjRcIcLJXTDDXAO5KcivGNPGYfMjX9ytJMlSvUQwkY=; b=m1wbJtnJRSOsPyA41g7k45Hjiewp6LcpKI8JVNJC+Ciq03CbJzDNzIxGUyYolrnaS1 zt+JezqLLUWQJ7hNnv+vSjwkXQ5wD0EqKDa5lufVHg+xVtot0m8YyjR8LstKdZ6vhXA0 jJO7FqGm6BG4gQGZNpYLT8eY8e95FmVu5Vd9qOyA9QczQObAZfN8UOcdCUypc8TxOncu s9c3UzZ2x9Mo19+GNbwz91BtSkJfXr8N2iqXmyhowmQdMGIxuyW12noDCgce20Ha/XiI AkmhHQHX7mJKF60wCuDCANKMTMIMCy5yunFjGWEslpuIXz97DH1dCHP01d4MjSV8Dy4W NnxA== X-Gm-Message-State: AOJu0Yz8PTT+nMI7qr63uMYGpBw932Seydui6A+mV6xSyED4foZUU6wk 1bG6ZnSYEzhZm7eREespjZlTbzBG5P7cu4mFH2vbb5FhFYhqab8Lpz9+eRRx8gTJhJwtp8gh+f9 4SJhlgIRQcZfd6GADuAq1Omf2f1ts8KPFPz95v0LAtZ9JAmNndpS4Wx9VP/uDoBZJUjTx X-Received: by 2002:a05:600c:1d19:b0:409:5a92:470e with SMTP id l25-20020a05600c1d1900b004095a92470emr1863518wms.28.1699351937244; Tue, 07 Nov 2023 02:12:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHU691etRFA2Y8LufSW9EIvaJ4kH/YMt0cHN8b9uiZqfamTj8VEZW4CA2v+vpDYQAorBv9VA== X-Received: by 2002:a05:600c:1d19:b0:409:5a92:470e with SMTP id l25-20020a05600c1d1900b004095a92470emr1863496wms.28.1699351936876; Tue, 07 Nov 2023 02:12:16 -0800 (PST) Date: Tue, 7 Nov 2023 05:12:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 37/63] tests: bios-tables-test: Prepare the ACPI table change for smbios type4 thread count2 test Message-ID: <7cb953ca1956d4ac5d8ad798321fe3fde765befc.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352359711100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu Following the guidelines in tests/qtest/bios-tables-test.c, this is step 1 - 3. List the ACPI tables that will be added to test the thread count2 field of smbios type4 table. Signed-off-by: Zhao Liu Reviewed-by: Michael S. Tsirkin Message-Id: <20231023094635.1588282-15-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 3 +++ tests/data/acpi/q35/APIC.thread-count2 | 0 tests/data/acpi/q35/DSDT.thread-count2 | 0 tests/data/acpi/q35/FACP.thread-count2 | 0 4 files changed, 3 insertions(+) create mode 100644 tests/data/acpi/q35/APIC.thread-count2 create mode 100644 tests/data/acpi/q35/DSDT.thread-count2 create mode 100644 tests/data/acpi/q35/FACP.thread-count2 diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..d17d80e21a 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,4 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/APIC.thread-count2", +"tests/data/acpi/q35/DSDT.thread-count2", +"tests/data/acpi/q35/FACP.thread-count2", diff --git a/tests/data/acpi/q35/APIC.thread-count2 b/tests/data/acpi/q35/A= PIC.thread-count2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/DSDT.thread-count2 b/tests/data/acpi/q35/D= SDT.thread-count2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/FACP.thread-count2 b/tests/data/acpi/q35/F= ACP.thread-count2 new file mode 100644 index 0000000000..e69de29bb2 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352229; cv=none; d=zohomail.com; s=zohoarc; b=SFSZ2+Jgv7cO/LfCK9zWICYwUHRrKeYKm9yd3OpLcZUFUI41n/CUw0Z1yu2iHWV4YVmm/VpDOrThBuSfTW/pf5qANaV9xaa35abTmwLjiULmlO4RpvNACiQb971xJOTXLWQLEdqRMfz5oRXXM0L8bnDvcMtjBI55XaVVik+g7Fs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352229; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0Ocf1GvnCZPw3fKHL0EDtSVhrXG0RlJR7LYrQ1QKH94=; b=iXexrykOSulMGiCSBba78cZsNHW58Ke4k3HWuYFor550/C+2JZqEYJlkv0CRcX7yLG2wFkM184qQgfXUGdc9QPC+4mdcG26GGJZj6FVNx2OBPKU0sUMl74d/06isyvd5raM53u46cyLFY8ISCRGquWY95DHSY2qU4MIwVBiYu3g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352229667146.76932822631522; Tue, 7 Nov 2023 02:17:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4i-0002ni-Pb; Tue, 07 Nov 2023 05:12:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4g-0002me-PU for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4Z-0002lB-TP for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:46 -0500 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-404-Nk9XfQ_xNtSzO8s74Z5ufw-1; Tue, 07 Nov 2023 05:12:22 -0500 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9e27cc6dbf0so29805966b.1 for ; Tue, 07 Nov 2023 02:12:22 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id q8-20020a05600c46c800b0040776008abdsm15110187wmo.40.2023.11.07.02.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:12:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351959; h=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=0Ocf1GvnCZPw3fKHL0EDtSVhrXG0RlJR7LYrQ1QKH94=; b=FSBApN2t2ictxXqwDzC0flUe3zf5WTMrFWzQKpMKvdDYlxsaA8wxyullLbZAxb35cg8/cA lAhl1RVamtC11EfvhWqA/qjm4IjGiC9PwqQyEMs7gsH3qoxZ9zJIFVBJ2cAHsVzl0H4Dl/ fd3SNcgk6q8nKsNMV9oLTvP35+xW3fU= X-MC-Unique: Nk9XfQ_xNtSzO8s74Z5ufw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351941; x=1699956741; 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=0Ocf1GvnCZPw3fKHL0EDtSVhrXG0RlJR7LYrQ1QKH94=; b=uMREKm7LrPcYXSoJZ2EaYRQdl/or5aRCC0Q1mksgemgO60fy6L8uhqPUgyB9/BT1+B fu9U2TXX+l9YzyE/jcT/39fQIbiRbBIbFqCSZ+BvB6YmiI7DPFcX3+kGBc3LWbuQoOq+ SFg/WpVSnmNRi8mNAEwnBRNoA8xax1GS+Sm8cg1/6i5BtxCqt2yORpRF585GkJ/zc1T7 Q8c3ey1Na3VyfJ0RUEXMpnI77144mPj5aXAm3kO2kpxMWk4surxI5AFtGw9yCPfgMonO XOc5O1caWpq+DFraKEJGGcv37VysIxH7f8V710XNTyg8kSuy6u2MhnfohT0GSL4+h4ZF l82A== X-Gm-Message-State: AOJu0YyqthK4rxBux3YA+Yha/oh/hT6T/nV0Vd8Vb8F+Fr8cp/6BE1bM OSZybmegwP7bhZOrJQMFWCjPOEo/7vf9XDLYPUKqMDoy2203J599a968xtHPPfIDBLcd4tRFOM8 mvaRnprozDI7NMj1m5GBHsU/MixEn5siOh/EXPnolWg1D0D37TW87YA+38C/drLEAvlyd X-Received: by 2002:a17:906:6686:b0:9ca:e7ce:8e60 with SMTP id z6-20020a170906668600b009cae7ce8e60mr12376809ejo.41.1699351941101; Tue, 07 Nov 2023 02:12:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAilrcRitFIbk95f2YYUrWZ6P82D6l2ARhIjIIyas3dyHbHZe+7CXcl7y+MRdZCXVGWNGxHw== X-Received: by 2002:a17:906:6686:b0:9ca:e7ce:8e60 with SMTP id z6-20020a170906668600b009cae7ce8e60mr12376791ejo.41.1699351940781; Tue, 07 Nov 2023 02:12:20 -0800 (PST) Date: Tue, 7 Nov 2023 05:12:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 38/63] tests: bios-tables-test: Add test for smbios type4 thread count2 Message-ID: <198eee0cc17d74f17ecd54ddf72681f421f7bc43.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352230903100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu This tests the commit 7298fd7de5551 ("hw/smbios: Fix thread count in type4"). In smbios_build_type_4_table() (hw/smbios/smbios.c), if the number of threads in the socket is more than 255, then smbios type4 table encodes threads per socket into the thread count2 field. So for the topology in this case, there're the following considerations: 1. threads per socket should be more than 255 to ensure we could cover the thread count2 field. 2. The original bug was that threads per socket was miscalculated, so now we should configure as many topology levels as possible (multiple dies, no module since x86 hasn't supported it) to cover more general topology scenarios, to ensure that the threads per socket encoded in the thread count2 field is correct. 3. For the more general topology, we should also add "cpus" (presented threads for machine) and "maxcpus" (total threads for machine) to make sure that configuring unpluged CPUs in smp (cpus < maxcpus) does not affect the correctness of threads per socket for thread count2 field. Note we don't consider the topology with multiple sockets since this topology would create too many vCPUs (more than 255 threads per socket with at least 2 sockets, which may cause the failure "Number of hotpluggable cpus requested (*) exceeds the maximum cpus supported by KVM (*) socket_accept failed: Resource temporarily unavailable"), and the calculation of threads per socket has already been covered by "thread count" test case. Based on these considerations, select the topology as the follow: -smp cpus=3D210,maxcpus=3D260,dies=3D2,cores=3D65,threads=3D2 The expected thread count2 =3D threads per socket =3D threads (2) * cores (65) * dies (2) =3D 260. Suggested-by: Igor Mammedov Signed-off-by: Zhao Liu Message-Id: <20231023094635.1588282-16-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index 395ed7f9ff..71af5cf69f 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -96,6 +96,7 @@ typedef struct { uint8_t smbios_core_count; uint16_t smbios_core_count2; uint8_t smbios_thread_count; + uint16_t smbios_thread_count2; uint8_t *required_struct_types; int required_struct_types_len; int type4_count; @@ -644,6 +645,7 @@ static void smbios_cpu_test(test_data *data, uint32_t a= ddr, uint8_t thread_count, expected_thread_count =3D data->smbios_thread_co= unt; uint16_t speed, expected_speed[2]; uint16_t core_count2, expected_core_count2 =3D data->smbios_core_count= 2; + uint16_t thread_count2, expected_thread_count2 =3D data->smbios_thread= _count2; int offset[2]; int i; =20 @@ -680,6 +682,15 @@ static void smbios_cpu_test(test_data *data, uint32_t = addr, if (expected_core_count =3D=3D 0xFF && expected_core_count2) { g_assert_cmpuint(core_count2, =3D=3D, expected_core_count2); } + + thread_count2 =3D qtest_readw(data->qts, + addr + offsetof(struct smbios_type_4, + thread_count2)); + + /* Thread Count has reached its limit, checking Thread Count 2 */ + if (expected_thread_count =3D=3D 0xFF && expected_thread_count2) { + g_assert_cmpuint(thread_count2, =3D=3D, expected_thread_count2= ); + } } } =20 @@ -1050,6 +1061,7 @@ static void test_acpi_q35_tcg_thread_count(void) .required_struct_types =3D base_required_struct_types, .required_struct_types_len =3D ARRAY_SIZE(base_required_struct_typ= es), .smbios_thread_count =3D 27, + .smbios_thread_count2 =3D 27, }; =20 test_acpi_one("-machine smbios-entry-point-type=3D64 " @@ -1058,6 +1070,23 @@ static void test_acpi_q35_tcg_thread_count(void) free_test_data(&data); } =20 +static void test_acpi_q35_tcg_thread_count2(void) +{ + test_data data =3D { + .machine =3D MACHINE_Q35, + .variant =3D ".thread-count2", + .required_struct_types =3D base_required_struct_types, + .required_struct_types_len =3D ARRAY_SIZE(base_required_struct_typ= es), + .smbios_thread_count =3D 0xFF, + .smbios_thread_count2 =3D 260, + }; + + test_acpi_one("-machine smbios-entry-point-type=3D64 " + "-smp cpus=3D210,maxcpus=3D260,dies=3D2,cores=3D65,threa= ds=3D2", + &data); + free_test_data(&data); +} + static void test_acpi_q35_tcg_bridge(void) { test_data data =3D {}; @@ -2228,6 +2257,8 @@ int main(int argc, char *argv[]) test_acpi_q35_tcg_core_count2); qtest_add_func("acpi/q35/thread-count", test_acpi_q35_tcg_thread_count); + qtest_add_func("acpi/q35/thread-count2", + test_acpi_q35_tcg_thread_count2); } if (qtest_has_device("virtio-iommu-pci")) { qtest_add_func("acpi/q35/viot", test_acpi_q35_viot); --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352453; cv=none; d=zohomail.com; s=zohoarc; b=Fdwae2IvMbkKzLivs5xRNweZZxsdQYf8QV2NC2Bb0y3yOlQu6u6fRDvm1KI3cP+r8nD/KMqKhe50JnbHnACQMC31AJ+BamTZM7i4N0VZ9uJqg9DsU23zsVaNLZPcgDC++PzjFiRp2bUUMXFBtXjE854Zebk4qGIgCuUm8pEL6b0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352453; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1owE6IyGaOlyuS8CuG++QJ8lJ4pVSg9khHyHNsZ5LmA=; b=a6NgXww3cOa1lQo+/L1vVVKgcfkRWw++hogKH4+Clvv1M9KxyvjD2O4P9ZBaeqbBeTwrtKpBsjpnOlZsdP/V2GtsEM/0L/4B2HmhDbFJ0u9z9ldaaxKtc1kLI/Zgz3lQaU7fUuuXWKhDVF4uJxrcm8LSDY5KnphuAAUkK4UjmI0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169935245362971.01532861462181; Tue, 7 Nov 2023 02:20:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4W-0002J4-CJ; Tue, 07 Nov 2023 05:12:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4U-00025P-5k for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4Q-0002jo-Ok for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:33 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-66-y26EWn_hPIK8LGAA3zdXhQ-1; Tue, 07 Nov 2023 05:12:28 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4093a561f7eso34972465e9.3 for ; Tue, 07 Nov 2023 02:12:28 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id w10-20020a5d404a000000b0031f82743e25sm1924512wrp.67.2023.11.07.02.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:12:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351950; h=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=1owE6IyGaOlyuS8CuG++QJ8lJ4pVSg9khHyHNsZ5LmA=; b=PnM9Piv30nPRew+2IGgP4A29PCEMfL5pIhlc47JCLSWxh7ojbMYAZCt/jgJVec/Cqw4pRT aJZI2Vf1nJHAwfJMbzRfmndRXm/ZBsNO+IWCEBYuC5P9dzs2bHEQSvmVscq6S0F9Ug9/lc sMipyLSKqnwQFg3GClNzg/9g9nD18aI= X-MC-Unique: y26EWn_hPIK8LGAA3zdXhQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351947; x=1699956747; 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=1owE6IyGaOlyuS8CuG++QJ8lJ4pVSg9khHyHNsZ5LmA=; b=M7h2yiyBVYQZxTbami0B80Y20dcQVfVj2I3lNnWY17l18CltP6AZlGOO2vY+ZDR6za NZseymedOvwBTC92t6ZqoLhEwjvRlgVsgdKZGNrzPHKzEL29SliuEH+wpVTunl6N8QIp 76aoa9K3JDTFk+sS38SH1v7colMEwluSR8pkpZBl7akNeSU4Fl562bS4NOANSHv+Tekz q4edj3/nhpQOXPDkumz2iZuJ73DV+H0BOHRUZS3DH2pRwM6pCQWrnVBObRhB5acDCN4V IHf5AkUCAh1QAnbC3KoK/tppmdSDTAQL0OrXbVJosdHLy0g/vr3o/ArVoIQ+fuazRlNa rQFw== X-Gm-Message-State: AOJu0YxIZhDPd/ZH9GE4qlD87AbI6il6gbqYSEczxJ3dH+93AFZI0Xa+ VTaoMznzXI0PrrTOnzMNV6LCYLhn8SOi/I/2lUUOuOa68iOnr6h9co1jn/4EWTru0Bcp5q6uuWO 9fjiCTpSdA9PIjjFM47cSEAYPVdiISjgoPJA2LCs/0d3yITmcKa+U7I48S4RV68AETTIN X-Received: by 2002:a05:600c:4f08:b0:409:637b:890d with SMTP id l8-20020a05600c4f0800b00409637b890dmr2298093wmq.2.1699351946447; Tue, 07 Nov 2023 02:12:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3nopt/16JgdIQ3sadfIml5VYn0OpnyWVfk/2v8Q/Gdow9ZHPkhgzrNbSottizxxwsiudf0g== X-Received: by 2002:a05:600c:4f08:b0:409:637b:890d with SMTP id l8-20020a05600c4f0800b00409637b890dmr2298048wmq.2.1699351945733; Tue, 07 Nov 2023 02:12:25 -0800 (PST) Date: Tue, 7 Nov 2023 05:12:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 39/63] tests: bios-tables-test: Add ACPI table binaries for smbios type4 thread count2 test 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352455724100006 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhao Liu Following the guidelines in tests/qtest/bios-tables-test.c, this is step 5 and 6. Changes in the tables: FACP: +/* + * Intel ACPI Component Architecture + * AML/ASL+ Disassembler version 20200925 (64-bit version) + * Copyright (c) 2000 - 2020 Intel Corporation + * + * Disassembly of /tmp/aml-CNE3C2, Mon Oct 23 15:25:01 2023 + * + * ACPI Data Table [FACP] + * + * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue + */ + +[000h 0000 4] Signature : "FACP" [Fixed ACPI Descr= iption Table (FADT)] +[004h 0004 4] Table Length : 000000F4 +[008h 0008 1] Revision : 03 +[009h 0009 1] Checksum : B3 +[00Ah 0010 6] Oem ID : "BOCHS " +[010h 0016 8] Oem Table ID : "BXPC " +[018h 0024 4] Oem Revision : 00000001 +[01Ch 0028 4] Asl Compiler ID : "BXPC" +[020h 0032 4] Asl Compiler Revision : 00000001 + +[024h 0036 4] FACS Address : 00000000 +[028h 0040 4] DSDT Address : 00000000 +[02Ch 0044 1] Model : 01 +[02Dh 0045 1] PM Profile : 00 [Unspecified] +[02Eh 0046 2] SCI Interrupt : 0009 +[030h 0048 4] SMI Command Port : 000000B2 +[034h 0052 1] ACPI Enable Value : 02 +[035h 0053 1] ACPI Disable Value : 03 +[036h 0054 1] S4BIOS Command : 00 +[037h 0055 1] P-State Control : 00 +[038h 0056 4] PM1A Event Block Address : 00000600 +[03Ch 0060 4] PM1B Event Block Address : 00000000 +[040h 0064 4] PM1A Control Block Address : 00000604 +[044h 0068 4] PM1B Control Block Address : 00000000 +[048h 0072 4] PM2 Control Block Address : 00000000 +[04Ch 0076 4] PM Timer Block Address : 00000608 +[050h 0080 4] GPE0 Block Address : 00000620 +[054h 0084 4] GPE1 Block Address : 00000000 +[058h 0088 1] PM1 Event Block Length : 04 +[059h 0089 1] PM1 Control Block Length : 02 +[05Ah 0090 1] PM2 Control Block Length : 00 +[05Bh 0091 1] PM Timer Block Length : 04 +[05Ch 0092 1] GPE0 Block Length : 10 +[05Dh 0093 1] GPE1 Block Length : 00 +[05Eh 0094 1] GPE1 Base Offset : 00 +[05Fh 0095 1] _CST Support : 00 +[060h 0096 2] C2 Latency : 0FFF +[062h 0098 2] C3 Latency : 0FFF +[064h 0100 2] CPU Cache Size : 0000 +[066h 0102 2] Cache Flush Stride : 0000 +[068h 0104 1] Duty Cycle Offset : 00 +[069h 0105 1] Duty Cycle Width : 00 +[06Ah 0106 1] RTC Day Alarm Index : 00 +[06Bh 0107 1] RTC Month Alarm Index : 00 +[06Ch 0108 1] RTC Century Index : 32 +[06Dh 0109 2] Boot Flags (decoded below) : 0002 + Legacy Devices Supported (V2) : 0 + 8042 Present on ports 60/64 (V2) : 1 + VGA Not Present (V4) : 0 + MSI Not Supported (V4) : 0 + PCIe ASPM Not Supported (V4) : 0 + CMOS RTC Not Present (V5) : 0 +[06Fh 0111 1] Reserved : 00 +[070h 0112 4] Flags (decoded below) : 000484A5 + WBINVD instruction is operational (V1) : 1 + WBINVD flushes all caches (V1) : 0 + All CPUs support C1 (V1) : 1 + C2 works on MP system (V1) : 0 + Control Method Power Button (V1) : 0 + Control Method Sleep Button (V1) : 1 + RTC wake not in fixed reg space (V1) : 0 + RTC can wake system from S4 (V1) : 1 + 32-bit PM Timer (V1) : 0 + Docking Supported (V1) : 0 + Reset Register Supported (V2) : 1 + Sealed Case (V3) : 0 + Headless - No Video (V3) : 0 + Use native instr after SLP_TYPx (V3) : 0 + PCIEXP_WAK Bits Supported (V4) : 0 + Use Platform Timer (V4) : 1 + RTC_STS valid on S4 wake (V4) : 0 + Remote Power-on capable (V4) : 0 + Use APIC Cluster Model (V4) : 1 + Use APIC Physical Destination Mode (V4) : 0 + Hardware Reduced (V5) : 0 + Low Power S0 Idle (V5) : 0 + +[074h 0116 12] Reset Register : [Generic Address Structure] +[074h 0116 1] Space ID : 01 [SystemIO] +[075h 0117 1] Bit Width : 08 +[076h 0118 1] Bit Offset : 00 +[077h 0119 1] Encoded Access Width : 00 [Undefined/Legacy] +[078h 0120 8] Address : 0000000000000CF9 + +[080h 0128 1] Value to cause reset : 0F +[081h 0129 2] ARM Flags (decoded below) : 0000 + PSCI Compliant : 0 + Must use HVC for PSCI : 0 + +[083h 0131 1] FADT Minor Revision : 00 +[084h 0132 8] FACS Address : 0000000000000000 +[08Ch 0140 8] DSDT Address : 0000000000000000 +[094h 0148 12] PM1A Event Block : [Generic Address Structure] +[094h 0148 1] Space ID : 01 [SystemIO] +[095h 0149 1] Bit Width : 20 +[096h 0150 1] Bit Offset : 00 +[097h 0151 1] Encoded Access Width : 00 [Undefined/Legacy] +[098h 0152 8] Address : 0000000000000600 + +[0A0h 0160 12] PM1B Event Block : [Generic Address Structure] +[0A0h 0160 1] Space ID : 00 [SystemMemory] +[0A1h 0161 1] Bit Width : 00 +[0A2h 0162 1] Bit Offset : 00 +[0A3h 0163 1] Encoded Access Width : 00 [Undefined/Legacy] +[0A4h 0164 8] Address : 0000000000000000 + +[0ACh 0172 12] PM1A Control Block : [Generic Address Structure] +[0ACh 0172 1] Space ID : 01 [SystemIO] +[0ADh 0173 1] Bit Width : 10 +[0AEh 0174 1] Bit Offset : 00 +[0AFh 0175 1] Encoded Access Width : 00 [Undefined/Legacy] +[0B0h 0176 8] Address : 0000000000000604 + +[0B8h 0184 12] PM1B Control Block : [Generic Address Structure] +[0B8h 0184 1] Space ID : 00 [SystemMemory] +[0B9h 0185 1] Bit Width : 00 +[0BAh 0186 1] Bit Offset : 00 +[0BBh 0187 1] Encoded Access Width : 00 [Undefined/Legacy] +[0BCh 0188 8] Address : 0000000000000000 + +[0C4h 0196 12] PM2 Control Block : [Generic Address Structure] +[0C4h 0196 1] Space ID : 00 [SystemMemory] +[0C5h 0197 1] Bit Width : 00 +[0C6h 0198 1] Bit Offset : 00 +[0C7h 0199 1] Encoded Access Width : 00 [Undefined/Legacy] +[0C8h 0200 8] Address : 0000000000000000 + +[0D0h 0208 12] PM Timer Block : [Generic Address Structure] +[0D0h 0208 1] Space ID : 01 [SystemIO] +[0D1h 0209 1] Bit Width : 20 +[0D2h 0210 1] Bit Offset : 00 +[0D3h 0211 1] Encoded Access Width : 00 [Undefined/Legacy] +[0D4h 0212 8] Address : 0000000000000608 + +[0DCh 0220 12] GPE0 Block : [Generic Address Structure] +[0DCh 0220 1] Space ID : 01 [SystemIO] +[0DDh 0221 1] Bit Width : 80 +[0DEh 0222 1] Bit Offset : 00 +[0DFh 0223 1] Encoded Access Width : 00 [Undefined/Legacy] +[0E0h 0224 8] Address : 0000000000000620 + +[0E8h 0232 12] GPE1 Block : [Generic Address Structure] +[0E8h 0232 1] Space ID : 00 [SystemMemory] +[0E9h 0233 1] Bit Width : 00 +[0EAh 0234 1] Bit Offset : 00 +[0EBh 0235 1] Encoded Access Width : 00 [Undefined/Legacy] +[0ECh 0236 8] Address : 0000000000000000 ... APIC: +/* + * Intel ACPI Component Architecture + * AML/ASL+ Disassembler version 20200925 (64-bit version) + * Copyright (c) 2000 - 2020 Intel Corporation + * + * Disassembly of /tmp/aml-WKE3C2, Mon Oct 23 15:25:01 2023 + * + * ACPI Data Table [APIC] + * + * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue + */ + +[000h 0000 4] Signature : "APIC" [Multiple APIC De= scription Table (MADT)] +[004h 0004 4] Table Length : 00000CA6 +[008h 0008 1] Revision : 03 +[009h 0009 1] Checksum : 2C +[00Ah 0010 6] Oem ID : "BOCHS " +[010h 0016 8] Oem Table ID : "BXPC " +[018h 0024 4] Oem Revision : 00000001 +[01Ch 0028 4] Asl Compiler ID : "BXPC" +[020h 0032 4] Asl Compiler Revision : 00000001 + +[024h 0036 4] Local Apic Address : FEE00000 +[028h 0040 4] Flags (decoded below) : 00000001 + PC-AT Compatibility : 1 + +[02Ch 0044 1] Subtable Type : 00 [Processor Local APIC] +[02Dh 0045 1] Length : 08 +[02Eh 0046 1] Processor ID : 00 +[02Fh 0047 1] Local Apic ID : 00 +[030h 0048 4] Flags (decoded below) : 00000001 + Processor Enabled : 1 + Runtime Online Capable : 0 + +[034h 0052 1] Subtable Type : 00 [Processor Local APIC] +[035h 0053 1] Length : 08 +[036h 0054 1] Processor ID : 01 +[037h 0055 1] Local Apic ID : 01 +[038h 0056 4] Flags (decoded below) : 00000001 + Processor Enabled : 1 + Runtime Online Capable : 0 [snip] +[434h 1076 1] Subtable Type : 00 [Processor Local APIC] +[435h 1077 1] Length : 08 +[436h 1078 1] Processor ID : 81 +[437h 1079 1] Local Apic ID : 81 +[438h 1080 4] Flags (decoded below) : 00000001 + Processor Enabled : 1 + Runtime Online Capable : 0 + +[43Ch 1084 1] Subtable Type : 09 [Processor Local x2APIC] +[43Dh 1085 1] Length : 10 +[43Eh 1086 2] Reserved : 0000 +[440h 1088 4] Processor x2Apic ID : 00000100 +[444h 1092 4] Flags (decoded below) : 00000001 + Processor Enabled : 1 +[448h 1096 4] Processor UID : 00000082 [snip] +[C4Ch 3148 1] Subtable Type : 09 [Processor Local x2APIC] +[C4Dh 3149 1] Length : 10 +[C4Eh 3150 2] Reserved : 0000 +[C50h 3152 4] Processor x2Apic ID : 00000181 +[C54h 3156 4] Flags (decoded below) : 00000000 + Processor Enabled : 0 +[C58h 3160 4] Processor UID : 00000103 + +[C5Ch 3164 1] Subtable Type : 01 [I/O APIC] +[C5Dh 3165 1] Length : 0C +[C5Eh 3166 1] I/O Apic ID : 00 +[C5Fh 3167 1] Reserved : 00 +[C60h 3168 4] Address : FEC00000 +[C64h 3172 4] Interrupt : 00000000 + +[C68h 3176 1] Subtable Type : 02 [Interrupt Source Overri= de] +[C69h 3177 1] Length : 0A +[C6Ah 3178 1] Bus : 00 +[C6Bh 3179 1] Source : 00 +[C6Ch 3180 4] Interrupt : 00000002 +[C70h 3184 2] Flags (decoded below) : 0000 + Polarity : 0 + Trigger Mode : 0 [snip] +[C90h 3216 1] Subtable Type : 02 [Interrupt Source Overri= de] +[C91h 3217 1] Length : 0A +[C92h 3218 1] Bus : 00 +[C93h 3219 1] Source : 0B +[C94h 3220 4] Interrupt : 0000000B +[C98h 3224 2] Flags (decoded below) : 000D + Polarity : 1 + Trigger Mode : 3 + +[C9Ah 3226 1] Subtable Type : 0A [Local x2APIC NMI] +[C9Bh 3227 1] Length : 0C +[C9Ch 3228 2] Flags (decoded below) : 0000 + Polarity : 0 + Trigger Mode : 0 +[C9Eh 3230 4] Processor UID : FFFFFFFF +[CA2h 3234 1] Interrupt Input LINT : 01 +[CA3h 3235 3] Reserved : 000000 ... DSDT: +/* + * Intel ACPI Component Architecture + * AML/ASL+ Disassembler version 20200925 (64-bit version) + * Copyright (c) 2000 - 2020 Intel Corporation + * + * Disassembling to symbolic ASL+ operators + * + * Disassembly of /tmp/aml-CDE3C2, Mon Oct 23 15:25:01 2023 + * + * Original Table Header: + * Signature "DSDT" + * Length 0x000083EA (33770) + * Revision 0x01 **** 32-bit table (V1), no 64-bit math support + * Checksum 0x01 + * OEM ID "BOCHS " + * OEM Table ID "BXPC " + * OEM Revision 0x00000001 (1) + * Compiler ID "BXPC" + * Compiler Version 0x00000001 (1) + */ +DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001) +{ + Scope (\) + { + OperationRegion (DBG, SystemIO, 0x0402, One) + Field (DBG, ByteAcc, NoLock, Preserve) + { + DBGB, 8 + } + + Method (DBUG, 1, NotSerialized) + { + ToHexString (Arg0, Local0) + ToBuffer (Local0, Local0) + Local1 =3D (SizeOf (Local0) - One) + Local2 =3D Zero + While ((Local2 < Local1)) + { + DBGB =3D DerefOf (Local0 [Local2]) + Local2++ + } + + DBGB =3D 0x0A + } + } [snip] + Processor (C000, 0x00, 0x00000000, 0x00) + { + Method (_STA, 0, Serialized) // _STA: Status + { + Return (CSTA (Zero)) + } + + Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + { + 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 // .= ....... + }) + Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion + { + COST (Zero, Arg0, Arg1, Arg2) + } + } [snip] + Processor (C081, 0x81, 0x00000000, 0x00) + { + Method (_STA, 0, Serialized) // _STA: Status + { + Return (CSTA (0x81)) + } + + Name (_MAT, Buffer (0x08) // _MAT: Multiple APIC Table En= try + { + 0x00, 0x08, 0x81, 0x81, 0x01, 0x00, 0x00, 0x00 // .= ....... + }) + Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device, x= =3D0-9 + { + CEJ0 (0x81) + } + + Method (_OST, 3, Serialized) // _OST: OSPM Status Indicat= ion + { + COST (0x81, Arg0, Arg1, Arg2) + } + } ... Signed-off-by: Zhao Liu Message-Id: <20231023094635.1588282-17-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 3 --- tests/data/acpi/q35/APIC.thread-count2 | Bin 0 -> 3238 bytes tests/data/acpi/q35/DSDT.thread-count2 | Bin 0 -> 33770 bytes tests/data/acpi/q35/FACP.thread-count2 | Bin 0 -> 244 bytes 4 files changed, 3 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index d17d80e21a..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,4 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/APIC.thread-count2", -"tests/data/acpi/q35/DSDT.thread-count2", -"tests/data/acpi/q35/FACP.thread-count2", diff --git a/tests/data/acpi/q35/APIC.thread-count2 b/tests/data/acpi/q35/A= PIC.thread-count2 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ac200ab7aa6e2fc4b6995ba0dfc= 1a77ae32e0412 100644 GIT binary patch literal 3238 zcmXxmWmuJI9E9-!M9(>ZVz+{diQP>If(43!4Ju%FCv513Zg;2K-R*X_Zg+Qg=3Dsv^D za)I~zqdtJwf5Zy^48jY&4n3|NNCMT;YDQf-tYJ&!9YO30>q1vdC+PJaWq>0+JsoJcW z+Pt~iqJ`SBrP`{M+Pbycrj6RRt=3Dg`g+P=3DN2p9>=3DC>2ik-YR8Uhr%q}{hT6Ha+NF!y zwX52#o7%m*+M|b>nW^^dsrKrn_U^6r>7(}TtM=3D=3Ds_V2F_7@!Uus16#W4j!xy8KMpy zsty~b4j-|Fsg4?@jvlRMWvSWOYEF)ttN$mFF=3DOPsJT*UG9XnPnC{POv)p6t0 z@#EDA6V!%^G#>T6Ntzb^UsE!v=3DNZMs?FBb@OI*%NBL(R(0Dpb^CU8#}0MpPIcEV zwYplZsbQn3;h*rp=3DcDX6`)Hd7f*(J|=3DAodEwRte;-8K&gy~pMOp^vk9Na*8j9u)cn zn}>xy(dL1n_u4!(^gf#hhd#;X;h|5qd4T9sY#t)|RGSBhKF#J~qEEMZpy)Gf9xD1w zn+Jw84 zY#u`TQajDQ%ucs2w|OALE3UA4DCsM09!z?_onc>P^MLZ>SKBoX9^e%$6@&`;QT_LFwL{glli;pabXb5Q7KYz_DfPo)u4KeVetw9EUvNg=3DW&$b2{_{G*x1HalDY~VLr!wvjyYrug&Yz;Z^ zr>#K;{<1afz~8n89{9)B&;$S48hqfet>Fib*!lw?ApG3<`_&%;fp)cjAKZC_*i)31D_HTLsR$^jsE`>3!k9(B_-89#llw~2`~JH{{h;7;sF2v literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/DSDT.thread-count2 b/tests/data/acpi/q35/D= SDT.thread-count2 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3a0cb8c581c8cc630a2ec21712b= 7f8b75fcad1c8 100644 GIT binary patch literal 33770 zcmb822Y6J)*N5+>5jGnLA#{X@Vpq}=3DtR%ae0wjbafEqLjMJbk5Kt)6;iiq8ay+p;{ zdspmTvG?A4S1f<|&hOsYopa8;KF=3DqQhTm*v-uKL=3D9QI~58*7cVeYMhYLZO;T(fZcH znmwDNh4d%nI1V!Y&TGh+?zAt9)zo!_a?&zF?aOoAOmAwk3wDUrOsNZCX~?M+4Og50&hB(bcRQC_T-(>JvX!z%iZ@C_w+xb+kLlpTOQt%=3D)^6TM7*1T zDqc6gU_xd**4micQ_(%oN%Tt(Ih{R2&+rP^Q2ErSt>s5Ho<8WS#vzYH8`pLA^jbSN zoVKnr5njH!({bpA;obAXy%PDEX-=3D-wN%z75j?9d&n}+uYP#6fG)t zX!k9x{YHj|A3w-(BDl-(=3DcY}YHa+M?CvUNnH?d$R+m%Xp_T_mP zMCtY^h4dy?*uJbaKAt{QPe#HS^s&MqT2mAsPw%K{YHSJRZ19$05UpvN(pcEs5Zkk` zJybI>I>9Lz-5iaNPix--qfMIpZdH=3DSl~XF*Nx zX7~P#W&Ni+lySX7+>l8#f=3D6Z?4YbJx+-@Q{9y`#7e5hoty5iOjeNYU}bV@y0?<1x+`gjl}Ss6yE0iphPyI3HN#t(ES`pZ zpP6ExneNKu)J$(>vUnQueP)S$X1ObqQ?ukgX~_54OYF0k*k>=3DfPa5)lW{Z7hi+yIx zebSKcv$xo1Z?Vtba-THh`wWYHhQ&U^a-THh`^*vh%n|#{k^7_}-)BVZGa~jGk^7_} z-)FAaXRg?1uG}XL`9AxIefAOi>?8L{L%z?xVxN7*KKsgj(va^nPwX>K>@!d9lZJes z{lq@|iGB8y`=3DlY?XTI2HzSw8J+$RnBKKqM(_80r?FZW49zRv=3D&&jPW}0=3DZ8b@_h~v z`y3$lIY91{hJ2p`#Xbj$eGZiSq#@rYwK4B|mit|4kl5!SxlbDMeGV4;94z)ZSniXC ze4j(ymDT1u;ShIajrnFb#9JA)L#&LMxkJUupVXuB0JfIb5t9 zE>;egD{07AZYEZ4CRT1HSJIHL9O14^evcpFu1tQ9AK|S`e&ePgRwg^iNZ}kQoFk=3D^ zhMqH<8fZ0ZpmnVcq;{KWh%$*y1Em3Jy+Jw+l2U4*-aPk{DCA&Ovc3>Wy{V}NO2g#V zsDXNOlMR$jMFaJwrWz;>shVU1_2!xpoJ37_Osq`aV`!i>q>9|R)IhztW@Ps0u0#X% zrY47cpVUA-thaIisrD1ZP)Ihzt?n-K)Y$_V4H`QH<21>)^$CDbUH`iTB4U|nq1NEl5 zE73q{nA|5dP;aigk{T$RiU#UUbyuQ+(lEJCYM|a+cO^AYHWdxjo9eDa1EpbdpVUCT zx$a78plm7{s5jMJi3Uo;G*B8Q_el-Zo9nKm2Fj+QfqGNjm1v+eOzx8! zs5jSLNez@uMFaJwx+~E@X_(w6HBfJ^yOJ6xn~DbNO?6kIfzmL!PimmvTz4fkP&O3} z)SK$AL<6N^a-Y;dy}9m6YM^W?8mKqbU5N%t!{k1xfqHY@mDE7lR5Va;s=3DE>ml!nQD zQUmqox+|%HvZ-jG-c)xb8Ym5u`=3Dkcy&2?8&17%auK)tE%N;FU!Cih7V)SK(Bqz1~S zqJer--IZvdG)(T38Yqoe1EmpfpfuzSl!mN9AahizNH3AqvU-{4U|U7`xXt9hRORD4U~p-4PVp0alj-q)Pwyq+WpkW$;oj@QIR#}6lcO!YsqMBD_3IPPIU&pG?OsY)?5x3U;Y@nl zkXSM&+}A-OP)kw!iiy3b&sQg}#6=3D#oZjiwp&a@i?9g{pXR%Yz zx1+VK+F6GZnp-AU7xe3hHMBZQk;BW}Tl(UH24+NC-0`4})|S@LnmMKh=3DyAKT*C>1F zKiF%Sy~efIP<`B9QxI&gXEo_GuJrML(Z`LxR_inWgT9vOYh8V<(%1fr zzSijLv_9)U=3Dx{l$>wEnNeLd6HyZU;ium2Z)J?S&>?MUnMJbm(; z2mRB4zTCZwlk&ELEcZ*E{=3D(O_!RasKa6gHoe=3DqoO-fe+6-`8cn#L+(@d^qp6K%DRE ztiQz3zbt$>@3ugk@9U;O;^?0nKAd-3AkO!7FhJty-ylAmcUvIN_jx@~;^-eHKAd-3 zAkO!BI!NN^Un@SGcbmlJHD-I4|Kr*9&GEM6r(cM^<>8`#`?C7xwnm5k<-Osb9EUDl z=3DV9D`YP=3D~{*xVB9C@iROJ5K_)bS7|9*O8s!yw0A;>D`@9cPCwsUFY=3DlIla5fIkPL` zeE4hTI%9OjzLb`6<(A1EfaByS$ij{M+rn^5Hpo+XI&3=3DlDP>1(} zmCS;MN1|=3DDd!_Y+yXQEoqO{w&h#|z{xji}EbHZuJC0)}psF!n*V_xoq9QSfx)IS*6)IS8-)ISv2)ISW_)IS{A)V~?Bsec5rsedH0 zslSkNiK%~cWK;hrWK;hZ$fo`+kxl)hkxl(uA)ETQMmF_tgKX;G7TMIl9kQu^dt_7p z4#=3Dkd9g$7_J0Y9;#~_>fizt_x`iqfG{Uykz{!(O9e;Kl=3DzZ}`rUx94uuS7QWS0S7F z$0D2hcSbh#?}BXV-xb-^zZhC}{ z^>{$-S_O#RD|P5mp7P5mp8P5s9roBEGK zHubMUHuWEmZ0cW)Z0bJ&+0?%V+0=3Dg`vZ?$?M z{|sbPe>bwJ|4d|4|5{{I|5?bU{OUXZ)PDi8ssBP`Q~yQC zrv8hOP5nKTt4;lvAe;IxMK<+chHUCzhivM<9NE-=3D1+uCCN@P?2Rmi6PtC3Cp*C3nv zuSGWXUx#e!zaH7te*?0q|3+j}|4o!@O#L?_oBD4-Huc|%Z0f%a+0=3DhKvZ?VFK`)c-iLss9ONQ~#65rv9gpP5nVFT})c-!Rss97YaZ~??$fo{}kWKv`Bb)j^K{oY&ifrot4B6EGIkKt$3uIIO zm&m66uaHgsUn86Pzd<(je~WDD{|?#I|2?v){|Cyorv4w1P5nP1oBDr7Hue94Z0i3N z+0_3VvZ?=3DfWK;h}WK;hi$fo{3kxl)7A)EUDMmF{T582fJ53;F$6Ef8w>7GMB23Zv? z#=3DrkD2)P5=3D0S0OAfVO}^x;rSHTTq`x2aKwFw{J0hOa^~Mghx6!A*64nM zz+;_6xG$Xy^1Wx`gms+-jhT4-^WQ`vjUqxIzo33#v^Cn4{V&_djyA=3Do<)>{*I5QKW zS(n!4ch3qXoLPxbXTs^av?+30cV}qr%$y9mu`@AKOWiH&8|m>|&!DyXR(b?C^YWhF z-Cf~LB)U8i^!}bLefJ$6A|__8MwMO8qAsfIlFFWP-!%6@Bt6cX8BS05?izY0ty?q` zNA%(u-WfdrXE-zQ*l;EZ+KYoX=3DVMVli)IAh(T%;MlUmy%|8hqMf4=3Dzmbmt}J2HZD^ zaGJgqQ|IX$>240Ju6<<{J(4WKl>i4P!00nOdmTQ%>9KNSbz8rjaJEA~tLkDYU9nCr4TapLIUVMad{KyDLN2Brm=3DgLaH5|FN0$h4d zanjOUP9((%r_uGjWIf?DODd&fUz$XhR8pjLI>G2}HCa(Oos-fnsf;d+XcAozPLVP) zG%16VGAyYaKQmCfqieeYDdHY><-3b;QpA#C z^iy?B%4MY7TwPNxC*@jFoPNr#NqrcpPajR{!%2NCsg{1~u1R#UG4)x{x34Dk<)pqT zQgIP3wX1uaF2<)wd3l1?VG^rma^|PcBTufIax&)sh<>zZs zJ}2c{QYo&ZD-vCOPm%if*QEZO)ZdcIa0y+J=3D)!x7R8XKv1)Nl1N#(eDu1IvvJw+NY zK$8Y=3D(f~`Uz=3Dd-~qRZ_m(!hb5G?0@9T2dvhnJW@qX-|;`4br4RoHWRis^}DeCJkn! z!GkqvFeeSRq_K1=3DK$C_r(vTsVG=3D!6eSW-0|v(u!Zj5KtpCJp7Jp_Wubrv@}>7$XfE zrb)v%X_zHN=3D@fw`4QHg`!!>C*Ck?lx7@aE6q|F#Nu^u(Nn0?|7F%f27M!$&C6#UICvC|{TW+aITXNEt zmQ+64Pa4fgqepAfXige!Nflf9Nn0_}R$FP(R-CkzB~@qB-cQ<| zk+$DnleXui?JX&~gP*hmBkiz*ChfpUJ6KX|M?YytM%r;lP1=3D!@cC@7UPJYr(jI`5E znzR!q?PN){WBjBsj5KD9CXL~wF)321c{nE?OVP8-Qk}D?NRx^LksV0?jQmG}CmHA0!j8s;pNoAZ=3D zW=3DZAceo{Fjm6vN$IVY7{QbmQIRKZ9U6`EARNfnk{v}2%SmG`sd{HWX=3Dg^-d1p=3D9nUi+5q?%p)q+J+kmt8bz z7f#y6lA^o%NxL%AuDfc|uAH>1CB=3D60lXhdI-FDNY-8gACON#IAC+*HiyYH?^yK~a+ zmQ=3DfkpR@-f?Xia@?ZHWVq)25&S|4@=3DA>#% zDyi|4=3Dm=3DMeR8yl#I9Zvx{#0X0rBOeLPH&}1QTJKI{Cg%2Nv23qODc=3D`Npx^4MT*6A zO*rqEBE>AJJnkpaS)UXs9@iusT}+YUmQ+#eC(&`O6seYu>d=3DEWc7+C~5L2XDORB8% zljx*Yid0vpNjOlLBGp+^RlT1?hqO|p`g%>m*}xR3-jc>P_(=3D_n)X<1 zr16Y2e!M1)=3DcMtLR5QU(n!rdCCTP+GPMTmz(TRT2L`Ir8QIjTe(nL#&HTp?(nk{vY zH#TZgBPTUlQoPAeYGS0OCQWMMq$W$Mo#ZD?Vx&ovG-(niO-hlK zq-oPMX&NU@v!tp${iHn^Y0o`1X-`ht(~`#SC-i7IwwuHq}V=3Dw(msr|&pw*84=3D3$o zN%4LCqv=3D+LANPU=3DXJDvCP&q)tZa?9`-APU^Iz;x0d_ zi;=3DpzG^vY|x-6+=3DhMzQpk!H-$q#2wv!;(s8`bjexY358#n#oBsEvamlpEQe+X3f&1 zS)4S>lFDcMNwXPg_H0d>%}KK@sbW7rX+K8VZ$C}ikCXPZq{{vMr2QFb|NS*-e@@!p zlB(wTNpl!!&Kyme!%1^2Y3y7-X)YtpovTT6IccsXRnPO2<}uQ|d73njljd1c&3r#; zJ|oSauSxScX}%>z5Ac%?V59@+m$Jxz`yRka2Ut?~ZCN1Ek1(sB{&`(;(NDCKg(n3yJ zXi4RZ{G>&Uv}lngE#jm_mQ-<=3DpL7@_9d?)|9mYwASyJWUe$wHLbok+#bT}s+Zb?-~ z_(?}F(h)~!(h;0=3Dge8q#>?bW|q{WLhX)z})wxsGK{iGuq>Bu8B=3D}1mG(voVH_(@9` zX~_~zTEa<7EGc@FpL7%>9d(o@9mPpUSyF7NpR|;bmM+z#rJS_XlHy1ENk=3Do%(MN02 z(VTR&CDk6|Cmq8`#~hh+w49Tc zgS28?7M zz_3ynRtiJN7*;C7N^V$b4Rq~1z;LWE94ibs)P+49s|?3-!?D&t*VF?H#|gu6!hpkG zFdU~0$8p1P)tbwiu2N+HkhLeQ>ht*&>Ss6~|hLf#IY=3DDZ^>paGEvH&qM%p)~~ehl_;aB4NNG zLKrSmhKso2B5Mfl4;Kr=3D#lnEYg)m&K3>S05#VJE|aDV6#h8|(Sp+gvYl%ac3B%^baG5e( z#toNQLvVjsCk*R^0f!ptKWCjXtmB4t))3quE*FN&g#m{hVYplwF6V~Jts%HSTprJT+0pDT0?MuxK0?Z69yd0gyA}6xQ-jHvxeaQaJ?{GFAO-W3B&cua6LC%ZwJRl4>L<_?M%J2X;JYWsM{oz4jcu*K{xE6*7mEl2dcray%2KR^c z!mwT#aOf6>^~$iG8`fJxaDRA67#QT;QsKiFgz>__x@R%^* zurCacDZ^vj@R&6O_lL)Y;c;QWAz&CDSBA&A;c;sS?hj80!xO>~H-;ya;R$Yd!Wx46 z!;`}Bq%hPP!;{MJBsV;14Z;24DPed@7;u;v_tI0!@Dw*ZWevgo;b~!bS{QK17>1{n z;c0Go+8ToU!!yG0j4m|=3DKc8J_2c=3DdB^QKfE9eF9-t;H^cCPGQ7YI zFQg2y;Qp{d7&Zt44n4!LK^Zo1!v<>z?hh{t!;8Xz!_Y9is0=3DT1!;97s+#g;NhL?l^ zhooV6Nf}<^hL@}%xIers3@-}<4o}1IvNF8P4KG_maDRA37+w*E7Grot8D8OrSF9np zKfEdouL=3DVWTVoHeD#NSX@TxTg_lMVn;Wc5vA#504Q-;^L;WcXr?hmgE!|TE@#TZ^! zhS#~_b!!Oj4{r#=3D8^VA?+t|Y!%J2p^ykQN&{ozevcvBc~m>Y&SmElcpc+(n!`@>tp z@Rl&(kT(o(DZ^Xb@Rl_M_lLKI;ca2S;cpn;R))8^;caUO?ho$>!#l!&L*X#IqYUqG z!#max+#lW*hIfSlhs9xdR~g>rhIg$YxIern4DSg84w1v~o-(}04ewb)aDRAT7~U5K z94?39ePwu`8{SVD;=3D%pl17Y|;7;xwuh7XkC18(@h8iM=3D7hr;loFyJsc3?C}PhurX? zH3avEkA&ePVdyl5kCfpfZurO=3Dg8ReA!tk*$bQ#0P%J4Bad~6ND{oxZ~_(T|RsGa_E zK2e5GxZx9P2<{J`3d5(ufWz)Ee5wqea>J+A5ZoU=3D6Nb-(0f*pW_)Hl-}bxIcU$3||Pte#Y>HGJL@eUsywMfA~@uz7&T2jp0jW_>vpG zw1(jR@RcxpB@8%ZPyabzDZ^LX@RcQ;d>aqR)(*+;cIIM?hoGx!#Bc! zL-{a#qYU40!#CCt+#kLbhHr%dhxK9jRvEtKhHtGQxIcU+4BrU@4)MeAoicpK4c}Qq zaDVt-7`_(<9PWqVdu8~Z8@^8&YJ>a355n++FyPQX3_mEt58UvBH3avEABEvZVZf6C zVE9oPe&mK9ts%HS{3HxN2?L%a0K-qp@Dn%uWDUXn;b&p^Ss3u-0T_N(hM&3NXKM)V z55EY*FT#K)6~OR|GW@~~zgR3@7569A2tfZMq$8{7O;nn%CM0eHd;e)fA~Wf z{tyN{nE{4Bl;IC<_`@24`@^5Y@TV}~Ne(dlsSJN|!=3DKg=3D+#miDhQEXXPkw;mFJ<_P z8~(C};QsKpF#IhHcv1ume=3DEb^-0-(G1owyk3B&({0Z*2I;eX2TKW_M+H3avEe}v&5 zVZf6pVE9KF{^5pytRc8RY!Ze|!hk1Nz_3XfHgUry*AUCXuPzQceM-O9n10i0>eso_ zP&n|k3pntGN=3Dg1cO{~gG{b~dnSxaD#px>7)EFo#ZQ!-$|GYPnbRxwM6Spxe6{UT;z zNt2dk#)4-Pa0{(smNaGw>=3DpDIo`oe{T9z9No>9Opw2E2MVJR3!uRueurqdBGDsjx~ z=3DHS(6@C%po8V7hUPvgF~ywJwT#z-ieZVyG$ar^J| z?v0VuIG0|9om$uNgB-_uKVFn>)219ur9Wwo`yQ&*{gX{E5Rc;y_;Zzb&-zW99>k|I z{aL^Jn(ZykyA1%mx_q`bOufaJUc_fbG=3DuhOJ^`DXn&}t$S9s4|$;IvLm4N8Aj@qij zIo_)exvvCNm{ph+$^&G4Mst00i}zV9A#^7NysD6&wLY>w5*kdeVzlja(zlj&_>K>>_U$`(bEbu~Y4|sQE&j9B-ULzY)0vYgNU0nR%Ib?V`N+ zu<7{C-+7Hg@lkAFk<(gK)REm$9c!W8Y}Z;;Mi1FKDf` zlSkrJks4Yir-eJik-TVzD`{W8^O$sKFca?$;l%>!g$*ay;7t^7V%ZM8Ce-9OaxLD} z;Z1#Z`--v&H8CoNPN&mr`lY9Pd+O_b6b6R})P*{oPWtk!3(az7(ch!e+>h#(jgzLN zR`u;KR%M4XM>+0?tz=3D?zoA+IT*csl3oxWypuNgyLIJYizMEViw+1aC(x#W`Qq{h^m zOqxxv9Tl)B4X$`mvGaehF-gM! literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/FACP.thread-count2 b/tests/data/acpi/q35/F= ACP.thread-count2 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..31fa5dd19c213034eef4eeefa6a= 04e61dadd8a2a 100644 GIT binary patch literal 244 zcmZ>BbPo8!z`($~*~#D8BUr&HBEVSz2pEB4AU24G0Y(N+hD|^Y6El!tgNU*~X%LSC z$X0-fGcm9T0LA|E|L2FOWMD92VqjR>!otAF!NBm72Obk1 YBHITON2VDSAnpK(F*YFF1LDH~0O^Si0RR91 literal 0 HcmV?d00001 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352371; cv=none; d=zohomail.com; s=zohoarc; b=e1e01kSiwXG2vlYhyQiD6kNDpFrjHv1reWLpy7Uz+DCKVjZCoiJYwp5PU9/t1SEfl1yI36N1zq1wjK/OvJ/pZjz/u0+clKzCbtpqBZqsrcU3YzbQQndUJRaPBABeJZwQKcXSTQXOvd9IbTQJUmwFMJAfnxj85q2gjCH/AiheaEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352371; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CEno9zW8w+VAHCwT91u0hyw6S/t7zwBF7SdlgJpC+g4=; b=C27cOTf4KZ6AiHzbEHWNK1b2UCc2tjSbtEsIAItTXN7+uSNNoa/DJxtY3pN9NNalZUtrYodtGVtsQC4fbZbSc747VpTrRErnjCfEo/P44EfIulB4n/L3IJ/K/Niz3SBeTeKRRbP9ZS5oB/yUQLccY8mlYnVIIxp7Zb9gGQ/n5R4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352371683247.29104333238865; Tue, 7 Nov 2023 02:19:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4Y-0002X0-Bg; Tue, 07 Nov 2023 05:12:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4W-0002Ix-9m for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4U-0002kL-Je for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:35 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-487-GOfWu8AEM0uo1rgWx_htXA-1; Tue, 07 Nov 2023 05:12:31 -0500 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4084001846eso36203325e9.1 for ; Tue, 07 Nov 2023 02:12:31 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id t8-20020a0560001a4800b0032d8034724esm1899356wry.94.2023.11.07.02.12.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:12:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351953; h=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=CEno9zW8w+VAHCwT91u0hyw6S/t7zwBF7SdlgJpC+g4=; b=LRwEUdMkIEkaDsDbe9hErZIBlFWOkBm/1uVGmdvgMz6iUJVvKL2XQyFvSRyt824z3jWdxs ffQoS4UJ5GlGSmPZAIev/p1+7KXxFYh2MANkazNCtyd1zxlb4L2b12ZHYK5lfwNdg8Dda7 w7/H/FO+GtKAL9w5YBJjGHi3q1Mz8ts= X-MC-Unique: GOfWu8AEM0uo1rgWx_htXA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351950; x=1699956750; 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=CEno9zW8w+VAHCwT91u0hyw6S/t7zwBF7SdlgJpC+g4=; b=V9tirodCeR0muGMoFHBcx8ptuAtye4B0zWARvIdYe8xIZAjSON4ea9zUyDRx4Q2Wfz kXS2juKolno5NMkYqJKLr75632FtpLMGuflQOlN+uUjoJ94Cqje5NutbnPmlYi8MQVdt hOx3bwdxjOWtPIfF77m204fttT+tTK5eCr7REHlhlx1rCVl4UNYj4Jg/4oH9GnPXBGl7 l1N078eSx3gH6OBDCbP6t0h0NjmWdfaLrkOUi8n/kh8M/7VHxoWruFq6MQXpfTc4hu6q BvxjefVKwvX2cIxO0PIxZxo4MdmKgHuGmREcWwZOtKdFuHo0qCk98sjplCwzmvT/E7sU k1QA== X-Gm-Message-State: AOJu0Yy8+nsoP7TB2aHvFlEQFsEll94VYDJo/ca6GzanaEAsBd6MaS7C fiEnZOaGBCsbC+wvmriEqO1+JlRL+GCspaocn5OeqX21N5Hr37NE3pz5YuCDwooCw9P8nkS6OYW 0GAklWEcp0/qLc92K+s/iJ8LQllDYwDhnbEAhV8KN7NkZMSbW3OXqO0ZebUS0Gr4fyaPB X-Received: by 2002:adf:e7d0:0:b0:32d:a0a9:4785 with SMTP id e16-20020adfe7d0000000b0032da0a94785mr24297173wrn.7.1699351950035; Tue, 07 Nov 2023 02:12:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFS5QI35Q9dbS6WrsmQ+HIyXxbQzJ7uuXg3FpPOtwcx/Wy1xqi2hVra/07sJQBVtEl/1GRr3A== X-Received: by 2002:adf:e7d0:0:b0:32d:a0a9:4785 with SMTP id e16-20020adfe7d0000000b0032da0a94785mr24297159wrn.7.1699351949763; Tue, 07 Nov 2023 02:12:29 -0800 (PST) Date: Tue, 7 Nov 2023 05:12:26 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Fan Ni Subject: [PULL 40/63] hw/cxl: Use a switch to explicitly check size in caps_reg_read() Message-ID: <629df5cc23cc9aec5d115cc9be3456458e2b44fa.1699351720.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352374123100011 From: Jonathan Cameron Bring this read function inline with the others that do check for unexpected size values. Also reduces line lengths to sub 80 chars. Signed-off-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fan Ni Message-Id: <20231023140210.3089-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-device-utils.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c index bd68328032..eb7195272e 100644 --- a/hw/cxl/cxl-device-utils.c +++ b/hw/cxl/cxl-device-utils.c @@ -32,10 +32,13 @@ static uint64_t caps_reg_read(void *opaque, hwaddr offs= et, unsigned size) { CXLDeviceState *cxl_dstate =3D opaque; =20 - if (size =3D=3D 4) { - return cxl_dstate->caps_reg_state32[offset / sizeof(*cxl_dstate->c= aps_reg_state32)]; - } else { - return cxl_dstate->caps_reg_state64[offset / sizeof(*cxl_dstate->c= aps_reg_state64)]; + switch (size) { + case 4: + return cxl_dstate->caps_reg_state32[offset / size]; + case 8: + return cxl_dstate->caps_reg_state64[offset / size]; + default: + g_assert_not_reached(); } } =20 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352223; cv=none; d=zohomail.com; s=zohoarc; b=oH2R7LX+jJ+oFuF9ehK+YxJpCG3wmspf9NQm5OKO/twW/7GPUHYB3/61XenAWX5QO9URIA2Er6MNZH0CFDMkyEhRl2k8b4MSR0Nr55jbnD4HdYJwVhphhuf9pA2MZxABI4LF/H8/duGCWwqEFvV65BGWn3b9aUBa4s0Hr2mojO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352223; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OvBCdjY+PBjwJoWVkUe/T5ldK9L6FSppXbnkR3Y6SYI=; b=GD17KZoZBoUYLQ9J7GtZumZsK2Qsmcqpxd7PHMF0crZRTG7kbLV51jgT0ynz0TcTFdGFmRp4NHPudQpJVsWHPd+xWJbxk5eR+at3+RmNC/m2reQ6HwXEO2xDzzWHPCkotoyF2iNniSVuSaBw840O6DymEnyNCi4iceQ1TYXsA14= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352223880993.903083402553; Tue, 7 Nov 2023 02:17:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4g-0002mR-6Z; Tue, 07 Nov 2023 05:12:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4e-0002m9-VT for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4d-0002lX-8q for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:44 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-vTPZlkMDP6WAveKqXVCviw-1; Tue, 07 Nov 2023 05:12:36 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4084163ecd9so36077595e9.3 for ; Tue, 07 Nov 2023 02:12:36 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id bd13-20020a05600c1f0d00b004078d71be9csm15270066wmb.13.2023.11.07.02.12.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:12:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351962; h=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=OvBCdjY+PBjwJoWVkUe/T5ldK9L6FSppXbnkR3Y6SYI=; b=aUPu9bQA7GMv6cFzaG52qLNHYLokGifofNzFBQBMzPJVGfrrdN4d18/f5eXuMqgWaywSbs fseNck/nNGmOLnOk/bjV8JHDobdcg28+sB//NPeixln14TzFEAdJcvMdpg/vcFTOCuDJre bQzOnBgkaRJD7Rnn/Xoci+RZgb5bE2A= X-MC-Unique: vTPZlkMDP6WAveKqXVCviw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351954; x=1699956754; 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=OvBCdjY+PBjwJoWVkUe/T5ldK9L6FSppXbnkR3Y6SYI=; b=XFnug2qE4++VgYRGGL530GCjcoMnCXeZI7moZf6wJ3SYwnAumK8pYXIYpM9K4WSMBz a1yJvCMdPf/PUDaECuM1IbrwYlpDv7p20mEMgJauRPMgzyQRQwuvahlWSyLL4ZjvB54W M8XgJO7U+8mT6KtNFeqHJbvsKsxr31ti7adAEVUy28SPTPP7U6VrwkVd1L98MC3aZGOk KImevBgTDtkJ1kMFTITdtvYN0Pi9sApq4YzdjPF7RU5pcqHnqDK+mZwoXmmFri3HCU37 wgPLoVfiQQY8TNhQF/029aPGO+UCv1suBMeFI7GH+fRrqcSpDIeK7nYS6NtoBh/0OTes BiHA== X-Gm-Message-State: AOJu0Yz4OIYUh9FgJsTkxr01w6nVxQY1qgoY2RMT1N9RbAJMdTB17n4Z eafSi0EuIOPEr+vF/XDpAVbCRbfMqRtbkuXpj018HKrowFUSNW6vvxy6RcW5B9svq9rUpzrLBSi gUkXztzNFKmxKAqvyILA6L9SJjWsJhOtKyuONp7cQX1aHdlDOuxBvKJHOQWvV2q2IWlBM X-Received: by 2002:a05:600c:198a:b0:407:8e68:4a5b with SMTP id t10-20020a05600c198a00b004078e684a5bmr2052073wmq.38.1699351954595; Tue, 07 Nov 2023 02:12:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7CTBPAWDN+cY6yu9WL3LBKMXJL3p3HoIlGxAh5wYbnnWaI/rtnNHp8fP+VKSPQhpIfmitEA== X-Received: by 2002:a05:600c:198a:b0:407:8e68:4a5b with SMTP id t10-20020a05600c198a00b004078e684a5bmr2052055wmq.38.1699351954259; Tue, 07 Nov 2023 02:12:34 -0800 (PST) Date: Tue, 7 Nov 2023 05:12:30 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Michael Tokarev , Fan Ni Subject: [PULL 41/63] hw/cxl: Use switch statements for read and write of cachemem registers Message-ID: <388d6b574e282b02e8180f4cba428316a404deea.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352224696100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Establishing that only register accesses of size 4 and 8 can occur using these functions requires looking at their callers. Make it easier to see that by using switch statements. Assertions are used to enforce that the register storage is of the matching size, allowing fixed values to be used for divisors of the array indices. Suggested-by: Michael Tokarev Signed-off-by: Jonathan Cameron Reviewed-by: Fan Ni Message-Id: <20231023140210.3089-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-component-utils.c | 66 +++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c index f3bbf0fd13..9d4f4bc8d4 100644 --- a/hw/cxl/cxl-component-utils.c +++ b/hw/cxl/cxl-component-utils.c @@ -67,16 +67,24 @@ static uint64_t cxl_cache_mem_read_reg(void *opaque, hw= addr offset, CXLComponentState *cxl_cstate =3D opaque; ComponentRegisters *cregs =3D &cxl_cstate->crb; =20 - if (size =3D=3D 8) { + switch (size) { + case 4: + if (cregs->special_ops && cregs->special_ops->read) { + return cregs->special_ops->read(cxl_cstate, offset, 4); + } else { + QEMU_BUILD_BUG_ON(sizeof(*cregs->cache_mem_registers) !=3D 4); + return cregs->cache_mem_registers[offset / 4]; + } + case 8: qemu_log_mask(LOG_UNIMP, "CXL 8 byte cache mem registers not implemented\n"); return 0; - } - - if (cregs->special_ops && cregs->special_ops->read) { - return cregs->special_ops->read(cxl_cstate, offset, size); - } else { - return cregs->cache_mem_registers[offset / sizeof(*cregs->cache_me= m_registers)]; + default: + /* + * In line with specifiction limitaions on access sizes, this + * routine is not called with other sizes. + */ + g_assert_not_reached(); } } =20 @@ -117,25 +125,37 @@ static void cxl_cache_mem_write_reg(void *opaque, hwa= ddr offset, uint64_t value, ComponentRegisters *cregs =3D &cxl_cstate->crb; uint32_t mask; =20 - if (size =3D=3D 8) { + switch (size) { + case 4: { + QEMU_BUILD_BUG_ON(sizeof(*cregs->cache_mem_regs_write_mask) !=3D 4= ); + QEMU_BUILD_BUG_ON(sizeof(*cregs->cache_mem_registers) !=3D 4); + mask =3D cregs->cache_mem_regs_write_mask[offset / 4]; + value &=3D mask; + /* RO bits should remain constant. Done by reading existing value = */ + value |=3D ~mask & cregs->cache_mem_registers[offset / 4]; + if (cregs->special_ops && cregs->special_ops->write) { + cregs->special_ops->write(cxl_cstate, offset, value, size); + return; + } + + if (offset >=3D A_CXL_HDM_DECODER_CAPABILITY && + offset <=3D A_CXL_HDM_DECODER3_TARGET_LIST_HI) { + dumb_hdm_handler(cxl_cstate, offset, value); + } else { + cregs->cache_mem_registers[offset / 4] =3D value; + } + return; + } + case 8: qemu_log_mask(LOG_UNIMP, "CXL 8 byte cache mem registers not implemented\n"); return; - } - mask =3D cregs->cache_mem_regs_write_mask[offset / sizeof(*cregs->cach= e_mem_regs_write_mask)]; - value &=3D mask; - /* RO bits should remain constant. Done by reading existing value */ - value |=3D ~mask & cregs->cache_mem_registers[offset / sizeof(*cregs->= cache_mem_registers)]; - if (cregs->special_ops && cregs->special_ops->write) { - cregs->special_ops->write(cxl_cstate, offset, value, size); - return; - } - - if (offset >=3D A_CXL_HDM_DECODER_CAPABILITY && - offset <=3D A_CXL_HDM_DECODER3_TARGET_LIST_HI) { - dumb_hdm_handler(cxl_cstate, offset, value); - } else { - cregs->cache_mem_registers[offset / sizeof(*cregs->cache_mem_regis= ters)] =3D value; + default: + /* + * In line with specifiction limitaions on access sizes, this + * routine is not called with other sizes. + */ + g_assert_not_reached(); } } =20 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352400; cv=none; d=zohomail.com; s=zohoarc; b=Kcmo060PpMOLAn6JtxZ7od0Dlwqqm5yts0/AeN19tcjVZ6UPvoLjWAlpJkASfOQPoyqoDDKKOD33UphfMTHoJ7raKIqujo3xeMxvoGkgbAq4eD7u4OZZ90U/h1xyiIxdxvpOIzgaxo85xXcEHo8YQd2A2Xvt+yPHvpeEHb/0V8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352400; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PzmxxvQVtCQlxrdp90CZq+87N/MZN/GaNdzZqugBwa8=; b=R7bHEI8MGrQPMpLvO/s/oECiVYWTfePrTdzPbm+r/o5YE99YxzbjCHNzIJxROnRbHvSbxvBKPa1zIYo2K1gBtcX5o9ze+CqTwQNwdygpyFE1NNh+eCGNceygzhaNipbl4g5ZBLbOC49TLKt4kNobhL3GKDLJP17qFxAcrnSqTpQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352400789280.64976859418675; Tue, 7 Nov 2023 02:20:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4q-0003FJ-VA; Tue, 07 Nov 2023 05:12:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4p-00036s-4q for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4n-0002mk-5J for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:54 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-577-jbMubMeFMHGgBCMlT_jJlw-1; Tue, 07 Nov 2023 05:12:41 -0500 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-32f8371247fso2815000f8f.2 for ; Tue, 07 Nov 2023 02:12:40 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id m28-20020a056000181c00b0032f78feb826sm1914482wrh.104.2023.11.07.02.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:12:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351972; h=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=PzmxxvQVtCQlxrdp90CZq+87N/MZN/GaNdzZqugBwa8=; b=MxIT/cZF4FhlwkRn8bZYLlQUfRpxLpetp2m9tCS68K8Nf4uZPDv83tqo/0VRpR3tEROTBg weGiNcXv8WRqz+4hBfkoqnPogv+UNQ025Txq/Zan8h2VLC8gkIpEl3sdkGevspLKI7xXGR vzGGx1G2VOaAqUbBA6OwAnupl5zt7xg= X-MC-Unique: jbMubMeFMHGgBCMlT_jJlw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351959; x=1699956759; 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=PzmxxvQVtCQlxrdp90CZq+87N/MZN/GaNdzZqugBwa8=; b=NmndJRTjTTEd9hM+00ynGLb7S/oHDROVHbDYeoAagWZd9igokCnJV+u4g6rZY51MFl RgxUMgFSccJgsRyoj/BZe/osgUAwe+/yFNUYV6178JZukE7CztG/R2mbRFbZc3Py1o1c vQbPU+sUY5wnyqX8WnB9s0xWCmuVjzgdxCn/ykuzoDhTVIyw3V9nSsf7djw4Xec3ykFj qc0+AKeysGPuyjCW6TLJpdO3UXGNK6AhXH1Bv3Fu4H/b4W+PhIgfySi4igfJS+7bFZin RHu4ruCja2chnaVYCwHXOMgQDT/eEl/vh2038Kc8gEvSlceh1zqkHVhWPkUAdkI7KAAP 1VzA== X-Gm-Message-State: AOJu0YwOuefpX6aSH9jWCzRDAzs6L2qm+Qqufkrvu4CpmJNaKcVT7Fdl JT0IOwvwj/qtxnsyPigUhrmECUlnqrghi17Lm63GXnARGukIoCD6ecFlyivOPJXQBMAzWE87pdp 2fcuBUCmRvVHOMU8egKz01EievSwr8O++RGeIS5Wno+3P5al6phIkrw3ovcEGhLqVvjIx X-Received: by 2002:adf:f946:0:b0:319:8a66:f695 with SMTP id q6-20020adff946000000b003198a66f695mr22193052wrr.55.1699351959445; Tue, 07 Nov 2023 02:12:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHGrLzdXxciCTBlykEjMCo/ycNySW9hVBTkgOi3CBzqR55FMzYpHPAi/LueBMrVzKcejCitg== X-Received: by 2002:adf:f946:0:b0:319:8a66:f695 with SMTP id q6-20020adff946000000b003198a66f695mr22193034wrr.55.1699351959115; Tue, 07 Nov 2023 02:12:39 -0800 (PST) Date: Tue, 7 Nov 2023 05:12:35 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Fan Ni , Marcel Apfelbaum Subject: [PULL 42/63] hw/cxl: CXLDVSECPortExtensions renamed to CXLDVSECPortExt Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352402639100003 From: Jonathan Cameron Done to reduce line lengths where this is used. Ext seems sufficiently obvious that it need not be spelt out fully. Signed-off-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fan Ni Message-Id: <20231023140210.3089-4-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_pci.h | 6 ++--- hw/cxl/cxl-component-utils.c | 49 ++++++++++++++++++++-------------- hw/pci-bridge/cxl_downstream.c | 2 +- hw/pci-bridge/cxl_root_port.c | 2 +- hw/pci-bridge/cxl_upstream.c | 2 +- 5 files changed, 35 insertions(+), 26 deletions(-) diff --git a/include/hw/cxl/cxl_pci.h b/include/hw/cxl/cxl_pci.h index 407be95b9e..ddf01a543b 100644 --- a/include/hw/cxl/cxl_pci.h +++ b/include/hw/cxl/cxl_pci.h @@ -86,7 +86,7 @@ typedef struct CXLDVSECDevice { QEMU_BUILD_BUG_ON(sizeof(CXLDVSECDevice) !=3D 0x38); =20 /* CXL 2.0 - 8.1.5 (ID 0003) */ -typedef struct CXLDVSECPortExtensions { +typedef struct CXLDVSECPortExt { DVSECHeader hdr; uint16_t status; uint16_t control; @@ -100,8 +100,8 @@ typedef struct CXLDVSECPortExtensions { uint32_t alt_prefetch_limit_high; uint32_t rcrb_base; uint32_t rcrb_base_high; -} CXLDVSECPortExtensions; -QEMU_BUILD_BUG_ON(sizeof(CXLDVSECPortExtensions) !=3D 0x28); +} CXLDVSECPortExt; +QEMU_BUILD_BUG_ON(sizeof(CXLDVSECPortExt) !=3D 0x28); =20 #define PORT_CONTROL_OFFSET 0xc #define PORT_CONTROL_UNMASK_SBR 1 diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c index 9d4f4bc8d4..1f4ea11640 100644 --- a/hw/cxl/cxl-component-utils.c +++ b/hw/cxl/cxl-component-utils.c @@ -393,26 +393,35 @@ void cxl_component_create_dvsec(CXLComponentState *cx= l, case NON_CXL_FUNCTION_MAP_DVSEC: break; /* Not yet implemented */ case EXTENSIONS_PORT_DVSEC: - wmask[offset + offsetof(CXLDVSECPortExtensions, control)] =3D 0x0F; - wmask[offset + offsetof(CXLDVSECPortExtensions, control) + 1] =3D = 0x40; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_bus_base)] =3D= 0xFF; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_bus_limit)] = =3D 0xFF; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_memory_base)] = =3D 0xF0; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_memory_base) += 1] =3D 0xFF; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_memory_limit)]= =3D 0xF0; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_memory_limit) = + 1] =3D 0xFF; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_prefetch_base)= ] =3D 0xF0; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_prefetch_base)= + 1] =3D 0xFF; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_prefetch_limit= )] =3D 0xF0; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_prefetch_limit= ) + 1] =3D 0xFF; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_prefetch_base_= high)] =3D 0xFF; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_prefetch_base_= high) + 1] =3D 0xFF; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_prefetch_base_= high) + 2] =3D 0xFF; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_prefetch_base_= high) + 3] =3D 0xFF; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_prefetch_limit= _high)] =3D 0xFF; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_prefetch_limit= _high) + 1] =3D 0xFF; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_prefetch_limit= _high) + 2] =3D 0xFF; - wmask[offset + offsetof(CXLDVSECPortExtensions, alt_prefetch_limit= _high) + 3] =3D 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, control)] =3D 0x0F; + wmask[offset + offsetof(CXLDVSECPortExt, control) + 1] =3D 0x40; + wmask[offset + offsetof(CXLDVSECPortExt, alt_bus_base)] =3D 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, alt_bus_limit)] =3D 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, alt_memory_base)] =3D 0xF= 0; + wmask[offset + offsetof(CXLDVSECPortExt, alt_memory_base) + 1] =3D= 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, alt_memory_limit)] =3D 0x= F0; + wmask[offset + offsetof(CXLDVSECPortExt, alt_memory_limit) + 1] = =3D 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, alt_prefetch_base)] =3D 0= xF0; + wmask[offset + offsetof(CXLDVSECPortExt, alt_prefetch_base) + 1] = =3D 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, alt_prefetch_limit)] =3D = 0xF0; + wmask[offset + offsetof(CXLDVSECPortExt, alt_prefetch_limit) + 1] = =3D + 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, alt_prefetch_base_high)] = =3D + 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, alt_prefetch_base_high) += 1] =3D + 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, alt_prefetch_base_high) += 2] =3D + 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, alt_prefetch_base_high) += 3] =3D + 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, alt_prefetch_limit_high)]= =3D + 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, alt_prefetch_limit_high) = + 1] =3D + 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, alt_prefetch_limit_high) = + 2] =3D + 0xFF; + wmask[offset + offsetof(CXLDVSECPortExt, alt_prefetch_limit_high) = + 3] =3D + 0xFF; break; case GPF_PORT_DVSEC: wmask[offset + offsetof(CXLDVSECPortGPF, phase1_ctrl)] =3D 0x0F; diff --git a/hw/pci-bridge/cxl_downstream.c b/hw/pci-bridge/cxl_downstream.c index 5a2b749c8e..8c0f759add 100644 --- a/hw/pci-bridge/cxl_downstream.c +++ b/hw/pci-bridge/cxl_downstream.c @@ -98,7 +98,7 @@ static void build_dvsecs(CXLComponentState *cxl) { uint8_t *dvsec; =20 - dvsec =3D (uint8_t *)&(CXLDVSECPortExtensions){ 0 }; + dvsec =3D (uint8_t *)&(CXLDVSECPortExt){ 0 }; cxl_component_create_dvsec(cxl, CXL2_DOWNSTREAM_PORT, EXTENSIONS_PORT_DVSEC_LENGTH, EXTENSIONS_PORT_DVSEC, diff --git a/hw/pci-bridge/cxl_root_port.c b/hw/pci-bridge/cxl_root_port.c index 7dfd20aa67..8f97697631 100644 --- a/hw/pci-bridge/cxl_root_port.c +++ b/hw/pci-bridge/cxl_root_port.c @@ -107,7 +107,7 @@ static void build_dvsecs(CXLComponentState *cxl) { uint8_t *dvsec; =20 - dvsec =3D (uint8_t *)&(CXLDVSECPortExtensions){ 0 }; + dvsec =3D (uint8_t *)&(CXLDVSECPortExt){ 0 }; cxl_component_create_dvsec(cxl, CXL2_ROOT_PORT, EXTENSIONS_PORT_DVSEC_LENGTH, EXTENSIONS_PORT_DVSEC, diff --git a/hw/pci-bridge/cxl_upstream.c b/hw/pci-bridge/cxl_upstream.c index a57806fb31..b81bb5fec9 100644 --- a/hw/pci-bridge/cxl_upstream.c +++ b/hw/pci-bridge/cxl_upstream.c @@ -116,7 +116,7 @@ static void build_dvsecs(CXLComponentState *cxl) { uint8_t *dvsec; =20 - dvsec =3D (uint8_t *)&(CXLDVSECPortExtensions){ + dvsec =3D (uint8_t *)&(CXLDVSECPortExt){ .status =3D 0x1, /* Port Power Management Init Complete */ }; cxl_component_create_dvsec(cxl, CXL2_UPSTREAM_PORT, --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352364; cv=none; d=zohomail.com; s=zohoarc; b=ZAib81b8ZJP4CoZmylhvDlLdQtHwNCABNZusfjfPHZsWz/TyCCLzFNEGOtVFzdf0jNUjBHY6UJDEUY0RNJROJJCTwvoBcJoCMJH1NjXBwXTDPpQPTylmx+2eI0pV7iv1CGhsdLwhp2pOpCsAnIiHY4+D+i9j3Fnc08jVtrXOt00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352364; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xB5lcPuUcxHE5NrWU1XvWl0Q9zQU2jRWZ5iV6plyM8o=; b=XtdVz8YV6HXNKZDpAcCfTYH/rl0scpggMOqWLBqz38C32kw/xKvAGxq3vLGtUh1RGG5Lqc94E7CRGZ4uO39+b7YT8DR2Q0xQ3NVBtUr5PoMpbNJ0A4uT2zksoJgZQq8sLJ6+y+dTUVUNumSf6EolsiT8E0hiMRxWNufythhIfoM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352364600254.66516447182926; Tue, 7 Nov 2023 02:19:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4k-0002oI-L4; Tue, 07 Nov 2023 05:12:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4j-0002o0-Qc for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4h-0002ly-Dd for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:49 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-216-n0xhePJcOpqYh9Wx3XyX_A-1; Tue, 07 Nov 2023 05:12:45 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4083717431eso36138475e9.1 for ; Tue, 07 Nov 2023 02:12:45 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id p7-20020a056000018700b0032f7eaa6e43sm1905003wrx.79.2023.11.07.02.12.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:12:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351966; h=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=xB5lcPuUcxHE5NrWU1XvWl0Q9zQU2jRWZ5iV6plyM8o=; b=AlUVHG6HqK4UEbvFeohf9LQToy6telvZJJrKvdMN1O5/oFOlzLimW4noaC/wnx6L5Ezuyg I/PkJZCX9Bt5rwKJL47ai/Uaxc2o1mNYSIZKRGwVnMD413XdbqLqqBN1UMIBRR6n2aQXjS VoYWZ8fCzshnclgijD8VDM491MbMfJI= X-MC-Unique: n0xhePJcOpqYh9Wx3XyX_A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351964; x=1699956764; 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=xB5lcPuUcxHE5NrWU1XvWl0Q9zQU2jRWZ5iV6plyM8o=; b=CrKBg5Wsejo9hGE2t+EzO0tF9lDoVb2XKtsvi4t57lou8FOAxwSmqI49W140jv5hhK aM1ufZCFFaysRBRywCaiwO9fG08HjPwm43QHdXMgruOzUOYG57s7l56GNUZc5kAzEfyu vQr/KJC59qoFfyuKXORSPNH1QVvg0l7EXaEz/KsJk40aPxiyEbzw5wJldZtx2Js0pSwK 2894I1av+Av2G1q6rr/urBZdaJa4/WLFj+tWmxxdoQmKEzVwMbwRFFp5yah9szJIRgRd ew3AgkshXko5CePToTZo0yR4NQJIXVUOVEZ6fdVq0g+eWtRuqYq1rGjdRG4keDNZ2U9C elMA== X-Gm-Message-State: AOJu0YzMbXCCfFVvDotd5pOACz/AYyBRLBF/nmCoR4DW/uRKy1xhU6TR Yu/o+PBE30MTAeav9djkqk+RpX97MiQ6VqKcrVwyHQV8Wh5mQkTWhqQdpEMMGz922rSd54nRfDj iGR66xXDW80m21Kagb2my1etUlfngbtnphPpCsVRYkStjWBtsoXzhWn4m4npisz2zE9MJ X-Received: by 2002:a05:600c:4587:b0:405:3a65:1b4c with SMTP id r7-20020a05600c458700b004053a651b4cmr1751692wmo.6.1699351963936; Tue, 07 Nov 2023 02:12:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4UcT57eV5eAk2muXoedAvBt9Bh+AkZu4VH7qSUu1GCKsqbL7sPxPP1qI34xHt0OJ408yrTw== X-Received: by 2002:a05:600c:4587:b0:405:3a65:1b4c with SMTP id r7-20020a05600c458700b004053a651b4cmr1751675wmo.6.1699351963481; Tue, 07 Nov 2023 02:12:43 -0800 (PST) Date: Tue, 7 Nov 2023 05:12:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Michael Tokarev , Fan Ni Subject: [PULL 43/63] hw/cxl: Line length reductions 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352365950100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Michael Tsirkin observed that there were some unnecessarily long lines in the CXL code in a recent review. This patch is intended to rectify that where it does not hurt readability. Signed-off-by: Jonathan Cameron Reviewed-by: Michael Tokarev Reviewed-by: Fan Ni Message-Id: <20231023140210.3089-5-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_component.h | 3 ++- include/hw/cxl/cxl_device.h | 5 +++-- include/hw/cxl/cxl_events.h | 3 ++- hw/cxl/cxl-cdat.c | 3 ++- hw/cxl/cxl-component-utils.c | 14 ++++++++------ hw/cxl/cxl-events.c | 9 ++++++--- hw/cxl/cxl-mailbox-utils.c | 21 ++++++++++++++------- hw/mem/cxl_type3.c | 31 +++++++++++++++++++------------ hw/mem/cxl_type3_stubs.c | 5 +++-- 9 files changed, 59 insertions(+), 35 deletions(-) diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h index 3c795a6278..e52dd8d2b9 100644 --- a/include/hw/cxl/cxl_component.h +++ b/include/hw/cxl/cxl_component.h @@ -175,7 +175,8 @@ HDM_DECODER_INIT(3); (CXL_IDE_REGISTERS_OFFSET + CXL_IDE_REGISTERS_SIZE) #define CXL_SNOOP_REGISTERS_SIZE 0x8 =20 -QEMU_BUILD_BUG_MSG((CXL_SNOOP_REGISTERS_OFFSET + CXL_SNOOP_REGISTERS_SIZE)= >=3D 0x1000, +QEMU_BUILD_BUG_MSG((CXL_SNOOP_REGISTERS_OFFSET + + CXL_SNOOP_REGISTERS_SIZE) >=3D 0x1000, "No space for registers"); =20 typedef struct component_registers { diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 51cd0d9ce3..007ddaf078 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -192,7 +192,7 @@ void cxl_device_register_init_common(CXLDeviceState *de= v); * Documented as a 128 bit register, but 64 bit accesses and the second * 64 bits are currently reserved. */ -REG64(CXL_DEV_CAP_ARRAY, 0) /* Documented as 128 bit register but 64 byte = accesses */ +REG64(CXL_DEV_CAP_ARRAY, 0) FIELD(CXL_DEV_CAP_ARRAY, CAP_ID, 0, 16) FIELD(CXL_DEV_CAP_ARRAY, CAP_VERSION, 16, 8) FIELD(CXL_DEV_CAP_ARRAY, CAP_COUNT, 32, 16) @@ -361,7 +361,8 @@ struct CXLType3Class { uint64_t offset); void (*set_lsa)(CXLType3Dev *ct3d, const void *buf, uint64_t size, uint64_t offset); - bool (*set_cacheline)(CXLType3Dev *ct3d, uint64_t dpa_offset, uint8_t = *data); + bool (*set_cacheline)(CXLType3Dev *ct3d, uint64_t dpa_offset, + uint8_t *data); }; =20 MemTxResult cxl_type3_read(PCIDevice *d, hwaddr host_addr, uint64_t *data, diff --git a/include/hw/cxl/cxl_events.h b/include/hw/cxl/cxl_events.h index 089ba2091f..d778487b7e 100644 --- a/include/hw/cxl/cxl_events.h +++ b/include/hw/cxl/cxl_events.h @@ -92,7 +92,8 @@ typedef enum CXLEventIntMode { CXL_INT_RES =3D 0x03, } CXLEventIntMode; #define CXL_EVENT_INT_MODE_MASK 0x3 -#define CXL_EVENT_INT_SETTING(vector) ((((uint8_t)vector & 0xf) << 4) | CX= L_INT_MSI_MSIX) +#define CXL_EVENT_INT_SETTING(vector) \ + ((((uint8_t)vector & 0xf) << 4) | CXL_INT_MSI_MSIX) typedef struct CXLEventInterruptPolicy { uint8_t info_settings; uint8_t warn_settings; diff --git a/hw/cxl/cxl-cdat.c b/hw/cxl/cxl-cdat.c index d246d6885b..639a2db3e1 100644 --- a/hw/cxl/cxl-cdat.c +++ b/hw/cxl/cxl-cdat.c @@ -60,7 +60,8 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp) return; } =20 - cdat->built_buf_len =3D cdat->build_cdat_table(&cdat->built_buf, cdat-= >private); + cdat->built_buf_len =3D cdat->build_cdat_table(&cdat->built_buf, + cdat->private); =20 if (!cdat->built_buf_len) { /* Build later as not all data available yet */ diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c index 1f4ea11640..5ebd81daf3 100644 --- a/hw/cxl/cxl-component-utils.c +++ b/hw/cxl/cxl-component-utils.c @@ -241,7 +241,8 @@ static void hdm_init_common(uint32_t *reg_state, uint32= _t *write_msk, ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, TARGET_COUNT, = 1); ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, INTERLEAVE_256= B, 1); ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, INTERLEAVE_4K,= 1); - ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, POISON_ON_ERR_= CAP, 0); + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, + POISON_ON_ERR_CAP, 0); ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_GLOBAL_CONTROL, HDM_DECODER_ENABLE, 0); write_msk[R_CXL_HDM_DECODER_GLOBAL_CONTROL] =3D 0x3; @@ -264,15 +265,16 @@ static void hdm_init_common(uint32_t *reg_state, uint= 32_t *write_msk, } } =20 -void cxl_component_register_init_common(uint32_t *reg_state, uint32_t *wri= te_msk, +void cxl_component_register_init_common(uint32_t *reg_state, + uint32_t *write_msk, enum reg_type type) { int caps =3D 0; =20 /* - * In CXL 2.0 the capabilities required for each CXL component are suc= h that, - * with the ordering chosen here, a single number can be used to define - * which capabilities should be provided. + * In CXL 2.0 the capabilities required for each CXL component are such + * that, with the ordering chosen here, a single number can be used to + * define which capabilities should be provided. */ switch (type) { case CXL2_DOWNSTREAM_PORT: @@ -449,7 +451,7 @@ void cxl_component_create_dvsec(CXLComponentState *cxl, default: /* Registers are RO for other component types */ break; } - /* There are rw1cs bits in the status register but never set curre= ntly */ + /* There are rw1cs bits in the status register but never set */ break; } =20 diff --git a/hw/cxl/cxl-events.c b/hw/cxl/cxl-events.c index 3ddd6369ad..e2172b94b9 100644 --- a/hw/cxl/cxl-events.c +++ b/hw/cxl/cxl-events.c @@ -170,8 +170,10 @@ CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds= , CXLGetEventPayload *pl, if (log->overflow_err_count) { pl->flags |=3D CXL_GET_EVENT_FLAG_OVERFLOW; pl->overflow_err_count =3D cpu_to_le16(log->overflow_err_count); - pl->first_overflow_timestamp =3D cpu_to_le64(log->first_overflow_t= imestamp); - pl->last_overflow_timestamp =3D cpu_to_le64(log->last_overflow_tim= estamp); + pl->first_overflow_timestamp =3D + cpu_to_le64(log->first_overflow_timestamp); + pl->last_overflow_timestamp =3D + cpu_to_le64(log->last_overflow_timestamp); } =20 pl->record_count =3D cpu_to_le16(nr); @@ -180,7 +182,8 @@ CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds,= CXLGetEventPayload *pl, return CXL_MBOX_SUCCESS; } =20 -CXLRetCode cxl_event_clear_records(CXLDeviceState *cxlds, CXLClearEventPay= load *pl) +CXLRetCode cxl_event_clear_records(CXLDeviceState *cxlds, + CXLClearEventPayload *pl) { CXLEventLog *log; uint8_t log_type; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 434ccc5f6e..ab082ec9de 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -366,9 +366,12 @@ static CXLRetCode cmd_identify_memory_device(struct cx= l_cmd *cmd, =20 snprintf(id->fw_revision, 0x10, "BWFW VERSION %02d", 0); =20 - stq_le_p(&id->total_capacity, cxl_dstate->mem_size / CXL_CAPACITY_MULT= IPLIER); - stq_le_p(&id->persistent_capacity, cxl_dstate->pmem_size / CXL_CAPACIT= Y_MULTIPLIER); - stq_le_p(&id->volatile_capacity, cxl_dstate->vmem_size / CXL_CAPACITY_= MULTIPLIER); + stq_le_p(&id->total_capacity, + cxl_dstate->mem_size / CXL_CAPACITY_MULTIPLIER); + stq_le_p(&id->persistent_capacity, + cxl_dstate->pmem_size / CXL_CAPACITY_MULTIPLIER); + stq_le_p(&id->volatile_capacity, + cxl_dstate->vmem_size / CXL_CAPACITY_MULTIPLIER); stl_le_p(&id->lsa_size, cvc->get_lsa_size(ct3d)); /* 256 poison records */ st24_le_p(id->poison_list_max_mer, 256); @@ -396,13 +399,15 @@ static CXLRetCode cmd_ccls_get_partition_info(struct = cxl_cmd *cmd, return CXL_MBOX_INTERNAL_ERROR; } =20 - stq_le_p(&part_info->active_vmem, cxl_dstate->vmem_size / CXL_CAPACITY= _MULTIPLIER); + stq_le_p(&part_info->active_vmem, + cxl_dstate->vmem_size / CXL_CAPACITY_MULTIPLIER); /* * When both next_vmem and next_pmem are 0, there is no pending change= to * partitioning. */ stq_le_p(&part_info->next_vmem, 0); - stq_le_p(&part_info->active_pmem, cxl_dstate->pmem_size / CXL_CAPACITY= _MULTIPLIER); + stq_le_p(&part_info->active_pmem, + cxl_dstate->pmem_size / CXL_CAPACITY_MULTIPLIER); stq_le_p(&part_info->next_pmem, 0); =20 *len =3D sizeof(*part_info); @@ -681,8 +686,10 @@ static struct cxl_cmd cxl_cmd_set[256][256] =3D { [FIRMWARE_UPDATE][GET_INFO] =3D { "FIRMWARE_UPDATE_GET_INFO", cmd_firmware_update_get_info, 0, 0 }, [TIMESTAMP][GET] =3D { "TIMESTAMP_GET", cmd_timestamp_get, 0, 0 }, - [TIMESTAMP][SET] =3D { "TIMESTAMP_SET", cmd_timestamp_set, 8, IMMEDIAT= E_POLICY_CHANGE }, - [LOGS][GET_SUPPORTED] =3D { "LOGS_GET_SUPPORTED", cmd_logs_get_support= ed, 0, 0 }, + [TIMESTAMP][SET] =3D { "TIMESTAMP_SET", cmd_timestamp_set, + 8, IMMEDIATE_POLICY_CHANGE }, + [LOGS][GET_SUPPORTED] =3D { "LOGS_GET_SUPPORTED", cmd_logs_get_support= ed, + 0, 0 }, [LOGS][GET_LOG] =3D { "LOGS_GET_LOG", cmd_logs_get_log, 0x18, 0 }, [IDENTIFY][MEMORY_DEVICE] =3D { "IDENTIFY_MEMORY_DEVICE", cmd_identify_memory_device, 0, 0 }, diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index c02be4ce45..18ad853f5b 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -208,10 +208,9 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_= table, void *priv) } =20 if (nonvolatile_mr) { + uint64_t base =3D volatile_mr ? memory_region_size(volatile_mr) : = 0; rc =3D ct3_build_cdat_entries_for_mr(&(table[cur_ent]), dsmad_hand= le++, - nonvolatile_mr, true, - (volatile_mr ? - memory_region_size(volatile_mr= ) : 0)); + nonvolatile_mr, true, base); if (rc < 0) { goto error_cleanup; } @@ -514,7 +513,8 @@ static void ct3d_reg_write(void *opaque, hwaddr offset,= uint64_t value, case A_CXL_RAS_UNC_ERR_STATUS: { uint32_t capctrl =3D ldl_le_p(cache_mem + R_CXL_RAS_ERR_CAP_CTRL); - uint32_t fe =3D FIELD_EX32(capctrl, CXL_RAS_ERR_CAP_CTRL, FIRST_ER= ROR_POINTER); + uint32_t fe =3D FIELD_EX32(capctrl, CXL_RAS_ERR_CAP_CTRL, + FIRST_ERROR_POINTER); CXLError *cxl_err; uint32_t unc_err; =20 @@ -533,7 +533,8 @@ static void ct3d_reg_write(void *opaque, hwaddr offset,= uint64_t value, * closest to behavior of hardware not capable of multiple * header recording. */ - QTAILQ_FOREACH_SAFE(cxl_err, &ct3d->error_list, node, cxl_= next) { + QTAILQ_FOREACH_SAFE(cxl_err, &ct3d->error_list, node, + cxl_next) { if ((1 << cxl_err->type) & value) { QTAILQ_REMOVE(&ct3d->error_list, cxl_err, node); g_free(cxl_err); @@ -1072,7 +1073,8 @@ void qmp_cxl_inject_poison(const char *path, uint64_t= start, uint64_t length, if (((start >=3D p->start) && (start < p->start + p->length)) || ((start + length > p->start) && (start + length <=3D p->start + p->length))) { - error_setg(errp, "Overlap with existing poisoned region not su= pported"); + error_setg(errp, + "Overlap with existing poisoned region not supporte= d"); return; } } @@ -1085,7 +1087,8 @@ void qmp_cxl_inject_poison(const char *path, uint64_t= start, uint64_t length, p =3D g_new0(CXLPoison, 1); p->length =3D length; p->start =3D start; - p->type =3D CXL_POISON_TYPE_INTERNAL; /* Different from injected via t= he mbox */ + /* Different from injected via the mbox */ + p->type =3D CXL_POISON_TYPE_INTERNAL; =20 QLIST_INSERT_HEAD(&ct3d->poison_list, p, node); ct3d->poison_list_cnt++; @@ -1222,7 +1225,8 @@ void qmp_cxl_inject_correctable_error(const char *pat= h, CxlCorErrorType type, return; } /* If the error is masked, nothting to do here */ - if (!((1 << cxl_err_type) & ~ldl_le_p(reg_state + R_CXL_RAS_COR_ERR_MA= SK))) { + if (!((1 << cxl_err_type) & + ~ldl_le_p(reg_state + R_CXL_RAS_COR_ERR_MASK))) { return; } =20 @@ -1372,7 +1376,8 @@ void qmp_cxl_inject_dram_event(const char *path, CxlE= ventLog log, uint8_t flags, bool has_bank, uint8_t bank, bool has_row, uint32_t row, bool has_column, uint16_t column, - bool has_correction_mask, uint64List *corre= ction_mask, + bool has_correction_mask, + uint64List *correction_mask, Error **errp) { Object *obj =3D object_resolve_path(path, NULL); @@ -1473,7 +1478,7 @@ void qmp_cxl_inject_memory_module_event(const char *p= ath, CxlEventLog log, int16_t temperature, uint32_t dirty_shutdown_count, uint32_t corrected_volatile_error_= count, - uint32_t corrected_persistent_erro= r_count, + uint32_t corrected_persist_error_c= ount, Error **errp) { Object *obj =3D object_resolve_path(path, NULL); @@ -1513,8 +1518,10 @@ void qmp_cxl_inject_memory_module_event(const char *= path, CxlEventLog log, module.life_used =3D life_used; stw_le_p(&module.temperature, temperature); stl_le_p(&module.dirty_shutdown_count, dirty_shutdown_count); - stl_le_p(&module.corrected_volatile_error_count, corrected_volatile_er= ror_count); - stl_le_p(&module.corrected_persistent_error_count, corrected_persisten= t_error_count); + stl_le_p(&module.corrected_volatile_error_count, + corrected_volatile_error_count); + stl_le_p(&module.corrected_persistent_error_count, + corrected_persist_error_count); =20 if (cxl_event_insert(cxlds, enc_log, (CXLEventRecordRaw *)&module)) { cxl_event_irq_assert(ct3d); diff --git a/hw/mem/cxl_type3_stubs.c b/hw/mem/cxl_type3_stubs.c index 8ba5d3d1f7..3e1851e32b 100644 --- a/hw/mem/cxl_type3_stubs.c +++ b/hw/mem/cxl_type3_stubs.c @@ -33,7 +33,8 @@ void qmp_cxl_inject_dram_event(const char *path, CxlEvent= Log log, uint8_t flags, bool has_bank, uint8_t bank, bool has_row, uint32_t row, bool has_column, uint16_t column, - bool has_correction_mask, uint64List *corre= ction_mask, + bool has_correction_mask, + uint64List *correction_mask, Error **errp) {} =20 void qmp_cxl_inject_memory_module_event(const char *path, CxlEventLog log, @@ -45,7 +46,7 @@ void qmp_cxl_inject_memory_module_event(const char *path,= CxlEventLog log, int16_t temperature, uint32_t dirty_shutdown_count, uint32_t corrected_volatile_error_= count, - uint32_t corrected_persistent_erro= r_count, + uint32_t corrected_persist_error_c= ount, Error **errp) {} =20 void qmp_cxl_inject_poison(const char *path, uint64_t start, uint64_t leng= th, --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352364; cv=none; d=zohomail.com; s=zohoarc; b=jGaULFaGG6BRVc/fHZTzxeEHaG9ChhcfxiqaubdY1bJScRrprnUNFYPxqlFJrPdZJQRoJTETPTU3vMmqLBfbWnzmmHKlI7lWYACG0i4wEpnW3nnWqsax9F5Wfjms+M6oob1816UBQI2h+3o2FXTLEk5Edx/Hjojf0OGdMWEqYHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352364; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Tb+Ihf3FZQsxjNCgYDPZDlw3xq0lYm3eqZrirVZB9V4=; b=TAnHz5hZmQnv3KPOvvgxdHOiKRuiEyEzEoj2lxr2qEwwTvqB3IfDHF6fxDMJK8I0Nyl4ffdx0x20JIErwIYOW9WuN/a6klSO98XskKvjU/7s3ivcSD8nD64DmSOKRDFpMcpUpZgh6lSf4/4iQGv46TS9ADjCN91IThbAAuckWF0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352364401536.288190671369; Tue, 7 Nov 2023 02:19:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4v-0003OC-Fh; Tue, 07 Nov 2023 05:13:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4t-0003LD-Nx for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4r-0002ny-Ia for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:59 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-515-irwdLg6aMuCmh5sUPibUEg-1; Tue, 07 Nov 2023 05:12:49 -0500 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-32d8d17dcbaso2824878f8f.2 for ; Tue, 07 Nov 2023 02:12:49 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id l2-20020a5d4bc2000000b0032da319a27asm1924053wrt.9.2023.11.07.02.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:12:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351976; h=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=Tb+Ihf3FZQsxjNCgYDPZDlw3xq0lYm3eqZrirVZB9V4=; b=GkRgdgbmwTAiPcyAGOjUvaQ0Sjwiq/ttZKWUyyls19GWCqVhCC4qN/YgO8Xj08cw4F9EKO /CFc1ZPDrKcOlhdq81Yg4mwSh9+4gTl+fT/OM2/dV7k2ywvyU2EpNk4YMPpQPIjGqW9TCR UtadQZkWfzMp3tfX0yim7ZKS5ETRXEM= X-MC-Unique: irwdLg6aMuCmh5sUPibUEg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351968; x=1699956768; 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=Tb+Ihf3FZQsxjNCgYDPZDlw3xq0lYm3eqZrirVZB9V4=; b=MlN/CqM0c40wtOxuMn+ez9l5kaftlrhK/Y9J68MtaGQniUc7LGD2H4NqfMQ20L2Rv1 6mE9xl6gnXUsh8JKElUelzuX7MHudT9oasNDImKmqvK6t5AKFJKAzLmdoZ6XsN30nF8o hhJ0JXQO1jSOWw1UmItbHKl2//0sJ7zVRiAMdZi+LPdquoGuTDOBZ48VnwC7z5RgrR4U wSvr2Rk+j7Z6Z/3nx+rvHwUqr1Ex/M6DmixuDH5s4lvb4fRvxWwjsI0/kOw+m6Gs0lv1 i8IzhvLNxxOuzvmXnBJDMETytQ9V7JT1jz+spka10VFdKbe4rg7B2miHe29mDABGYIeU i+Og== X-Gm-Message-State: AOJu0YwYLd7ANMgpV6/Kdeh3qeUWs2YKR+B35HO46ENQ2GhZnKd2QRub qyOCDy+FG4Tc+Ht9EiNN+airIw/Prc6QfOX98ZOMy1eeITIiKoGlyZ8e5aoOO+6FvVvONnDdIzR 7976vquHVSyTuwkAQCa22SfXvELWEEa45Ovd6qiXYDk+s3hgcrQ9YgqUUJR4QE+Cxypkt X-Received: by 2002:a5d:6d82:0:b0:32f:9511:9795 with SMTP id l2-20020a5d6d82000000b0032f95119795mr20193263wrs.11.1699351967948; Tue, 07 Nov 2023 02:12:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHstBS62lVmTW8qyFCt5VA8dMhxbgK00lckVpjPK3N3XOAP/8TIB5UGoKpEXeI9kGDLbbEcMA== X-Received: by 2002:a5d:6d82:0:b0:32f:9511:9795 with SMTP id l2-20020a5d6d82000000b0032f95119795mr20193249wrs.11.1699351967646; Tue, 07 Nov 2023 02:12:47 -0800 (PST) Date: Tue, 7 Nov 2023 05:12:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Jeongtae Park , Fan Ni Subject: [PULL 44/63] hw/cxl: Fix a QEMU_BUILD_BUG_ON() in switch statement scope issue. Message-ID: <45234c2dd2920f16f768bda1ec8353bda8c5a929.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352365900100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron As _Static_assert is a declaration, it can't follow a label until C23. Some older versions of GCC trip up on this one. This check has no obvious purpose so just remove it. Reported-by: Jeongtae Park Signed-off-by: Jonathan Cameron Message-Id: <20231023140210.3089-6-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-component-utils.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c index 5ebd81daf3..d0245cc55d 100644 --- a/hw/cxl/cxl-component-utils.c +++ b/hw/cxl/cxl-component-utils.c @@ -305,7 +305,6 @@ void cxl_component_register_init_common(uint32_t *reg_s= tate, ARRAY_FIELD_DP32(reg_state, CXL_CAPABILITY_HEADER, ARRAY_SIZE, caps); =20 #define init_cap_reg(reg, id, version) = \ - QEMU_BUILD_BUG_ON(CXL_##reg##_REGISTERS_OFFSET =3D=3D 0); = \ do { = \ int which =3D R_CXL_##reg##_CAPABILITY_HEADER; = \ reg_state[which] =3D FIELD_DP32(reg_state[which], = \ --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352201; cv=none; d=zohomail.com; s=zohoarc; b=c/FhRch5dwM2NX5L0GLSkGPfWbxjxWdEJbq8kHzNtNLBZBs7UalKy6CJavTshlXbMVpegCNESXOaoWFMlmTGwVioqiF7lwQegXo/PTwRG9jgguMMRjVKMfNbpBXuCounnEOaWZDDGSZM0OlEcYDUP+D1dWhX28Ur/9xnQ/jX0/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352201; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=j2F88JokXJXgcMSPSDXbLTq7o37ECrHFxcmlb224C7w=; b=l4ygh2azrywGb4XnSIojEiZHuTz41EOJF5AV/pDpDzkLNVs/NTPamheoV8JLuJpzlejE4djjnWs45oWOq/B9eKRL5MttFFV7UQVa0HZHSifXyeW47RsnXzmf5l8MHy/hjPOq+I/7DEwAWnLVy0/3dNkoS9OqPskmXazDPudR7fM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169935220176554.18617090438465; Tue, 7 Nov 2023 02:16:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J4u-0003M0-NB; Tue, 07 Nov 2023 05:13:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4t-0003KU-4A for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4q-0002np-OB for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:12:58 -0500 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-606-gfwiHeVyPnq4xtigvO8uYA-1; Tue, 07 Nov 2023 05:12:54 -0500 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2c59a4dcdd0so51375481fa.0 for ; Tue, 07 Nov 2023 02:12:54 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id a1-20020a05600c348100b003fe1fe56202sm15528349wmq.33.2023.11.07.02.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:12:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351976; h=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=j2F88JokXJXgcMSPSDXbLTq7o37ECrHFxcmlb224C7w=; b=cV8nMWi8sg9DrhJfjLW3utS+eSGeXUXTH2b3vXRpHTJGkVyfM6rln/WUAwgAfSnliXpjx3 Y8znBkq2NDYal03XdZZZorU0zOLwa2pBASnYUVf+R63bm0mtbHvq4HbSOypvJWS506z7uI eph32e0APePpwBhZmgYOMbzXKnS0HmQ= X-MC-Unique: gfwiHeVyPnq4xtigvO8uYA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351973; x=1699956773; 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=j2F88JokXJXgcMSPSDXbLTq7o37ECrHFxcmlb224C7w=; b=O7F/m075/ZjYhUfPsSffL0tEiPlN91fFvRvUqY2Q3bs5aP/0JHg34WlgNJGT5avrg0 3YeqgO4oAwvAn9NDHB0kAYva8lCcuacMUlNKZG5pPNgytYoRMJz5pkv+WHK23BHNysON sqBIzA8rjl8wQrEYSjJmJNX8II17zR5gCZ3Kir/aHAHPwOtxMuni3hAl/UTtCJ5mlB9Y XCcGzoS3yrSiorxsp6Y8qZeqqDGV9WM3P6FHmSNYmZow6P9I3EUDKPJc3wOX/vfvB/an MtDMs3Bh0M0ZjAkqKZCCUYlbSaj2NbBR6bJflp7W89CtTzqQL8WhZiBz+8r1EXTE8xoT k5bg== X-Gm-Message-State: AOJu0YxOTHGheN3mLebduU67eJisV0mQaVDStxk6q9uBQF3+juAloMve IP65CYF9arxhi+HfP/0lcONZQ6ZyraKxGAVmy/1y3SvBKBjz9G5zFPEloqBHNaGX1KW/p5S0thJ E+MfZ/rK710FLjfJBnwYJv7tGgpmfw/N22L4Q0IMGsOEwTooo8mRquO1LTXuYpqw/329r X-Received: by 2002:a2e:be0c:0:b0:2c5:1bd9:f95c with SMTP id z12-20020a2ebe0c000000b002c51bd9f95cmr29933562ljq.53.1699351972574; Tue, 07 Nov 2023 02:12:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGdw/guimOtq7FYbmRWBj8Temw8/R8CnSzLBKD6/Uj/ZhyDC5tWcJ1aTiVEcyCxfxNa9uRHQ== X-Received: by 2002:a2e:be0c:0:b0:2c5:1bd9:f95c with SMTP id z12-20020a2ebe0c000000b002c51bd9f95cmr29933529ljq.53.1699351972068; Tue, 07 Nov 2023 02:12:52 -0800 (PST) Date: Tue, 7 Nov 2023 05:12:48 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 45/63] hw/cxl/mbox: Pull the payload out of struct cxl_cmd and make instances constant 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352202509100007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Putting the pointer in the structure for command handling puts a single variable element inside an otherwise constant structure. Move it out as a directly passed variable and take the cxl_cmd structures constant. Signed-off-by: Jonathan Cameron Reviewed-by: Fan Ni Message-Id: <20231023160806.13206-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 13 ++++ hw/cxl/cxl-mailbox-utils.c | 121 +++++++++++++++++++----------------- 2 files changed, 78 insertions(+), 56 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 007ddaf078..556953469c 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -111,6 +111,18 @@ typedef enum { CXL_MBOX_MAX =3D 0x17 } CXLRetCode; =20 +typedef struct cxl_device_state CXLDeviceState; +struct cxl_cmd; +typedef CXLRetCode (*opcode_handler)(const struct cxl_cmd *cmd, + uint8_t *payload, + CXLDeviceState *cxl_dstate, uint16_t = *len); +struct cxl_cmd { + const char *name; + opcode_handler handler; + ssize_t in; + uint16_t effect; /* Reported in CEL */ +}; + typedef struct CXLEvent { CXLEventRecordRaw data; QSIMPLEQ_ENTRY(CXLEvent) node; @@ -178,6 +190,7 @@ typedef struct cxl_device_state { uint64_t pmem_size; uint64_t vmem_size; =20 + const struct cxl_cmd (*cxl_cmd_set)[256]; CXLEventLog event_logs[CXL_EVENT_TYPE_MAX]; } CXLDeviceState; =20 diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index ab082ec9de..c02de06943 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -69,18 +69,9 @@ enum { #define CLEAR_POISON 0x2 }; =20 -struct cxl_cmd; -typedef CXLRetCode (*opcode_handler)(struct cxl_cmd *cmd, - CXLDeviceState *cxl_dstate, uint16_t *l= en); -struct cxl_cmd { - const char *name; - opcode_handler handler; - ssize_t in; - uint16_t effect; /* Reported in CEL */ - uint8_t *payload; -}; =20 -static CXLRetCode cmd_events_get_records(struct cxl_cmd *cmd, +static CXLRetCode cmd_events_get_records(const struct cxl_cmd *cmd, + uint8_t *payload, CXLDeviceState *cxlds, uint16_t *len) { @@ -92,9 +83,9 @@ static CXLRetCode cmd_events_get_records(struct cxl_cmd *= cmd, return CXL_MBOX_INVALID_INPUT; } =20 - log_type =3D *((uint8_t *)cmd->payload); + log_type =3D payload[0]; =20 - pl =3D (CXLGetEventPayload *)cmd->payload; + pl =3D (CXLGetEventPayload *)payload; memset(pl, 0, sizeof(*pl)); =20 max_recs =3D (cxlds->payload_size - CXL_EVENT_PAYLOAD_HDR_SIZE) / @@ -106,25 +97,27 @@ static CXLRetCode cmd_events_get_records(struct cxl_cm= d *cmd, return cxl_event_get_records(cxlds, pl, log_type, max_recs, len); } =20 -static CXLRetCode cmd_events_clear_records(struct cxl_cmd *cmd, +static CXLRetCode cmd_events_clear_records(const struct cxl_cmd *cmd, + uint8_t *payload, CXLDeviceState *cxlds, uint16_t *len) { CXLClearEventPayload *pl; =20 - pl =3D (CXLClearEventPayload *)cmd->payload; + pl =3D (CXLClearEventPayload *)payload; *len =3D 0; return cxl_event_clear_records(cxlds, pl); } =20 -static CXLRetCode cmd_events_get_interrupt_policy(struct cxl_cmd *cmd, +static CXLRetCode cmd_events_get_interrupt_policy(const struct cxl_cmd *cm= d, + uint8_t *payload, CXLDeviceState *cxlds, uint16_t *len) { CXLEventInterruptPolicy *policy; CXLEventLog *log; =20 - policy =3D (CXLEventInterruptPolicy *)cmd->payload; + policy =3D (CXLEventInterruptPolicy *)payload; memset(policy, 0, sizeof(*policy)); =20 log =3D &cxlds->event_logs[CXL_EVENT_TYPE_INFO]; @@ -157,7 +150,8 @@ static CXLRetCode cmd_events_get_interrupt_policy(struc= t cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 -static CXLRetCode cmd_events_set_interrupt_policy(struct cxl_cmd *cmd, +static CXLRetCode cmd_events_set_interrupt_policy(const struct cxl_cmd *cm= d, + uint8_t *payload, CXLDeviceState *cxlds, uint16_t *len) { @@ -168,7 +162,7 @@ static CXLRetCode cmd_events_set_interrupt_policy(struc= t cxl_cmd *cmd, return CXL_MBOX_INVALID_PAYLOAD_LENGTH; } =20 - policy =3D (CXLEventInterruptPolicy *)cmd->payload; + policy =3D (CXLEventInterruptPolicy *)payload; =20 log =3D &cxlds->event_logs[CXL_EVENT_TYPE_INFO]; log->irq_enabled =3D (policy->info_settings & CXL_EVENT_INT_MODE_MASK)= =3D=3D @@ -200,7 +194,8 @@ static CXLRetCode cmd_events_set_interrupt_policy(struc= t cxl_cmd *cmd, } =20 /* 8.2.9.2.1 */ -static CXLRetCode cmd_firmware_update_get_info(struct cxl_cmd *cmd, +static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, + uint8_t *payload, CXLDeviceState *cxl_dstate, uint16_t *len) { @@ -221,7 +216,7 @@ static CXLRetCode cmd_firmware_update_get_info(struct c= xl_cmd *cmd, return CXL_MBOX_INTERNAL_ERROR; } =20 - fw_info =3D (void *)cmd->payload; + fw_info =3D (void *)payload; memset(fw_info, 0, sizeof(*fw_info)); =20 fw_info->slots_supported =3D 2; @@ -234,27 +229,29 @@ static CXLRetCode cmd_firmware_update_get_info(struct= cxl_cmd *cmd, } =20 /* 8.2.9.3.1 */ -static CXLRetCode cmd_timestamp_get(struct cxl_cmd *cmd, +static CXLRetCode cmd_timestamp_get(const struct cxl_cmd *cmd, + uint8_t *payload, CXLDeviceState *cxl_dstate, uint16_t *len) { uint64_t final_time =3D cxl_device_get_timestamp(cxl_dstate); =20 - stq_le_p(cmd->payload, final_time); + stq_le_p(payload, final_time); *len =3D 8; =20 return CXL_MBOX_SUCCESS; } =20 /* 8.2.9.3.2 */ -static CXLRetCode cmd_timestamp_set(struct cxl_cmd *cmd, - CXLDeviceState *cxl_dstate, - uint16_t *len) +static CXLRetCode cmd_timestamp_set(const struct cxl_cmd *cmd, + uint8_t *payload, + CXLDeviceState *cxl_dstate, + uint16_t *len) { cxl_dstate->timestamp.set =3D true; cxl_dstate->timestamp.last_set =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUA= L); =20 - cxl_dstate->timestamp.host_set =3D le64_to_cpu(*(uint64_t *)cmd->paylo= ad); + cxl_dstate->timestamp.host_set =3D le64_to_cpu(*(uint64_t *)payload); =20 *len =3D 0; return CXL_MBOX_SUCCESS; @@ -267,7 +264,8 @@ static const QemuUUID cel_uuid =3D { }; =20 /* 8.2.9.4.1 */ -static CXLRetCode cmd_logs_get_supported(struct cxl_cmd *cmd, +static CXLRetCode cmd_logs_get_supported(const struct cxl_cmd *cmd, + uint8_t *payload, CXLDeviceState *cxl_dstate, uint16_t *len) { @@ -278,7 +276,7 @@ static CXLRetCode cmd_logs_get_supported(struct cxl_cmd= *cmd, QemuUUID uuid; uint32_t size; } log_entries[1]; - } QEMU_PACKED *supported_logs =3D (void *)cmd->payload; + } QEMU_PACKED *supported_logs =3D (void *)payload; QEMU_BUILD_BUG_ON(sizeof(*supported_logs) !=3D 0x1c); =20 supported_logs->entries =3D 1; @@ -290,7 +288,8 @@ static CXLRetCode cmd_logs_get_supported(struct cxl_cmd= *cmd, } =20 /* 8.2.9.4.2 */ -static CXLRetCode cmd_logs_get_log(struct cxl_cmd *cmd, +static CXLRetCode cmd_logs_get_log(const struct cxl_cmd *cmd, + uint8_t *payload, CXLDeviceState *cxl_dstate, uint16_t *len) { @@ -298,7 +297,9 @@ static CXLRetCode cmd_logs_get_log(struct cxl_cmd *cmd, QemuUUID uuid; uint32_t offset; uint32_t length; - } QEMU_PACKED QEMU_ALIGNED(16) *get_log =3D (void *)cmd->payload; + } QEMU_PACKED QEMU_ALIGNED(16) *get_log; + + get_log =3D (void *)payload; =20 /* * 8.2.9.4.2 @@ -324,14 +325,15 @@ static CXLRetCode cmd_logs_get_log(struct cxl_cmd *cm= d, /* Store off everything to local variables so we can wipe out the payl= oad */ *len =3D get_log->length; =20 - memmove(cmd->payload, cxl_dstate->cel_log + get_log->offset, + memmove(payload, cxl_dstate->cel_log + get_log->offset, get_log->length); =20 return CXL_MBOX_SUCCESS; } =20 /* 8.2.9.5.1.1 */ -static CXLRetCode cmd_identify_memory_device(struct cxl_cmd *cmd, +static CXLRetCode cmd_identify_memory_device(const struct cxl_cmd *cmd, + uint8_t *payload, CXLDeviceState *cxl_dstate, uint16_t *len) { @@ -361,7 +363,7 @@ static CXLRetCode cmd_identify_memory_device(struct cxl= _cmd *cmd, return CXL_MBOX_INTERNAL_ERROR; } =20 - id =3D (void *)cmd->payload; + id =3D (void *)payload; memset(id, 0, sizeof(*id)); =20 snprintf(id->fw_revision, 0x10, "BWFW VERSION %02d", 0); @@ -382,7 +384,8 @@ static CXLRetCode cmd_identify_memory_device(struct cxl= _cmd *cmd, return CXL_MBOX_SUCCESS; } =20 -static CXLRetCode cmd_ccls_get_partition_info(struct cxl_cmd *cmd, +static CXLRetCode cmd_ccls_get_partition_info(const struct cxl_cmd *cmd, + uint8_t *payload, CXLDeviceState *cxl_dstate, uint16_t *len) { @@ -391,7 +394,7 @@ static CXLRetCode cmd_ccls_get_partition_info(struct cx= l_cmd *cmd, uint64_t active_pmem; uint64_t next_vmem; uint64_t next_pmem; - } QEMU_PACKED *part_info =3D (void *)cmd->payload; + } QEMU_PACKED *part_info =3D (void *)payload; QEMU_BUILD_BUG_ON(sizeof(*part_info) !=3D 0x20); =20 if ((!QEMU_IS_ALIGNED(cxl_dstate->vmem_size, CXL_CAPACITY_MULTIPLIER))= || @@ -414,7 +417,8 @@ static CXLRetCode cmd_ccls_get_partition_info(struct cx= l_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 -static CXLRetCode cmd_ccls_get_lsa(struct cxl_cmd *cmd, +static CXLRetCode cmd_ccls_get_lsa(const struct cxl_cmd *cmd, + uint8_t *payload, CXLDeviceState *cxl_dstate, uint16_t *len) { @@ -426,7 +430,7 @@ static CXLRetCode cmd_ccls_get_lsa(struct cxl_cmd *cmd, CXLType3Class *cvc =3D CXL_TYPE3_GET_CLASS(ct3d); uint32_t offset, length; =20 - get_lsa =3D (void *)cmd->payload; + get_lsa =3D (void *)payload; offset =3D get_lsa->offset; length =3D get_lsa->length; =20 @@ -439,7 +443,8 @@ static CXLRetCode cmd_ccls_get_lsa(struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 -static CXLRetCode cmd_ccls_set_lsa(struct cxl_cmd *cmd, +static CXLRetCode cmd_ccls_set_lsa(const struct cxl_cmd *cmd, + uint8_t *payload, CXLDeviceState *cxl_dstate, uint16_t *len) { @@ -448,7 +453,7 @@ static CXLRetCode cmd_ccls_set_lsa(struct cxl_cmd *cmd, uint32_t rsvd; uint8_t data[]; } QEMU_PACKED; - struct set_lsa_pl *set_lsa_payload =3D (void *)cmd->payload; + struct set_lsa_pl *set_lsa_payload =3D (void *)payload; CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); CXLType3Class *cvc =3D CXL_TYPE3_GET_CLASS(ct3d); const size_t hdr_len =3D offsetof(struct set_lsa_pl, data); @@ -474,7 +479,8 @@ static CXLRetCode cmd_ccls_set_lsa(struct cxl_cmd *cmd, * make this stateful. We may want to allow longer poison lists to aid * testing that kernel functionality. */ -static CXLRetCode cmd_media_get_poison_list(struct cxl_cmd *cmd, +static CXLRetCode cmd_media_get_poison_list(const struct cxl_cmd *cmd, + uint8_t *payload, CXLDeviceState *cxl_dstate, uint16_t *len) { @@ -496,8 +502,8 @@ static CXLRetCode cmd_media_get_poison_list(struct cxl_= cmd *cmd, } QEMU_PACKED records[]; } QEMU_PACKED; =20 - struct get_poison_list_pl *in =3D (void *)cmd->payload; - struct get_poison_list_out_pl *out =3D (void *)cmd->payload; + struct get_poison_list_pl *in =3D (void *)payload; + struct get_poison_list_out_pl *out =3D (void *)payload; CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); uint16_t record_count =3D 0, i =3D 0; uint64_t query_start, query_length; @@ -550,7 +556,8 @@ static CXLRetCode cmd_media_get_poison_list(struct cxl_= cmd *cmd, return CXL_MBOX_SUCCESS; } =20 -static CXLRetCode cmd_media_inject_poison(struct cxl_cmd *cmd, +static CXLRetCode cmd_media_inject_poison(const struct cxl_cmd *cmd, + uint8_t *payload, CXLDeviceState *cxl_dstate, uint16_t *len_unused) { @@ -560,7 +567,7 @@ static CXLRetCode cmd_media_inject_poison(struct cxl_cm= d *cmd, struct inject_poison_pl { uint64_t dpa; }; - struct inject_poison_pl *in =3D (void *)cmd->payload; + struct inject_poison_pl *in =3D (void *)payload; uint64_t dpa =3D ldq_le_p(&in->dpa); CXLPoison *p; =20 @@ -589,7 +596,8 @@ static CXLRetCode cmd_media_inject_poison(struct cxl_cm= d *cmd, return CXL_MBOX_SUCCESS; } =20 -static CXLRetCode cmd_media_clear_poison(struct cxl_cmd *cmd, +static CXLRetCode cmd_media_clear_poison(const struct cxl_cmd *cmd, + uint8_t *payload, CXLDeviceState *cxl_dstate, uint16_t *len_unused) { @@ -603,7 +611,7 @@ static CXLRetCode cmd_media_clear_poison(struct cxl_cmd= *cmd, CXLPoison *ent; uint64_t dpa; =20 - struct clear_poison_pl *in =3D (void *)cmd->payload; + struct clear_poison_pl *in =3D (void *)payload; =20 dpa =3D ldq_le_p(&in->dpa); if (dpa + CXL_CACHE_LINE_SIZE > cxl_dstate->mem_size) { @@ -673,7 +681,7 @@ static CXLRetCode cmd_media_clear_poison(struct cxl_cmd= *cmd, #define IMMEDIATE_POLICY_CHANGE (1 << 3) #define IMMEDIATE_LOG_CHANGE (1 << 4) =20 -static struct cxl_cmd cxl_cmd_set[256][256] =3D { +static const struct cxl_cmd cxl_cmd_set[256][256] =3D { [EVENTS][GET_RECORDS] =3D { "EVENTS_GET_RECORDS", cmd_events_get_records, 1, 0 }, [EVENTS][CLEAR_RECORDS] =3D { "EVENTS_CLEAR_RECORDS", @@ -709,21 +717,21 @@ static struct cxl_cmd cxl_cmd_set[256][256] =3D { void cxl_process_mailbox(CXLDeviceState *cxl_dstate) { uint16_t ret =3D CXL_MBOX_SUCCESS; - struct cxl_cmd *cxl_cmd; - uint64_t status_reg; + const struct cxl_cmd *cxl_cmd; + uint64_t status_reg =3D 0; opcode_handler h; uint64_t command_reg =3D cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBO= X_CMD]; =20 uint8_t set =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND_S= ET); uint8_t cmd =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND); uint16_t len =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, LENGTH); - cxl_cmd =3D &cxl_cmd_set[set][cmd]; + uint8_t *pl =3D cxl_dstate->mbox_reg_state + A_CXL_DEV_CMD_PAYLOAD; + + cxl_cmd =3D &cxl_dstate->cxl_cmd_set[set][cmd]; h =3D cxl_cmd->handler; if (h) { if (len =3D=3D cxl_cmd->in || cxl_cmd->in =3D=3D ~0) { - cxl_cmd->payload =3D cxl_dstate->mbox_reg_state + - A_CXL_DEV_CMD_PAYLOAD; - ret =3D (*h)(cxl_cmd, cxl_dstate, &len); + ret =3D (*h)(cxl_cmd, pl, cxl_dstate, &len); assert(len <=3D cxl_dstate->payload_size); } else { ret =3D CXL_MBOX_INVALID_PAYLOAD_LENGTH; @@ -752,10 +760,11 @@ void cxl_process_mailbox(CXLDeviceState *cxl_dstate) =20 void cxl_initialize_mailbox(CXLDeviceState *cxl_dstate) { + cxl_dstate->cxl_cmd_set =3D cxl_cmd_set; for (int set =3D 0; set < 256; set++) { for (int cmd =3D 0; cmd < 256; cmd++) { - if (cxl_cmd_set[set][cmd].handler) { - struct cxl_cmd *c =3D &cxl_cmd_set[set][cmd]; + if (cxl_dstate->cxl_cmd_set[set][cmd].handler) { + const struct cxl_cmd *c =3D &cxl_dstate->cxl_cmd_set[set][= cmd]; struct cel_log *log =3D &cxl_dstate->cel_log[cxl_dstate->cel_size]; =20 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352454; cv=none; d=zohomail.com; s=zohoarc; b=Ynv9KPzT/cZ9+4KpsFaO3lpnZfR9ILoVsa77Mdg9nv+wxY7eENI4YJClUkQld2MwSB5Re2AvT1lngF6rTK0pgJh48kpYd0WZpGoCVorhx/x8H7iOn/Uz/Rilxyg+Tx6m9W1/bhqZnIfYp7R1FQJk8kamgkIIicw5DB/fsIjY6JE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352454; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qCQ8Bc7r1ZWmECZIkoA9QDb2hwxsOcaeJUpPPLoe0pY=; b=W/IdIBVl0fDYATuh9J310JgNwmFrnageOyJYYMyw1bUEpdfLg4G8UCLS815xmDhep/9785rn3y3Wkk6XILlm3GEVKCxa06zIWtrxDo4OEdUkzqT4FELrztPuCmMfzJa0YGBqnCeG9ulg9WK3JhVaX2f1YQJmlbw54X1w8GYu1Ug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352454826300.07108092454985; Tue, 7 Nov 2023 02:20:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J55-0003hG-KT; Tue, 07 Nov 2023 05:13:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J53-0003h0-Ut for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J51-0002sT-1G for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:09 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-m5JOuqlNPf-SiT2XQ1mjng-1; Tue, 07 Nov 2023 05:12:59 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4090181eec2so35037135e9.1 for ; Tue, 07 Nov 2023 02:12:58 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id du15-20020a05600c634f00b00405959bbf4fsm14724926wmb.19.2023.11.07.02.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:12:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351986; h=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=qCQ8Bc7r1ZWmECZIkoA9QDb2hwxsOcaeJUpPPLoe0pY=; b=Y65mC0u9jrhh6YtLL5Gi6m+06GZGmA+LmM+FFgBG+fvpdS7xizcHGcC9jRqoS4LoZwU2zG Zd4EU3jG2ReLBqpoiXhiG1FClzecc5ZcwDrggoH+fYh1Xby/H1TfXFjutO61XnLfQbLLR9 wgNP1PymSAXGw6CSRza2UPjv0fccJKc= X-MC-Unique: m5JOuqlNPf-SiT2XQ1mjng-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351977; x=1699956777; 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=qCQ8Bc7r1ZWmECZIkoA9QDb2hwxsOcaeJUpPPLoe0pY=; b=ZTdepqaYTgIeHJ02l7HrxTzU4ljtO5/lNob8euRBVPbKU8wSw2fC0Ah1qf9QbKEy1j +3B2GBlw8z3epmRzaOwaZLQlisWQL7SHBPHfBF9Xbdtf2d20Pz0EbrjlFnJ8Q+xrOwQ6 N+cDB7VZTZRhyXnz0KBXNUnISxXvNHNLKm9w5wkd1JwTAjHsy2sPLl6gubOKezntTks7 t0qTYJ4t9+3eenA37oSLSmFfodmgOMf0bd8TLLtb6vSfnphB49vRagxb+de4ogMxRD0V QJZT3if3X+Lb6ylSYdFXfFVHFawa5cHdIDS39+D4Lzu2jlj95O62/xYuUh6wizfmcspu wsgw== X-Gm-Message-State: AOJu0YzHJAwoeWW+2e6YYx0UKX/+2qY6ER3t+coOLjyjrvMZC1SsXDDY 3PzADLFEtyf4JkuQNAA/nAqWgIQkhpP6nvyJUjTkLvpVhXLeBqBHfnYH8/XZRp86uMcq1P3xSH0 SVui40V5KMLltvLHuNP4gl97gqp3JliCPSpIsgtSOFP2DCa1mwnbFsitMahDyM5EsdDQq X-Received: by 2002:a05:600c:46c6:b0:406:5308:cfeb with SMTP id q6-20020a05600c46c600b004065308cfebmr2188037wmo.11.1699351976921; Tue, 07 Nov 2023 02:12:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGof15HDQVZK8pT+o7VUeVBUI8ssewlE1lCEIj3ahjTNiBkd3tsdoojQg2vaqJ3OMcQUWYlUw== X-Received: by 2002:a05:600c:46c6:b0:406:5308:cfeb with SMTP id q6-20020a05600c46c600b004065308cfebmr2188019wmo.11.1699351976564; Tue, 07 Nov 2023 02:12:56 -0800 (PST) Date: Tue, 7 Nov 2023 05:12:52 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 46/63] hw/cxl/mbox: Split mailbox command payload into separate input and output Message-ID: <6f59274e937576fbb2623b687aa2556e115a712f.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352455748100008 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron New CCI types that will be supported shortly do not have a single buffer used in both directions. As such, split it up. To avoid the complexities of implementing all commands to handle potential aliasing, take a copy of the input before use. Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-3-Jonathan.Cameron@huawei.com> Reviewed-by: Fan Ni Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 7 +- hw/cxl/cxl-events.c | 2 +- hw/cxl/cxl-mailbox-utils.c | 230 +++++++++++++++++++++--------------- 3 files changed, 140 insertions(+), 99 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 556953469c..d7a2c4009e 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -114,8 +114,9 @@ typedef enum { typedef struct cxl_device_state CXLDeviceState; struct cxl_cmd; typedef CXLRetCode (*opcode_handler)(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, uint16_t = *len); + uint8_t *payload_in, size_t len_in, + uint8_t *payload_out, size_t *len_out, + CXLDeviceState *cxl_dstate); struct cxl_cmd { const char *name; opcode_handler handler; @@ -390,7 +391,7 @@ bool cxl_event_insert(CXLDeviceState *cxlds, CXLEventLo= gType log_type, CXLEventRecordRaw *event); CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds, CXLGetEventPayload= *pl, uint8_t log_type, int max_recs, - uint16_t *len); + size_t *len); CXLRetCode cxl_event_clear_records(CXLDeviceState *cxlds, CXLClearEventPayload *pl); =20 diff --git a/hw/cxl/cxl-events.c b/hw/cxl/cxl-events.c index e2172b94b9..bee6dfaf14 100644 --- a/hw/cxl/cxl-events.c +++ b/hw/cxl/cxl-events.c @@ -143,7 +143,7 @@ bool cxl_event_insert(CXLDeviceState *cxlds, CXLEventLo= gType log_type, =20 CXLRetCode cxl_event_get_records(CXLDeviceState *cxlds, CXLGetEventPayload= *pl, uint8_t log_type, int max_recs, - uint16_t *len) + size_t *len) { CXLEventLog *log; CXLEvent *entry; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index c02de06943..e5ddce37c7 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -71,9 +71,9 @@ enum { =20 =20 static CXLRetCode cmd_events_get_records(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxlds, - uint16_t *len) + uint8_t *payload_in, size_t len_i= n, + uint8_t *payload_out, size_t *len= _out, + CXLDeviceState *cxlds) { CXLGetEventPayload *pl; uint8_t log_type; @@ -83,9 +83,9 @@ static CXLRetCode cmd_events_get_records(const struct cxl= _cmd *cmd, return CXL_MBOX_INVALID_INPUT; } =20 - log_type =3D payload[0]; + log_type =3D payload_in[0]; =20 - pl =3D (CXLGetEventPayload *)payload; + pl =3D (CXLGetEventPayload *)payload_out; memset(pl, 0, sizeof(*pl)); =20 max_recs =3D (cxlds->payload_size - CXL_EVENT_PAYLOAD_HDR_SIZE) / @@ -94,30 +94,34 @@ static CXLRetCode cmd_events_get_records(const struct c= xl_cmd *cmd, max_recs =3D 0xFFFF; } =20 - return cxl_event_get_records(cxlds, pl, log_type, max_recs, len); + return cxl_event_get_records(cxlds, pl, log_type, max_recs, len_out); } =20 static CXLRetCode cmd_events_clear_records(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxlds, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxlds) { CXLClearEventPayload *pl; =20 - pl =3D (CXLClearEventPayload *)payload; - *len =3D 0; + pl =3D (CXLClearEventPayload *)payload_in; + *len_out =3D 0; return cxl_event_clear_records(cxlds, pl); } =20 static CXLRetCode cmd_events_get_interrupt_policy(const struct cxl_cmd *cm= d, - uint8_t *payload, - CXLDeviceState *cxlds, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxlds) { CXLEventInterruptPolicy *policy; CXLEventLog *log; =20 - policy =3D (CXLEventInterruptPolicy *)payload; + policy =3D (CXLEventInterruptPolicy *)payload_out; memset(policy, 0, sizeof(*policy)); =20 log =3D &cxlds->event_logs[CXL_EVENT_TYPE_INFO]; @@ -146,23 +150,25 @@ static CXLRetCode cmd_events_get_interrupt_policy(con= st struct cxl_cmd *cmd, policy->dyn_cap_settings =3D CXL_INT_MSI_MSIX; } =20 - *len =3D sizeof(*policy); + *len_out =3D sizeof(*policy); return CXL_MBOX_SUCCESS; } =20 static CXLRetCode cmd_events_set_interrupt_policy(const struct cxl_cmd *cm= d, - uint8_t *payload, - CXLDeviceState *cxlds, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxlds) { CXLEventInterruptPolicy *policy; CXLEventLog *log; =20 - if (*len < CXL_EVENT_INT_SETTING_MIN_LEN) { + if (len_in < CXL_EVENT_INT_SETTING_MIN_LEN) { return CXL_MBOX_INVALID_PAYLOAD_LENGTH; } =20 - policy =3D (CXLEventInterruptPolicy *)payload; + policy =3D (CXLEventInterruptPolicy *)payload_in; =20 log =3D &cxlds->event_logs[CXL_EVENT_TYPE_INFO]; log->irq_enabled =3D (policy->info_settings & CXL_EVENT_INT_MODE_MASK)= =3D=3D @@ -181,7 +187,7 @@ static CXLRetCode cmd_events_set_interrupt_policy(const= struct cxl_cmd *cmd, CXL_INT_MSI_MSIX; =20 /* DCD is optional */ - if (*len < sizeof(*policy)) { + if (len_in < sizeof(*policy)) { return CXL_MBOX_SUCCESS; } =20 @@ -189,15 +195,17 @@ static CXLRetCode cmd_events_set_interrupt_policy(con= st struct cxl_cmd *cmd, log->irq_enabled =3D (policy->dyn_cap_settings & CXL_EVENT_INT_MODE_MA= SK) =3D=3D CXL_INT_MSI_MSIX; =20 - *len =3D sizeof(*policy); + *len_out =3D 0; return CXL_MBOX_SUCCESS; } =20 /* 8.2.9.2.1 */ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct { uint8_t slots_supported; @@ -216,7 +224,7 @@ static CXLRetCode cmd_firmware_update_get_info(const st= ruct cxl_cmd *cmd, return CXL_MBOX_INTERNAL_ERROR; } =20 - fw_info =3D (void *)payload; + fw_info =3D (void *)payload_out; memset(fw_info, 0, sizeof(*fw_info)); =20 fw_info->slots_supported =3D 2; @@ -224,36 +232,40 @@ static CXLRetCode cmd_firmware_update_get_info(const = struct cxl_cmd *cmd, fw_info->caps =3D 0; pstrcpy(fw_info->fw_rev1, sizeof(fw_info->fw_rev1), "BWFW VERSION 0"); =20 - *len =3D sizeof(*fw_info); + *len_out =3D sizeof(*fw_info); return CXL_MBOX_SUCCESS; } =20 /* 8.2.9.3.1 */ static CXLRetCode cmd_timestamp_get(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { uint64_t final_time =3D cxl_device_get_timestamp(cxl_dstate); =20 - stq_le_p(payload, final_time); - *len =3D 8; + stq_le_p(payload_out, final_time); + *len_out =3D 8; =20 return CXL_MBOX_SUCCESS; } =20 /* 8.2.9.3.2 */ static CXLRetCode cmd_timestamp_set(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { cxl_dstate->timestamp.set =3D true; cxl_dstate->timestamp.last_set =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUA= L); =20 - cxl_dstate->timestamp.host_set =3D le64_to_cpu(*(uint64_t *)payload); + cxl_dstate->timestamp.host_set =3D le64_to_cpu(*(uint64_t *)payload_in= ); =20 - *len =3D 0; + *len_out =3D 0; return CXL_MBOX_SUCCESS; } =20 @@ -265,9 +277,11 @@ static const QemuUUID cel_uuid =3D { =20 /* 8.2.9.4.1 */ static CXLRetCode cmd_logs_get_supported(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct { uint16_t entries; @@ -276,22 +290,24 @@ static CXLRetCode cmd_logs_get_supported(const struct= cxl_cmd *cmd, QemuUUID uuid; uint32_t size; } log_entries[1]; - } QEMU_PACKED *supported_logs =3D (void *)payload; + } QEMU_PACKED *supported_logs =3D (void *)payload_out; QEMU_BUILD_BUG_ON(sizeof(*supported_logs) !=3D 0x1c); =20 supported_logs->entries =3D 1; supported_logs->log_entries[0].uuid =3D cel_uuid; supported_logs->log_entries[0].size =3D 4 * cxl_dstate->cel_size; =20 - *len =3D sizeof(*supported_logs); + *len_out =3D sizeof(*supported_logs); return CXL_MBOX_SUCCESS; } =20 /* 8.2.9.4.2 */ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct { QemuUUID uuid; @@ -299,7 +315,7 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd= *cmd, uint32_t length; } QEMU_PACKED QEMU_ALIGNED(16) *get_log; =20 - get_log =3D (void *)payload; + get_log =3D (void *)payload_in; =20 /* * 8.2.9.4.2 @@ -323,19 +339,21 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_c= md *cmd, } =20 /* Store off everything to local variables so we can wipe out the payl= oad */ - *len =3D get_log->length; + *len_out =3D get_log->length; =20 - memmove(payload, cxl_dstate->cel_log + get_log->offset, - get_log->length); + memmove(payload_out, cxl_dstate->cel_log + get_log->offset, + get_log->length); =20 return CXL_MBOX_SUCCESS; } =20 /* 8.2.9.5.1.1 */ static CXLRetCode cmd_identify_memory_device(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct { char fw_revision[0x10]; @@ -363,7 +381,7 @@ static CXLRetCode cmd_identify_memory_device(const stru= ct cxl_cmd *cmd, return CXL_MBOX_INTERNAL_ERROR; } =20 - id =3D (void *)payload; + id =3D (void *)payload_out; memset(id, 0, sizeof(*id)); =20 snprintf(id->fw_revision, 0x10, "BWFW VERSION %02d", 0); @@ -380,21 +398,23 @@ static CXLRetCode cmd_identify_memory_device(const st= ruct cxl_cmd *cmd, /* No limit - so limited by main poison record limit */ stw_le_p(&id->inject_poison_limit, 0); =20 - *len =3D sizeof(*id); + *len_out =3D sizeof(*id); return CXL_MBOX_SUCCESS; } =20 static CXLRetCode cmd_ccls_get_partition_info(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct { uint64_t active_vmem; uint64_t active_pmem; uint64_t next_vmem; uint64_t next_pmem; - } QEMU_PACKED *part_info =3D (void *)payload; + } QEMU_PACKED *part_info =3D (void *)payload_out; QEMU_BUILD_BUG_ON(sizeof(*part_info) !=3D 0x20); =20 if ((!QEMU_IS_ALIGNED(cxl_dstate->vmem_size, CXL_CAPACITY_MULTIPLIER))= || @@ -413,14 +433,16 @@ static CXLRetCode cmd_ccls_get_partition_info(const s= truct cxl_cmd *cmd, cxl_dstate->pmem_size / CXL_CAPACITY_MULTIPLIER); stq_le_p(&part_info->next_pmem, 0); =20 - *len =3D sizeof(*part_info); + *len_out =3D sizeof(*part_info); return CXL_MBOX_SUCCESS; } =20 static CXLRetCode cmd_ccls_get_lsa(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct { uint32_t offset; @@ -430,46 +452,47 @@ static CXLRetCode cmd_ccls_get_lsa(const struct cxl_c= md *cmd, CXLType3Class *cvc =3D CXL_TYPE3_GET_CLASS(ct3d); uint32_t offset, length; =20 - get_lsa =3D (void *)payload; + get_lsa =3D (void *)payload_in; offset =3D get_lsa->offset; length =3D get_lsa->length; =20 if (offset + length > cvc->get_lsa_size(ct3d)) { - *len =3D 0; + *len_out =3D 0; return CXL_MBOX_INVALID_INPUT; } =20 - *len =3D cvc->get_lsa(ct3d, get_lsa, length, offset); + *len_out =3D cvc->get_lsa(ct3d, payload_out, length, offset); return CXL_MBOX_SUCCESS; } =20 static CXLRetCode cmd_ccls_set_lsa(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct set_lsa_pl { uint32_t offset; uint32_t rsvd; uint8_t data[]; } QEMU_PACKED; - struct set_lsa_pl *set_lsa_payload =3D (void *)payload; + struct set_lsa_pl *set_lsa_payload =3D (void *)payload_in; CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); CXLType3Class *cvc =3D CXL_TYPE3_GET_CLASS(ct3d); const size_t hdr_len =3D offsetof(struct set_lsa_pl, data); - uint16_t plen =3D *len; =20 - *len =3D 0; - if (!plen) { + *len_out =3D 0; + if (!len_in) { return CXL_MBOX_SUCCESS; } =20 - if (set_lsa_payload->offset + plen > cvc->get_lsa_size(ct3d) + hdr_len= ) { + if (set_lsa_payload->offset + len_in > cvc->get_lsa_size(ct3d) + hdr_l= en) { return CXL_MBOX_INVALID_INPUT; } - plen -=3D hdr_len; + len_in -=3D hdr_len; =20 - cvc->set_lsa(ct3d, set_lsa_payload->data, plen, set_lsa_payload->offse= t); + cvc->set_lsa(ct3d, set_lsa_payload->data, len_in, set_lsa_payload->off= set); return CXL_MBOX_SUCCESS; } =20 @@ -480,9 +503,11 @@ static CXLRetCode cmd_ccls_set_lsa(const struct cxl_cm= d *cmd, * testing that kernel functionality. */ static CXLRetCode cmd_media_get_poison_list(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { struct get_poison_list_pl { uint64_t pa; @@ -502,8 +527,8 @@ static CXLRetCode cmd_media_get_poison_list(const struc= t cxl_cmd *cmd, } QEMU_PACKED records[]; } QEMU_PACKED; =20 - struct get_poison_list_pl *in =3D (void *)payload; - struct get_poison_list_out_pl *out =3D (void *)payload; + struct get_poison_list_pl *in =3D (void *)payload_in; + struct get_poison_list_out_pl *out =3D (void *)payload_out; CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); uint16_t record_count =3D 0, i =3D 0; uint64_t query_start, query_length; @@ -552,14 +577,16 @@ static CXLRetCode cmd_media_get_poison_list(const str= uct cxl_cmd *cmd, stq_le_p(&out->overflow_timestamp, ct3d->poison_list_overflow_ts); } stw_le_p(&out->count, record_count); - *len =3D out_pl_len; + *len_out =3D out_pl_len; return CXL_MBOX_SUCCESS; } =20 static CXLRetCode cmd_media_inject_poison(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len_unused) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); CXLPoisonList *poison_list =3D &ct3d->poison_list; @@ -567,7 +594,7 @@ static CXLRetCode cmd_media_inject_poison(const struct = cxl_cmd *cmd, struct inject_poison_pl { uint64_t dpa; }; - struct inject_poison_pl *in =3D (void *)payload; + struct inject_poison_pl *in =3D (void *)payload_in; uint64_t dpa =3D ldq_le_p(&in->dpa); CXLPoison *p; =20 @@ -592,14 +619,17 @@ static CXLRetCode cmd_media_inject_poison(const struc= t cxl_cmd *cmd, */ QLIST_INSERT_HEAD(poison_list, p, node); ct3d->poison_list_cnt++; + *len_out =3D 0; =20 return CXL_MBOX_SUCCESS; } =20 static CXLRetCode cmd_media_clear_poison(const struct cxl_cmd *cmd, - uint8_t *payload, - CXLDeviceState *cxl_dstate, - uint16_t *len_unused) + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLDeviceState *cxl_dstate) { CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); CXLPoisonList *poison_list =3D &ct3d->poison_list; @@ -611,7 +641,7 @@ static CXLRetCode cmd_media_clear_poison(const struct c= xl_cmd *cmd, CXLPoison *ent; uint64_t dpa; =20 - struct clear_poison_pl *in =3D (void *)payload; + struct clear_poison_pl *in =3D (void *)payload_in; =20 dpa =3D ldq_le_p(&in->dpa); if (dpa + CXL_CACHE_LINE_SIZE > cxl_dstate->mem_size) { @@ -672,6 +702,7 @@ static CXLRetCode cmd_media_clear_poison(const struct c= xl_cmd *cmd, } /* Any fragments have been added, free original entry */ g_free(ent); + *len_out =3D 0; =20 return CXL_MBOX_SUCCESS; } @@ -724,15 +755,24 @@ void cxl_process_mailbox(CXLDeviceState *cxl_dstate) =20 uint8_t set =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND_S= ET); uint8_t cmd =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND); - uint16_t len =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, LENGTH); + uint16_t len_in =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, LENGT= H); uint8_t *pl =3D cxl_dstate->mbox_reg_state + A_CXL_DEV_CMD_PAYLOAD; + /* + * Copy taken to avoid need for individual command handlers to care + * about aliasing. + */ + g_autofree uint8_t *pl_in_copy =3D NULL; + size_t len_out =3D 0; =20 + pl_in_copy =3D g_memdup2(pl, len_in); + /* Avoid stale data - including from earlier commands */ + memset(pl, 0, CXL_MAILBOX_MAX_PAYLOAD_SIZE); cxl_cmd =3D &cxl_dstate->cxl_cmd_set[set][cmd]; h =3D cxl_cmd->handler; if (h) { - if (len =3D=3D cxl_cmd->in || cxl_cmd->in =3D=3D ~0) { - ret =3D (*h)(cxl_cmd, pl, cxl_dstate, &len); - assert(len <=3D cxl_dstate->payload_size); + if (len_in =3D=3D cxl_cmd->in || cxl_cmd->in =3D=3D ~0) { + ret =3D (*h)(cxl_cmd, pl_in_copy, len_in, pl, &len_out, cxl_ds= tate); + assert(len_out <=3D cxl_dstate->payload_size); } else { ret =3D CXL_MBOX_INVALID_PAYLOAD_LENGTH; } @@ -748,7 +788,7 @@ void cxl_process_mailbox(CXLDeviceState *cxl_dstate) /* Set the return length */ command_reg =3D FIELD_DP64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND_S= ET, 0); command_reg =3D FIELD_DP64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND, = 0); - command_reg =3D FIELD_DP64(command_reg, CXL_DEV_MAILBOX_CMD, LENGTH, l= en); + command_reg =3D FIELD_DP64(command_reg, CXL_DEV_MAILBOX_CMD, LENGTH, l= en_out); =20 cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBOX_CMD] =3D command_reg; cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBOX_STS] =3D status_reg; --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352637; cv=none; d=zohomail.com; s=zohoarc; b=IaEkcPmnA6TkeGOANBb2ynnyi+KnftzhzadFQLtULw+IlG9eVuMhNAfpEmxWXgMGAFYkItgKJkteM0HLJvpFqgGgq0Xmlr4t0K1XAovnYynw04/rbye4O+QsN04o7MW7rqxpO+ie2gtBNWLzCjhBkwzMxBNEqItfXdOsO8IhG/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352637; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZMctnQvJxyFWwWUQRDseACjm1vatUKtn2R/WzxwNdvY=; b=FOrK4i9JlhgOXNvk5cjiVcxmyVu00RXStuDA1VCpYrwTu0kMmcJualruM46jHW0SW46y3FHza723Z6/ra7dDsubhctanu0Gf0fYDPWqJzQ5n5TPkQ2Bpmzl82Eb1p43a82KIBAaf/9RBNiQaNqduGVp+t/soBYbSKsljLO2f0AM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352637459278.4788598704421; Tue, 7 Nov 2023 02:23:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J53-0003gf-8h; Tue, 07 Nov 2023 05:13:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J51-0003gD-JI for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J4z-0002rb-0c for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:07 -0500 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-615-yZGHt1oXP1qr7rVylMQ59g-1; Tue, 07 Nov 2023 05:13:03 -0500 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-542d910f34bso4399769a12.3 for ; Tue, 07 Nov 2023 02:13:02 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id o29-20020a05600c511d00b004083996dad8sm15180262wms.18.2023.11.07.02.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351984; h=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=ZMctnQvJxyFWwWUQRDseACjm1vatUKtn2R/WzxwNdvY=; b=icijlylZlfafVnu4FT3HGK1HUEJEaEAIqs3+2mzsmflLX1AOsb+UmoiUiE5HV/kLRzpk3L SfDxn+ZXIzM8XNO5I5CHYo1XfbKjgggPkohCVDTNbmBZ/nxtB/v5GGakwynw6W6fQFK6IC QjmKs88xk+X8LwVLwqpwCk9otYixiik= X-MC-Unique: yZGHt1oXP1qr7rVylMQ59g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351981; x=1699956781; 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=ZMctnQvJxyFWwWUQRDseACjm1vatUKtn2R/WzxwNdvY=; b=l2U1+2Dh6ZjUWd2wiZe90yYtE2CMuotlV3N/30SlBbTDWnGsJWLyWDC5pu0XDGyvnl G1tfvll9j/P1G9npOq9iih+Rv/mYFRB3neuyG5uL4IBdtvJ8EuC8D46tLVv7zINsuG7X kwLgY/ySMMO30h299btpazQbnZC19N/RIcqwmGk0Jgc89CYL9pFF7w/qjwk16cXdPsxR FNDEE3AouOO1425oceSCGFJJfzYkcNaOpKCJxQT6d4PhgjpBbtJczCAKoNt8oiy64xo1 Lj/GthijpcEfqzaCw34h8RyYUFqLKNzNKbuIt9MLZQu7TSVRY5UQDoX15hM4qkw/e18Q +cPQ== X-Gm-Message-State: AOJu0Yz37bl0s/gXTiUIcLXjYvKyi7d+wjH+UOFJ1Yrv0twHO7iDOmbG reeHdPAgqXnO/OV5tNI+Jjcyd2C0hY8SYkVDeTMC76he/5pYQ+5FwqcoDYoFRS59eoCawz1l4nV oTXm/QrM+5J5hu17H/7fqxwkXspQ+r1+9aDxkYMPNV+JEt1hVMQ2ZzPkRT5qA6tb7GLsd X-Received: by 2002:a17:907:783:b0:9be:fc31:8cd3 with SMTP id xd3-20020a170907078300b009befc318cd3mr15267818ejb.17.1699351981210; Tue, 07 Nov 2023 02:13:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcyutl3M5YapH8pA1heOJ3Q6i4Uws8uz37mneAwtbmtkTvIMZFF0NTueCTJrBCEGa9C/i9Fg== X-Received: by 2002:a17:907:783:b0:9be:fc31:8cd3 with SMTP id xd3-20020a170907078300b009befc318cd3mr15267801ejb.17.1699351980888; Tue, 07 Nov 2023 02:13:00 -0800 (PST) Date: Tue, 7 Nov 2023 05:12:56 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 47/63] hw/cxl/mbox: Pull the CCI definition out of the CXLDeviceState 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352639471100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Enables having multiple CCIs per devices. Each CCI (mailbox) has it's own state and command list, so they can't share a single structure. Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-4-Jonathan.Cameron@huawei.com> Reviewed-by: Fan Ni Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 35 ++++++++++---- hw/cxl/cxl-device-utils.c | 31 +++++++++--- hw/cxl/cxl-mailbox-utils.c | 94 ++++++++++++++++++++++--------------- hw/mem/cxl_type3.c | 5 +- 4 files changed, 109 insertions(+), 56 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index d7a2c4009e..779ca85319 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -111,12 +111,13 @@ typedef enum { CXL_MBOX_MAX =3D 0x17 } CXLRetCode; =20 +typedef struct CXLCCI CXLCCI; typedef struct cxl_device_state CXLDeviceState; struct cxl_cmd; typedef CXLRetCode (*opcode_handler)(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxl_dstate); + CXLCCI *cci); struct cxl_cmd { const char *name; opcode_handler handler; @@ -140,6 +141,21 @@ typedef struct CXLEventLog { QSIMPLEQ_HEAD(, CXLEvent) events; } CXLEventLog; =20 +typedef struct CXLCCI { + const struct cxl_cmd (*cxl_cmd_set)[256]; + struct cel_log { + uint16_t opcode; + uint16_t effect; + } cel_log[1 << 16]; + size_t cel_size; + + size_t payload_max; + /* Pointer to device hosting the CCI */ + DeviceState *d; + /* Pointer to the device hosting the protocol conversion */ + DeviceState *intf; +} CXLCCI; + typedef struct cxl_device_state { MemoryRegion device_registers; =20 @@ -173,11 +189,6 @@ typedef struct cxl_device_state { uint32_t mbox_reg_state32[CXL_MAILBOX_REGISTERS_LENGTH / 4]; uint64_t mbox_reg_state64[CXL_MAILBOX_REGISTERS_LENGTH / 8]; }; - struct cel_log { - uint16_t opcode; - uint16_t effect; - } cel_log[1 << 16]; - size_t cel_size; }; =20 struct { @@ -196,10 +207,12 @@ typedef struct cxl_device_state { } CXLDeviceState; =20 /* Initialize the register block for a device */ -void cxl_device_register_block_init(Object *obj, CXLDeviceState *dev); +void cxl_device_register_block_init(Object *obj, CXLDeviceState *dev, + CXLCCI *cci); =20 +typedef struct CXLType3Dev CXLType3Dev; /* Set up default values for the register block */ -void cxl_device_register_init_common(CXLDeviceState *dev); +void cxl_device_register_init_t3(CXLType3Dev *ct3d); =20 /* * CXL 2.0 - 8.2.8.1 including errata F4 @@ -245,8 +258,9 @@ CXL_DEVICE_CAPABILITY_HEADER_REGISTER(MEMORY_DEVICE, CXL_DEVICE_CAP_HDR1_OFFSET + CXL_DEVICE_CAP_REG_SIZE * 2) =20 -void cxl_initialize_mailbox(CXLDeviceState *cxl_dstate); -void cxl_process_mailbox(CXLDeviceState *cxl_dstate); +void cxl_initialize_mailbox_t3(CXLCCI *cci, DeviceState *d, size_t payload= _max); +void cxl_init_cci(CXLCCI *cci, size_t payload_max); +void cxl_process_mailbox(CXLCCI *cci); =20 #define cxl_device_cap_init(dstate, reg, cap_id, ver) = \ do { = \ @@ -347,6 +361,7 @@ struct CXLType3Dev { AddressSpace hostpmem_as; CXLComponentState cxl_cstate; CXLDeviceState cxl_dstate; + CXLCCI cci; /* Primary PCI mailbox CCI */ =20 /* DOE */ DOECap doe_cdat; diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c index eb7195272e..327949a805 100644 --- a/hw/cxl/cxl-device-utils.c +++ b/hw/cxl/cxl-device-utils.c @@ -62,7 +62,14 @@ static uint64_t dev_reg_read(void *opaque, hwaddr offset= , unsigned size) =20 static uint64_t mailbox_reg_read(void *opaque, hwaddr offset, unsigned siz= e) { - CXLDeviceState *cxl_dstate =3D opaque; + CXLDeviceState *cxl_dstate; + CXLCCI *cci =3D opaque; + + if (object_dynamic_cast(OBJECT(cci->intf), TYPE_CXL_TYPE3)) { + cxl_dstate =3D &CXL_TYPE3(cci->intf)->cxl_dstate; + } else { + return 0; + } =20 switch (size) { case 1: @@ -123,7 +130,14 @@ static void mailbox_mem_writeq(uint64_t *reg_state, hw= addr offset, static void mailbox_reg_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { - CXLDeviceState *cxl_dstate =3D opaque; + CXLDeviceState *cxl_dstate; + CXLCCI *cci =3D opaque; + + if (object_dynamic_cast(OBJECT(cci->intf), TYPE_CXL_TYPE3)) { + cxl_dstate =3D &CXL_TYPE3(cci->intf)->cxl_dstate; + } else { + return; + } =20 if (offset >=3D A_CXL_DEV_CMD_PAYLOAD) { memcpy(cxl_dstate->mbox_reg_state + offset, &value, size); @@ -143,7 +157,7 @@ static void mailbox_reg_write(void *opaque, hwaddr offs= et, uint64_t value, =20 if (ARRAY_FIELD_EX32(cxl_dstate->mbox_reg_state32, CXL_DEV_MAILBOX_CTR= L, DOORBELL)) { - cxl_process_mailbox(cxl_dstate); + cxl_process_mailbox(cci); } } =20 @@ -223,7 +237,8 @@ static const MemoryRegionOps caps_ops =3D { }, }; =20 -void cxl_device_register_block_init(Object *obj, CXLDeviceState *cxl_dstat= e) +void cxl_device_register_block_init(Object *obj, CXLDeviceState *cxl_dstat= e, + CXLCCI *cci) { /* This will be a BAR, so needs to be rounded up to pow2 for PCI spec = */ memory_region_init(&cxl_dstate->device_registers, obj, "device-registe= rs", @@ -233,7 +248,7 @@ void cxl_device_register_block_init(Object *obj, CXLDev= iceState *cxl_dstate) "cap-array", CXL_CAPS_SIZE); memory_region_init_io(&cxl_dstate->device, obj, &dev_ops, cxl_dstate, "device-status", CXL_DEVICE_STATUS_REGISTERS_LEN= GTH); - memory_region_init_io(&cxl_dstate->mailbox, obj, &mailbox_ops, cxl_dst= ate, + memory_region_init_io(&cxl_dstate->mailbox, obj, &mailbox_ops, cci, "mailbox", CXL_MAILBOX_REGISTERS_LENGTH); memory_region_init_io(&cxl_dstate->memory_device, obj, &mdev_ops, cxl_dstate, "memory device caps", @@ -284,8 +299,9 @@ static void mailbox_reg_init_common(CXLDeviceState *cxl= _dstate) =20 static void memdev_reg_init_common(CXLDeviceState *cxl_dstate) { } =20 -void cxl_device_register_init_common(CXLDeviceState *cxl_dstate) +void cxl_device_register_init_t3(CXLType3Dev *ct3d) { + CXLDeviceState *cxl_dstate =3D &ct3d->cxl_dstate; uint64_t *cap_h =3D cxl_dstate->caps_reg_state64; const int cap_count =3D 3; =20 @@ -303,7 +319,8 @@ void cxl_device_register_init_common(CXLDeviceState *cx= l_dstate) cxl_device_cap_init(cxl_dstate, MEMORY_DEVICE, 0x4000, 1); memdev_reg_init_common(cxl_dstate); =20 - cxl_initialize_mailbox(cxl_dstate); + cxl_initialize_mailbox_t3(&ct3d->cci, DEVICE(ct3d), + CXL_MAILBOX_MAX_PAYLOAD_SIZE); } =20 uint64_t cxl_device_get_timestamp(CXLDeviceState *cxl_dstate) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index e5ddce37c7..5484dfbbf1 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -73,8 +73,9 @@ enum { static CXLRetCode cmd_events_get_records(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_i= n, uint8_t *payload_out, size_t *len= _out, - CXLDeviceState *cxlds) + CXLCCI *cci) { + CXLDeviceState *cxlds =3D &CXL_TYPE3(cci->d)->cxl_dstate; CXLGetEventPayload *pl; uint8_t log_type; int max_recs; @@ -102,8 +103,9 @@ static CXLRetCode cmd_events_clear_records(const struct= cxl_cmd *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxlds) + CXLCCI *cci) { + CXLDeviceState *cxlds =3D &CXL_TYPE3(cci->d)->cxl_dstate; CXLClearEventPayload *pl; =20 pl =3D (CXLClearEventPayload *)payload_in; @@ -116,8 +118,9 @@ static CXLRetCode cmd_events_get_interrupt_policy(const= struct cxl_cmd *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxlds) + CXLCCI *cci) { + CXLDeviceState *cxlds =3D &CXL_TYPE3(cci->d)->cxl_dstate; CXLEventInterruptPolicy *policy; CXLEventLog *log; =20 @@ -159,8 +162,9 @@ static CXLRetCode cmd_events_set_interrupt_policy(const= struct cxl_cmd *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxlds) + CXLCCI *cci) { + CXLDeviceState *cxlds =3D &CXL_TYPE3(cci->d)->cxl_dstate; CXLEventInterruptPolicy *policy; CXLEventLog *log; =20 @@ -205,8 +209,9 @@ static CXLRetCode cmd_firmware_update_get_info(const st= ruct cxl_cmd *cmd, size_t len, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxl_dstate) + CXLCCI *cci) { + CXLDeviceState *cxl_dstate =3D &CXL_TYPE3(cci->d)->cxl_dstate; struct { uint8_t slots_supported; uint8_t slot_info; @@ -242,8 +247,9 @@ static CXLRetCode cmd_timestamp_get(const struct cxl_cm= d *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxl_dstate) + CXLCCI *cci) { + CXLDeviceState *cxl_dstate =3D &CXL_TYPE3(cci->d)->cxl_dstate; uint64_t final_time =3D cxl_device_get_timestamp(cxl_dstate); =20 stq_le_p(payload_out, final_time); @@ -258,8 +264,10 @@ static CXLRetCode cmd_timestamp_set(const struct cxl_c= md *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxl_dstate) + CXLCCI *cci) { + CXLDeviceState *cxl_dstate =3D &CXL_TYPE3(cci->d)->cxl_dstate; + cxl_dstate->timestamp.set =3D true; cxl_dstate->timestamp.last_set =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUA= L); =20 @@ -281,7 +289,7 @@ static CXLRetCode cmd_logs_get_supported(const struct c= xl_cmd *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxl_dstate) + CXLCCI *cci) { struct { uint16_t entries; @@ -295,7 +303,7 @@ static CXLRetCode cmd_logs_get_supported(const struct c= xl_cmd *cmd, =20 supported_logs->entries =3D 1; supported_logs->log_entries[0].uuid =3D cel_uuid; - supported_logs->log_entries[0].size =3D 4 * cxl_dstate->cel_size; + supported_logs->log_entries[0].size =3D 4 * cci->cel_size; =20 *len_out =3D sizeof(*supported_logs); return CXL_MBOX_SUCCESS; @@ -307,7 +315,7 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd= *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxl_dstate) + CXLCCI *cci) { struct { QemuUUID uuid; @@ -330,7 +338,7 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd= *cmd, * the only possible failure would be if the mailbox itself isn't big * enough. */ - if (get_log->offset + get_log->length > cxl_dstate->payload_size) { + if (get_log->offset + get_log->length > cci->payload_max) { return CXL_MBOX_INVALID_INPUT; } =20 @@ -341,8 +349,7 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd= *cmd, /* Store off everything to local variables so we can wipe out the payl= oad */ *len_out =3D get_log->length; =20 - memmove(payload_out, cxl_dstate->cel_log + get_log->offset, - get_log->length); + memmove(payload_out, cci->cel_log + get_log->offset, get_log->length); =20 return CXL_MBOX_SUCCESS; } @@ -353,7 +360,7 @@ static CXLRetCode cmd_identify_memory_device(const stru= ct cxl_cmd *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxl_dstate) + CXLCCI *cci) { struct { char fw_revision[0x10]; @@ -372,9 +379,9 @@ static CXLRetCode cmd_identify_memory_device(const stru= ct cxl_cmd *cmd, uint8_t qos_telemetry_caps; } QEMU_PACKED *id; QEMU_BUILD_BUG_ON(sizeof(*id) !=3D 0x43); - - CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); CXLType3Class *cvc =3D CXL_TYPE3_GET_CLASS(ct3d); + CXLDeviceState *cxl_dstate =3D &ct3d->cxl_dstate; =20 if ((!QEMU_IS_ALIGNED(cxl_dstate->vmem_size, CXL_CAPACITY_MULTIPLIER))= || (!QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER))= ) { @@ -407,8 +414,9 @@ static CXLRetCode cmd_ccls_get_partition_info(const str= uct cxl_cmd *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxl_dstate) + CXLCCI *cci) { + CXLDeviceState *cxl_dstate =3D &CXL_TYPE3(cci->d)->cxl_dstate; struct { uint64_t active_vmem; uint64_t active_pmem; @@ -442,13 +450,13 @@ static CXLRetCode cmd_ccls_get_lsa(const struct cxl_c= md *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxl_dstate) + CXLCCI *cci) { struct { uint32_t offset; uint32_t length; } QEMU_PACKED *get_lsa; - CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); CXLType3Class *cvc =3D CXL_TYPE3_GET_CLASS(ct3d); uint32_t offset, length; =20 @@ -470,7 +478,7 @@ static CXLRetCode cmd_ccls_set_lsa(const struct cxl_cmd= *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxl_dstate) + CXLCCI *cci) { struct set_lsa_pl { uint32_t offset; @@ -478,7 +486,7 @@ static CXLRetCode cmd_ccls_set_lsa(const struct cxl_cmd= *cmd, uint8_t data[]; } QEMU_PACKED; struct set_lsa_pl *set_lsa_payload =3D (void *)payload_in; - CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); CXLType3Class *cvc =3D CXL_TYPE3_GET_CLASS(ct3d); const size_t hdr_len =3D offsetof(struct set_lsa_pl, data); =20 @@ -507,7 +515,7 @@ static CXLRetCode cmd_media_get_poison_list(const struc= t cxl_cmd *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxl_dstate) + CXLCCI *cci) { struct get_poison_list_pl { uint64_t pa; @@ -529,7 +537,7 @@ static CXLRetCode cmd_media_get_poison_list(const struc= t cxl_cmd *cmd, =20 struct get_poison_list_pl *in =3D (void *)payload_in; struct get_poison_list_out_pl *out =3D (void *)payload_out; - CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); uint16_t record_count =3D 0, i =3D 0; uint64_t query_start, query_length; CXLPoisonList *poison_list =3D &ct3d->poison_list; @@ -586,9 +594,9 @@ static CXLRetCode cmd_media_inject_poison(const struct = cxl_cmd *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxl_dstate) + CXLCCI *cci) { - CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); CXLPoisonList *poison_list =3D &ct3d->poison_list; CXLPoison *ent; struct inject_poison_pl { @@ -629,9 +637,10 @@ static CXLRetCode cmd_media_clear_poison(const struct = cxl_cmd *cmd, size_t len_in, uint8_t *payload_out, size_t *len_out, - CXLDeviceState *cxl_dstate) + CXLCCI *cci) { - CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + CXLDeviceState *cxl_dstate =3D &ct3d->cxl_dstate; CXLPoisonList *poison_list =3D &ct3d->poison_list; CXLType3Class *cvc =3D CXL_TYPE3_GET_CLASS(ct3d); struct clear_poison_pl { @@ -745,12 +754,13 @@ static const struct cxl_cmd cxl_cmd_set[256][256] =3D= { cmd_media_clear_poison, 72, 0 }, }; =20 -void cxl_process_mailbox(CXLDeviceState *cxl_dstate) +void cxl_process_mailbox(CXLCCI *cci) { uint16_t ret =3D CXL_MBOX_SUCCESS; const struct cxl_cmd *cxl_cmd; uint64_t status_reg =3D 0; opcode_handler h; + CXLDeviceState *cxl_dstate =3D &CXL_TYPE3(cci->d)->cxl_dstate; uint64_t command_reg =3D cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBO= X_CMD]; =20 uint8_t set =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND_S= ET); @@ -767,12 +777,12 @@ void cxl_process_mailbox(CXLDeviceState *cxl_dstate) pl_in_copy =3D g_memdup2(pl, len_in); /* Avoid stale data - including from earlier commands */ memset(pl, 0, CXL_MAILBOX_MAX_PAYLOAD_SIZE); - cxl_cmd =3D &cxl_dstate->cxl_cmd_set[set][cmd]; + cxl_cmd =3D &cci->cxl_cmd_set[set][cmd]; h =3D cxl_cmd->handler; if (h) { if (len_in =3D=3D cxl_cmd->in || cxl_cmd->in =3D=3D ~0) { - ret =3D (*h)(cxl_cmd, pl_in_copy, len_in, pl, &len_out, cxl_ds= tate); - assert(len_out <=3D cxl_dstate->payload_size); + ret =3D (*h)(cxl_cmd, pl, len_in, pl, &len_out, cci); + assert(len_out <=3D cci->payload_max); } else { ret =3D CXL_MBOX_INVALID_PAYLOAD_LENGTH; } @@ -798,20 +808,30 @@ void cxl_process_mailbox(CXLDeviceState *cxl_dstate) DOORBELL, 0); } =20 -void cxl_initialize_mailbox(CXLDeviceState *cxl_dstate) +void cxl_init_cci(CXLCCI *cci, size_t payload_max) { - cxl_dstate->cxl_cmd_set =3D cxl_cmd_set; + cci->payload_max =3D payload_max; for (int set =3D 0; set < 256; set++) { for (int cmd =3D 0; cmd < 256; cmd++) { - if (cxl_dstate->cxl_cmd_set[set][cmd].handler) { - const struct cxl_cmd *c =3D &cxl_dstate->cxl_cmd_set[set][= cmd]; + if (cci->cxl_cmd_set[set][cmd].handler) { + const struct cxl_cmd *c =3D &cci->cxl_cmd_set[set][cmd]; struct cel_log *log =3D - &cxl_dstate->cel_log[cxl_dstate->cel_size]; + &cci->cel_log[cci->cel_size]; =20 log->opcode =3D (set << 8) | cmd; log->effect =3D c->effect; - cxl_dstate->cel_size++; + cci->cel_size++; } } } } + +void cxl_initialize_mailbox_t3(CXLCCI *cci, DeviceState *d, size_t payload= _max) +{ + cci->cxl_cmd_set =3D cxl_cmd_set; + cci->d =3D d; + + /* No separation for PCI MB as protocol handled in PCI device */ + cci->intf =3D d; + cxl_init_cci(cci, payload_max); +} diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 18ad853f5b..0529745786 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -716,7 +716,8 @@ static void ct3_realize(PCIDevice *pci_dev, Error **err= p) pci_dev, CXL_COMPONENT_REG_BAR_IDX, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, mr); =20 - cxl_device_register_block_init(OBJECT(pci_dev), &ct3d->cxl_dstate); + cxl_device_register_block_init(OBJECT(pci_dev), &ct3d->cxl_dstate, + &ct3d->cci); pci_register_bar(pci_dev, CXL_DEVICE_REG_BAR_IDX, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, @@ -922,7 +923,7 @@ static void ct3d_reset(DeviceState *dev) uint32_t *write_msk =3D ct3d->cxl_cstate.crb.cache_mem_regs_write_mask; =20 cxl_component_register_init_common(reg_state, write_msk, CXL2_TYPE3_DE= VICE); - cxl_device_register_init_common(&ct3d->cxl_dstate); + cxl_device_register_init_t3(ct3d); } =20 static Property ct3_props[] =3D { --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352578; cv=none; d=zohomail.com; s=zohoarc; b=aFu+bOkpPPY0e6HDhMUrIRCDEXPDaiit4p3bgobQBDDghubmSjcHpGDd+s1ubGdMzGO1Bf8OwbLWm8AM61SlhiPnHn/4rcR1o7i+at3NYAbPVani4LpfmDvx1EeYn6Xa88ow+dG35tZWw7jLfDsQJfR66sGiV3ZXMghbCsE3Z/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352578; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rHJ2D9xDQ+Tz1Walx9bxOs4xv1lSe9aYQe31wj9f+X4=; b=N8MsXOMsUsyUi/MvpLGWA1//nyZphualdquwi81gXKPnb1GQXpjQa/w9/wsmail2VoCpyOyl3rximi/bqw9Rx3M+EC4yVqLHQLY8TM9M2nCJ38gAaRasj8nb60UeIbM40E1j12RIpyG0g/dW47aFiqSw2C1U6anOQin1dxsDSqI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352577991144.50284782707865; Tue, 7 Nov 2023 02:22:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J5H-0003v4-27; Tue, 07 Nov 2023 05:13:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5F-0003jD-7R for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5D-0002vE-Ee for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:20 -0500 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-378-dqkCUYrNOLudS2RohifygA-1; Tue, 07 Nov 2023 05:13:07 -0500 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-507cee14477so6345442e87.3 for ; Tue, 07 Nov 2023 02:13:07 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id j19-20020a05600c191300b004090ca6d785sm15305739wmq.2.2023.11.07.02.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351999; h=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=rHJ2D9xDQ+Tz1Walx9bxOs4xv1lSe9aYQe31wj9f+X4=; b=EX/Yay4A6kAkvjkdB+JL1weLalM0j7l37ytw99yy2XexzvxwHa9rFyyjJIUX1bCu1jeiWv wINqgygORssrPiFApDUqAUGTdOojKQuTFGLcZ9cAFByOjM9MBWExHJsnKDYQFt+jFh1X8g MXyeYRXr9hkvOQPb61MBkI+9AbGEf24= X-MC-Unique: dqkCUYrNOLudS2RohifygA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351985; x=1699956785; 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=rHJ2D9xDQ+Tz1Walx9bxOs4xv1lSe9aYQe31wj9f+X4=; b=vank7+KDMel6uQsDTCiVCUV6ALbLJno61EhWOgzjerAkqOCkWdLptZ8PdfS/C6qPP+ 12Plvbubmj5YRJgqYUw+LpG4aQZ+q87PwRUze8eFrjE2Ps0qct7gyea9QMyKoGh71mzn SKjDgUBcojMbYgiEAmXoveG2Qu3hrCwTC6iy4FX603/zei0SiLwTj/0m9rG1p9MdjVgo iwIF9NMmTd+qfL2uxoCe1WVJ2lJzOV8X/1mD6IYwBIhpzJaLUIDE4lP1lvgVuCzCXeVX ftSmStdbuTQkM8gbqcMVHV4UcU0Ave2XI3eoGTfMz0XloJKlS3Nc0AozO5YshT/N8aoP pc4w== X-Gm-Message-State: AOJu0Yy7d1dWMtEBp9sO4Wu5sFujiC1hAOo7pv36l/n/YJ2VPGZXVK5D 1hBU4ihF2JACSX1B2J98hFQ7ooRvjYN/kirylqIq+R+CoS8cHSTxRV75KvIQyRK6AL5nKby2xL4 MbuDjAt7OiqdAblQZI3S+YkDL0Gf5xthvc/I9DjeC1Ui+nOFGsy8RLKOFzuiIHDL1mkR5 X-Received: by 2002:ac2:4895:0:b0:500:7a21:3e78 with SMTP id x21-20020ac24895000000b005007a213e78mr21711213lfc.55.1699351984906; Tue, 07 Nov 2023 02:13:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/1Xq/Xtj63MJNVrhBDSXc9b1k2lsyfFwg0eYdixVsYpNQ7DQawXkHEELARVtVCRFp6KD/ug== X-Received: by 2002:ac2:4895:0:b0:500:7a21:3e78 with SMTP id x21-20020ac24895000000b005007a213e78mr21711197lfc.55.1699351984570; Tue, 07 Nov 2023 02:13:04 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 48/63] hw/cxl/mbox: Generalize the CCI command processing 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352578382100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron By moving the parts of the mailbox command handling that are CCI type specific out to the caller, make the main handling code generic. Rename it to cxl_process_cci_message() to reflect this new generality. Change the type3 mailbox handling (reused shortly for the switch mailbox CCI) to take a snapshot of the mailbox input data rather than operating on it in place. This reduces the chance of bugs due to aliasing going forwars. Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-5-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 5 +++- hw/cxl/cxl-device-utils.c | 44 +++++++++++++++++++++++++++++++- hw/cxl/cxl-mailbox-utils.c | 51 ++++++++----------------------------- 3 files changed, 57 insertions(+), 43 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 779ca85319..6f8040b5ff 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -260,7 +260,10 @@ CXL_DEVICE_CAPABILITY_HEADER_REGISTER(MEMORY_DEVICE, =20 void cxl_initialize_mailbox_t3(CXLCCI *cci, DeviceState *d, size_t payload= _max); void cxl_init_cci(CXLCCI *cci, size_t payload_max); -void cxl_process_mailbox(CXLCCI *cci); +int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, + size_t len_in, uint8_t *pl_in, + size_t *len_out, uint8_t *pl_out, + bool *bg_started); =20 #define cxl_device_cap_init(dstate, reg, cap_id, ver) = \ do { = \ diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c index 327949a805..eb86634250 100644 --- a/hw/cxl/cxl-device-utils.c +++ b/hw/cxl/cxl-device-utils.c @@ -157,7 +157,49 @@ static void mailbox_reg_write(void *opaque, hwaddr off= set, uint64_t value, =20 if (ARRAY_FIELD_EX32(cxl_dstate->mbox_reg_state32, CXL_DEV_MAILBOX_CTR= L, DOORBELL)) { - cxl_process_mailbox(cci); + uint64_t command_reg =3D + cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBOX_CMD]; + uint8_t cmd_set =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, + COMMAND_SET); + uint8_t cmd =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, COMMA= ND); + size_t len_in =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, LEN= GTH); + uint8_t *pl =3D cxl_dstate->mbox_reg_state + A_CXL_DEV_CMD_PAYLOAD; + /* + * Copy taken to avoid need for individual command handlers to care + * about aliasing. + */ + g_autofree uint8_t *pl_in_copy =3D NULL; + size_t len_out =3D 0; + uint64_t status_reg; + bool bg_started =3D false; + int rc; + + pl_in_copy =3D g_memdup2(pl, len_in); + if (len_in =3D=3D 0 || pl_in_copy) { + /* Avoid stale data - including from earlier cmds */ + memset(pl, 0, CXL_MAILBOX_MAX_PAYLOAD_SIZE); + rc =3D cxl_process_cci_message(cci, cmd_set, cmd, len_in, pl_i= n_copy, + &len_out, pl, &bg_started); + } else { + rc =3D CXL_MBOX_INTERNAL_ERROR; + } + + /* Set bg and the return code */ + status_reg =3D FIELD_DP64(0, CXL_DEV_MAILBOX_STS, BG_OP, + bg_started ? 1 : 0); + status_reg =3D FIELD_DP64(status_reg, CXL_DEV_MAILBOX_STS, ERRNO, = rc); + /* Set the return length */ + command_reg =3D FIELD_DP64(0, CXL_DEV_MAILBOX_CMD, COMMAND_SET, cm= d_set); + command_reg =3D FIELD_DP64(command_reg, CXL_DEV_MAILBOX_CMD, + COMMAND, cmd); + command_reg =3D FIELD_DP64(command_reg, CXL_DEV_MAILBOX_CMD, + LENGTH, len_out); + + cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBOX_CMD] =3D command_re= g; + cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBOX_STS] =3D status_reg; + /* Tell the host we're done */ + ARRAY_FIELD_DP32(cxl_dstate->mbox_reg_state32, CXL_DEV_MAILBOX_CTR= L, + DOORBELL, 0); } } =20 diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 5484dfbbf1..239acc659d 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -754,58 +754,27 @@ static const struct cxl_cmd cxl_cmd_set[256][256] =3D= { cmd_media_clear_poison, 72, 0 }, }; =20 -void cxl_process_mailbox(CXLCCI *cci) +int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, + size_t len_in, uint8_t *pl_in, size_t *len_out, + uint8_t *pl_out, bool *bg_started) { - uint16_t ret =3D CXL_MBOX_SUCCESS; const struct cxl_cmd *cxl_cmd; - uint64_t status_reg =3D 0; opcode_handler h; - CXLDeviceState *cxl_dstate =3D &CXL_TYPE3(cci->d)->cxl_dstate; - uint64_t command_reg =3D cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBO= X_CMD]; =20 - uint8_t set =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND_S= ET); - uint8_t cmd =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND); - uint16_t len_in =3D FIELD_EX64(command_reg, CXL_DEV_MAILBOX_CMD, LENGT= H); - uint8_t *pl =3D cxl_dstate->mbox_reg_state + A_CXL_DEV_CMD_PAYLOAD; - /* - * Copy taken to avoid need for individual command handlers to care - * about aliasing. - */ - g_autofree uint8_t *pl_in_copy =3D NULL; - size_t len_out =3D 0; - - pl_in_copy =3D g_memdup2(pl, len_in); - /* Avoid stale data - including from earlier commands */ - memset(pl, 0, CXL_MAILBOX_MAX_PAYLOAD_SIZE); + *len_out =3D 0; cxl_cmd =3D &cci->cxl_cmd_set[set][cmd]; h =3D cxl_cmd->handler; - if (h) { - if (len_in =3D=3D cxl_cmd->in || cxl_cmd->in =3D=3D ~0) { - ret =3D (*h)(cxl_cmd, pl, len_in, pl, &len_out, cci); - assert(len_out <=3D cci->payload_max); - } else { - ret =3D CXL_MBOX_INVALID_PAYLOAD_LENGTH; - } - } else { + if (!h) { qemu_log_mask(LOG_UNIMP, "Command %04xh not implemented\n", set << 8 | cmd); - ret =3D CXL_MBOX_UNSUPPORTED; + return CXL_MBOX_UNSUPPORTED; } =20 - /* Set the return code */ - status_reg =3D FIELD_DP64(0, CXL_DEV_MAILBOX_STS, ERRNO, ret); + if (len_in !=3D cxl_cmd->in && cxl_cmd->in !=3D ~0) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } =20 - /* Set the return length */ - command_reg =3D FIELD_DP64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND_S= ET, 0); - command_reg =3D FIELD_DP64(command_reg, CXL_DEV_MAILBOX_CMD, COMMAND, = 0); - command_reg =3D FIELD_DP64(command_reg, CXL_DEV_MAILBOX_CMD, LENGTH, l= en_out); - - cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBOX_CMD] =3D command_reg; - cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBOX_STS] =3D status_reg; - - /* Tell the host we're done */ - ARRAY_FIELD_DP32(cxl_dstate->mbox_reg_state32, CXL_DEV_MAILBOX_CTRL, - DOORBELL, 0); + return (*h)(cxl_cmd, pl_in, len_in, pl_out, len_out, cci); } =20 void cxl_init_cci(CXLCCI *cci, size_t payload_max) --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352306; cv=none; d=zohomail.com; s=zohoarc; b=kIBrC/Mxk9rfrJqhwX+G0mPQIN/qhhNVCwo8Ov0ZfPJJTlaEqmkpe16mZcYu5i8ZJMDTozuH7dJ82TjBCUN4Q4XZf1A8KMJpL8XX6YEu+Tda5RBOKL8aTzIZZVK5igyb42mA0klKUmlAj0in1wIDD6pufOyIz5fNx+oh7E5frHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352306; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XNWOwrs5zagROUa4HX64Ay0lI5qsgsRbHzYFsj3DF2M=; b=DlnmmCNNJTNBUQrJzNB/jcryoTew4cezcDl51kSlLPQkBHzAimWBWygT66sjnGDWZsEpZeLbWb9PYsVGn/oW6qsV+qmtxwoW9AoNdSAA1CygeFqZS5xBXoop+k8HdJDDbLT/1h5RTszm+ozRzE9mtiywRklFc9D4uuCL1DWI41M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352306564649.0199700518502; Tue, 7 Nov 2023 02:18:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J59-0003i9-Pz; Tue, 07 Nov 2023 05:13:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J58-0003hy-Hi for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J56-0002ug-Q2 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:14 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-593-HI7tHKkRMbaYl-Z5m3-EXA-1; Tue, 07 Nov 2023 05:13:11 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4090181eec2so35038105e9.1 for ; Tue, 07 Nov 2023 02:13:10 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id y14-20020a056000108e00b0032dbf6bf7a2sm1897532wrw.97.2023.11.07.02.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351992; h=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=XNWOwrs5zagROUa4HX64Ay0lI5qsgsRbHzYFsj3DF2M=; b=HluVkj8SZ4C0mRePade1JZSTMtF2nQDk4MQogRCmQyUHcxNIwslBjGl5AuG4/9n8LkdKfy woXMdnc8/9IkcMH4EK9vDV1u5n2so7CKd1PWmMUDJRZ7Jn7vVokaIt8hzInYVn8D7/oKvX uJTS+VQ3kYIfqAwAm1ssbV3Q2NhJxtM= X-MC-Unique: HI7tHKkRMbaYl-Z5m3-EXA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351989; x=1699956789; 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=XNWOwrs5zagROUa4HX64Ay0lI5qsgsRbHzYFsj3DF2M=; b=gwlZsLIsZ1hXU+zyzTJ6aVvvvcc9bRhU7v0UzWWGutq+cztIyXnrLd1vlOqU4WHfxp ZzlljdhWJS6VntGmi1iBbJ7FhlxTAJ232bqWMBjemTvSsKSmwXnsEpWfenMgeGWO54kY DBtVNoKUhZH6mU8DVBfKS1EIN4eknukDzyoeLBuKjbLlyrxXgz05QedjOI8adHFPmC7x vDMRC6IzZfUMibiRYOuz3aaHfmbRoN7A2jxYc0SosMNr92EuIiLoPvrFPqSYDKObN2lR 5lPc2B1F7+TVCvo1+3dZmdpetZrqZvJgd/J/1NFwtfesVi35IPwraahA8UQ1jKRuMfpq bbuw== X-Gm-Message-State: AOJu0YyyXTu2xY4r3qGbfLEQ9ytRBUtpb2tbc0GcvigRlmjxU5NIYNbO 5ofYgZYIIKcmJH8UswK240hnkFZrZywwsHRBVYAW3n9wKBZWdj8pkwn2KW7QoAnPR+aoT1rnLwB jXjq7enm8ExG3KkOhdF3s6Ac3EL5moFHYm+DIxTHYbn/aoQjlbVE31yPIwo6W74CgkmEO X-Received: by 2002:adf:dd92:0:b0:32d:b051:9a29 with SMTP id x18-20020adfdd92000000b0032db0519a29mr24906993wrl.2.1699351989251; Tue, 07 Nov 2023 02:13:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFWKI+UfPL9KHklMVnUEvErMsrD69UE+sCnOzSDtHvUlof3bkaM0zc/iCJVwnAs3AIq4waZBw== X-Received: by 2002:adf:dd92:0:b0:32d:b051:9a29 with SMTP id x18-20020adfdd92000000b0032db0519a29mr24906971wrl.2.1699351988827; Tue, 07 Nov 2023 02:13:08 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:04 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni , Marcel Apfelbaum Subject: [PULL 49/63] hw/pci-bridge/cxl_upstream: Move defintion of device to header. Message-ID: <2710d49a7c8b9b117a46847c7ace5eb21d48e882.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352308501100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron To avoid repetition of switch upstream port specific data in the CXLDeviceState structure it will be necessary to access the switch USP specific data from mailbox callbacks. Hence move it to cxl_device.h so it is no longer an opaque structure. Signed-off-by: Jonathan Cameron Reviewed-by: Fan Ni Message-Id: <20231023160806.13206-6-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci-bridge/cxl_upstream_port.h | 18 ++++++++++++++++++ hw/pci-bridge/cxl_upstream.c | 11 +---------- 2 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 include/hw/pci-bridge/cxl_upstream_port.h diff --git a/include/hw/pci-bridge/cxl_upstream_port.h b/include/hw/pci-bri= dge/cxl_upstream_port.h new file mode 100644 index 0000000000..b02aa8f659 --- /dev/null +++ b/include/hw/pci-bridge/cxl_upstream_port.h @@ -0,0 +1,18 @@ + +#ifndef CXL_USP_H +#define CXL_USP_H +#include "hw/pci/pcie.h" +#include "hw/pci/pcie_port.h" +#include "hw/cxl/cxl.h" + +typedef struct CXLUpstreamPort { + /*< private >*/ + PCIEPort parent_obj; + + /*< public >*/ + CXLComponentState cxl_cstate; + DOECap doe_cdat; + uint64_t sn; +} CXLUpstreamPort; + +#endif /* CXL_SUP_H */ diff --git a/hw/pci-bridge/cxl_upstream.c b/hw/pci-bridge/cxl_upstream.c index b81bb5fec9..36737189c6 100644 --- a/hw/pci-bridge/cxl_upstream.c +++ b/hw/pci-bridge/cxl_upstream.c @@ -14,6 +14,7 @@ #include "hw/pci/msi.h" #include "hw/pci/pcie.h" #include "hw/pci/pcie_port.h" +#include "hw/pci-bridge/cxl_upstream_port.h" /* * Null value of all Fs suggested by IEEE RA guidelines for use of * EU, OUI and CID @@ -30,16 +31,6 @@ #define CXL_UPSTREAM_PORT_DVSEC_OFFSET \ (CXL_UPSTREAM_PORT_SN_OFFSET + PCI_EXT_CAP_DSN_SIZEOF) =20 -typedef struct CXLUpstreamPort { - /*< private >*/ - PCIEPort parent_obj; - - /*< public >*/ - CXLComponentState cxl_cstate; - DOECap doe_cdat; - uint64_t sn; -} CXLUpstreamPort; - CXLComponentState *cxl_usp_to_cstate(CXLUpstreamPort *usp) { return &usp->cxl_cstate; --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352250; cv=none; d=zohomail.com; s=zohoarc; b=kbGpyu/I7EsGqtOkGP/Nt3iod2+c8P4eczZGDrhWNbWeher0fRfjlzI74gK90WkHzCRBZUGzBWo+PX8KIc9N8olq4QQmrafZeJi4CE/Z10RwZgt0OOTupgf1tOEKN+K8bHbSlRaJLVYO6f9wMvu520kabPUD/bsZFUcweE8eBco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352250; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=M42e+QCTFHQpfioghFl7GHYJ8ILvQFm/3mBUX2ZJf8w=; b=KZU4njwNxZ+v+9R+9QqtH8SGYFC6dsRTzPfE5lIQBbIWIA8QoUHTojgKv78//3oW6CKCRx/T2uKpqsDkEgIN9Luri1LxxU1wcN4J4RlLZtuWQq/rqkeAqAFuUXLWSZJjqcnwt1C5C3RN82L54cDz3ob8P10rAh63UdnLnEsD39A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352250479231.70704188898833; Tue, 7 Nov 2023 02:17:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J5G-0003qf-HP; Tue, 07 Nov 2023 05:13:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5E-0003j4-OX for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5C-0002v8-L3 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:20 -0500 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-215-N4OT-66PMMekjb44a0toJQ-1; Tue, 07 Nov 2023 05:13:16 -0500 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-50911cc75adso5933039e87.1 for ; Tue, 07 Nov 2023 02:13:15 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id fo15-20020a05600c690f00b0040535648639sm14733979wmb.36.2023.11.07.02.13.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699351997; h=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=M42e+QCTFHQpfioghFl7GHYJ8ILvQFm/3mBUX2ZJf8w=; b=Ej36mip+f62eKeM2qoNjX9LEQxkkQc/bzb4kpngdDphfukMnlJUDtglEAkqaseY0rNZZga k8VEto+wyVxchsRA9VFgPodNLM0HwZwZY7Nf3L6xkwg/Nt1k442wDdrmhcNqVYaj0k3GWl eux+0pnQCk4npKxgo2wBNBgxLDJPQXo= X-MC-Unique: N4OT-66PMMekjb44a0toJQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351994; x=1699956794; 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=M42e+QCTFHQpfioghFl7GHYJ8ILvQFm/3mBUX2ZJf8w=; b=M+KDjMaUwW7ZJlnsRvXuIvCAzdg/u0+QC1WHWKfNXt3QjIjMDEuK5tHploUthIk8A9 /FgpRFolLv3hcNNLh63raUO6qbgTIDiWLYOQV7Q2N6IqCVO9uc+gtZXHEAw6ZTiWL5e/ Lc/Wu/6xv2hlUVa7ELjtC0aTDoJMn/edkQzKuC1xANkaVsVc25VMZbZ23ktIVeRi0+Yg OE/cpmlOau3yIQViBneWEtTMX4tPIXr7kmZNWJJMYlZUs0gYS40w4ms3uwyo6Ngs4ITJ bNGeHf97JFvsmE1KohB9QI+HHo1sqbYNMhQRde/H7/ZDQOPgknuVEZhc58XOnSwdWIHl PjxA== X-Gm-Message-State: AOJu0YyPjvFGEdElZN0htik/AcOKHvoI60l9jgc6hpuX8xJ3LGc3VjtK uTjpJqZLNSYXqrWauUvUnbc22r73jTiK5hrdkdWk3ipQFGxmHQpL0ypWlMPerwfv6M8niB/r33I Q3Uk5H4P2SDtB015/5qD2V1+pLiRboM31RdiGCM7YEKINIRXaqT0xqQ524oDd70+AvvE7 X-Received: by 2002:a2e:8043:0:b0:2c5:70f:614a with SMTP id p3-20020a2e8043000000b002c5070f614amr24591829ljg.17.1699351993780; Tue, 07 Nov 2023 02:13:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEwYHJi0czUxSqIiEoPAxOqubDjovxetkWvAgzwQN+WNFz5TBru84VRizIhfHEZNYDNdMCmBQ== X-Received: by 2002:a2e:8043:0:b0:2c5:70f:614a with SMTP id p3-20020a2e8043000000b002c5070f614amr24591810ljg.17.1699351993311; Tue, 07 Nov 2023 02:13:13 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 50/63] hw/cxl: Add a switch mailbox CCI function Message-ID: <4a58330343e6a16f6828e225fd0c054c8d1916bd.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352251221100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron CXL switch CCIs were added in CXL r3.0. They are a PCI function, identified by class code that provides a CXL mailbox (identical to that previously defined for CXL type 3 memory devices) over which various FM-API commands may be used. Whilst the intent of this feature is enable switch control from a BMC attached to a switch upstream port, it is also useful to allow emulation of this feature on the upstream port connected to a host using the CXL devices as this greatly simplifies testing. Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-7-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_component.h | 3 +- include/hw/cxl/cxl_device.h | 15 +++ include/hw/pci-bridge/cxl_upstream_port.h | 1 + hw/cxl/cxl-device-utils.c | 27 ++++++ hw/cxl/cxl-mailbox-utils.c | 18 ++++ hw/cxl/switch-mailbox-cci.c | 111 ++++++++++++++++++++++ hw/cxl/meson.build | 1 + 7 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 hw/cxl/switch-mailbox-cci.c diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h index e52dd8d2b9..5227a8e833 100644 --- a/include/hw/cxl/cxl_component.h +++ b/include/hw/cxl/cxl_component.h @@ -26,7 +26,8 @@ enum reg_type { CXL2_LOGICAL_DEVICE, CXL2_ROOT_PORT, CXL2_UPSTREAM_PORT, - CXL2_DOWNSTREAM_PORT + CXL2_DOWNSTREAM_PORT, + CXL3_SWITCH_MAILBOX_CCI, }; =20 /* diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 6f8040b5ff..fa73ed03e5 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -211,8 +211,10 @@ void cxl_device_register_block_init(Object *obj, CXLDe= viceState *dev, CXLCCI *cci); =20 typedef struct CXLType3Dev CXLType3Dev; +typedef struct CSWMBCCIDev CSWMBCCIDev; /* Set up default values for the register block */ void cxl_device_register_init_t3(CXLType3Dev *ct3d); +void cxl_device_register_init_swcci(CSWMBCCIDev *sw); =20 /* * CXL 2.0 - 8.2.8.1 including errata F4 @@ -259,6 +261,8 @@ CXL_DEVICE_CAPABILITY_HEADER_REGISTER(MEMORY_DEVICE, CXL_DEVICE_CAP_REG_SIZE * 2) =20 void cxl_initialize_mailbox_t3(CXLCCI *cci, DeviceState *d, size_t payload= _max); +void cxl_initialize_mailbox_swcci(CXLCCI *cci, DeviceState *intf, + DeviceState *d, size_t payload_max); void cxl_init_cci(CXLCCI *cci, size_t payload_max); int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, size_t len_in, uint8_t *pl_in, @@ -397,6 +401,17 @@ struct CXLType3Class { uint8_t *data); }; =20 +struct CSWMBCCIDev { + PCIDevice parent_obj; + PCIDevice *target; + CXLComponentState cxl_cstate; + CXLDeviceState cxl_dstate; + CXLCCI *cci; +}; + +#define TYPE_CXL_SWITCH_MAILBOX_CCI "cxl-switch-mailbox-cci" +OBJECT_DECLARE_TYPE(CSWMBCCIDev, CSWMBCCIClass, CXL_SWITCH_MAILBOX_CCI) + MemTxResult cxl_type3_read(PCIDevice *d, hwaddr host_addr, uint64_t *data, unsigned size, MemTxAttrs attrs); MemTxResult cxl_type3_write(PCIDevice *d, hwaddr host_addr, uint64_t data, diff --git a/include/hw/pci-bridge/cxl_upstream_port.h b/include/hw/pci-bri= dge/cxl_upstream_port.h index b02aa8f659..12635139f6 100644 --- a/include/hw/pci-bridge/cxl_upstream_port.h +++ b/include/hw/pci-bridge/cxl_upstream_port.h @@ -11,6 +11,7 @@ typedef struct CXLUpstreamPort { =20 /*< public >*/ CXLComponentState cxl_cstate; + CXLCCI swcci; DOECap doe_cdat; uint64_t sn; } CXLUpstreamPort; diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c index eb86634250..f8938678c7 100644 --- a/hw/cxl/cxl-device-utils.c +++ b/hw/cxl/cxl-device-utils.c @@ -67,6 +67,9 @@ static uint64_t mailbox_reg_read(void *opaque, hwaddr off= set, unsigned size) =20 if (object_dynamic_cast(OBJECT(cci->intf), TYPE_CXL_TYPE3)) { cxl_dstate =3D &CXL_TYPE3(cci->intf)->cxl_dstate; + } else if (object_dynamic_cast(OBJECT(cci->intf), + TYPE_CXL_SWITCH_MAILBOX_CCI)) { + cxl_dstate =3D &CXL_SWITCH_MAILBOX_CCI(cci->intf)->cxl_dstate; } else { return 0; } @@ -135,6 +138,9 @@ static void mailbox_reg_write(void *opaque, hwaddr offs= et, uint64_t value, =20 if (object_dynamic_cast(OBJECT(cci->intf), TYPE_CXL_TYPE3)) { cxl_dstate =3D &CXL_TYPE3(cci->intf)->cxl_dstate; + } else if (object_dynamic_cast(OBJECT(cci->intf), + TYPE_CXL_SWITCH_MAILBOX_CCI)) { + cxl_dstate =3D &CXL_SWITCH_MAILBOX_CCI(cci->intf)->cxl_dstate; } else { return; } @@ -365,6 +371,27 @@ void cxl_device_register_init_t3(CXLType3Dev *ct3d) CXL_MAILBOX_MAX_PAYLOAD_SIZE); } =20 +void cxl_device_register_init_swcci(CSWMBCCIDev *sw) +{ + CXLDeviceState *cxl_dstate =3D &sw->cxl_dstate; + uint64_t *cap_h =3D cxl_dstate->caps_reg_state64; + const int cap_count =3D 3; + + /* CXL Device Capabilities Array Register */ + ARRAY_FIELD_DP64(cap_h, CXL_DEV_CAP_ARRAY, CAP_ID, 0); + ARRAY_FIELD_DP64(cap_h, CXL_DEV_CAP_ARRAY, CAP_VERSION, 1); + ARRAY_FIELD_DP64(cap_h, CXL_DEV_CAP_ARRAY, CAP_COUNT, cap_count); + + cxl_device_cap_init(cxl_dstate, DEVICE_STATUS, 1, 2); + device_reg_init_common(cxl_dstate); + + cxl_device_cap_init(cxl_dstate, MAILBOX, 2, 1); + mailbox_reg_init_common(cxl_dstate); + + cxl_device_cap_init(cxl_dstate, MEMORY_DEVICE, 0x4000, 1); + memdev_reg_init_common(cxl_dstate); +} + uint64_t cxl_device_get_timestamp(CXLDeviceState *cxl_dstate) { uint64_t time, delta; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 239acc659d..28ea02fcbe 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -754,6 +754,15 @@ static const struct cxl_cmd cxl_cmd_set[256][256] =3D { cmd_media_clear_poison, 72, 0 }, }; =20 +static const struct cxl_cmd cxl_cmd_set_sw[256][256] =3D { + [TIMESTAMP][GET] =3D { "TIMESTAMP_GET", cmd_timestamp_get, 0, 0 }, + [TIMESTAMP][SET] =3D { "TIMESTAMP_SET", cmd_timestamp_set, 0, + IMMEDIATE_POLICY_CHANGE }, + [LOGS][GET_SUPPORTED] =3D { "LOGS_GET_SUPPORTED", cmd_logs_get_support= ed, 0, + 0 }, + [LOGS][GET_LOG] =3D { "LOGS_GET_LOG", cmd_logs_get_log, 0x18, 0 }, +}; + int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, size_t len_in, uint8_t *pl_in, size_t *len_out, uint8_t *pl_out, bool *bg_started) @@ -795,6 +804,15 @@ void cxl_init_cci(CXLCCI *cci, size_t payload_max) } } =20 +void cxl_initialize_mailbox_swcci(CXLCCI *cci, DeviceState *intf, + DeviceState *d, size_t payload_max) +{ + cci->cxl_cmd_set =3D cxl_cmd_set_sw; + cci->d =3D d; + cci->intf =3D intf; + cxl_init_cci(cci, payload_max); +} + void cxl_initialize_mailbox_t3(CXLCCI *cci, DeviceState *d, size_t payload= _max) { cci->cxl_cmd_set =3D cxl_cmd_set; diff --git a/hw/cxl/switch-mailbox-cci.c b/hw/cxl/switch-mailbox-cci.c new file mode 100644 index 0000000000..ba399c6240 --- /dev/null +++ b/hw/cxl/switch-mailbox-cci.c @@ -0,0 +1,111 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Emulation of a CXL Switch Mailbox CCI PCIe function. + * + * Copyright (c) 2023 Huawei Technologies. + * + * From www.computeexpresslink.org + * Compute Express Link (CXL) Specification revision 3.0 Version 1.0 + */ +#include "qemu/osdep.h" +#include "hw/pci/pci.h" +#include "hw/pci-bridge/cxl_upstream_port.h" +#include "qapi/error.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "hw/qdev-properties.h" +#include "hw/cxl/cxl.h" + +static void cswmbcci_reset(DeviceState *dev) +{ + CSWMBCCIDev *cswmb =3D CXL_SWITCH_MAILBOX_CCI(dev); + cxl_device_register_init_swcci(cswmb); +} + +static void cswbcci_realize(PCIDevice *pci_dev, Error **errp) +{ + CSWMBCCIDev *cswmb =3D CXL_SWITCH_MAILBOX_CCI(pci_dev); + CXLComponentState *cxl_cstate =3D &cswmb->cxl_cstate; + CXLDeviceState *cxl_dstate =3D &cswmb->cxl_dstate; + CXLDVSECRegisterLocator *regloc_dvsec; + CXLUpstreamPort *usp; + + if (!cswmb->target) { + error_setg(errp, "Target not set"); + return; + } + usp =3D CXL_USP(cswmb->target); + + pcie_endpoint_cap_init(pci_dev, 0x80); + cxl_cstate->dvsec_offset =3D 0x100; + cxl_cstate->pdev =3D pci_dev; + cswmb->cci =3D &usp->swcci; + cxl_device_register_block_init(OBJECT(pci_dev), cxl_dstate, cswmb->cci= ); + pci_register_bar(pci_dev, 0, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_TYPE_64, + &cxl_dstate->device_registers); + regloc_dvsec =3D &(CXLDVSECRegisterLocator) { + .rsvd =3D 0, + .reg0_base_lo =3D RBI_CXL_DEVICE_REG | 0, + .reg0_base_hi =3D 0, + }; + cxl_component_create_dvsec(cxl_cstate, CXL3_SWITCH_MAILBOX_CCI, + REG_LOC_DVSEC_LENGTH, REG_LOC_DVSEC, + REG_LOC_DVSEC_REVID, (uint8_t *)regloc_dvse= c); + + cxl_initialize_mailbox_swcci(cswmb->cci, DEVICE(pci_dev), + DEVICE(cswmb->target), + CXL_MAILBOX_MAX_PAYLOAD_SIZE); +} + +static void cswmbcci_exit(PCIDevice *pci_dev) +{ + /* Nothing to do here yet */ +} + +static Property cxl_switch_cci_props[] =3D { + DEFINE_PROP_LINK("target", CSWMBCCIDev, + target, TYPE_CXL_USP, PCIDevice *), + DEFINE_PROP_END_OF_LIST(), +}; + +static void cswmbcci_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + PCIDeviceClass *pc =3D PCI_DEVICE_CLASS(oc); + + pc->realize =3D cswbcci_realize; + pc->exit =3D cswmbcci_exit; + /* Serial bus, CXL Switch CCI */ + pc->class_id =3D 0x0c0b; + /* + * Huawei Technologies + * CXL Switch Mailbox CCI - DID assigned for emulation only. + * No real hardware will ever use this ID. + */ + pc->vendor_id =3D 0x19e5; + pc->device_id =3D 0xa123; + pc->revision =3D 0; + dc->desc =3D "CXL Switch Mailbox CCI"; + dc->reset =3D cswmbcci_reset; + device_class_set_props(dc, cxl_switch_cci_props); +} + +static const TypeInfo cswmbcci_info =3D { + .name =3D TYPE_CXL_SWITCH_MAILBOX_CCI, + .parent =3D TYPE_PCI_DEVICE, + .class_init =3D cswmbcci_class_init, + .instance_size =3D sizeof(CSWMBCCIDev), + .interfaces =3D (InterfaceInfo[]) { + { INTERFACE_PCIE_DEVICE }, + { } + }, +}; + +static void cxl_switch_mailbox_cci_register(void) +{ + type_register_static(&cswmbcci_info); +} +type_init(cxl_switch_mailbox_cci_register); diff --git a/hw/cxl/meson.build b/hw/cxl/meson.build index e261ff3881..ea0aebf6e3 100644 --- a/hw/cxl/meson.build +++ b/hw/cxl/meson.build @@ -6,6 +6,7 @@ system_ss.add(when: 'CONFIG_CXL', 'cxl-host.c', 'cxl-cdat.c', 'cxl-events.c', + 'switch-mailbox-cci.c', ), if_false: files( 'cxl-host-stubs.c', --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352469; cv=none; d=zohomail.com; s=zohoarc; b=e/tA7afAmqw/Sa9HzIVH4HBPmoXhtJ5FStTzFPGKPjDoWi0GvKB9ujaUycnma8DUhVW+sAznpzFjCD67vdhKJ1ncMbUV+gJTrZs1ojQRRqsfJF7IB4A+R7u3YMHKkJ5a9+ePt4T7c3EshRTpjV05bwA0pjTDImgnn+ThMs4x95Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352469; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9Psz1BOwTQBVnWrBi4/EaLOXmxV87kpmQ8siLKG1GMM=; b=C1pseZ3iqI1PhL78IUYb/07G7WeovV+RPgclJ4WNRhp7LjcMtNdCR4tuo/JJsJ6XQFNCFRGbDzCymwEKMbmXyEwwXfAOfZKYTSHr1cxIIqtrLISYqhWaMYoQoaCuxq5S20LG3XsMA0sKq/9Gl2M9HU9U9YIVUItFDvYniTjSLow= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352469176405.36227756829896; Tue, 7 Nov 2023 02:21:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J5b-000514-Qg; Tue, 07 Nov 2023 05:13:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5Y-0004un-6b for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5W-0002xj-EL for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:39 -0500 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-70-dOP3ND8tNJeyhnaVNLL9pg-1; Tue, 07 Nov 2023 05:13:19 -0500 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2c6f3cd892cso55338661fa.3 for ; Tue, 07 Nov 2023 02:13:19 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c19d100b00405c7591b09sm15290202wmq.35.2023.11.07.02.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352017; h=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=9Psz1BOwTQBVnWrBi4/EaLOXmxV87kpmQ8siLKG1GMM=; b=BibaiojKv4V8vCwJsDhdZJ9VPCPt7K9Xf9VS08H1JVLHgrdtsZnk6/82OH6ep5o9htr9F7 NBad8aF7XW1ZqfpaWplYl+rcpxRd1m1LZzLkQMp0cNmCG39QhFeirvxAaJmYvwfZt4hPPS 8/YLCsxN8vDfSL4ARkm1/6H85SzyDcM= X-MC-Unique: dOP3ND8tNJeyhnaVNLL9pg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699351997; x=1699956797; 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=9Psz1BOwTQBVnWrBi4/EaLOXmxV87kpmQ8siLKG1GMM=; b=Bl/mN6Sm7vqPyW+yRaeAT/VocPojrpXzEYWRvJr6a0s3LZm/uuz/d0kyvEDP05ubEm PybylJHQqfiwU+lDV7Z05LoIFldZRXr8++K2Rzw2x4kCAvwmXmv+elvJwYZiK9ei+U0f oCuP0pM3PLplYtypH2LcQ//+RtGtOsJiTdA337wZKJ+oxoI2zcAB9lk2+lIByitAYxfk 2sBOGB85nNW2YZUDlj3v04r02xtYW877/61iNewe/JIlOzxwQ/ijMws1yTZ1o6jz1zP3 kIll6dtUSayyRqYBBydf9nw3u7o3HnjBWG+1t7+26C5xnUFOAdtcB+QGNOZ7H0iH8w78 7VpQ== X-Gm-Message-State: AOJu0YyuWZzVx2IyPegKyC8ZcW1UWja11k0OKIw0N0/wv3jlHjY1hn07 WrMJGWYP7WjlW5thKQj8lianguTjtDKSbeOxqOxAgQ+koiUfrKfHsGDvC6byn2oI1uYcgrdEtNK fN/hOzSyX9wuZ7ktHVd2nLXKIP2c5nP5rlRC+FcT2VY9lKRBk01czHMewQL8Rur1t+49E X-Received: by 2002:a2e:a9a7:0:b0:2bc:db70:b563 with SMTP id x39-20020a2ea9a7000000b002bcdb70b563mr30360221ljq.32.1699351997624; Tue, 07 Nov 2023 02:13:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IEaUpMu/REQ9YWQSE/IZlcGogyKM2FPtenubdGQLdI/3oj9Z/SHn+vDI+vIbRgbkJpg96oSOA== X-Received: by 2002:a2e:a9a7:0:b0:2bc:db70:b563 with SMTP id x39-20020a2ea9a7000000b002bcdb70b563mr30360196ljq.32.1699351997243; Tue, 07 Nov 2023 02:13:17 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 51/63] hw/cxl/mbox: Add Information and Status / Identify command Message-ID: <6cf416c176f11bc093fcc1818d6c9a95136f4c59.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352470033100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Add this command that is only available via out of band CCIs. It replicates information that can be discovered inband via PCI config space. Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-8-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 28ea02fcbe..6741698ee7 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -11,6 +11,7 @@ #include "hw/cxl/cxl.h" #include "hw/cxl/cxl_events.h" #include "hw/pci/pci.h" +#include "hw/pci-bridge/cxl_upstream_port.h" #include "qemu/cutils.h" #include "qemu/log.h" #include "qemu/units.h" @@ -44,6 +45,8 @@ */ =20 enum { + INFOSTAT =3D 0x00, + #define IS_IDENTIFY 0x1 EVENTS =3D 0x01, #define GET_RECORDS 0x0 #define CLEAR_RECORDS 0x1 @@ -203,6 +206,57 @@ static CXLRetCode cmd_events_set_interrupt_policy(cons= t struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 +/* CXL r3.0 section 8.2.9.1.1: Identify (Opcode 0001h) */ +static CXLRetCode cmd_infostat_identify(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + PCIDeviceClass *class =3D PCI_DEVICE_GET_CLASS(cci->d); + struct { + uint16_t pcie_vid; + uint16_t pcie_did; + uint16_t pcie_subsys_vid; + uint16_t pcie_subsys_id; + uint64_t sn; + uint8_t max_message_size; + uint8_t component_type; + } QEMU_PACKED *is_identify; + QEMU_BUILD_BUG_ON(sizeof(*is_identify) !=3D 18); + + is_identify =3D (void *)payload_out; + memset(is_identify, 0, sizeof(*is_identify)); + is_identify->pcie_vid =3D class->vendor_id; + is_identify->pcie_did =3D class->device_id; + if (object_dynamic_cast(OBJECT(cci->d), TYPE_CXL_USP)) { + is_identify->sn =3D CXL_USP(cci->d)->sn; + /* Subsystem info not defined for a USP */ + is_identify->pcie_subsys_vid =3D 0; + is_identify->pcie_subsys_id =3D 0; + is_identify->component_type =3D 0x0; /* Switch */ + } else if (object_dynamic_cast(OBJECT(cci->d), TYPE_CXL_TYPE3)) { + PCIDevice *pci_dev =3D PCI_DEVICE(cci->d); + + is_identify->sn =3D CXL_TYPE3(cci->d)->sn; + /* + * We can't always use class->subsystem_vendor_id as + * it is not set if the defaults are used. + */ + is_identify->pcie_subsys_vid =3D + pci_get_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID); + is_identify->pcie_subsys_id =3D + pci_get_word(pci_dev->config + PCI_SUBSYSTEM_ID); + is_identify->component_type =3D 0x3; /* Type 3 */ + } + + /* TODO: Allow this to vary across different CCIs */ + is_identify->max_message_size =3D 9; /* 512 bytes - MCTP_CXL_MAILBOX_B= YTES */ + *len_out =3D sizeof(*is_identify); + return CXL_MBOX_SUCCESS; +} + /* 8.2.9.2.1 */ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, uint8_t *payload_in, @@ -755,6 +809,7 @@ static const struct cxl_cmd cxl_cmd_set[256][256] =3D { }; =20 static const struct cxl_cmd cxl_cmd_set_sw[256][256] =3D { + [INFOSTAT][IS_IDENTIFY] =3D { "IDENTIFY", cmd_infostat_identify, 0, 0 = }, [TIMESTAMP][GET] =3D { "TIMESTAMP_GET", cmd_timestamp_get, 0, 0 }, [TIMESTAMP][SET] =3D { "TIMESTAMP_SET", cmd_timestamp_set, 0, IMMEDIATE_POLICY_CHANGE }, --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352651; cv=none; d=zohomail.com; s=zohoarc; b=miITgnyl4BKqZB2k+k+0smm0oyZuzehBrJseBh+Wfh+0gh+ezN1E1n+OKrlr84fy2GFV0LUEOWqTFejaUQnTtcqAtHAksR9eOG4E0zJOJzSMAv8jL1cDidQSN40wEmXyNRDTtxTrjWu+Gmlo99JYlWKMcmJMMR7Qk4P5uGpgtPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352651; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=B4NuGQZaHq8Q+4F5F83IqV9aNTAYT6ys0MEYQ1OXl4M=; b=X/fUxe4917wvD6qRBE0rH4T3sOZcDXRvZ1AX2uP1+/q3BltIEvR4nFD2KB9GkSmgTTMr3gXB6QQcyBPFBOzYSzgR1lo7M7fovUDnAirnB/NNs2vbi+pN0stNRhoGY73pkEZovcX/FZ4lA+G0+Lwttn4yGreK2S5kblPD3Sat9QY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352651558323.5688218993678; Tue, 7 Nov 2023 02:24:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J5T-0004X7-0B; Tue, 07 Nov 2023 05:13:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5R-0004Wb-M6 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5O-0002ww-S5 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:33 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-97-tP1BeqRVPT6GmjOvrqSX7w-1; Tue, 07 Nov 2023 05:13:24 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-408695c377dso34611815e9.2 for ; Tue, 07 Nov 2023 02:13:23 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id k25-20020a05600c1c9900b004067e905f44sm15394340wms.9.2023.11.07.02.13.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352010; h=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=B4NuGQZaHq8Q+4F5F83IqV9aNTAYT6ys0MEYQ1OXl4M=; b=USqjpJRyaYK/idNRuvNUfwwQilDRd+BKmNLkRy+qLBdkXgJ6IzfwGgac6w9AdwBrajefVz ccxi+tJCnGDd7iLRvqFzdfTA0lWDqMM/0OwwqYV0HDl1wKBXcWejuvFQ/bDFFxlAWPPjZ/ wO1r51NHBXnnyoTwS7Dfqu1gISRSH+o= X-MC-Unique: tP1BeqRVPT6GmjOvrqSX7w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699352002; x=1699956802; 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=B4NuGQZaHq8Q+4F5F83IqV9aNTAYT6ys0MEYQ1OXl4M=; b=B0aoRJH3Pjzj0/X8t/WtEVsYxqofFzo2xZiwQBcJV5awY/JD1OI5HLSKUfqEF+loRz ZYimpilVNKtIbjkeirRQf7jPvKiKr50RnDXVM04U5MSgVqsuBiuKcdL1Hk5f4Kzo8OHn Ao2ArkyPOy8B1u8rElMEremTKBjDJrjJY8691SPHiZnTAX67bN5yZrarJ6J6MpcUYAZ5 Rymkke2oWN7GlXksS1DYgJvtYtD+uDnv8t/gGGyRsnR0RNllsKpvljNnTZ00VZYg0EdM 7zhyKt3bxrjLid/4uEdfn48lqRgzXFEV7WbLZRAhzGzXUtz/vljUWMH7xpAuy6K7yI7T o/sA== X-Gm-Message-State: AOJu0Yxn7CK0Q3A/+Ck+1CjpiRHuUxb3k0h4TxDhyCXAuSl9m+GkBy7z EK32yv61RRBgd3jMxy0vbqPXd8BsBgKfoYykPkz7YD6BTYlZk08hbDPbCoEzkxhrDxfgOFgZzXy hX8FCfI9LamG/GiyfrBSif/hhHgxRfL74IwV9PSdsggq+4UsR8SldX0wbX8BQVgST/lFa X-Received: by 2002:a05:600c:3c9a:b0:3fe:f74c:b4f6 with SMTP id bg26-20020a05600c3c9a00b003fef74cb4f6mr1906041wmb.17.1699352002310; Tue, 07 Nov 2023 02:13:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRuD2sj++FQEJS5RVrslYj7ljlZbcBjrmcmDMzKCI2UT/VYsYTeHwnmWbC/KyF8jWyh0SU5g== X-Received: by 2002:a05:600c:3c9a:b0:3fe:f74c:b4f6 with SMTP id bg26-20020a05600c3c9a00b003fef74cb4f6mr1906027wmb.17.1699352001963; Tue, 07 Nov 2023 02:13:21 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni , Marcel Apfelbaum Subject: [PULL 52/63] hw/cxl/mbox: Add Physical Switch Identify command. Message-ID: <3314efd276ada18cc0b8beb70b8943f8deb872b7.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352653727100007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Enable it for the switch CCI. Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-9-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl.h | 6 ++++ hw/cxl/cxl-mailbox-utils.c | 65 ++++++++++++++++++++++++++++++++++ hw/pci-bridge/cxl_downstream.c | 4 +-- 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/include/hw/cxl/cxl.h b/include/hw/cxl/cxl.h index 4944725849..75e47b6864 100644 --- a/include/hw/cxl/cxl.h +++ b/include/hw/cxl/cxl.h @@ -61,4 +61,10 @@ OBJECT_DECLARE_SIMPLE_TYPE(CXLHost, PXB_CXL_HOST) typedef struct CXLUpstreamPort CXLUpstreamPort; DECLARE_INSTANCE_CHECKER(CXLUpstreamPort, CXL_USP, TYPE_CXL_USP) CXLComponentState *cxl_usp_to_cstate(CXLUpstreamPort *usp); + +#define TYPE_CXL_DSP "cxl-downstream" + +typedef struct CXLDownstreamPort CXLDownstreamPort; +DECLARE_INSTANCE_CHECKER(CXLDownstreamPort, CXL_DSP, TYPE_CXL_DSP) + #endif diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 6741698ee7..6ada49d37c 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -70,6 +70,8 @@ enum { #define GET_POISON_LIST 0x0 #define INJECT_POISON 0x1 #define CLEAR_POISON 0x2 + PHYSICAL_SWITCH =3D 0x51, + #define IDENTIFY_SWITCH_DEVICE 0x0 }; =20 =20 @@ -257,6 +259,67 @@ static CXLRetCode cmd_infostat_identify(const struct c= xl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 +static void cxl_set_dsp_active_bm(PCIBus *b, PCIDevice *d, + void *private) +{ + uint8_t *bm =3D private; + if (object_dynamic_cast(OBJECT(d), TYPE_CXL_DSP)) { + uint8_t port =3D PCIE_PORT(d)->port; + bm[port / 8] |=3D 1 << (port % 8); + } +} + +/* CXL r3 8.2.9.1.1 */ +static CXLRetCode cmd_identify_switch_device(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + PCIEPort *usp =3D PCIE_PORT(cci->d); + PCIBus *bus =3D &PCI_BRIDGE(cci->d)->sec_bus; + int num_phys_ports =3D pcie_count_ds_ports(bus); + + struct cxl_fmapi_ident_switch_dev_resp_pl { + uint8_t ingress_port_id; + uint8_t rsvd; + uint8_t num_physical_ports; + uint8_t num_vcss; + uint8_t active_port_bitmask[0x20]; + uint8_t active_vcs_bitmask[0x20]; + uint16_t total_vppbs; + uint16_t bound_vppbs; + uint8_t num_hdm_decoders_per_usp; + } QEMU_PACKED *out; + QEMU_BUILD_BUG_ON(sizeof(*out) !=3D 0x49); + + out =3D (struct cxl_fmapi_ident_switch_dev_resp_pl *)payload_out; + *out =3D (struct cxl_fmapi_ident_switch_dev_resp_pl) { + .num_physical_ports =3D num_phys_ports + 1, /* 1 USP */ + .num_vcss =3D 1, /* Not yet support multiple VCS - potentialy tric= ky */ + .active_vcs_bitmask[0] =3D 0x1, + .total_vppbs =3D num_phys_ports + 1, + .bound_vppbs =3D num_phys_ports + 1, + .num_hdm_decoders_per_usp =3D 4, + }; + + /* Depends on the CCI type */ + if (object_dynamic_cast(OBJECT(cci->intf), TYPE_PCIE_PORT)) { + out->ingress_port_id =3D PCIE_PORT(cci->intf)->port; + } else { + /* MCTP? */ + out->ingress_port_id =3D 0; + } + + pci_for_each_device_under_bus(bus, cxl_set_dsp_active_bm, + out->active_port_bitmask); + out->active_port_bitmask[usp->port / 8] |=3D (1 << usp->port % 8); + + *len_out =3D sizeof(*out); + + return CXL_MBOX_SUCCESS; +} /* 8.2.9.2.1 */ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, uint8_t *payload_in, @@ -816,6 +879,8 @@ static const struct cxl_cmd cxl_cmd_set_sw[256][256] = =3D { [LOGS][GET_SUPPORTED] =3D { "LOGS_GET_SUPPORTED", cmd_logs_get_support= ed, 0, 0 }, [LOGS][GET_LOG] =3D { "LOGS_GET_LOG", cmd_logs_get_log, 0x18, 0 }, + [PHYSICAL_SWITCH][IDENTIFY_SWITCH_DEVICE] =3D { "IDENTIFY_SWITCH_DEVIC= E", + cmd_identify_switch_device, 0, 0 }, }; =20 int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, diff --git a/hw/pci-bridge/cxl_downstream.c b/hw/pci-bridge/cxl_downstream.c index 8c0f759add..8d99e1e96d 100644 --- a/hw/pci-bridge/cxl_downstream.c +++ b/hw/pci-bridge/cxl_downstream.c @@ -13,6 +13,7 @@ #include "hw/pci/msi.h" #include "hw/pci/pcie.h" #include "hw/pci/pcie_port.h" +#include "hw/cxl/cxl.h" #include "qapi/error.h" =20 typedef struct CXLDownstreamPort { @@ -23,9 +24,6 @@ typedef struct CXLDownstreamPort { CXLComponentState cxl_cstate; } CXLDownstreamPort; =20 -#define TYPE_CXL_DSP "cxl-downstream" -DECLARE_INSTANCE_CHECKER(CXLDownstreamPort, CXL_DSP, TYPE_CXL_DSP) - #define CXL_DOWNSTREAM_PORT_MSI_OFFSET 0x70 #define CXL_DOWNSTREAM_PORT_MSI_NR_VECTOR 1 #define CXL_DOWNSTREAM_PORT_EXP_OFFSET 0x90 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352288; cv=none; d=zohomail.com; s=zohoarc; b=YAEkLjGQsIyZaRA9R3BnQmJV/QO7/9/3HEYtmfR24P7zmvEF31UA01z3Rvr+9dHAgp7mrw7cZF0nGNDRVeD0P+7aV2pArmjq7Ehl/M7s63d8+jj3X5rF/Ckrr3r3F/QWjPMCZMN4SATMiOSAbiV2MNqq+yzf01D4RFOK5Cja+9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352288; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TacgJjHON2zMurw0kdT8D8vIJYf8KlviQ9Ggn3SKROs=; b=TSz4RPeh10yWFl10oh5llKH1Z+SS3imZnd4MPkpaUy5fQ6Pjob8I9dWYI0d8xfZ95X4/ZTBmFYdaRb8dmfYVKdxPT++yKLBfFXzzLW1QVCleFt+RWyQOrB1myy3hhu6ht2fQz9YG8X6CYrUb2rcOGQqeTphSKttIjkbKvXw9Q5k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352288785516.0859074744066; Tue, 7 Nov 2023 02:18:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J5R-0004Wc-N7; Tue, 07 Nov 2023 05:13:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5Q-0004WB-4k for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5O-0002wu-KP for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:31 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-45-G4J68aW-NNm_n9nVpKihZQ-1; Tue, 07 Nov 2023 05:13:28 -0500 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-32f7943913aso2856765f8f.1 for ; Tue, 07 Nov 2023 02:13:27 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id e12-20020adffd0c000000b0032196c508e3sm1941181wrr.53.2023.11.07.02.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352009; h=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=TacgJjHON2zMurw0kdT8D8vIJYf8KlviQ9Ggn3SKROs=; b=GsVvM4dFtAcxRYXiTmh49FuPMWBVymVu4XsHyHniEqTlwHqDN+BWN2uOILQZge2EKqtFqA PGPOL5hC1cZX7ZzMh9QhtxK/wFv2wnuAbloiPhkqyIRZroZKq74FzB0wOuGqtXqvl+qs+i gT5aLEJP27MFdNA5+r3nIn6fv8dcAx4= X-MC-Unique: G4J68aW-NNm_n9nVpKihZQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699352006; x=1699956806; 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=TacgJjHON2zMurw0kdT8D8vIJYf8KlviQ9Ggn3SKROs=; b=r5R1ACZtVXiLgwaenEP0u7WRu00nW+SPDc9BC9RIcGbEIgBTUkb85mhUDJq2QXHTCF qEUE5NBUVSS54IiHteHtovtVrrJKVlH+rf1anXVfF6kUSntslqG/cqfUedKBPVDhM/sE mKCUEtoyRajZsaafQkSXPCdOITwnz4dyApKLdNfaEi1yaN5Pzo3GuVXoyTDiDzViMaSd /HRgChj6cR3xTzR+HWRmr2p+wPnzPJrMpIaYPZTVdM/wl21EOS/f1kbASdEdvAft+Dbo ZD2nA/Fjw/JO53vI/g6pKpiIJRAkleYG+Co6xd6jBmmbp4RYaxjJ5Gsf5f9LLBFtahsI 4ymQ== X-Gm-Message-State: AOJu0YxgOzVk9QUYWP91dqONJVqwMk8F60f5y8YIF6iosDzMitqQ9Yu/ iadO/1beRkdIcRp8GjUTfVlNBASs+nlwjiwXwCyaXdF/w9HjXcW7kFfJ9dQHWNVmAIE8R408UzD ZCtN8tKVrLHOcvbjo/mr6HAzA7Sec4BGUAQCLECe5NUhav2UowuNjaOb5KN0pdIEsID29 X-Received: by 2002:adf:e543:0:b0:32d:b2e0:ed79 with SMTP id z3-20020adfe543000000b0032db2e0ed79mr22658249wrm.67.1699352006366; Tue, 07 Nov 2023 02:13:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnVOu7VOOsx8p89AEA5YrCBnibAD5+7WZHLNY1RfU0plyB6L0v2gPwDk2KDfqdOO7/eDFdBQ== X-Received: by 2002:adf:e543:0:b0:32d:b2e0:ed79 with SMTP id z3-20020adfe543000000b0032db2e0ed79mr22658237wrm.67.1699352006107; Tue, 07 Nov 2023 02:13:26 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:22 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Marcel Apfelbaum Subject: [PULL 53/63] hw/pci-bridge/cxl_downstream: Set default link width and link speed Message-ID: <314f5033c639ebe8218078a17513935747f15d9d.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352290257100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Without these being set the PCIE Link Capabilities register has invalid values in these two fields. Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-10-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-bridge/cxl_downstream.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/pci-bridge/cxl_downstream.c b/hw/pci-bridge/cxl_downstream.c index 8d99e1e96d..405a133eef 100644 --- a/hw/pci-bridge/cxl_downstream.c +++ b/hw/pci-bridge/cxl_downstream.c @@ -210,6 +210,19 @@ static void cxl_dsp_exitfn(PCIDevice *d) pci_bridge_exitfn(d); } =20 +static void cxl_dsp_instance_post_init(Object *obj) +{ + PCIESlot *s =3D PCIE_SLOT(obj); + + if (!s->speed) { + s->speed =3D QEMU_PCI_EXP_LNK_2_5GT; + } + + if (!s->width) { + s->width =3D QEMU_PCI_EXP_LNK_X1; + } +} + static void cxl_dsp_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); @@ -230,6 +243,7 @@ static const TypeInfo cxl_dsp_info =3D { .name =3D TYPE_CXL_DSP, .instance_size =3D sizeof(CXLDownstreamPort), .parent =3D TYPE_PCIE_SLOT, + .instance_post_init =3D cxl_dsp_instance_post_init, .class_init =3D cxl_dsp_class_init, .interfaces =3D (InterfaceInfo[]) { { INTERFACE_PCIE_DEVICE }, --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352307; cv=none; d=zohomail.com; s=zohoarc; b=PU+r0KxWYwXOP704fpxfm+qtE70HbPvmYU2OO+zJqB8vna5EQIHrR20mTaPCCQ+R8kU3SqekHSvd9SSrZqtM/fmG18Pa1LbY0+oeQ0+2qXDnLWPmDqDT9HZYyCySKGSIfqmF6hlvZdBcnGRRTgV3+Fzg9YJlbVcCwqj4jkcwcWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352307; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=o15ruDZqaFYFg/HLiletSP9urCgLHFyZ9Ye+iXOkypo=; b=NKWK6CYgfSIz3pon2J6/IDfO633DFf+CDmuFw1CMzc9Qd8srfxK6QDK5tx1CffrmdkRE6SOvYDlSC0MX2Vi0ViXY+hdpyput1nnHwlOlIsXat5d+JtKeOX6wBB8aMHuUd0Uql+G0mtY+W0wGj3dQSL604+cbmbKHc60z++koa3A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352307578716.8135741267472; Tue, 7 Nov 2023 02:18:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J5X-0004qa-Qn; Tue, 07 Nov 2023 05:13:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5U-0004eF-Jn for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5S-0002xL-RZ for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:36 -0500 Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-548-nuLSyVyhNJOAAQpWri_48g-1; Tue, 07 Nov 2023 05:13:32 -0500 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2c59a4dcdd0so51379071fa.0 for ; Tue, 07 Nov 2023 02:13:32 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id p6-20020a05600c358600b004053a6b8c41sm14900658wmq.12.2023.11.07.02.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352014; h=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=o15ruDZqaFYFg/HLiletSP9urCgLHFyZ9Ye+iXOkypo=; b=HUSSLvgEahDfMjRbGXYSmcgY5+FQzlgMRleKiPltwLo50OyjSjqVf4HXlFLVjQtn/ZlcY8 MKekidnaJE26XdXoLZfmObOh9cOpveiv+FNwGEgSBHa2uaEMstWGqQM+HNTSMqNtcQgCYR yKU8IKhGpY0sDegqMJ2bG1dMjOonjVo= X-MC-Unique: nuLSyVyhNJOAAQpWri_48g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699352011; x=1699956811; 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=o15ruDZqaFYFg/HLiletSP9urCgLHFyZ9Ye+iXOkypo=; b=CLcv55HyOjY5iCszhUAz0wfZzOhnwGxFKvbJFcSFS57eQ9DdyswBeJG8p4PQhU4uE2 8ydIwe7fmeqZu07cSHy/3ug3nli+CfZaOEmcpvfaXAm7eUhL/c3IYHI5XOLmG4VO+p/H VB7qLWzOxmBzhLnAP/jLZ9M1DQaMRXkfUGG820Fcr2lQ9bEklybIvNGwwix72E5a7dTt xFYdA0J6OcMM17THOcjNM0OKFT/oErfQzgVwtwoDEM5hLZlEFxPhutYr9gryjrjv6FjJ XDxxWhegGJEAo/xYdtJnJVTcLhoaSVdVrhF1YVuOTSf+Mhf9fZ54SEc5CU8k/8ZF7xyM VV6A== X-Gm-Message-State: AOJu0YwmlX5Pt8NRwkK2zhlnPlaZaJUc1WnY32TpkfHWmlgF64iD8qDT eO9fPPdcKhrhOSYFEInDCbuImbJBPJ7+PzagvChK5NNf7YZWgCJ9xh+optoTvSC2vxKg2iS1Pn3 QiOATOBBVE8aPToCoNV1AyDHtIx3puO77CC2m39m0lNaliho9V+WyAUQ/rjhWQvOCqbed X-Received: by 2002:a2e:a98e:0:b0:2bc:c4af:36b9 with SMTP id x14-20020a2ea98e000000b002bcc4af36b9mr30057549ljq.52.1699352010869; Tue, 07 Nov 2023 02:13:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGaANo39hINpnQK0yq1SfiGyAph27fjl0qRC8x3U8HDNQzTj9GKn34QH6x0PTnFxQOm0mvuRA== X-Received: by 2002:a2e:a98e:0:b0:2bc:c4af:36b9 with SMTP id x14-20020a2ea98e000000b002bcc4af36b9mr30057525ljq.52.1699352010449; Tue, 07 Nov 2023 02:13:30 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:26 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 54/63] hw/cxl: Implement Physical Ports status retrieval Message-ID: <892e3479d7283a38b50e06f42624f5a1ce61d24a.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352308524100006 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Add this command for both the Switch CCI in switch upstream ports. Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-11-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 128 +++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 6ada49d37c..de63fc1a28 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -72,6 +72,7 @@ enum { #define CLEAR_POISON 0x2 PHYSICAL_SWITCH =3D 0x51, #define IDENTIFY_SWITCH_DEVICE 0x0 + #define GET_PHYSICAL_PORT_STATE 0x1 }; =20 =20 @@ -320,6 +321,131 @@ static CXLRetCode cmd_identify_switch_device(const st= ruct cxl_cmd *cmd, =20 return CXL_MBOX_SUCCESS; } + +/* CXL r3.0 Section 7.6.7.1.2: Get Physical Port State (Opcode 5101h) */ +static CXLRetCode cmd_get_physical_port_state(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + /* CXL r3.0 Table 7-18: Get Physical Port State Request Payload */ + struct cxl_fmapi_get_phys_port_state_req_pl { + uint8_t num_ports; + uint8_t ports[]; + } QEMU_PACKED *in; + + /* + * CXL r3.0 Table 7-20: Get Physical Port State Port Information Block + * Format + */ + struct cxl_fmapi_port_state_info_block { + uint8_t port_id; + uint8_t config_state; + uint8_t connected_device_cxl_version; + uint8_t rsv1; + uint8_t connected_device_type; + uint8_t port_cxl_version_bitmask; + uint8_t max_link_width; + uint8_t negotiated_link_width; + uint8_t supported_link_speeds_vector; + uint8_t max_link_speed; + uint8_t current_link_speed; + uint8_t ltssm_state; + uint8_t first_lane_num; + uint16_t link_state; + uint8_t supported_ld_count; + } QEMU_PACKED; + + /* CXL r3.0 Table 7-19: Get Physical Port State Response Payload */ + struct cxl_fmapi_get_phys_port_state_resp_pl { + uint8_t num_ports; + uint8_t rsv1[3]; + struct cxl_fmapi_port_state_info_block ports[]; + } QEMU_PACKED *out; + PCIBus *bus =3D &PCI_BRIDGE(cci->d)->sec_bus; + PCIEPort *usp =3D PCIE_PORT(cci->d); + size_t pl_size; + int i; + + in =3D (struct cxl_fmapi_get_phys_port_state_req_pl *)payload_in; + out =3D (struct cxl_fmapi_get_phys_port_state_resp_pl *)payload_out; + + /* Check if what was requested can fit */ + if (sizeof(*out) + sizeof(*out->ports) * in->num_ports > cci->payload_= max) { + return CXL_MBOX_INVALID_INPUT; + } + + /* For success there should be a match for each requested */ + out->num_ports =3D in->num_ports; + + for (i =3D 0; i < in->num_ports; i++) { + struct cxl_fmapi_port_state_info_block *port; + /* First try to match on downstream port */ + PCIDevice *port_dev; + uint16_t lnkcap, lnkcap2, lnksta; + + port =3D &out->ports[i]; + + port_dev =3D pcie_find_port_by_pn(bus, in->ports[i]); + if (port_dev) { /* DSP */ + PCIDevice *ds_dev =3D pci_bridge_get_sec_bus(PCI_BRIDGE(port_d= ev)) + ->devices[0]; + port->config_state =3D 3; + if (ds_dev) { + if (object_dynamic_cast(OBJECT(ds_dev), TYPE_CXL_TYPE3)) { + port->connected_device_type =3D 5; /* Assume MLD for n= ow */ + } else { + port->connected_device_type =3D 1; + } + } else { + port->connected_device_type =3D 0; + } + port->supported_ld_count =3D 3; + } else if (usp->port =3D=3D in->ports[i]) { /* USP */ + port_dev =3D PCI_DEVICE(usp); + port->config_state =3D 4; + port->connected_device_type =3D 0; + } else { + return CXL_MBOX_INVALID_INPUT; + } + + port->port_id =3D in->ports[i]; + /* Information on status of this port in lnksta, lnkcap */ + if (!port_dev->exp.exp_cap) { + return CXL_MBOX_INTERNAL_ERROR; + } + lnksta =3D port_dev->config_read(port_dev, + port_dev->exp.exp_cap + PCI_EXP_LNK= STA, + sizeof(lnksta)); + lnkcap =3D port_dev->config_read(port_dev, + port_dev->exp.exp_cap + PCI_EXP_LNK= CAP, + sizeof(lnkcap)); + lnkcap2 =3D port_dev->config_read(port_dev, + port_dev->exp.exp_cap + PCI_EXP_LN= KCAP2, + sizeof(lnkcap2)); + + port->max_link_width =3D (lnkcap & PCI_EXP_LNKCAP_MLW) >> 4; + port->negotiated_link_width =3D (lnksta & PCI_EXP_LNKSTA_NLW) >> 4; + /* No definition for SLS field in linux/pci_regs.h */ + port->supported_link_speeds_vector =3D (lnkcap2 & 0xFE) >> 1; + port->max_link_speed =3D lnkcap & PCI_EXP_LNKCAP_SLS; + port->current_link_speed =3D lnksta & PCI_EXP_LNKSTA_CLS; + /* TODO: Track down if we can get the rest of the info */ + port->ltssm_state =3D 0x7; + port->first_lane_num =3D 0; + port->link_state =3D 0; + port->port_cxl_version_bitmask =3D 0x2; + port->connected_device_cxl_version =3D 0x2; + } + + pl_size =3D sizeof(*out) + sizeof(*out->ports) * in->num_ports; + *len_out =3D pl_size; + + return CXL_MBOX_SUCCESS; +} + /* 8.2.9.2.1 */ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, uint8_t *payload_in, @@ -881,6 +1007,8 @@ static const struct cxl_cmd cxl_cmd_set_sw[256][256] = =3D { [LOGS][GET_LOG] =3D { "LOGS_GET_LOG", cmd_logs_get_log, 0x18, 0 }, [PHYSICAL_SWITCH][IDENTIFY_SWITCH_DEVICE] =3D { "IDENTIFY_SWITCH_DEVIC= E", cmd_identify_switch_device, 0, 0 }, + [PHYSICAL_SWITCH][GET_PHYSICAL_PORT_STATE] =3D { "SWITCH_PHYSICAL_PORT= _STATS", + cmd_get_physical_port_state, ~0, 0 }, }; =20 int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352457; cv=none; d=zohomail.com; s=zohoarc; b=l6N97CjL6DRDj1WwZbdZVEPSxsEvJRxun0BOiFjwIPiEwYjVnhwEt4tooaaKOuoqv14lsHva0p+kXZV1zRlWzbMWpUDFttljl6ropVAgHzn0/OdJqcBahWMNcC0OpuCarEEk7mhAwbrGcH+cxZsNkgo2y5odaVpMsnOyF3jjFjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352457; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DOMtNCG0j48PYjLMBwp//f827+iY78t4UfoTn9nV4MY=; b=AuMLo+PPsR0oETwEzITtX3OEHkFbxI9cHohQtrsW0Gq51v64QHZanW1UoiGMYUnuflCqfFJV1umTZrja68ssM30xCDikVASQJo2zTRNji4UjaehJpD61R4L4TunXVqDzvqZ34kVHbWoHX4RjoD1S6tx45wZFOTyPQ+wGIQEvllU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169935245787966.02676790671615; Tue, 7 Nov 2023 02:20:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J5h-00056B-MT; Tue, 07 Nov 2023 05:13:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5a-0004yg-Fz for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5W-0002xl-G1 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:41 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-ZO86sv6lMaaY6Q3UBpz5Cw-1; Tue, 07 Nov 2023 05:13:36 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4084a9e637eso35051845e9.2 for ; Tue, 07 Nov 2023 02:13:35 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id j6-20020a5d6046000000b0032fc5f5abafsm1901459wrt.96.2023.11.07.02.13.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352017; h=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=DOMtNCG0j48PYjLMBwp//f827+iY78t4UfoTn9nV4MY=; b=H7mT6mFmi9Z37O6OOXKh/Lj9sLGGZ+dbQ9kOTtLQLPxP5OzV4tMy5fdWDz4Z7risKWsv74 qlCTaNUTNvEpm7bHcjlLbh/+s9+SYi0wkfacAX6ajfp0j4WCKnXGkw2lj323TcEjWSBbW5 WV7oca0xNBmQPv3AV/HCJ4o3ZQi6zhk= X-MC-Unique: ZO86sv6lMaaY6Q3UBpz5Cw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699352014; x=1699956814; 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=DOMtNCG0j48PYjLMBwp//f827+iY78t4UfoTn9nV4MY=; b=sJZB4G29AnoyiPfhlZLOnD7Nhpj4eur1xn6lWKq8oHM2wNBBDtLtUONQHzuwa5/TxU X36oTtYzkLsilNJaLGJy4UmQ64lZrc+4FwMZ0U034AzkYVoSockjkPKAA/SUkSG5D2JG EP8wEFnZJMMdAI6Kyh+aGZ0NRYJHYzvGPaTdnfhhXn5PE5XG0BdpZZVpdXrBBdlVVzaN cWX0R28tY+dSlKbByCKtGHmuihncfscVj/xMTb1RL2XwhIGZUDIEgOLOMg0eSnJhMhGz X9uJNwVwcpCztvv4McMiCSng/6tMmlMTVgpEQAIIH8XoQCrwryRrRwMiGMA01TAu9DXM t6yA== X-Gm-Message-State: AOJu0YzZoPV0UwppuAy9vbFpZbkiLqMWCV4AjlkqkpRCcy/yBtmOgyuT 9rKcKqPKaR0ACQwR58CzX5bCpjVGXK3Py504s/WtT81KyxpdZqW0Q/BMx642PDedZu03eQ/7wpZ KhpX0gUDqq6qzi3wShYx+Am9uIHvgbv1Zvq+XtbXIX7L/IPEx6SSzWwaOAvqM00tpE0mH X-Received: by 2002:a05:600c:4fc8:b0:404:f9c1:d5d7 with SMTP id o8-20020a05600c4fc800b00404f9c1d5d7mr1820537wmq.25.1699352014481; Tue, 07 Nov 2023 02:13:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdM0PNybOIdRFQP61lZTYm7GvzzhA0+f1hLLsBbEefubNaLpxFpUejds/gRjfw5r29UxRxPg== X-Received: by 2002:a05:600c:4fc8:b0:404:f9c1:d5d7 with SMTP id o8-20020a05600c4fc800b00404f9c1d5d7mr1820515wmq.25.1699352014091; Tue, 07 Nov 2023 02:13:34 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:30 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Jonathan Cameron , Fan Ni Subject: [PULL 55/63] hw/cxl/mbox: Add support for background operations Message-ID: <221d2cfbdb5301f8f0cfbf26baf76544a5d71c27.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352459796100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Davidlohr Bueso Support background commands in the mailbox, and update cmd_infostat_bg_op_sts() accordingly. This patch does not implement mbox interrupts upon completion, so the kernel driver must rely on polling to know when the operation is done. Signed-off-by: Davidlohr Bueso Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-12-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-device-utils.c | 24 ++++++++-- hw/cxl/cxl-mailbox-utils.c | 92 ++++++++++++++++++++++++++++++++++++- 3 files changed, 122 insertions(+), 4 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index fa73ed03e5..124ff969ec 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -149,6 +149,16 @@ typedef struct CXLCCI { } cel_log[1 << 16]; size_t cel_size; =20 + /* background command handling (times in ms) */ + struct { + uint16_t opcode; + uint16_t complete_pct; + uint16_t ret_code; /* Current value of retcode */ + uint64_t starttime; + /* set by each bg cmd, cleared by the bg_timer when complete */ + uint64_t runtime; + QEMUTimer *timer; + } bg; size_t payload_max; /* Pointer to device hosting the CCI */ DeviceState *d; diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c index f8938678c7..51466a626b 100644 --- a/hw/cxl/cxl-device-utils.c +++ b/hw/cxl/cxl-device-utils.c @@ -82,6 +82,25 @@ static uint64_t mailbox_reg_read(void *opaque, hwaddr of= fset, unsigned size) case 4: return cxl_dstate->mbox_reg_state32[offset / size]; case 8: + if (offset =3D=3D A_CXL_DEV_BG_CMD_STS) { + uint64_t bg_status_reg; + bg_status_reg =3D FIELD_DP64(0, CXL_DEV_BG_CMD_STS, OP, + cci->bg.opcode); + bg_status_reg =3D FIELD_DP64(bg_status_reg, CXL_DEV_BG_CMD_STS, + PERCENTAGE_COMP, cci->bg.complete_p= ct); + bg_status_reg =3D FIELD_DP64(bg_status_reg, CXL_DEV_BG_CMD_STS, + RET_CODE, cci->bg.ret_code); + /* endian? */ + cxl_dstate->mbox_reg_state64[offset / size] =3D bg_status_reg; + } + if (offset =3D=3D A_CXL_DEV_MAILBOX_STS) { + uint64_t status_reg =3D cxl_dstate->mbox_reg_state64[offset / = size]; + if (cci->bg.complete_pct) { + status_reg =3D FIELD_DP64(status_reg, CXL_DEV_MAILBOX_STS,= BG_OP, + 0); + cxl_dstate->mbox_reg_state64[offset / size] =3D status_reg; + } + } return cxl_dstate->mbox_reg_state64[offset / size]; default: g_assert_not_reached(); @@ -114,8 +133,7 @@ static void mailbox_mem_writeq(uint64_t *reg_state, hwa= ddr offset, case A_CXL_DEV_MAILBOX_CMD: break; case A_CXL_DEV_BG_CMD_STS: - /* BG not supported */ - /* fallthrough */ + break; case A_CXL_DEV_MAILBOX_STS: /* Read only register, will get updated by the state machine */ return; @@ -339,7 +357,7 @@ static void device_reg_init_common(CXLDeviceState *cxl_= dstate) =20 static void mailbox_reg_init_common(CXLDeviceState *cxl_dstate) { - /* 2048 payload size, with no interrupt or background support */ + /* 2048 payload size, with no interrupt */ ARRAY_FIELD_DP32(cxl_dstate->mbox_reg_state32, CXL_DEV_MAILBOX_CAP, PAYLOAD_SIZE, CXL_MAILBOX_PAYLOAD_SHIFT); cxl_dstate->payload_size =3D CXL_MAILBOX_MAX_PAYLOAD_SIZE; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index de63fc1a28..f1226f8f39 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -963,6 +963,8 @@ static CXLRetCode cmd_media_clear_poison(const struct c= xl_cmd *cmd, #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) =20 static const struct cxl_cmd cxl_cmd_set[256][256] =3D { [EVENTS][GET_RECORDS] =3D { "EVENTS_GET_RECORDS", @@ -1011,10 +1013,19 @@ static const struct cxl_cmd cxl_cmd_set_sw[256][256= ] =3D { cmd_get_physical_port_state, ~0, 0 }, }; =20 +/* + * While the command is executing in the background, the device should + * update the percentage complete in the Background Command Status Register + * at least once per second. + */ + +#define CXL_MBOX_BG_UPDATE_FREQ 1000UL + int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, size_t len_in, uint8_t *pl_in, size_t *len_out, uint8_t *pl_out, bool *bg_started) { + int ret; const struct cxl_cmd *cxl_cmd; opcode_handler h; =20 @@ -1031,7 +1042,81 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set= , uint8_t cmd, return CXL_MBOX_INVALID_PAYLOAD_LENGTH; } =20 - return (*h)(cxl_cmd, pl_in, len_in, pl_out, len_out, cci); + /* Only one bg command at a time */ + if ((cxl_cmd->effect & BACKGROUND_OPERATION) && + cci->bg.runtime > 0) { + return CXL_MBOX_BUSY; + } + + ret =3D (*h)(cxl_cmd, pl_in, len_in, pl_out, len_out, cci); + if ((cxl_cmd->effect & BACKGROUND_OPERATION) && + ret =3D=3D CXL_MBOX_BG_STARTED) { + *bg_started =3D true; + } else { + *bg_started =3D false; + } + + /* Set bg and the return code */ + if (*bg_started) { + uint64_t now; + + cci->bg.opcode =3D (set << 8) | cmd; + + cci->bg.complete_pct =3D 0; + cci->bg.ret_code =3D 0; + + now =3D qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); + cci->bg.starttime =3D now; + timer_mod(cci->bg.timer, now + CXL_MBOX_BG_UPDATE_FREQ); + } + + return ret; +} + +static void bg_timercb(void *opaque) +{ + CXLCCI *cci =3D opaque; + CXLDeviceState *cxl_dstate =3D &CXL_TYPE3(cci->d)->cxl_dstate; + uint64_t bg_status_reg =3D 0; + uint64_t now =3D qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); + uint64_t total_time =3D cci->bg.starttime + cci->bg.runtime; + + assert(cci->bg.runtime > 0); + bg_status_reg =3D FIELD_DP64(bg_status_reg, CXL_DEV_BG_CMD_STS, + OP, cci->bg.opcode); + + if (now >=3D total_time) { /* we are done */ + uint64_t status_reg; + uint16_t ret =3D CXL_MBOX_SUCCESS; + + cci->bg.complete_pct =3D 100; + /* Clear bg */ + status_reg =3D FIELD_DP64(0, CXL_DEV_MAILBOX_STS, BG_OP, 0); + cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBOX_STS] =3D status_reg; + + bg_status_reg =3D FIELD_DP64(bg_status_reg, CXL_DEV_BG_CMD_STS, + RET_CODE, ret); + + /* TODO add ad-hoc cmd succesful completion handling */ + + qemu_log("Background command %04xh finished: %s\n", + cci->bg.opcode, + ret =3D=3D CXL_MBOX_SUCCESS ? "success" : "aborted"); + } else { + /* estimate only */ + cci->bg.complete_pct =3D 100 * now / total_time; + timer_mod(cci->bg.timer, now + CXL_MBOX_BG_UPDATE_FREQ); + } + + bg_status_reg =3D FIELD_DP64(bg_status_reg, CXL_DEV_BG_CMD_STS, + PERCENTAGE_COMP, cci->bg.complete_pct); + cxl_dstate->mbox_reg_state64[R_CXL_DEV_BG_CMD_STS] =3D bg_status_reg; + + if (cci->bg.complete_pct =3D=3D 100) { + cci->bg.starttime =3D 0; + /* registers are updated, allow new bg-capable cmds */ + cci->bg.runtime =3D 0; + } } =20 void cxl_init_cci(CXLCCI *cci, size_t payload_max) @@ -1050,6 +1135,11 @@ void cxl_init_cci(CXLCCI *cci, size_t payload_max) } } } + cci->bg.complete_pct =3D 0; + cci->bg.starttime =3D 0; + cci->bg.runtime =3D 0; + cci->bg.timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, + bg_timercb, cci); } =20 void cxl_initialize_mailbox_swcci(CXLCCI *cci, DeviceState *intf, --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352257; cv=none; d=zohomail.com; s=zohoarc; b=MpQsnXJMUAKBWRdwNs0C/1gYPdxCIYVGmaHKix51XmrULt+BnCTkQttBKiTqHARbRsDp1vVLm84l2H4AcxIQ/sTIUQnE4/hBK3uBxiHmgDRQ2s8w2IYdbg62QgMU2izeVMtIMfFUWM8tB1gULGINaxPRtQeTHV5lRpJqI698KAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352257; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aDlG+KSLEUR999MUGfvGQca2+SnwdEFbcYEobQ5t/OA=; b=CM1p2oWosW9/Krpyl2jMNjH1Gj8L0ZozIELCylUNKQsaFw87mIJgcea/tV25VdI8/eN03ubj36gDmSQ169I32c9O30W7WDTCt85k2BERY5JR/o4t5MbW8fWz6Lnk74vLVp417578VG+IZBWJwcu8pcymGHZBKVEG3T24ql0bquU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352257067155.46414290015707; Tue, 7 Nov 2023 02:17:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J5i-00059C-EC; Tue, 07 Nov 2023 05:13:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5c-00053i-6i for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5a-0002y9-Hv for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:43 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-C1820GTMPvi0obUFbJnl5A-1; Tue, 07 Nov 2023 05:13:40 -0500 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-32dee12c5b4so2987787f8f.2 for ; Tue, 07 Nov 2023 02:13:40 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id a15-20020a5d456f000000b0032fab28e9c9sm1910484wrc.73.2023.11.07.02.13.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352021; h=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=aDlG+KSLEUR999MUGfvGQca2+SnwdEFbcYEobQ5t/OA=; b=AFZaO3lJh5KYG9bPuTm94OJX/zLf0jvKMcttKh4kNur6SAgFc6MHaYEz8c+96SBavPoZak oZaFIEV1f8LVxWMNB9WgXOoJtms2p7pxxPwdiKOEwSERCS9xqqbydb8aGzBfwACtPY9p/R cFvsGaBXqbQoX4yASFQmq/eFrO0cBSE= X-MC-Unique: C1820GTMPvi0obUFbJnl5A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699352019; x=1699956819; 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=aDlG+KSLEUR999MUGfvGQca2+SnwdEFbcYEobQ5t/OA=; b=tMl6PEpJxvVYtGfoRftACP7NKkRjDfBFaGJayY1uP23HP2pOhPlm3CG8RmUYqgXpz/ CHpkKChwvwQ+XqW/up3xQj7j0cqjXBakW8akpQ+4eA24XT538U8egtB9viXL4ZrY6dEA NQ9Rrjr5osgfa/34qDNNjk0FHAmGGr+pm+zPbJOJ8OenPN1IZiq9Cd5sNzPAKeXO2D+E l1c1K2mEg06rl/Tq+9SC/ZSzJ9mrESShBDSq3yYE05JjgGUiwO7mllqu0j6h1JSCFalL pZGMt3JP3rl1rCreo+/Opq4LNVkpE9eQV1m4K8ss4Oud0I+t13h5lUfmvvMQ8CN3cbgJ Q7pg== X-Gm-Message-State: AOJu0YzxpMXc6VhlVPENfKVZFwrS6qwpX6VBL+AMddgCoCrtwv6AGGBv zYjCJ+oqsBp8jFEi1kWbFhRa62aQ+ua3MDXWy7M5RlC+znh9nhmqUns52yf3IEbNgSOF7pRhILq v2IwslS8NxOsAbmtCFouSVPTASKeEhstJsobFALugSD+lQYa12b+DSp4RAak93+gMn37S X-Received: by 2002:a05:6000:1842:b0:32f:73d2:f196 with SMTP id c2-20020a056000184200b0032f73d2f196mr24277254wri.35.1699352018959; Tue, 07 Nov 2023 02:13:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBPPQTwFAYqGIMQ68KlIb1p0dJW3MEQlfgOKFcnxqs7aZAZgbgzRTSdJ1b/Etc9uE+XytuOw== X-Received: by 2002:a05:6000:1842:b0:32f:73d2:f196 with SMTP id c2-20020a056000184200b0032f73d2f196mr24277242wri.35.1699352018613; Tue, 07 Nov 2023 02:13:38 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:34 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Jonathan Cameron , Fan Ni Subject: [PULL 56/63] hw/cxl/mbox: Wire up interrupts for background completion Message-ID: <43efb0bfad2b81b32fc19da442cbea2835cf38d4.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352257371100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Davidlohr Bueso Notify when the background operation is done. Note that for now background commands are only supported on the main Type 3 mailbox. Signed-off-by: Davidlohr Bueso Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-13-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-device-utils.c | 10 +++++++++- hw/cxl/cxl-mailbox-utils.c | 31 ++++++++++++++----------------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 124ff969ec..2a813cdddd 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -193,6 +193,7 @@ typedef struct cxl_device_state { struct { MemoryRegion mailbox; uint16_t payload_size; + uint8_t mbox_msi_n; union { uint8_t mbox_reg_state[CXL_MAILBOX_REGISTERS_LENGTH]; uint16_t mbox_reg_state16[CXL_MAILBOX_REGISTERS_LENGTH / 2]; diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c index 51466a626b..61a3c4dc2e 100644 --- a/hw/cxl/cxl-device-utils.c +++ b/hw/cxl/cxl-device-utils.c @@ -357,10 +357,18 @@ static void device_reg_init_common(CXLDeviceState *cx= l_dstate) =20 static void mailbox_reg_init_common(CXLDeviceState *cxl_dstate) { - /* 2048 payload size, with no interrupt */ + const uint8_t msi_n =3D 9; + + /* 2048 payload size */ ARRAY_FIELD_DP32(cxl_dstate->mbox_reg_state32, CXL_DEV_MAILBOX_CAP, PAYLOAD_SIZE, CXL_MAILBOX_PAYLOAD_SHIFT); cxl_dstate->payload_size =3D CXL_MAILBOX_MAX_PAYLOAD_SIZE; + /* irq support */ + ARRAY_FIELD_DP32(cxl_dstate->mbox_reg_state32, CXL_DEV_MAILBOX_CAP, + BG_INT_CAP, 1); + ARRAY_FIELD_DP32(cxl_dstate->mbox_reg_state32, CXL_DEV_MAILBOX_CAP, + MSI_N, msi_n); + cxl_dstate->mbox_msi_n =3D msi_n; } =20 static void memdev_reg_init_common(CXLDeviceState *cxl_dstate) { } diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index f1226f8f39..f3fd97deb5 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -8,6 +8,8 @@ */ =20 #include "qemu/osdep.h" +#include "hw/pci/msi.h" +#include "hw/pci/msix.h" #include "hw/cxl/cxl.h" #include "hw/cxl/cxl_events.h" #include "hw/pci/pci.h" @@ -1076,28 +1078,16 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t se= t, uint8_t cmd, static void bg_timercb(void *opaque) { CXLCCI *cci =3D opaque; - CXLDeviceState *cxl_dstate =3D &CXL_TYPE3(cci->d)->cxl_dstate; - uint64_t bg_status_reg =3D 0; uint64_t now =3D qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); uint64_t total_time =3D cci->bg.starttime + cci->bg.runtime; =20 assert(cci->bg.runtime > 0); - bg_status_reg =3D FIELD_DP64(bg_status_reg, CXL_DEV_BG_CMD_STS, - OP, cci->bg.opcode); =20 if (now >=3D total_time) { /* we are done */ - uint64_t status_reg; uint16_t ret =3D CXL_MBOX_SUCCESS; =20 cci->bg.complete_pct =3D 100; - /* Clear bg */ - status_reg =3D FIELD_DP64(0, CXL_DEV_MAILBOX_STS, BG_OP, 0); - cxl_dstate->mbox_reg_state64[R_CXL_DEV_MAILBOX_STS] =3D status_reg; - - bg_status_reg =3D FIELD_DP64(bg_status_reg, CXL_DEV_BG_CMD_STS, - RET_CODE, ret); - - /* TODO add ad-hoc cmd succesful completion handling */ + cci->bg.ret_code =3D ret; =20 qemu_log("Background command %04xh finished: %s\n", cci->bg.opcode, @@ -1108,14 +1098,21 @@ static void bg_timercb(void *opaque) timer_mod(cci->bg.timer, now + CXL_MBOX_BG_UPDATE_FREQ); } =20 - bg_status_reg =3D FIELD_DP64(bg_status_reg, CXL_DEV_BG_CMD_STS, - PERCENTAGE_COMP, cci->bg.complete_pct); - cxl_dstate->mbox_reg_state64[R_CXL_DEV_BG_CMD_STS] =3D bg_status_reg; - if (cci->bg.complete_pct =3D=3D 100) { + /* TODO: generalize to switch CCI */ + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + CXLDeviceState *cxl_dstate =3D &ct3d->cxl_dstate; + PCIDevice *pdev =3D PCI_DEVICE(cci->d); + cci->bg.starttime =3D 0; /* registers are updated, allow new bg-capable cmds */ cci->bg.runtime =3D 0; + + if (msix_enabled(pdev)) { + msix_notify(pdev, cxl_dstate->mbox_msi_n); + } else if (msi_enabled(pdev)) { + msi_notify(pdev, cxl_dstate->mbox_msi_n); + } } } =20 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352211; cv=none; d=zohomail.com; s=zohoarc; b=WF0UVJ5Ht94FE1vBMX/ZpqrNpyE95xlEAipqwOtbJ6juN31eA4VJfjCg1WiPPPlKa/WsLoc0jujTAacWzxjf6QNg/YP7y0YwNVpuo3JnnrMwf929mqiijj4b9yyp5VK3UON9hRaxjcRtdpkvgAIhGuAJVQhAd5CufIThzggacK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352211; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Cd9W/8zkY194vb6pZir4961+V5rZF/NXCls+/nqUWMo=; b=Zi4fxL2fQwQrrcfeyWY+vzaf/QAfWvnGD1ij2Px5fiHhAlb32ycEEejZSWxPfHBI9oyNIKIiI9MZ5C0n+4x9UBtEFhWHUcNEXEo/F1Fgup4+jyaP+HJK0x+8hzyBZDo8IgNZWUJbDvQtielOS8EcBUNQ24gczucef1jYPPDFsR4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352211303647.8523010131834; Tue, 7 Nov 2023 02:16:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J5o-0005EI-8J; Tue, 07 Nov 2023 05:13:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5j-0005AP-Bt for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5h-0002yV-1h for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:51 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-dexJiD50Nvei_FP2Fu77Sw-1; Tue, 07 Nov 2023 05:13:45 -0500 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-32d9751ca2cso2622217f8f.3 for ; Tue, 07 Nov 2023 02:13:44 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id m5-20020a5d4a05000000b0032db4e660d9sm1947410wrq.56.2023.11.07.02.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352026; h=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=Cd9W/8zkY194vb6pZir4961+V5rZF/NXCls+/nqUWMo=; b=cBMAMtA3bljYuX2MZ8maSaOZ0ycxX2UmT5Ac0AxVZ5DY9rgmKHn66UWf/Iw8d9Bw3FWcJT voexBVg6JTo1xzZnCj4r/UoA04BmJOYpBe4o+4F/sdpLGxBK0soix2rRJmrZ8iGmbrmiXm fZFFSLYsps2aJgDKGo1aJNvtxfeNVwE= X-MC-Unique: dexJiD50Nvei_FP2Fu77Sw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699352023; x=1699956823; 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=Cd9W/8zkY194vb6pZir4961+V5rZF/NXCls+/nqUWMo=; b=HIYsuU/OLrpTcdu9xXzX6Hj7/FHhahJ9+ox8ScGfWDtt6+ncNZVIHwJOAccjfNjgBP BlKEOnuDYZCvurxx9yFIC+QLQyOheO6zxt9M0yvUvFGnEArhAlL9in1D3+JrXsd0s/zE CBxMXI0kvCWP2MGK/GHOH3unttvBeOqJMFBcFS6PCDdBxkrWRJ66GUdp85kMzNBBFlGL 9HlczaDPX0Jz8jwdKvYtmHLkkFkXgqNGmaN3psPylxpCSCV2noVQVkmHiQbOHQs/tJPY N8lvPTuPXLNoVa9e6+OMqmQqR/mAYL5HdjqAnGkh0kz13lvVm4HYnpAMsjipO1wZZJkX JebQ== X-Gm-Message-State: AOJu0YxUtcOY0QhRRlB8GX1tTlajg0ws2q86ZuIeTjjYwIbQ9r7MdM+J SIrMO5Rs+O6+dAsFYy45/UJ9ek4nCyfZQvKPv+/S5NsoYFAG0H/khU2xGCoj3qRblPZ9NVIqF1u WEfgh3SehYndoREEECd0PhonGc6PBghItdopOflpGQ/w8KOaHt4UGrkR4A78UsNWOdI2t X-Received: by 2002:a05:6000:1445:b0:32f:7a07:be07 with SMTP id v5-20020a056000144500b0032f7a07be07mr27217786wrx.17.1699352023384; Tue, 07 Nov 2023 02:13:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvYRQXPkfrGmP6XpXvkbD5RMN4S1jPqzhcJ0vc1h2OW2Tdp2Qp32+UrapviElDShzLBkjYvA== X-Received: by 2002:a05:6000:1445:b0:32f:7a07:be07 with SMTP id v5-20020a056000144500b0032f7a07be07mr27217769wrx.17.1699352023009; Tue, 07 Nov 2023 02:13:43 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:38 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Jonathan Cameron , Fan Ni Subject: [PULL 57/63] hw/cxl: Add support for device sanitation Message-ID: <25a52959f99d6860a186175bda898e3bdb605f91.1699351720.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352212856100007 From: Davidlohr Bueso Make use of the background operations through the sanitize command, per CXL 3.0 specs. Traditionally run times can be rather long, depending on the size of the media. Estimate times based on: https://pmem.io/documents/NVDIMM_DSM_Interface-V1.8.pdf Signed-off-by: Davidlohr Bueso Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-14-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 17 +++++ hw/cxl/cxl-mailbox-utils.c | 140 ++++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3.c | 10 +++ 3 files changed, 167 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 2a813cdddd..70aca9024c 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -343,6 +343,23 @@ REG64(CXL_MEM_DEV_STS, 0) FIELD(CXL_MEM_DEV_STS, MBOX_READY, 4, 1) FIELD(CXL_MEM_DEV_STS, RESET_NEEDED, 5, 3) =20 +static inline void __toggle_media(CXLDeviceState *cxl_dstate, int val) +{ + uint64_t dev_status_reg; + + dev_status_reg =3D FIELD_DP64(0, CXL_MEM_DEV_STS, MEDIA_STATUS, val); + cxl_dstate->mbox_reg_state64[R_CXL_MEM_DEV_STS] =3D dev_status_reg; +} +#define cxl_dev_disable_media(cxlds) \ + do { __toggle_media((cxlds), 0x3); } while (0) +#define cxl_dev_enable_media(cxlds) \ + do { __toggle_media((cxlds), 0x1); } while (0) + +static inline bool sanitize_running(CXLCCI *cci) +{ + return !!cci->bg.runtime && cci->bg.opcode =3D=3D 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 f3fd97deb5..2463f239af 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -18,6 +18,7 @@ #include "qemu/log.h" #include "qemu/units.h" #include "qemu/uuid.h" +#include "sysemu/hostmem.h" =20 #define CXL_CAPACITY_MULTIPLIER (256 * MiB) =20 @@ -68,6 +69,9 @@ enum { #define GET_PARTITION_INFO 0x0 #define GET_LSA 0x2 #define SET_LSA 0x3 + SANITIZE =3D 0x44, + #define OVERWRITE 0x0 + #define SECURE_ERASE 0x1 MEDIA_AND_POISON =3D 0x43, #define GET_POISON_LIST 0x0 #define INJECT_POISON 0x1 @@ -749,6 +753,108 @@ static CXLRetCode cmd_ccls_set_lsa(const struct cxl_c= md *cmd, return CXL_MBOX_SUCCESS; } =20 +/* Perform the actual device zeroing */ +static void __do_sanitization(CXLType3Dev *ct3d) +{ + MemoryRegion *mr; + + if (ct3d->hostvmem) { + mr =3D host_memory_backend_get_memory(ct3d->hostvmem); + if (mr) { + void *hostmem =3D memory_region_get_ram_ptr(mr); + memset(hostmem, 0, memory_region_size(mr)); + } + } + + if (ct3d->hostpmem) { + mr =3D host_memory_backend_get_memory(ct3d->hostpmem); + if (mr) { + void *hostmem =3D memory_region_get_ram_ptr(mr); + memset(hostmem, 0, memory_region_size(mr)); + } + } + if (ct3d->lsa) { + mr =3D host_memory_backend_get_memory(ct3d->lsa); + if (mr) { + void *lsa =3D memory_region_get_ram_ptr(mr); + memset(lsa, 0, memory_region_size(mr)); + } + } +} + +/* + * CXL 3.0 spec section 8.2.9.8.5.1 - Sanitize. + * + * Once the Sanitize command has started successfully, the device shall be + * placed in the media disabled state. If the command fails or is interrup= ted + * by a reset or power failure, it shall remain in the media disabled state + * until a successful Sanitize command has been completed. During this sta= te: + * + * 1. Memory writes to the device will have no effect, and all memory reads + * will return random values (no user data returned, even for locations th= at + * the failed Sanitize operation didn=E2=80=99t sanitize yet). + * + * 2. Mailbox commands shall still be processed in the disabled state, exc= ept + * that commands that access Sanitized areas shall fail with the Media Dis= abled + * error code. + */ +static CXLRetCode cmd_sanitize_overwrite(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + uint64_t total_mem; /* in Mb */ + int secs; + + total_mem =3D (ct3d->cxl_dstate.vmem_size + ct3d->cxl_dstate.pmem_size= ) >> 20; + if (total_mem <=3D 512) { + secs =3D 4; + } else if (total_mem <=3D 1024) { + secs =3D 8; + } else if (total_mem <=3D 2 * 1024) { + secs =3D 15; + } else if (total_mem <=3D 4 * 1024) { + secs =3D 30; + } else if (total_mem <=3D 8 * 1024) { + secs =3D 60; + } else if (total_mem <=3D 16 * 1024) { + secs =3D 2 * 60; + } else if (total_mem <=3D 32 * 1024) { + secs =3D 4 * 60; + } else if (total_mem <=3D 64 * 1024) { + secs =3D 8 * 60; + } else if (total_mem <=3D 128 * 1024) { + secs =3D 15 * 60; + } else if (total_mem <=3D 256 * 1024) { + secs =3D 30 * 60; + } else if (total_mem <=3D 512 * 1024) { + secs =3D 60 * 60; + } else if (total_mem <=3D 1024 * 1024) { + secs =3D 120 * 60; + } else { + secs =3D 240 * 60; /* max 4 hrs */ + } + + /* EBUSY other bg cmds as of now */ + cci->bg.runtime =3D secs * 1000UL; + *len_out =3D 0; + + cxl_dev_disable_media(&ct3d->cxl_dstate); + + if (secs > 2) { + /* sanitize when done */ + return CXL_MBOX_BG_STARTED; + } else { + __do_sanitization(ct3d); + cxl_dev_enable_media(&ct3d->cxl_dstate); + + return CXL_MBOX_SUCCESS; + } +} + /* * This is very inefficient, but good enough for now! * Also the payload will always fit, so no need to handle the MORE flag and @@ -993,6 +1099,8 @@ static const struct cxl_cmd cxl_cmd_set[256][256] =3D { [CCLS][GET_LSA] =3D { "CCLS_GET_LSA", cmd_ccls_get_lsa, 8, 0 }, [CCLS][SET_LSA] =3D { "CCLS_SET_LSA", cmd_ccls_set_lsa, ~0, IMMEDIATE_CONFIG_CHANGE | IMMEDIATE_DATA_CHANGE }, + [SANITIZE][OVERWRITE] =3D { "SANITIZE_OVERWRITE", cmd_sanitize_overwri= te, 0, + IMMEDIATE_DATA_CHANGE | SECURITY_STATE_CHANGE | BACKGROUND_OPERATI= ON }, [MEDIA_AND_POISON][GET_POISON_LIST] =3D { "MEDIA_AND_POISON_GET_POISON= _LIST", cmd_media_get_poison_list, 16, 0 }, [MEDIA_AND_POISON][INJECT_POISON] =3D { "MEDIA_AND_POISON_INJECT_POISO= N", @@ -1050,6 +1158,21 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set= , uint8_t cmd, return CXL_MBOX_BUSY; } =20 + /* forbid any selected commands while overwriting */ + if (sanitize_running(cci)) { + if (h =3D=3D cmd_events_get_records || + h =3D=3D cmd_ccls_get_partition_info || + h =3D=3D cmd_ccls_set_lsa || + h =3D=3D cmd_ccls_get_lsa || + h =3D=3D cmd_logs_get_log || + h =3D=3D cmd_media_get_poison_list || + h =3D=3D cmd_media_inject_poison || + h =3D=3D cmd_media_clear_poison || + h =3D=3D cmd_sanitize_overwrite) { + return CXL_MBOX_MEDIA_DISABLED; + } + } + ret =3D (*h)(cxl_cmd, pl_in, len_in, pl_out, len_out, cci); if ((cxl_cmd->effect & BACKGROUND_OPERATION) && ret =3D=3D CXL_MBOX_BG_STARTED) { @@ -1088,6 +1211,23 @@ static void bg_timercb(void *opaque) =20 cci->bg.complete_pct =3D 100; cci->bg.ret_code =3D ret; + if (ret =3D=3D CXL_MBOX_SUCCESS) { + switch (cci->bg.opcode) { + case 0x4400: /* sanitize */ + { + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + + __do_sanitization(ct3d); + cxl_dev_enable_media(&ct3d->cxl_dstate); + } + break; + case 0x4304: /* TODO: scan media */ + break; + default: + __builtin_unreachable(); + break; + } + } =20 qemu_log("Background command %04xh finished: %s\n", cci->bg.opcode, diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 0529745786..cc8220592f 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -23,6 +23,7 @@ #include "qemu/pmem.h" #include "qemu/range.h" #include "qemu/rcu.h" +#include "qemu/guest-random.h" #include "sysemu/hostmem.h" #include "sysemu/numa.h" #include "hw/cxl/cxl.h" @@ -897,6 +898,11 @@ MemTxResult cxl_type3_read(PCIDevice *d, hwaddr host_a= ddr, uint64_t *data, return MEMTX_ERROR; } =20 + if (sanitize_running(&CXL_TYPE3(d)->cci)) { + qemu_guest_getrandom_nofail(data, size); + return MEMTX_OK; + } + return address_space_read(as, dpa_offset, attrs, data, size); } =20 @@ -913,6 +919,10 @@ MemTxResult cxl_type3_write(PCIDevice *d, hwaddr host_= addr, uint64_t data, return MEMTX_ERROR; } =20 + if (sanitize_running(&CXL_TYPE3(d)->cci)) { + return MEMTX_OK; + } + return address_space_write(as, dpa_offset, attrs, &data, size); } =20 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352268; cv=none; d=zohomail.com; s=zohoarc; b=HbQZkj3a+PIvQK5S2rvvTVe5BzUdvpODSqIQFh0JI+R8Y1OhXZihXbKlpM8B7tNYGHxV5DiCb6gf6RFqfJjNJ4GFlAktWdPUQqifV1v7+usOrdwvqMlopIraFPv3RBuKtD8bLsbrcoiP9+88OJrAGiueMkoNs3gFrP4SyJ1XW78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352268; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hpjO7cqX1+zgW+Zy/8FDSdSBEl0cy3TqXeEl7yOst3E=; b=gYBpNgHH8EVIIWMy3p4JiLdPlHwQdEs4DCJavg1EYw0Hm9sjUPni/KCE1PPUhdmeta+KU6M7oFHLapK/qBwjnL7vEsJYFQ/cescaDKnkURsP8Qb5qg7qCaXDtUJ+++KYY2s2+lBq9jcibP6XofOah7QkFWUl6Mj8wQ97vWepqrQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352268340535.8192720237187; Tue, 7 Nov 2023 02:17:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J68-0005MX-47; Tue, 07 Nov 2023 05:14:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J62-0005Lr-7b for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:14:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5s-0002yy-JV for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:14:09 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-e3V5hI3APMSA-rX997ooIA-1; Tue, 07 Nov 2023 05:13:48 -0500 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-408f9cee5e8so35170575e9.0 for ; Tue, 07 Nov 2023 02:13:48 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id i20-20020a05600c355400b0040839fcb217sm15227132wmq.8.2023.11.07.02.13.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352039; h=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=hpjO7cqX1+zgW+Zy/8FDSdSBEl0cy3TqXeEl7yOst3E=; b=HbzeKnyEaVSiN8wsJNvaPt/Avk/f0qfS21vjUSFZNLyWBOYENYTEtwWX+ngnvGQCLH6jhj GjVKhcJ/SzlGT2UOChAcTWdfcvBma9N6OmCI1FczgdpLxy3gtil9NiQmKLA/tHlkf4RRIN xr4BJhEKGTgxGEjqMCtDsRlVdXgrKAE= X-MC-Unique: e3V5hI3APMSA-rX997ooIA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699352027; x=1699956827; 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=hpjO7cqX1+zgW+Zy/8FDSdSBEl0cy3TqXeEl7yOst3E=; b=VxKm4EruksK9ubbzuO6ghLBAkIGR6/p54crWFHwtFqpjGZF2rB5ZtTSllVKYzK/BdV a4YiQZ1rEehBm1c7OhTU79Fmo9bfNSFpcSZgcoXFRX1x5AYwUnTmUce2zUu0iWNN1ZH4 TAOemxz1jsBHhxhMj3K4LQG643fsXnfYy626YRbUwizBalTTxuFEyEHKJn6rW9f4DRjf ce2KgEG7aI5jw9rF077mvQ7vDOFH22/Ugd+RSst56P69qRsVQrI+1oyD6isNqu89hDgU osGwJdbJC43kEhDUGVR0rtcVW+0i3OO6nJyNlKa03iGh3mEpmnAQwMqj2H+pzSjAwgbc UPKQ== X-Gm-Message-State: AOJu0YzYMSVsk6os+ql00TvnhwEzGWdT31CM1C0MFtWmsvViVMwrMtBz Mj+Cs2dnXJpQN/QcGrBexUHSFluKVPc1I0JW1z+Qqi2cFF53y68mDVSXHJnKo0G0TzAB+q6KNAV S0UYl1KdMwxYHtBatcMmOq3zBhADe+bo3az2zz6v/5kHSg6oqxIDQ2F3w7dx28QX3OR6G X-Received: by 2002:a05:600c:3588:b0:401:eb0:a974 with SMTP id p8-20020a05600c358800b004010eb0a974mr1636954wmq.3.1699352027186; Tue, 07 Nov 2023 02:13:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHD6nj5bJtdYKknzfj1oTRjtJDKsu0Ls9b0H5K9d8cHcnaPrRmRhLg6k5piKwjpDxR9vytp/g== X-Received: by 2002:a05:600c:3588:b0:401:eb0:a974 with SMTP id p8-20020a05600c358800b004010eb0a974mr1636943wmq.3.1699352026890; Tue, 07 Nov 2023 02:13:46 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 58/63] hw/cxl/mbox: Add Get Background Operation Status Command Message-ID: <9dd15ab6e6b35db6ff166e5016b0c2042c5439c6.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352269636100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron For now, provide this command on type 3 main mailbox only. Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-15-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 2463f239af..2b78136588 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -50,6 +50,7 @@ enum { INFOSTAT =3D 0x00, #define IS_IDENTIFY 0x1 + #define BACKGROUND_OPERATION_STATUS 0x2 EVENTS =3D 0x01, #define GET_RECORDS 0x0 #define CLEAR_RECORDS 0x1 @@ -452,6 +453,36 @@ static CXLRetCode cmd_get_physical_port_state(const st= ruct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 +/* CXL r3.0 8.2.9.1.2 */ +static CXLRetCode cmd_infostat_bg_op_sts(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct { + uint8_t status; + uint8_t rsvd; + uint16_t opcode; + uint16_t returncode; + uint16_t vendor_ext_status; + } QEMU_PACKED *bg_op_status; + QEMU_BUILD_BUG_ON(sizeof(*bg_op_status) !=3D 8); + + bg_op_status =3D (void *)payload_out; + memset(bg_op_status, 0, sizeof(*bg_op_status)); + bg_op_status->status =3D cci->bg.complete_pct << 1; + if (cci->bg.runtime > 0) { + bg_op_status->status |=3D 1U << 0; + } + bg_op_status->opcode =3D cci->bg.opcode; + bg_op_status->returncode =3D cci->bg.ret_code; + *len_out =3D sizeof(*bg_op_status); + + return CXL_MBOX_SUCCESS; +} + /* 8.2.9.2.1 */ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, uint8_t *payload_in, @@ -1111,6 +1142,8 @@ static const struct cxl_cmd cxl_cmd_set[256][256] =3D= { =20 static const struct cxl_cmd cxl_cmd_set_sw[256][256] =3D { [INFOSTAT][IS_IDENTIFY] =3D { "IDENTIFY", cmd_infostat_identify, 0, 0 = }, + [INFOSTAT][BACKGROUND_OPERATION_STATUS] =3D { "BACKGROUND_OPERATION_ST= ATUS", + cmd_infostat_bg_op_sts, 0, 0 }, [TIMESTAMP][GET] =3D { "TIMESTAMP_GET", cmd_timestamp_get, 0, 0 }, [TIMESTAMP][SET] =3D { "TIMESTAMP_SET", cmd_timestamp_set, 0, IMMEDIATE_POLICY_CHANGE }, --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352211; cv=none; d=zohomail.com; s=zohoarc; b=BPGFYZKYmbsTxUMniyw+XErkcqL4j2oG0u+iF5sSl0hUiSkf0DoW/Ls6+wbvjVqkzpTzg+7x/7dgtt9ZHNaI9TagRXpQdxwakSx0EoFNvvsEMMtLjgTHjzf0PViP8cseR6sfU2KDnuxh3CK9FJjTeuRmSIv30M0L40H6GsBqJhw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352211; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KQuD0MNvhUhapxwsPVq4rZ3ip7Xjdt38HGbe4S+/MRk=; b=LZyisOU/Vz4gNrMQjvw+vbsIwGFYQPS6ShA2D2B5BUTvKIiNCdzXKuNimxcXurgmbzfDJqzTbU1+R60lxSFVGqqZvVNf6WrOvvZmT1kerxFQdhhZRkFsnGJZBSmogzPmIr0HYD+jgyCGUCdVBy269imP9wayHMcZgi/aYIgTPRk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352211054327.0789108256654; Tue, 7 Nov 2023 02:16:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J5r-0005Hp-JL; Tue, 07 Nov 2023 05:13:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5p-0005Fn-B9 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5n-0002yj-EK for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:13:57 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-684-jT3eK_LVNQSe0VV4-g38qg-1; Tue, 07 Nov 2023 05:13:53 -0500 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-40839252e81so36871875e9.3 for ; Tue, 07 Nov 2023 02:13:53 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id c2-20020a5d4f02000000b00327de0173f6sm1901463wru.115.2023.11.07.02.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352034; h=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=KQuD0MNvhUhapxwsPVq4rZ3ip7Xjdt38HGbe4S+/MRk=; b=EH1+qhGjn3hHkigzIC5BAwt/b3JkJ5322Rvulcxf14MLDrDhvZvpaWNCpob73mjK6Ywf0K WhEtLnLO/P1wWWHanmNX1NszeRxf0zTbmNC8S27aLltje3dEr8R5y9/KdZeFKdJrGRYiBW z25fUKLQE69/KWI58GpFgvUFDYbKJSc= X-MC-Unique: jT3eK_LVNQSe0VV4-g38qg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699352032; x=1699956832; 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=KQuD0MNvhUhapxwsPVq4rZ3ip7Xjdt38HGbe4S+/MRk=; b=ZXnqTSR6cOsVVTw86tOs4GUKSvp51fEckW+a4urQ5khiPHtepGOZTGd016gZhnlojd +b06IAATKRdzvlDOFCWAIzZ1VGN9vymPovCaE2zB0Bhu9wKRTNVcsHMBfpAGE7gf4/4+ M488jQVR3sVhlSNI7dXHkmlro0Fw+xL45+nZzkjCVXhmtO+hciPK9dN7MN699cKkvIgP JSAs066PiDASU4r8vBLSVJNiTvJCRe0tNpD1CeVqLr2uCMOiEAZV6GaW215JOaOJAw0V Ad13oIaP5VsGJjoVWNIhofMWPrBA1UuIfWzKk5ezUP4hDnPGyEIdwaLm4kowdOnwkL53 6Tqg== X-Gm-Message-State: AOJu0Ywc4MYaoJ+9XkRzzEnfqcjScLFx/Pe3bI/W18PwO27NV8kp9jAt qXgp23EoREM4Y4mzmc6tTAgTNENeCLFhlSA8nb+1DndM2g8ByV0e0H/Zcvn+cIjvvkbPhp9GZFM hyx97CxO+Tli8o2nef/yoFusF7LFLa5wwquPqeWBWdAnZVhh+QX2MDqI20IVxbdkb6ssg X-Received: by 2002:a05:600c:45cd:b0:405:1c14:9227 with SMTP id s13-20020a05600c45cd00b004051c149227mr2117701wmo.33.1699352031820; Tue, 07 Nov 2023 02:13:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvm1fwOD13vcdRrDtgyPw7POZHvHsllVAj7jBJIM1xGfjOA1XV6NeFIX+gULVqte23sttNBQ== X-Received: by 2002:a05:600c:45cd:b0:405:1c14:9227 with SMTP id s13-20020a05600c45cd00b004051c149227mr2117682wmo.33.1699352031461; Tue, 07 Nov 2023 02:13:51 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:47 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Gregory Price , Gregory Price , Jonathan Cameron , Fan Ni Subject: [PULL 59/63] hw/cxl/type3: Cleanup multiple CXL_TYPE3() calls in read/write functions 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352212785100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Gregory Price Call CXL_TYPE3 once at top of function to avoid multiple invocations. Signed-off-by: Gregory Price Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-16-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/cxl_type3.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index cc8220592f..a766c64575 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -888,17 +888,18 @@ static int cxl_type3_hpa_to_as_and_dpa(CXLType3Dev *c= t3d, MemTxResult cxl_type3_read(PCIDevice *d, hwaddr host_addr, uint64_t *data, unsigned size, MemTxAttrs attrs) { + CXLType3Dev *ct3d =3D CXL_TYPE3(d); uint64_t dpa_offset =3D 0; AddressSpace *as =3D NULL; int res; =20 - res =3D cxl_type3_hpa_to_as_and_dpa(CXL_TYPE3(d), host_addr, size, + res =3D cxl_type3_hpa_to_as_and_dpa(ct3d, host_addr, size, &as, &dpa_offset); if (res) { return MEMTX_ERROR; } =20 - if (sanitize_running(&CXL_TYPE3(d)->cci)) { + if (sanitize_running(&ct3d->cci)) { qemu_guest_getrandom_nofail(data, size); return MEMTX_OK; } @@ -909,17 +910,18 @@ MemTxResult cxl_type3_read(PCIDevice *d, hwaddr host_= addr, uint64_t *data, MemTxResult cxl_type3_write(PCIDevice *d, hwaddr host_addr, uint64_t data, unsigned size, MemTxAttrs attrs) { + CXLType3Dev *ct3d =3D CXL_TYPE3(d); uint64_t dpa_offset =3D 0; AddressSpace *as =3D NULL; int res; =20 - res =3D cxl_type3_hpa_to_as_and_dpa(CXL_TYPE3(d), host_addr, size, + res =3D cxl_type3_hpa_to_as_and_dpa(ct3d, host_addr, size, &as, &dpa_offset); if (res) { return MEMTX_ERROR; } =20 - if (sanitize_running(&CXL_TYPE3(d)->cci)) { + if (sanitize_running(&ct3d->cci)) { return MEMTX_OK; } =20 --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352395; cv=none; d=zohomail.com; s=zohoarc; b=B7gWssmQKf2547k+6itAQtmrL0gh4yp2twKL5VHHhZEE7F0tt9mwT9FAcz/T3VGUDGaFXf+RdD5vFWYBjnhkQqIdyZEX+zPpAUeKM6y+Mlmn6l+qKdC6WUf1nWH1YovymDMDts4JBJU8Qwg8a3Ixeel04vXR8q1AYy7Crsast+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352395; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=T3yrgrl0RNeE158j1VrBs7i+P3sJ2jz/GXI+atYLlO4=; b=Owe9tvcwYdcncubhUZEy7VXWmZWOinjfx7Kz24O2dttCPEHsLtlqpy8Nn8DrShHpLW7v/t07T+rPfLhQw8jwpUG0BoUO44tF5K1aUR2vySPjPqR8u/JZqRWmWZq96bf0CWVjuzwsc/XrAKUr0sfAlyZTeepgc6f8HQ5Mh3d4r0c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352395321383.39549430135673; Tue, 7 Nov 2023 02:19:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J5v-0005KV-Tm; Tue, 07 Nov 2023 05:14:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5s-0005Jn-L9 for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:14:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5q-0002yu-Vh for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:14:00 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-509-pmBxll1SPwi3QO5_JsyDwQ-1; Tue, 07 Nov 2023 05:13:56 -0500 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4091c9bdb8eso39683545e9.1 for ; Tue, 07 Nov 2023 02:13:56 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id z2-20020adfec82000000b003232380ffd5sm1923146wrn.106.2023.11.07.02.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352038; h=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=T3yrgrl0RNeE158j1VrBs7i+P3sJ2jz/GXI+atYLlO4=; b=OG7RUJgLO89skzjk6rUIC+ruJ4mnqEKNfpyjw6XAS5CQIzwgbglH9faAsD+FlnxDD1ZJvE /H+2n0NEgO6wboZDuNoWy3+dlvCdh6Zh0n3sdfptBRhK//8TjfZSO5iPhmuhVg36Kz5/vB 53vHSbQxPFS4TQAxcrJI8MBrH9tPVdY= X-MC-Unique: pmBxll1SPwi3QO5_JsyDwQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699352035; x=1699956835; 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=T3yrgrl0RNeE158j1VrBs7i+P3sJ2jz/GXI+atYLlO4=; b=MpI3JsldpWnRrOUmtlTJC9luIq4mjQClhkyVds+hCH0wP4kjb4Cfuwyu/gXvId71z/ 2WDdHRoKN2NsAZOTqY/7C+6I9XLHmzq6Ldsr2ZFFrPiXnKy4TRfEq3s7xQU2+GG8Ol7M v+IAkKTjJr2GauoGvI5SxmPYufTxHreCKq7Jm9ItZVEB5h+TyE7w4tDlrlDGDw29A3m8 mvdW1lX+n5Bq5N5Li7YUKGf06PhxMCtelh+JXPVnD/3/a0xtWeHVykPoQBc6oh7RP86r 4d+XCyx7xKeozGkRk/hpdPuOWBeT9OQMYtqV9qb6Av2r9hIILfoAA10FptWKIpwZzkLt 6ztg== X-Gm-Message-State: AOJu0YxJJhY7mUzWEBegAiEUhP39lXjVIvjUeqDUk2Kzq2XGmVrkHbWw bddAV7EaCx8qFABNVZWH3Kvr2rmMA/Kg8nDGpk9X91lpEnxwBa6CZVNbDHr1wCunvqsX3vVGpun rBBxVNeL7LgF8T0FFaRmM7FWpHr2uQB8SKxZTKzfolD8k/sEFtssBuna9qNo3C989bJ4Q X-Received: by 2002:a05:600c:1c88:b0:403:c70b:b688 with SMTP id k8-20020a05600c1c8800b00403c70bb688mr2508416wms.6.1699352035302; Tue, 07 Nov 2023 02:13:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlOMJI+8W9imy3CGGC/+bkkM98TG1diHkXe09GmjgFY6NrcGfqSLsPaZ28CFGwUG+K1ye0EA== X-Received: by 2002:a05:600c:1c88:b0:403:c70b:b688 with SMTP id k8-20020a05600c1c8800b00403c70bb688mr2508393wms.6.1699352034971; Tue, 07 Nov 2023 02:13:54 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 60/63] hw/cxl: Add dummy security state get Message-ID: <44e4b316e4bf8f7327f3917c25aae38172695680.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352396536100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Needed to allow the santize comamnds to be tested with proposed Linux Kernel support. Default value + no control of the security state will work for no= w. Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-17-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 2b78136588..693c2cbdcd 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -73,6 +73,8 @@ enum { SANITIZE =3D 0x44, #define OVERWRITE 0x0 #define SECURE_ERASE 0x1 + PERSISTENT_MEM =3D 0x45, + #define GET_SECURITY_STATE 0x0 MEDIA_AND_POISON =3D 0x43, #define GET_POISON_LIST 0x0 #define INJECT_POISON 0x1 @@ -886,6 +888,19 @@ static CXLRetCode cmd_sanitize_overwrite(const struct = cxl_cmd *cmd, } } =20 +static CXLRetCode cmd_get_security_state(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + uint32_t *state =3D (uint32_t *)payload_out; + + *state =3D 0; + *len_out =3D 4; + return CXL_MBOX_SUCCESS; +} /* * This is very inefficient, but good enough for now! * Also the payload will always fit, so no need to handle the MORE flag and @@ -1132,6 +1147,8 @@ static const struct cxl_cmd cxl_cmd_set[256][256] =3D= { ~0, IMMEDIATE_CONFIG_CHANGE | IMMEDIATE_DATA_CHANGE }, [SANITIZE][OVERWRITE] =3D { "SANITIZE_OVERWRITE", cmd_sanitize_overwri= te, 0, IMMEDIATE_DATA_CHANGE | SECURITY_STATE_CHANGE | BACKGROUND_OPERATI= ON }, + [PERSISTENT_MEM][GET_SECURITY_STATE] =3D { "GET_SECURITY_STATE", + cmd_get_security_state, 0, 0 }, [MEDIA_AND_POISON][GET_POISON_LIST] =3D { "MEDIA_AND_POISON_GET_POISON= _LIST", cmd_media_get_poison_list, 16, 0 }, [MEDIA_AND_POISON][INJECT_POISON] =3D { "MEDIA_AND_POISON_INJECT_POISO= N", --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352658; cv=none; d=zohomail.com; s=zohoarc; b=WtQeww+Rito0r429AwI8wkNcb4Ms/B9kKY5MtjaIF9LPY3g4K8nEgQT4LNL+gnclqyRxwM+K4srmfjg68xG3AXfXYJ+fuwb01Ly4A+YPdGXHpSEuwbVI0+A13OphvUC74+Gcouh/TGjvVci/xmHTSH7hJaYnCAvn2eZ4JqEH/Y0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352658; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h6V1LJj1Apk6QlNSZxAM3YnC4nWhgSQdoGTs1SUHLn0=; b=JT9UgHccYhM++YVC9oWcLwVNwU3U/wrSfKv7q57ysTTvDKXhTp/pBsIpNx79oGVdmx9ptEN9w4Vkk0t7UwfmMazS3Q9phWdoHoyhRjVCTGCZ2Kq3vU2a3/o/9CF7Ys513jxEOk60yv0IjHuKAcp6N5aL1vvZenLCRNI4uN93vC0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352658553918.2533764033843; Tue, 7 Nov 2023 02:24:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J62-0005Lp-BX; Tue, 07 Nov 2023 05:14:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5w-0005Kn-7S for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:14:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J5u-0002z9-9G for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:14:03 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-gOagPDn4MB6WFl77e091ag-1; Tue, 07 Nov 2023 05:14:00 -0500 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-32fd35e88fcso1201679f8f.1 for ; Tue, 07 Nov 2023 02:14:00 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id m2-20020adffe42000000b0032dab20e773sm1911984wrs.69.2023.11.07.02.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:13:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352041; h=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=h6V1LJj1Apk6QlNSZxAM3YnC4nWhgSQdoGTs1SUHLn0=; b=UofbzWI8QpyrNkjvYINXuD1OsBdazfdeo/K7ugBNyc76wPWJofvxeDhP7gs12CGRNNi8zD hMa6LYDXyxnDvE6K3JtahHo5JG4FuxHF2fhLyvoAZrIm19njJ3bEmNi5npcrMqk0PhgZGx iHzAPZ6zNS80jL2e/qUROgFoSNCL4xo= X-MC-Unique: gOagPDn4MB6WFl77e091ag-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699352038; x=1699956838; 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=h6V1LJj1Apk6QlNSZxAM3YnC4nWhgSQdoGTs1SUHLn0=; b=C4cPjQRMsWCIsP5ukTAZW8McTX3BomLqle4I9paFpKsC5EC/M4r7Opc/yhqhDKl5EV 0ZTK9vaOAMutIDdRLiHyDAqDZTmRsq6HnKgQZ9irCmfnpgPc3AeQXpKvw7qrWxvzlLuA 7JUNiP4Z3iS99jDF4vVeYpstlXyzvbAEeEjw/bXgEP3wWEfE/dRuxSV2sDga+boIKZUG KvPsUz54H29t6Z7VhKxfTidm0oSyFIo1uao3QXMBSDWmTOggc9md5AZLtbNGanZ63ERb BVoc97AztNGyP5+/her1qJJnoKI5STlxxlikfoO/wt1z99D4YwFGi8tVnaheUdpHzSek MgpQ== X-Gm-Message-State: AOJu0YxyTMrJ7K2kmDNI1SG3qSwTonzFx9pU10p/NVNDTliGYjr3PIHq RNqxYlHQ6FGstjMsttrTN8uWYGKSAR0Y4p2oM8Ag+iBVPg5J+SEIq7xocibR+hPSifmvPoVzssh OS98NklIqjyB1vK4sRJjri/wOW24YgdADi/oycW5L6CSy/FwG8KSfp/n27UPsskqQVEYo X-Received: by 2002:a05:6000:b8d:b0:32d:9395:dec6 with SMTP id dl13-20020a0560000b8d00b0032d9395dec6mr23208717wrb.67.1699352038564; Tue, 07 Nov 2023 02:13:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDWh3LhN3goX6/gvfOUaEDECNpOwB92K8VMdLU3Zq6OSv+xzdnUgP7e790c7hIu/JsJlQR/w== X-Received: by 2002:a05:6000:b8d:b0:32d:9395:dec6 with SMTP id dl13-20020a0560000b8d00b0032d9395dec6mr23208699wrb.67.1699352038257; Tue, 07 Nov 2023 02:13:58 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 61/63] hw/cxl: Add tunneled command support to mailbox for switch cci. Message-ID: <004e3a93b814ca2d13ee2feb1f9ebacef6c83b9e.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352660615100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron This implementation of tunneling makes the choice that our Type 3 device is a Logical Device (LD) of a Multi-Logical Device (MLD) that just happens to only have one LD for now. Tunneling is supported from a Switch Mailbox CCI (and shortly via MCTP over I2C connected to the switch MCTP CCI) via an outer level to the FM owned LD in the MLD Type 3 device. From there an inner tunnel may be used to access particular LDs. Protocol wise, the following is what happens in a real system but we don't emulate the transports - just the destinations and the payloads. ( Host -> Switch Mailbox CCI - in band FM-API mailbox command or Host -> Switch MCTP CCI - MCTP over I2C using the CXL FM-API MCTP Binding. ) then (if a tunnel command) Switch -> Type 3 FM Owned LD - MCTP over PCI VDM using the CXL FM-API binding (addressed by switch port) then (if unwrapped command also a tunnel command) Type 3 FM Owned LD to LD0 via internal transport (addressed by LD number) or (added shortly) Host to Type 3 FM Owned MCTP CCI - MCTP over I2C using the CXL FM-API MCTP Binding. then (if unwrapped comand is a tunnel comamnd) Type 3 FM Owned LD to LD0 via internal transport. (addressed by LD number) It is worth noting that the tunneling commands over PCI VDM presumably use the appropriate MCTP binding depending on opcode. This may be the CXL FMAPI binding or the CXL Memory Device Binding. Additional commands will need to be added to make this useful beyond testing the tunneling works. Signed-off-by: Jonathan Cameron Message-Id: <20231023160806.13206-18-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 | 162 ++++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3.c | 11 +++ 3 files changed, 182 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 70aca9024c..61b7f897f7 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -279,6 +279,12 @@ int cxl_process_cci_message(CXLCCI *cci, uint8_t set, = uint8_t cmd, size_t len_in, uint8_t *pl_in, size_t *len_out, uint8_t *pl_out, bool *bg_started); +void cxl_initialize_t3_fm_owned_ld_mctpcci(CXLCCI *cci, DeviceState *d, + DeviceState *intf, + size_t payload_max); + +void cxl_initialize_t3_ld_cci(CXLCCI *cci, DeviceState *d, + DeviceState *intf, size_t payload_max); =20 #define cxl_device_cap_init(dstate, reg, cap_id, ver) = \ do { = \ @@ -397,6 +403,9 @@ struct CXLType3Dev { CXLComponentState cxl_cstate; CXLDeviceState cxl_dstate; CXLCCI cci; /* Primary PCI mailbox CCI */ + /* Always intialized as no way to know if a VDM might show up */ + CXLCCI vdm_fm_owned_ld_mctp_cci; + CXLCCI ld0_cci; =20 /* DOE */ DOECap doe_cdat; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 693c2cbdcd..b365575097 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -82,8 +82,132 @@ enum { PHYSICAL_SWITCH =3D 0x51, #define IDENTIFY_SWITCH_DEVICE 0x0 #define GET_PHYSICAL_PORT_STATE 0x1 + TUNNEL =3D 0x53, + #define MANAGEMENT_COMMAND 0x0 }; =20 +/* CCI Message Format CXL r3.0 Figure 7-19 */ +typedef struct CXLCCIMessage { + uint8_t category; +#define CXL_CCI_CAT_REQ 0 +#define CXL_CCI_CAT_RSP 1 + uint8_t tag; + uint8_t resv1; + uint8_t command; + uint8_t command_set; + uint8_t pl_length[3]; + uint16_t rc; + uint16_t vendor_specific; + uint8_t payload[]; +} QEMU_PACKED CXLCCIMessage; + +/* This command is only defined to an MLD FM Owned LD or an MHD */ +static CXLRetCode cmd_tunnel_management_cmd(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + PCIDevice *tunnel_target; + CXLCCI *target_cci; + struct { + uint8_t port_or_ld_id; + uint8_t target_type; + uint16_t size; + CXLCCIMessage ccimessage; + } QEMU_PACKED *in; + struct { + uint16_t resp_len; + uint8_t resv[2]; + CXLCCIMessage ccimessage; + } QEMU_PACKED *out; + size_t pl_length, length_out; + bool bg_started; + int rc; + + if (cmd->in < sizeof(*in)) { + return CXL_MBOX_INVALID_INPUT; + } + in =3D (void *)payload_in; + out =3D (void *)payload_out; + + /* Enough room for minimum sized message - no payload */ + if (in->size < sizeof(in->ccimessage)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + /* Length of input payload should be in->size + a wrapping tunnel head= er */ + if (in->size !=3D len_in - offsetof(typeof(*out), ccimessage)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + if (in->ccimessage.category !=3D CXL_CCI_CAT_REQ) { + return CXL_MBOX_INVALID_INPUT; + } + + if (in->target_type !=3D 0) { + qemu_log_mask(LOG_UNIMP, + "Tunneled Command sent to non existent FM-LD"); + return CXL_MBOX_INVALID_INPUT; + } + + /* + * Target of a tunnel unfortunately depends on type of CCI readint + * the message. + * If in a switch, then it's the port number. + * If in an MLD it is the ld number. + * If in an MHD target type indicate where we are going. + */ + if (object_dynamic_cast(OBJECT(cci->d), TYPE_CXL_TYPE3)) { + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + if (in->port_or_ld_id !=3D 0) { + /* Only pretending to have one for now! */ + return CXL_MBOX_INVALID_INPUT; + } + target_cci =3D &ct3d->ld0_cci; + } else if (object_dynamic_cast(OBJECT(cci->d), TYPE_CXL_USP)) { + CXLUpstreamPort *usp =3D CXL_USP(cci->d); + + tunnel_target =3D pcie_find_port_by_pn(&PCI_BRIDGE(usp)->sec_bus, + in->port_or_ld_id); + if (!tunnel_target) { + return CXL_MBOX_INVALID_INPUT; + } + tunnel_target =3D + pci_bridge_get_sec_bus(PCI_BRIDGE(tunnel_target))->devices[0]; + if (!tunnel_target) { + return CXL_MBOX_INVALID_INPUT; + } + if (object_dynamic_cast(OBJECT(tunnel_target), TYPE_CXL_TYPE3)) { + CXLType3Dev *ct3d =3D CXL_TYPE3(tunnel_target); + /* Tunneled VDMs always land on FM Owned LD */ + target_cci =3D &ct3d->vdm_fm_owned_ld_mctp_cci; + } else { + return CXL_MBOX_INVALID_INPUT; + } + } else { + return CXL_MBOX_INVALID_INPUT; + } + + pl_length =3D in->ccimessage.pl_length[2] << 16 | + in->ccimessage.pl_length[1] << 8 | in->ccimessage.pl_length[0]; + rc =3D cxl_process_cci_message(target_cci, + in->ccimessage.command_set, + in->ccimessage.command, + pl_length, in->ccimessage.payload, + &length_out, out->ccimessage.payload, + &bg_started); + /* Payload should be in place. Rest of CCI header and needs filling */ + out->resp_len =3D length_out + sizeof(CXLCCIMessage); + st24_le_p(out->ccimessage.pl_length, length_out); + out->ccimessage.rc =3D rc; + out->ccimessage.category =3D CXL_CCI_CAT_RSP; + out->ccimessage.command =3D in->ccimessage.command; + out->ccimessage.command_set =3D in->ccimessage.command_set; + out->ccimessage.tag =3D in->ccimessage.tag; + *len_out =3D length_out + sizeof(*out); + + return CXL_MBOX_SUCCESS; +} =20 static CXLRetCode cmd_events_get_records(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_i= n, @@ -1171,6 +1295,8 @@ static const struct cxl_cmd cxl_cmd_set_sw[256][256] = =3D { cmd_identify_switch_device, 0, 0 }, [PHYSICAL_SWITCH][GET_PHYSICAL_PORT_STATE] =3D { "SWITCH_PHYSICAL_PORT= _STATS", cmd_get_physical_port_state, ~0, 0 }, + [TUNNEL][MANAGEMENT_COMMAND] =3D { "TUNNEL_MANAGEMENT_COMMAND", + cmd_tunnel_management_cmd, ~0, 0 }, }; =20 /* @@ -1347,3 +1473,39 @@ void cxl_initialize_mailbox_t3(CXLCCI *cci, DeviceSt= ate *d, size_t payload_max) cci->intf =3D d; cxl_init_cci(cci, payload_max); } + +static const struct cxl_cmd cxl_cmd_set_t3_ld[256][256] =3D { + [INFOSTAT][IS_IDENTIFY] =3D { "IDENTIFY", cmd_infostat_identify, 0, 0 = }, + [LOGS][GET_SUPPORTED] =3D { "LOGS_GET_SUPPORTED", cmd_logs_get_support= ed, 0, + 0 }, + [LOGS][GET_LOG] =3D { "LOGS_GET_LOG", cmd_logs_get_log, 0x18, 0 }, +}; + +void cxl_initialize_t3_ld_cci(CXLCCI *cci, DeviceState *d, DeviceState *in= tf, + size_t payload_max) +{ + cci->cxl_cmd_set =3D cxl_cmd_set_t3_ld; + cci->d =3D d; + cci->intf =3D intf; + cxl_init_cci(cci, payload_max); +} + +static const struct cxl_cmd cxl_cmd_set_t3_fm_owned_ld_mctp[256][256] =3D { + [INFOSTAT][IS_IDENTIFY] =3D { "IDENTIFY", cmd_infostat_identify, 0, 0= }, + [LOGS][GET_SUPPORTED] =3D { "LOGS_GET_SUPPORTED", cmd_logs_get_support= ed, 0, + 0 }, + [LOGS][GET_LOG] =3D { "LOGS_GET_LOG", cmd_logs_get_log, 0x18, 0 }, + [TIMESTAMP][GET] =3D { "TIMESTAMP_GET", cmd_timestamp_get, 0, 0 }, + [TUNNEL][MANAGEMENT_COMMAND] =3D { "TUNNEL_MANAGEMENT_COMMAND", + cmd_tunnel_management_cmd, ~0, 0 }, +}; + +void cxl_initialize_t3_fm_owned_ld_mctpcci(CXLCCI *cci, DeviceState *d, + DeviceState *intf, + size_t payload_max) +{ + cci->cxl_cmd_set =3D cxl_cmd_set_t3_fm_owned_ld_mctp; + cci->d =3D d; + cci->intf =3D intf; + cxl_init_cci(cci, payload_max); +} diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index a766c64575..52647b4ac7 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -936,6 +936,17 @@ static void ct3d_reset(DeviceState *dev) =20 cxl_component_register_init_common(reg_state, write_msk, CXL2_TYPE3_DE= VICE); cxl_device_register_init_t3(ct3d); + + /* + * Bring up an endpoint to target with MCTP over VDM. + * This device is emulating an MLD with single LD for now. + */ + cxl_initialize_t3_fm_owned_ld_mctpcci(&ct3d->vdm_fm_owned_ld_mctp_cci, + DEVICE(ct3d), DEVICE(ct3d), + 512); /* Max payload made up */ + cxl_initialize_t3_ld_cci(&ct3d->ld0_cci, DEVICE(ct3d), DEVICE(ct3d), + 512); /* Max payload made up */ + } =20 static Property ct3_props[] =3D { --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352479; cv=none; d=zohomail.com; s=zohoarc; b=e9mAFZMEdbqR3Z6FkE+RXrijkwZWxELQA2IVMyjd1Tjq2nVe3XG0bYWsle5FgCMcC6riNqNTo/d/B/KHos/uxB8q6fxGThZKxGXMglL56itj+jBvMXuvjWqM9RywGvHHXNOa61xKFH7fry5ZekOjc6fBMge1f80dJ1fzP3W/cmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352479; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YEPOijjZL1kA2zDdRTW73xdfs8GU4Xo0XUpXURKwEzo=; b=QuBU5BnYW+7Cq+89a5raEesp97/jfvHxDEx2F3TU1zuBhJ8e+ruwHL+v7B3Dyl1vjepCplWOPup7ZvkeyL9HQuD4cXmUA8TCpUgrxKEMmamAyBlxnW46DHlM9V8Pajh3MfmajDcYykkBXlgCmNNwBaSJBQgYlFG0yclhOUXGU4k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352479405399.49454104225333; Tue, 7 Nov 2023 02:21:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J6F-0005eu-NC; Tue, 07 Nov 2023 05:14:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J6C-0005aR-If for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:14:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J6A-00033b-Ot for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:14:20 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-594-hqEwXPbUPGeRuN8tSI5aDw-1; Tue, 07 Nov 2023 05:14:07 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-32f7384d5a2so2648760f8f.3 for ; Tue, 07 Nov 2023 02:14:05 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id e12-20020adffd0c000000b0032196c508e3sm1942587wrr.53.2023.11.07.02.14.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:14:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352058; h=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=YEPOijjZL1kA2zDdRTW73xdfs8GU4Xo0XUpXURKwEzo=; b=AZpRLVxBTFjKB6x8M8YAQgHZ6dMEmbjfcA3fvf/+i7kikxeT6mHD8xf+P8css1DX+JKEc+ 0WROKpLogWa8w0JITiiDosiQbmQW1nSWNBOUEuuPOxf6kS/txaNgf+0hzEbYjet3igMvQg T5Z9phu9B6Ew8mUdVGVz5fuEIL2/ti4= X-MC-Unique: hqEwXPbUPGeRuN8tSI5aDw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699352044; x=1699956844; 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=YEPOijjZL1kA2zDdRTW73xdfs8GU4Xo0XUpXURKwEzo=; b=YNxtAE/T/vOZzIfgLZch9kaRpH51NTHJbIBBPx33ioAELRu0UbHiUQqXdJtUte/9Cn 1hDVBuMFo+F4JlRMNlChOVshig/4OR31QfrcFbh3rIsu1HbiX1iOYuKUeQr1DSAV4mYG N2pTnvXrNi3U6depPkazjv1mPIBVLjojYpY8HTLOUkifX39ngiD6LJ8s4jb4jZigEO4H 5hKC9X+hrlZJPIickInaqIdsYpoQseJvzwd7luqzzTRZ96c96kN5okcPhghBxLucAnr9 kw9E4IgvCIdIgH+4wfnowuVVH7vcKkibxwbahpTeCIftvkOK37+Bx6wC4z4c1sKdrQjb CpgA== X-Gm-Message-State: AOJu0YwDjLsaITPZy53snNTWadrYPqI8bUkKC12tqDp9FTvSkcrEgtWj VxpZATqLHH0eeGU0EV1LBVGzV77OThsFDfYIpmlmnTdQCmEh7658ZAF/3QPNLd3P29kALRHdTc6 jsWnorN7fikP9SCH7NDiGkNDBT+gXC8Pwp1B2sz0ccpUhrFLMARw6tVOEcL6oKqVI+UNy X-Received: by 2002:a5d:6dae:0:b0:32f:7867:112 with SMTP id u14-20020a5d6dae000000b0032f78670112mr25048321wrs.13.1699352044327; Tue, 07 Nov 2023 02:14:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IExKkQrV4S28CoIB0QM+lL7BXx18WQn28OvYKx+N/aA5+VYjiFU/gIS9bOQJgJpzLfQmuhSlQ== X-Received: by 2002:a5d:6dae:0:b0:32f:7867:112 with SMTP id u14-20020a5d6dae000000b0032f78670112mr25048294wrs.13.1699352043890; Tue, 07 Nov 2023 02:14:03 -0800 (PST) Date: Tue, 7 Nov 2023 05:13:58 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ani Sinha , jusual@redhat.com, imammedo@redhat.com, Cleber Rosa , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Beraldo Leal Subject: [PULL 62/63] acpi/tests/avocado/bits: enforce 32-bit SMBIOS entry point 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352480177100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ani Sinha QEMU defaults to 64-bit entry point since the following commit bf376f3020 ("hw/i386/pc: Default to use SMBIOS 3.0 for newer machine models= ") The above change is applicable for all newer machine versions from version = 8.1 and newer. i440fx and q35 machine versions 8.0 and older still use 32-bit e= ntry points. Unfortunately, bits currently does not recognize 64-bit entry points and he= nce is not able to parse SMBIOS tables. Therefore, we need to enforce 32-bit SMBIOS entry point in QEMU command line so that bits is able to parse the SMBIOS tables. Once we implement the support in bits to parse 64-bit entry points, we can remove the extra command line that is passed to enforce a 32-bit entry poin= t. The support can be added to the following smbios test script: tests/avocado/acpi-bits/bits-tests/smbios.py2 in QEMU repository. CC: jusual@redhat.com CC: imammedo@redhat.com Signed-off-by: Ani Sinha Message-Id: <20231027032120.6012-2-anisinha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/avocado/acpi-bits.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/avocado/acpi-bits.py b/tests/avocado/acpi-bits.py index eca13dc518..042007b0b8 100644 --- a/tests/avocado/acpi-bits.py +++ b/tests/avocado/acpi-bits.py @@ -380,6 +380,11 @@ def test_acpi_smbios_bits(self): # consistent in terms of timing. smilatency tests have consistent # timing requirements. self._vm.add_args('-icount', 'auto') + # currently there is no support in bits for recognizing 64-bit SMB= IOS + # entry points. QEMU defaults to 64-bit entry points since the + # upstream commit bf376f3020 ("hw/i386/pc: Default to use SMBIOS 3= .0 + # for newer machine models"). Therefore, enforce 32-bit entry poin= t. + self._vm.add_args('-machine', 'smbios-entry-point-type=3D32') =20 args =3D " ".join(str(arg) for arg in self._vm.base_args()) + \ " " + " ".join(str(arg) for arg in self._vm.args) --=20 MST From nobody Fri May 17 12:13:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699352548; cv=none; d=zohomail.com; s=zohoarc; b=DfqtqENA7OqPedIU2QhLwjzQIdjhiJ0EZEKa+elvSwjB5d8rSu018iFC30mtRNChQWSSZr/F9WnWopYUsgLUksWaNedcaeP8WBfKxHZNG/x9hETKcOSa5rYy6Sx6a0GJlB5QQiSgTBvYNIg/ypBH+h4LpMmrjGqXQmYtMmQN63U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699352548; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Cq8e/T3fhqKdlArKCJAyjRr/9dufWVuRJaWAjpre1Es=; b=EFjgRVS0mHnfZyF7EeypGb5YapN9JeqgdhdNS8hOLXgBQ0LzWrH+bjeEW2eSfbR20fFfOmndH5Eku0k8VZ2VtclmKsVlMVgfxBn7z1NrpCb2MIiXVhT5glDzniZZ0SDDD7p3INlmvAOVVuIi9HvVtWmboPrRiFD/qKdHKW/qziw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699352547637276.4002224197052; Tue, 7 Nov 2023 02:22:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0J6A-0005Qc-4t; Tue, 07 Nov 2023 05:14:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J66-0005MR-8H for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:14:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0J64-00033B-GB for qemu-devel@nongnu.org; Tue, 07 Nov 2023 05:14:14 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-132-Tcv4-fWEMXinGgak8V6aRQ-1; Tue, 07 Nov 2023 05:14:10 -0500 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-32d83fd3765so2478849f8f.3 for ; Tue, 07 Nov 2023 02:14:10 -0800 (PST) Received: from redhat.com ([2.55.5.143]) by smtp.gmail.com with ESMTPSA id v17-20020a5d6111000000b0031c52e81490sm1932943wrt.72.2023.11.07.02.14.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:14:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699352052; h=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=Cq8e/T3fhqKdlArKCJAyjRr/9dufWVuRJaWAjpre1Es=; b=hSKrj4R4W8DvhviqJG12dJPKoRJ4Y087UTJ/mp+9iQWlVBJ4PmkdD6kafC4MsdsOHOxVWb dGL9eRguCBnbhnc6LRo2w5LziqA9YHvnmnTj07k280qQO3PpMfchIkwztqEXJRk5YWFhL2 fJW8AWXH6XRsaKwO+iQqo+/ksAmsEWA= X-MC-Unique: Tcv4-fWEMXinGgak8V6aRQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699352048; x=1699956848; 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=Cq8e/T3fhqKdlArKCJAyjRr/9dufWVuRJaWAjpre1Es=; b=MS91MyKU1Eh0xSgHYXdhj3CZylIWAoj8AaVxc1jHr4fYZ9i3tZN4bMx1J6d6ROYH57 f5G3f7uKvyxjXLNKBHG8j/+gjq5io38oT/DoShgq5MdnA9z+bLJGnOai5VX6oNOIIeOt DnrCRY5AsrE3SC02ZwnR9BjzoZ529FxAb+XpbcwG5TNZvGaoy551Eoqtp69mddz+dT2G Mfn7R0dAFCS902+ncKc0uqE20yp2YXE3B+bF60cGdigziByu36ZpplhCKq0iJuMry6Sn Sa678rFjtCDLqtdPMp3fZFj7YV7TUET/ZQ3CyAcpFYIMmm5LZWViw1fvvlz5GjFC58NE HV5Q== X-Gm-Message-State: AOJu0YwY5pBdikK2PWKf/cR8uLEqsDq4VYIOdvkM8WzcKFU7m3rpLOzC 0bbGJ1Qcpc5TyjApq24zDYBYp+PNtVl9htmbUJ0ieItjj3oEblAssr0bWSrxlqbmEVpcli8Ptbu kul3kGBURDQ3fLS4/3k5YUwoRFJ2ldVyZk5ouF77pwVfQ3r1pEEjW4umf+SFf83W+Ye7C X-Received: by 2002:a5d:64e6:0:b0:32f:7734:a0fa with SMTP id g6-20020a5d64e6000000b0032f7734a0famr30537580wri.2.1699352048614; Tue, 07 Nov 2023 02:14:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwX+FWz4E28nZS2rA3aJn23YqMBRf7DfkqIGs1KckgqGeiWFY2+y3wkldsrXq66xyrl3vE1A== X-Received: by 2002:a5d:64e6:0:b0:32f:7734:a0fa with SMTP id g6-20020a5d64e6000000b0032f7734a0famr30537550wri.2.1699352048093; Tue, 07 Nov 2023 02:14:08 -0800 (PST) Date: Tue, 7 Nov 2023 05:14:04 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ani Sinha , jsnow@redhat.com, Cleber Rosa , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Beraldo Leal Subject: [PULL 63/63] acpi/tests/avocado/bits: enable console logging from bits VM Message-ID: <94cd94f1c0137b56000c01208e03d0907ad34910.1699351720.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699352549714100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ani Sinha Console logs from the VM can be useful for debugging when things go wrong. Other avocado tests enables them. This change enables console logging with = the following changes: - point to the newer bios bits image that actually enabled VM console. - change the bits test to drain the console logs from the VM and write the logs. - wait for SHUTDOWN event from QEMU so that console logs can be drained out of the socket before it is closed as a part of vm.wait(). Additionally, following two cosmetic changes have been made: - Removed VM QEMU command line logging as avocado framework already logs i= t. This is a minor cleanup along the way. - Update my email to my work email in the avocado acpi bios bits test. CC: jsnow@redhat.com Signed-off-by: Ani Sinha Message-Id: <20231027032120.6012-3-anisinha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/avocado/acpi-bits.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/avocado/acpi-bits.py b/tests/avocado/acpi-bits.py index 042007b0b8..68b9e98d4e 100644 --- a/tests/avocado/acpi-bits.py +++ b/tests/avocado/acpi-bits.py @@ -18,7 +18,7 @@ # # # Author: -# Ani Sinha +# Ani Sinha =20 # pylint: disable=3Dinvalid-name # pylint: disable=3Dconsider-using-f-string @@ -48,6 +48,7 @@ ) from qemu.machine import QEMUMachine from avocado import skipIf +from avocado.utils import datadrainer as drainer from avocado_qemu import QemuBaseTest =20 deps =3D ["xorriso", "mformat"] # dependent tools needed in the test setup= /box. @@ -141,12 +142,12 @@ def __init__(self, *args, **kwargs): self._baseDir =3D None =20 # following are some standard configuration constants - self._bitsInternalVer =3D 2020 - self._bitsCommitHash =3D 'b48b88ff' # commit hash must match + self._bitsInternalVer =3D 2020 # gitlab CI does shallow clones of = depth 20 + self._bitsCommitHash =3D 'c7920d2b' # commit hash must match # the artifact tag below - self._bitsTag =3D "qemu-bits-10182022" # this is the latest bits + self._bitsTag =3D "qemu-bits-10262023" # this is the latest bits # release as of today. - self._bitsArtSHA1Hash =3D 'b04790ac9b99b5662d0416392c73b97580641fe= 5' + self._bitsArtSHA1Hash =3D 'b22cdfcfc7453875297d06d626f5474ee36a343= f' self._bitsArtURL =3D ("https://gitlab.com/qemu-project/" "biosbits-bits/-/jobs/artifacts/%s/" "download?job=3Dqemu-bits-build" %self._bitsTa= g) @@ -386,15 +387,20 @@ def test_acpi_smbios_bits(self): # for newer machine models"). Therefore, enforce 32-bit entry poin= t. self._vm.add_args('-machine', 'smbios-entry-point-type=3D32') =20 - args =3D " ".join(str(arg) for arg in self._vm.base_args()) + \ - " " + " ".join(str(arg) for arg in self._vm.args) - - self.logger.info("launching QEMU vm with the following arguments: = %s", - args) - + # enable console logging + self._vm.set_console() self._vm.launch() + + self.logger.debug("Console output from bits VM follows ...") + c_drainer =3D drainer.LineLogger(self._vm.console_socket.fileno(), + logger=3Dself.logger.getChild("cons= ole"), + stop_check=3D(lambda : + not self._vm.is_running= ())) + c_drainer.start() + # biosbits has been configured to run all the specified test suites # in batch mode and then automatically initiate a vm shutdown. # Rely on avocado's unit test timeout. + self._vm.event_wait('SHUTDOWN') self._vm.wait(timeout=3DNone) self.parse_log() --=20 MST