From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630558; cv=none; d=zohomail.com; s=zohoarc; b=CrbdmzByoSv9bC3vinmdI9VhCS1N1kE19UukCp9dW200GYpNtrmjxEE5dA+E1MCgt9QACYr4zDzCzes4YfEvc5LcpCyDQtkkzg9YFv0ooOnlQ0AHmYlqcoHXmqmckZyEQO/NV6wlh3Hh+Ao0m3+Ab+k+ZoVzdfTMaR7sqDkGj/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630558; 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=gfd+vfybB3O3+4pkXHRWr1BbxFsd2M2r8td4r0aSbjQ=; b=CERF2GfKlvZYxhrMbthT+zTv3tv5ZYxuRawv/lzrKpfdYPie09gNyK/gySbEXKr8S79PAwLgd21V4jpRsRJQrsj3WEMBboZuK4pzsT+WHG3kVtYoW8z+d3xkWXATjAZqM20LsPzR3vsGBKJbeqYXe/O/2BdyLbs5zprsChDY/d0= 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+importer=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 1717630558389309.1869730853185; Wed, 5 Jun 2024 16:35:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF09d-0002oZ-QL; Wed, 05 Jun 2024 19:34:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09c-0002oA-1n for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:34:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09a-0004m5-4Y for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:34:51 -0400 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-180-S78EXbO1MUCdYQaMNc0JvQ-1; Wed, 05 Jun 2024 19:34:48 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a68ccd15540so12849766b.3 for ; Wed, 05 Jun 2024 16:34:48 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c80728867sm6209066b.192.2024.06.05.16.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630489; h=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=gfd+vfybB3O3+4pkXHRWr1BbxFsd2M2r8td4r0aSbjQ=; b=d6v5z41MRLHnIFsaCpiQkTHHtvMn3KaBwQsS/2JIcXwMmN0Y5T6bCCklRVtxJ4REd15w42 zoAPhGCM9XtB03o6aCCd8sb49VUUMrx3MuO3Qy9uqqz/ljICttVCPdgRSCpQKlg7G5g84P 6ZFgDF87KsXMNv86Q9G1Spzb+1LA40Y= X-MC-Unique: S78EXbO1MUCdYQaMNc0JvQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630486; x=1718235286; 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=gfd+vfybB3O3+4pkXHRWr1BbxFsd2M2r8td4r0aSbjQ=; b=PO5EzIrtMOfftBtDYCT01ER8bd2NPpOThlbi+MR+HK4G/23seX4jRZ15zR/m0qL6yX OIc8TJILJWGxuRU/XgsMrn4w6Ij/JIkD9Zfpi5yc7Hsm01CR6Tg5lRfGsRgQZlXiB8EX Wd0OXePmoAPFMiniztAR9QXEAUqWk2LSX6i/4aApEdH80FCs9ZFMbWWkHbnDy9Tsz6w9 mYKvQmzUG4JLA5A3SZiaX7Q4gSk0GOMF3nIWXbx/HHOBr77SK2iv2nVbxu6jTnWcmCyx fxJKPAwm1ggul0tPFyNcXXbOc7KeC+pyj3mczPmOevtM2JO5ihHf6RKy5bPlcHDoTlKG yn8g== X-Gm-Message-State: AOJu0Yw+n5cbXOsFLM1fRb2aFOIiYBCGQqqAsdb8mTs9fWHG40j8BTzM q6onNTFQZu5GwXkEMl9EvUdlLQ5I/wbKBsQzF0ESGK5SZGUkwAJFvcT5p17PKQAUKA5focoh/d0 DvRnJ/hzoaOFATXIGrwQuWSnOYcQ7xg+qsHLYWpgN7GkT9tnePh4hmsJAW2L2ftsX3pOAq0Uaho J5yI51UXCDwQR2B+l0M6ynBZ+sdFUdZw== X-Received: by 2002:a17:906:bc4e:b0:a61:ab74:413e with SMTP id a640c23a62f3a-a699fcf5204mr251953066b.46.1717630486170; Wed, 05 Jun 2024 16:34:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+O/3wFcnF7YSXUbxv1FEuwqXKu/t5TiLfAD0q2kXvwS0arHx/fw6LRwgj43/M7VGzFaK2+Q== X-Received: by 2002:a17:906:bc4e:b0:a61:ab74:413e with SMTP id a640c23a62f3a-a699fcf5204mr251951866b.46.1717630485592; Wed, 05 Jun 2024 16:34:45 -0700 (PDT) Date: Wed, 5 Jun 2024 19:34:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Si-Wei Liu Subject: [PULL v3 01/41] vhost: dirty log should be per backend type Message-ID: <0b7ca10a059089caef535e86c6523991240e5f29.1717630437.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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630559761100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Si-Wei Liu There could be a mix of both vhost-user and vhost-kernel clients in the same QEMU process, where separate vhost loggers for the specific vhost type have to be used. Make the vhost logger per backend type, and have them properly reference counted. Suggested-by: Michael S. Tsirkin Signed-off-by: Si-Wei Liu Message-Id: <1710448055-11709-1-git-send-email-si-wei.liu@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost.c | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 4acd77e890..a1e8b79e1a 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -43,8 +43,8 @@ do { } while (0) #endif =20 -static struct vhost_log *vhost_log; -static struct vhost_log *vhost_log_shm; +static struct vhost_log *vhost_log[VHOST_BACKEND_TYPE_MAX]; +static struct vhost_log *vhost_log_shm[VHOST_BACKEND_TYPE_MAX]; =20 /* Memslots used by backends that support private memslots (without an fd)= . */ static unsigned int used_memslots; @@ -287,6 +287,10 @@ static int vhost_set_backend_type(struct vhost_dev *de= v, r =3D -1; } =20 + if (r =3D=3D 0) { + assert(dev->vhost_ops->backend_type =3D=3D backend_type); + } + return r; } =20 @@ -319,16 +323,22 @@ static struct vhost_log *vhost_log_alloc(uint64_t siz= e, bool share) return log; } =20 -static struct vhost_log *vhost_log_get(uint64_t size, bool share) +static struct vhost_log *vhost_log_get(VhostBackendType backend_type, + uint64_t size, bool share) { - struct vhost_log *log =3D share ? vhost_log_shm : vhost_log; + struct vhost_log *log; + + assert(backend_type > VHOST_BACKEND_TYPE_NONE); + assert(backend_type < VHOST_BACKEND_TYPE_MAX); + + log =3D share ? vhost_log_shm[backend_type] : vhost_log[backend_type]; =20 if (!log || log->size !=3D size) { log =3D vhost_log_alloc(size, share); if (share) { - vhost_log_shm =3D log; + vhost_log_shm[backend_type] =3D log; } else { - vhost_log =3D log; + vhost_log[backend_type] =3D log; } } else { ++log->refcnt; @@ -340,11 +350,20 @@ static struct vhost_log *vhost_log_get(uint64_t size,= bool share) static void vhost_log_put(struct vhost_dev *dev, bool sync) { struct vhost_log *log =3D dev->log; + VhostBackendType backend_type; =20 if (!log) { return; } =20 + assert(dev->vhost_ops); + backend_type =3D dev->vhost_ops->backend_type; + + if (backend_type =3D=3D VHOST_BACKEND_TYPE_NONE || + backend_type >=3D VHOST_BACKEND_TYPE_MAX) { + return; + } + --log->refcnt; if (log->refcnt =3D=3D 0) { /* Sync only the range covered by the old log */ @@ -352,13 +371,13 @@ static void vhost_log_put(struct vhost_dev *dev, bool= sync) vhost_log_sync_range(dev, 0, dev->log_size * VHOST_LOG_CHUNK -= 1); } =20 - if (vhost_log =3D=3D log) { + if (vhost_log[backend_type] =3D=3D log) { g_free(log->log); - vhost_log =3D NULL; - } else if (vhost_log_shm =3D=3D log) { + vhost_log[backend_type] =3D NULL; + } else if (vhost_log_shm[backend_type] =3D=3D log) { qemu_memfd_free(log->log, log->size * sizeof(*(log->log)), log->fd); - vhost_log_shm =3D NULL; + vhost_log_shm[backend_type] =3D NULL; } =20 g_free(log); @@ -376,7 +395,8 @@ static bool vhost_dev_log_is_shared(struct vhost_dev *d= ev) =20 static inline void vhost_dev_log_resize(struct vhost_dev *dev, uint64_t si= ze) { - struct vhost_log *log =3D vhost_log_get(size, vhost_dev_log_is_shared(= dev)); + struct vhost_log *log =3D vhost_log_get(dev->vhost_ops->backend_type, + size, vhost_dev_log_is_shared(de= v)); uint64_t log_base =3D (uintptr_t)log->log; int r; =20 @@ -2044,7 +2064,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODev= ice *vdev, bool vrings) uint64_t log_base; =20 hdev->log_size =3D vhost_get_log_size(hdev); - hdev->log =3D vhost_log_get(hdev->log_size, + hdev->log =3D vhost_log_get(hdev->vhost_ops->backend_type, + hdev->log_size, vhost_dev_log_is_shared(hdev)); log_base =3D (uintptr_t)hdev->log->log; r =3D hdev->vhost_ops->vhost_set_log_base(hdev, --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630711; cv=none; d=zohomail.com; s=zohoarc; b=DYdKwWi0N0DCC5Zo2ElpTtZCn/kk4bG1Fd8yRN7/VvLCcj91VUCfMWMgcfWfwskl+XzKIPahdEtjJwJlRCCL9dmFSYYlnvqQHXBWa/4ba/4qWet2SyR74ThJaDWGWo4wMs85Xs1TSOfmjNIHnXZxSKKqin1jwFAgS8b2WZ/QL/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630711; 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=uKK/AiLdjMfeKEPpHLdhaqq0Kf5J8WlC0WD4BsUonqY=; b=m9dI9GLEqFiqb4/os0o6mCknDK+n2rhbp62UBEUG/CDUYAHSkAzPJq6yJmt95GP71ovJ8LgwGW03sSt+osFxq920LNwnYIaCdFjSak3GuJ80zBoTIF1/omJlGJlXoDzvteJuywouHf+pVLTsjEwtL9GW8M+mAulqR2AlvN7ltgE= 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+importer=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 171763071169251.47953408961985; Wed, 5 Jun 2024 16:38:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF09g-0002pa-Hf; Wed, 05 Jun 2024 19:34:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09f-0002p2-1v for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:34:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09d-0004mw-2g for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:34:54 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-346-NFp6kSUFOQyWVuNcjYNZTg-1; Wed, 05 Jun 2024 19:34:51 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a6c718150f8so44944266b.2 for ; Wed, 05 Jun 2024 16:34:50 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c8058232asm7013366b.6.2024.06.05.16.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:34:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630492; h=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=uKK/AiLdjMfeKEPpHLdhaqq0Kf5J8WlC0WD4BsUonqY=; b=RJFC5KL8NlA6DOv2zsw6FG0zN1qNv+g5bzGLkZaLIlnWthOQlHjLULkWPOIDCg9upL41HE mP8yavaLJjp8qPllV3yOaswMPp0HIAl1iZlasIzOFl6/BLUqZ0bp/zFZl0TMo6Xo+/MBjt bLCnGIj6dXm+m2ODGknvp4SfWXIQ7HA= X-MC-Unique: NFp6kSUFOQyWVuNcjYNZTg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630489; x=1718235289; 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=uKK/AiLdjMfeKEPpHLdhaqq0Kf5J8WlC0WD4BsUonqY=; b=BJyiyk4DG2Dp/Gqwg/ppTigVwtzhV84ounZODeyrtvT4Eg3EJnwH1YPzVMI9Sz6vBz cUupb8j7GnNH9wlIEvs7aMhNo1upFBFBfW5d93l0/tsoDj7s9Zcv1RbtKugZo7l2h0xt SbODkkStqHK2ofBhumwuLWl3ugqMFAZPfSjf/F+wDT0ei3Op/ppcRvOao+7+WhNUYaNs HpBSXi2W70wqlHCpN3mH8xDWHA+pJ4i3Dd1FKjsD+lOa9f+9VaHVgreVAKHcmFEip7ew 9Lpqx4TTxexCytHjGeenBk91ufRq5AyahokzZw8H7BrqhqmKSCD50U4tVzqmOc4sBmu5 vm7A== X-Gm-Message-State: AOJu0YwdCn+/mEYIlbIVXhAjUEwg6/jocEwLBfAxTA1U56N6Njxu0jB4 GuokQTNhg4WsPOGnk8BBDmOL0xkawqRRBIC6opcwXksCOyv8wmcReJlt4HjPve9OlkZ9WiPBiqs YwmvdRrzZtphcBANEx994P6VrUl5A1r/pD4rp5sRAV1fqMMXGNl3+DoLXO8uVW5Of5TyR78UsgT hJHSTiPNDKUO/7BX6J5iOzTOz2WMcqhg== X-Received: by 2002:a17:906:81d3:b0:a63:147b:b2 with SMTP id a640c23a62f3a-a69a002b099mr269871866b.66.1717630489341; Wed, 05 Jun 2024 16:34:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0wQKuvphuvhvCen1FHs32H5X+O4eqYGCwupr4EsDkHjqiXUXFfa1eRQJAze0CnjBJKMplWg== X-Received: by 2002:a17:906:81d3:b0:a63:147b:b2 with SMTP id a640c23a62f3a-a69a002b099mr269870166b.66.1717630488789; Wed, 05 Jun 2024 16:34:48 -0700 (PDT) Date: Wed, 5 Jun 2024 19:34:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Si-Wei Liu , Joao Martins , Jason Wang Subject: [PULL v3 02/41] vhost: Perform memory section dirty scans once per iteration Message-ID: <1775c641d54dcb24bc485ac5c871c97e85f985d8.1717630437.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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630712317100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Si-Wei Liu On setups with one or more virtio-net devices with vhost on, dirty tracking iteration increases cost the bigger the number amount of queues are set up e.g. on idle guests migration the following is observed with virtio-net with vhost=3Don: 48 queues -> 78.11% [.] vhost_dev_sync_region.isra.13 8 queues -> 40.50% [.] vhost_dev_sync_region.isra.13 1 queue -> 6.89% [.] vhost_dev_sync_region.isra.13 2 devices, 1 queue -> 18.60% [.] vhost_dev_sync_region.isra.14 With high memory rates the symptom is lack of convergence as soon as it has a vhost device with a sufficiently high number of queues, the sufficient number of vhost devices. On every migration iteration (every 100msecs) it will redundantly query the *shared log* the number of queues configured with vhost that exist in the guest. For the virtqueue data, this is necessary, but not for the memory sections which are the same. So essentially we end up scanning the dirty log too often. To fix that, select a vhost device responsible for scanning the log with regards to memory sections dirty tracking. It is selected when we enable the logger (during migration) and cleared when we disable the logger. If the vhost logger device goes away for some reason, the logger will be re-selected from the rest of vhost devices. After making mem-section logger a singleton instance, constant cost of 7%-9% (like the 1 queue report) will be seen, no matter how many queues or how many vhost devices are configured: 48 queues -> 8.71% [.] vhost_dev_sync_region.isra.13 2 devices, 8 queues -> 7.97% [.] vhost_dev_sync_region.isra.14 Co-developed-by: Joao Martins Signed-off-by: Joao Martins Signed-off-by: Si-Wei Liu Message-Id: <1710448055-11709-2-git-send-email-si-wei.liu@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- include/hw/virtio/vhost.h | 1 + hw/virtio/vhost.c | 67 +++++++++++++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 02477788df..d75faf46e9 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -129,6 +129,7 @@ struct vhost_dev { void *opaque; struct vhost_log *log; QLIST_ENTRY(vhost_dev) entry; + QLIST_ENTRY(vhost_dev) logdev_entry; QLIST_HEAD(, vhost_iommu) iommu_list; IOMMUNotifier n; const VhostDevConfigOps *config_ops; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index a1e8b79e1a..06fc71746e 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -45,6 +45,7 @@ =20 static struct vhost_log *vhost_log[VHOST_BACKEND_TYPE_MAX]; static struct vhost_log *vhost_log_shm[VHOST_BACKEND_TYPE_MAX]; +static QLIST_HEAD(, vhost_dev) vhost_log_devs[VHOST_BACKEND_TYPE_MAX]; =20 /* Memslots used by backends that support private memslots (without an fd)= . */ static unsigned int used_memslots; @@ -149,6 +150,47 @@ bool vhost_dev_has_iommu(struct vhost_dev *dev) } } =20 +static inline bool vhost_dev_should_log(struct vhost_dev *dev) +{ + assert(dev->vhost_ops); + assert(dev->vhost_ops->backend_type > VHOST_BACKEND_TYPE_NONE); + assert(dev->vhost_ops->backend_type < VHOST_BACKEND_TYPE_MAX); + + return dev =3D=3D QLIST_FIRST(&vhost_log_devs[dev->vhost_ops->backend_= type]); +} + +static inline void vhost_dev_elect_mem_logger(struct vhost_dev *hdev, bool= add) +{ + VhostBackendType backend_type; + + assert(hdev->vhost_ops); + + backend_type =3D hdev->vhost_ops->backend_type; + assert(backend_type > VHOST_BACKEND_TYPE_NONE); + assert(backend_type < VHOST_BACKEND_TYPE_MAX); + + if (add && !QLIST_IS_INSERTED(hdev, logdev_entry)) { + if (QLIST_EMPTY(&vhost_log_devs[backend_type])) { + QLIST_INSERT_HEAD(&vhost_log_devs[backend_type], + hdev, logdev_entry); + } else { + /* + * The first vhost_device in the list is selected as the shared + * logger to scan memory sections. Put new entry next to the h= ead + * to avoid inadvertent change to the underlying logger device. + * This is done in order to get better cache locality and to a= void + * performance churn on the hot path for log scanning. Even wh= en + * new devices come and go quickly, it wouldn't end up changing + * the active leading logger device at all. + */ + QLIST_INSERT_AFTER(QLIST_FIRST(&vhost_log_devs[backend_type]), + hdev, logdev_entry); + } + } else if (!add && QLIST_IS_INSERTED(hdev, logdev_entry)) { + QLIST_REMOVE(hdev, logdev_entry); + } +} + static int vhost_sync_dirty_bitmap(struct vhost_dev *dev, MemoryRegionSection *section, hwaddr first, @@ -166,12 +208,14 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *= dev, start_addr =3D MAX(first, start_addr); end_addr =3D MIN(last, end_addr); =20 - for (i =3D 0; i < dev->mem->nregions; ++i) { - struct vhost_memory_region *reg =3D dev->mem->regions + i; - vhost_dev_sync_region(dev, section, start_addr, end_addr, - reg->guest_phys_addr, - range_get_last(reg->guest_phys_addr, - reg->memory_size)); + if (vhost_dev_should_log(dev)) { + for (i =3D 0; i < dev->mem->nregions; ++i) { + struct vhost_memory_region *reg =3D dev->mem->regions + i; + vhost_dev_sync_region(dev, section, start_addr, end_addr, + reg->guest_phys_addr, + range_get_last(reg->guest_phys_addr, + reg->memory_size)); + } } for (i =3D 0; i < dev->nvqs; ++i) { struct vhost_virtqueue *vq =3D dev->vqs + i; @@ -383,6 +427,7 @@ static void vhost_log_put(struct vhost_dev *dev, bool s= ync) g_free(log); } =20 + vhost_dev_elect_mem_logger(dev, false); dev->log =3D NULL; dev->log_size =3D 0; } @@ -998,6 +1043,15 @@ static int vhost_dev_set_log(struct vhost_dev *dev, b= ool enable_log) goto err_vq; } } + + /* + * At log start we select our vhost_device logger that will scan the + * memory sections and skip for the others. This is possible because + * the log is shared amongst all vhost devices for a given type of + * backend. + */ + vhost_dev_elect_mem_logger(dev, enable_log); + return 0; err_vq: for (; i >=3D 0; --i) { @@ -2075,6 +2129,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODev= ice *vdev, bool vrings) VHOST_OPS_DEBUG(r, "vhost_set_log_base failed"); goto fail_log; } + vhost_dev_elect_mem_logger(hdev, true); } if (vrings) { r =3D vhost_dev_set_vring_enable(hdev, true); --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630558; cv=none; d=zohomail.com; s=zohoarc; b=XU47xUdGum6C3vTDf5r+2/PvofWuT9yoWwEtRox+OhQ2RPg3aOOvkGIFxM2tdcaqnkuRH6Sr1yLx2Rrg05t1w/sKsKPxiqnMSaxF7ZGjd0XYhT0HbOGNZ6TdDuuaEverQ/S5OUB5/fq9Dkn/gCGpIWGqN/1Ozh6duhDU2Py1Qgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630558; 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=ZMYpex8C2s46cF0GfMcoGvUcCxmqXFvGY/Nt+8TTLHo=; b=jTBeQZ4a5e/T2E1vzVIFJyDHG1UVtBWD7VUQOdCCF5oWbYtwvwwJZU83fHIqAPTRU8R9pTyf8wRaFQyly37l1rbifKMyWkw723mTf8I6dxVfAJ7lctwL/RSxTPrrT0UtI3cAyEG2qtZt/XuFzOS8nYLQ62ZvYYtgzabKi9MmPTo= 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+importer=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 1717630558415688.847818188389; Wed, 5 Jun 2024 16:35:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF09k-0002q0-3w; Wed, 05 Jun 2024 19:35:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09j-0002pd-2a for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:34:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09h-0004nf-EE for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:34:58 -0400 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-428-EqWCQrpVOk-Z_9V_BLE9cQ-1; Wed, 05 Jun 2024 19:34:55 -0400 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2ead17d8db6so1153711fa.0 for ; Wed, 05 Jun 2024 16:34:55 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae201a6esm92473a12.71.2024.06.05.16.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630496; h=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=ZMYpex8C2s46cF0GfMcoGvUcCxmqXFvGY/Nt+8TTLHo=; b=aajlcr5V8y7QKPy1F4U+J2hKHsN8OaoTOxCwpfQN1/vxxWmI2aamoVS7rvjz9YhNAVl3t2 ec1YXXltm5AcFawMw+PiVYzl4I4412naMDt/i5ks1uAWeVT/+klDynlLvIFjMRVKYraKVu LF3+f41priyky/Tr7YX9nJ9Az3LZj2Y= X-MC-Unique: EqWCQrpVOk-Z_9V_BLE9cQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630493; x=1718235293; 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=ZMYpex8C2s46cF0GfMcoGvUcCxmqXFvGY/Nt+8TTLHo=; b=E5oDLljQXGanhRiiLu1EANogAnkBfxnkLhUkp1hmysAN1CU2OyidWwUWl9VSqEu6kP VnHCA0D8gRmyJMYWfSAa4fLudE/qRwuY49vcUWWHfORmGpCQLSnI7wETmL0SjSIqfCt3 wjQYHV2HHPFtsKkER1wPD1Wgt2j0MEbHHGVOk4ccIvuHqBBGYZZ7uiODpdsMWrtlMXSZ rR5cgt9am1jF4KH4v0XjReqEl3v6zDjljR1QD2l3y16Qb/XTQ8xWs4M6aOTSxeaY3/Zy pbH0wYGoChA/nH3kloZ7RznEfdnjetyZbillWwe/t1M6ar+VwrSnYkzZf1b/lyR3LmOx 7Aqg== X-Gm-Message-State: AOJu0Yyr78eHzmsfFvsryF19w0xab1luOgFLVzAjfuZZQq4BLxPEAxFR rIysllq2kbbMVJe6Gmiu4kjVwdqnD9LVr72shoS9iDffDUkUqA1bE8FYlb2/U806tDu/BXkdwbM /zRdKa5ybuH8DkHskQ4kEU4px58iqtR0yVfxlVb5HzpF1EdZ8h4ZgMnmZ5VCez9dm+MwBnFJR5I W9NeHkQEJWgdLQMVZdUAzoTblHSB+4sg== X-Received: by 2002:a05:651c:10b3:b0:2ea:adf7:4dd0 with SMTP id 38308e7fff4ca-2eac7a6ee1bmr19386811fa.46.1717630493273; Wed, 05 Jun 2024 16:34:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHmL3iHUMgRwpDdc9+IuGWPg8k4uVteUcKLSdsswgxsu3F0U+HZN3+19FdUkpvJGkhuKea7gw== X-Received: by 2002:a05:651c:10b3:b0:2ea:adf7:4dd0 with SMTP id 38308e7fff4ca-2eac7a6ee1bmr19386641fa.46.1717630492586; Wed, 05 Jun 2024 16:34:52 -0700 (PDT) Date: Wed, 5 Jun 2024 19:34:49 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , Eugenio =?utf-8?B?UMOpcmV6?= , Jason Wang , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Subject: [PULL v3 03/41] vhost-vdpa: check vhost_vdpa_set_vring_ready() return value Message-ID: <982ae85fe81e3849e27d9eacad85c2ffc131d7e3.1717630437.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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630559761100006 From: Stefano Garzarella vhost_vdpa_set_vring_ready() could already fail, but if Linux's patch [1] will be merged, it may fail with more chance if userspace does not activate virtqueues before DRIVER_OK when VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK is not negotiated. So better check its return value anyway. [1] https://lore.kernel.org/virtualization/20240206145154.118044-1-sgarzare= @redhat.com/T/#u Acked-by: Eugenio P=C3=A9rez Acked-by: Jason Wang Signed-off-by: Stefano Garzarella Message-Id: <20240322092315.31885-1-sgarzare@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 85e73dd6a7..eda714d1a4 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -399,7 +399,10 @@ static int vhost_vdpa_net_data_load(NetClientState *nc) } =20 for (int i =3D 0; i < v->dev->nvqs; ++i) { - vhost_vdpa_set_vring_ready(v, i + v->dev->vq_index); + int ret =3D vhost_vdpa_set_vring_ready(v, i + v->dev->vq_index); + if (ret < 0) { + return ret; + } } return 0; } @@ -1238,7 +1241,10 @@ static int vhost_vdpa_net_cvq_load(NetClientState *n= c) =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 - vhost_vdpa_set_vring_ready(v, v->dev->vq_index); + r =3D vhost_vdpa_set_vring_ready(v, v->dev->vq_index); + if (unlikely(r < 0)) { + return r; + } =20 if (v->shadow_vqs_enabled) { n =3D VIRTIO_NET(v->dev->vdev); @@ -1277,7 +1283,10 @@ static int vhost_vdpa_net_cvq_load(NetClientState *n= c) } =20 for (int i =3D 0; i < v->dev->vq_index; ++i) { - vhost_vdpa_set_vring_ready(v, i); + r =3D vhost_vdpa_set_vring_ready(v, i); + if (unlikely(r < 0)) { + return r; + } } =20 return 0; --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630629; cv=none; d=zohomail.com; s=zohoarc; b=VV4pzRVq5bFwIjZI4W1kUaK9pp8PohjHfnosukoiHSxGw9ZkoDjhhSg0ROe6hyUM++CvdlQeaqb+321puJAEZUzlWfn2pZV39Vvom1vH/8mQZyOjjesj9D4TWqklo6OknhLgrdNGHA2uzu4qen3aUEdjQydtUr/vbOQCrod3zGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630629; 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=rU41nJqg3mDUGH1bcBpKF5g1VLC3bOtqyqIezIWqM9s=; b=YdRwcGbMLgekO70ngl9IeewsaOWk5txo3zHELpBPtl23oxk7c61JWS0BOizD+Ze12arut4w4YrjtVg/7+75m+nOHaCOrw558mXIJiOvHdWtFJU0TiTMy9mQ1ppvIVIaSxHgiyglhDNni99VJ/OVMetsfypk9XU+YxE+WzCB/Gls= 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+importer=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 1717630629478432.9238938243411; Wed, 5 Jun 2024 16:37:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF09o-0002qt-3I; Wed, 05 Jun 2024 19:35:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09m-0002qO-5H for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09k-0004pA-J7 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:01 -0400 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-256--swm5-G7OJyAlTqJ1hubEQ-1; Wed, 05 Jun 2024 19:34:58 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57a32f2f782so79340a12.1 for ; Wed, 05 Jun 2024 16:34:58 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae0c9f88sm99816a12.21.2024.06.05.16.34.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630499; h=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=rU41nJqg3mDUGH1bcBpKF5g1VLC3bOtqyqIezIWqM9s=; b=YDHkkQcjCxi0uFckLXkFl5QpellKuftC/IqcrXaGy+AuA8aIuiW72WgGM+77dClDF8NLRH rTF7AsKToFFeRDGrRwCv0kQnUX3mmgREbJx0dWEsGxW0jIHeEPaMM1oEmVT4PQ8Z6/DX4Z vUe+6UzDegm7P/jASLidcgM8c/BQRiI= X-MC-Unique: -swm5-G7OJyAlTqJ1hubEQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630496; x=1718235296; 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=rU41nJqg3mDUGH1bcBpKF5g1VLC3bOtqyqIezIWqM9s=; b=fgRVbLUFxGobH26AvWwAgDa/tn+0Aej9Cby7YSC2LP5cDnqgIrWNrnyt50aVnGxXPH uBkmiryXS7iaBmV+4qAdQiCMhC3clkZxJJoYC6w+hRpbUb8OcB4CQFJRHZwOKcxe9Lzv FtyaSOsyeuxc27b1foun5aJvig/i2PaDqnq4+2CoCaASFeeH4MHs3PAkFsnpsSFKwxet T8RN5MPM0vtpXFkkWD9fLGyrTQ1MrFo7oGnj4VMIzQ6zhXdy3EGIkVQjyBFzEwkXjhdJ Fl2FMHb0Vm9FUo4t6m519Zhc26Fk4LLTqZkqqDV8SSU6Yy1/TAjjk8mW2D9/xhMQl9Hx AYrA== X-Gm-Message-State: AOJu0YxfI9owl0/mjNiGvY1pGYz8Yo1aOlEPm/OlhGuLlI1X10HvYzEQ wF1rssxg+IMtvhKUyiN932flRu8dlRku53twkhfRWc9QQypTl3ELwHsJIXjZrJIO9+EAPG659r1 9mBVojIi2MvCET1mBT/YtdlzyCRwZRSDHUK1pvi4xCfZ6M3mUT5DClqALd/qgSpC2KTVXY00YiG i+PDLBwZLXKCFnBdWMlvEX5X+y4zE+Jw== X-Received: by 2002:a50:cd10:0:b0:57a:3357:5967 with SMTP id 4fb4d7f45d1cf-57a8bc9f858mr2411428a12.30.1717630496446; Wed, 05 Jun 2024 16:34:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMgv2ZpIyUyXfJqvPhlWngNJwMCoAUIFMvG+vfHkCxWi4UXIr2W3HFnv9tCefxMfWqLMCZBg== X-Received: by 2002:a50:cd10:0:b0:57a:3357:5967 with SMTP id 4fb4d7f45d1cf-57a8bc9f858mr2411422a12.30.1717630495960; Wed, 05 Jun 2024 16:34:55 -0700 (PDT) Date: Wed, 5 Jun 2024 19:34:53 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?B?UMOpcmV6?= Subject: [PULL v3 04/41] virtio/virtio-pci: Handle extra notification data Message-ID: <2e169a5bc1e75cda7075401ae9ee7e4d28a4df31.1717630437.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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630629938100001 From: Jonah Palmer Add support to virtio-pci devices for handling the extra data sent from the driver to the device when the VIRTIO_F_NOTIFICATION_DATA transport feature has been negotiated. The extra data that's passed to the virtio-pci device when this feature is enabled varies depending on the device's virtqueue layout. In a split virtqueue layout, this data includes: - upper 16 bits: shadow_avail_idx - lower 16 bits: virtqueue index In a packed virtqueue layout, this data includes: - upper 16 bits: 1-bit wrap counter & 15-bit shadow_avail_idx - lower 16 bits: virtqueue index Signed-off-by: Jonah Palmer Message-Id: <20240315165557.26942-2-jonah.palmer@oracle.com> Reviewed-by: Eugenio P=C3=A9rez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 2 ++ hw/virtio/virtio-pci.c | 12 +++++++++--- hw/virtio/virtio.c | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 7d5ffdc145..1451926a13 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -307,6 +307,8 @@ int virtio_queue_ready(VirtQueue *vq); =20 int virtio_queue_empty(VirtQueue *vq); =20 +void virtio_queue_set_shadow_avail_idx(VirtQueue *vq, uint16_t idx); + /* Host binding interface. */ =20 uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr); diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index b1d02f4b3d..cffc7efcae 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -384,7 +384,7 @@ static void virtio_ioport_write(void *opaque, uint32_t = addr, uint32_t val) { VirtIOPCIProxy *proxy =3D opaque; VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); - uint16_t vector; + uint16_t vector, vq_idx; hwaddr pa; =20 switch (addr) { @@ -408,8 +408,14 @@ static void virtio_ioport_write(void *opaque, uint32_t= addr, uint32_t val) vdev->queue_sel =3D val; break; case VIRTIO_PCI_QUEUE_NOTIFY: - if (val < VIRTIO_QUEUE_MAX) { - virtio_queue_notify(vdev, val); + vq_idx =3D val; + if (vq_idx < VIRTIO_QUEUE_MAX && virtio_queue_get_num(vdev, vq_idx= )) { + if (virtio_vdev_has_feature(vdev, VIRTIO_F_NOTIFICATION_DATA))= { + VirtQueue *vq =3D virtio_get_queue(vdev, vq_idx); + + virtio_queue_set_shadow_avail_idx(vq, val >> 16); + } + virtio_queue_notify(vdev, vq_idx); } break; case VIRTIO_PCI_STATUS: diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 893a072c9d..f7c99e3a96 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2264,6 +2264,24 @@ void virtio_queue_set_align(VirtIODevice *vdev, int = n, int align) } } =20 +void virtio_queue_set_shadow_avail_idx(VirtQueue *vq, uint16_t shadow_avai= l_idx) +{ + if (!vq->vring.desc) { + return; + } + + /* + * 16-bit data for packed VQs include 1-bit wrap counter and + * 15-bit shadow_avail_idx. + */ + if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED)) { + vq->shadow_avail_wrap_counter =3D (shadow_avail_idx >> 15) & 0x1; + vq->shadow_avail_idx =3D shadow_avail_idx & 0x7FFF; + } else { + vq->shadow_avail_idx =3D shadow_avail_idx; + } +} + static void virtio_queue_notify_vq(VirtQueue *vq) { if (vq->vring.desc && vq->handle_output) { --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630638; cv=none; d=zohomail.com; s=zohoarc; b=L35mIA2ng8ELxiiqkwq1k3ikgzLRXM/tgWXlJFe4lCaomV7rHvOajzyMJoEn5sWVMbzD8qeVTCNg3EGFhovl0fqzg2FLebV+j/e/ul6YeF55I0WHSQ7nIG7PLBecx1ljgHQ1U4OpzmABlJLRQH1eBadR5P99ifTlin3GoPKQnek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630638; 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=czI6QAqPz2gxBOi54M6w2CiDVJgkcwfGVW3OGis4Be4=; b=VzR8qQwbEokwwt0qyXgCGmI2A7VC1DQRwhcSxhG86OVWCV2p++R/eRCGBCuEiyOWr4HNLnXwIkpDX7AThf+AJ/I3xaHQm+i7mywXmR1aSGhu8WbZD6G8Iy9iKiCYyXoy+yVdqTqPFM8E0snJVnBVNGrwQDKjztiTclLJZVO4G7c= 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+importer=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 1717630638825764.1952547774099; Wed, 5 Jun 2024 16:37:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF09r-0002rC-N4; Wed, 05 Jun 2024 19:35:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09p-0002r3-Ud for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09o-0004w0-BH for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:05 -0400 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-463-pscAqLgpPwWIpG81SfnxVA-1; Wed, 05 Jun 2024 19:35:02 -0400 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-52b91217fcfso211831e87.3 for ; Wed, 05 Jun 2024 16:35:01 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c805d0af8sm6914366b.87.2024.06.05.16.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:34:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630503; h=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=czI6QAqPz2gxBOi54M6w2CiDVJgkcwfGVW3OGis4Be4=; b=Q3a4WbZGliQd/g6ukAcJfOlvkVXzNIRUUoIMAFRUWDIu+qPx3xB0aCL8tRGCbMZqalFlNo FPf3njUueSuZEDrK9A/2rvri5Tm3rlS/JVh6AlF8+AE0KmvTHweBb4zQgwN7l9YFC0CI0r fZ8R3nRwDN/etlADE/whyDtHt8erTPE= X-MC-Unique: pscAqLgpPwWIpG81SfnxVA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630500; x=1718235300; 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=czI6QAqPz2gxBOi54M6w2CiDVJgkcwfGVW3OGis4Be4=; b=ErruqIlt7L2nFrsLdJEFGknCBFZwA50hvgB+U7Ys3dCdtExPA/lZ8wvJym5ARcjRYy sxBnDm49QqKdlfSkqmabnzIjni+Jw8wh5spCQeslCtH3J04c68z2EBxUqcmcnI2l6wPE ZG2yIDpO8wgrjPbrag/2qUw4JUZwtVGSXmdq3mY6zlj/h/R8kqVe8JgQ0HH3P2WUIbvX Fp8BgkcYfOhGcEENTeo/SeYGkMBw7tjte5WZwCtgg/tVsYmOGwWkcnYK7yvVQf23Cq6v yoKH7U7YwBP6wK0nGl/3OdKPUKYjm9IELEdZL9BveRj5iBwxOfRnPCN6P0yEKlH18dCK ZF/g== X-Gm-Message-State: AOJu0YxyPhH+1cy/egj9onWU5NlMev+FsXqA++Wm9vjcCh1pNNmhYUn5 wCG7AXmi+QHVwiRV+KLKBDpRUt+1+pHT4ygtiA0Gy3Yg8gjZW1cRiN7YPxpaG97JkxGpmOFiJxX oBRxrsOZEVmRHvWy1cg0mL8RXu7nS5Fe9DPGl32dIcl1/gwqUngF9VZ+hLY6zHb9u8ghwJ57U/s Gk90eNzpswGRs+N5w/3Fe/zwzwX1wvDQ== X-Received: by 2002:a05:6512:701:b0:52b:851e:256 with SMTP id 2adb3069b0e04-52bab4c8ea5mr2121686e87.2.1717630500006; Wed, 05 Jun 2024 16:35:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE4WLXi0bBIL3OT03bJ4+nfahaM13sRo7yMo9FqEV9GAEsx9c5tKE3MUq3g9cAdqUttkIihFw== X-Received: by 2002:a05:6512:701:b0:52b:851e:256 with SMTP id 2adb3069b0e04-52bab4c8ea5mr2121679e87.2.1717630499532; Wed, 05 Jun 2024 16:34:59 -0700 (PDT) Date: Wed, 5 Jun 2024 19:34:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer Subject: [PULL v3 05/41] virtio: Prevent creation of device using notification-data with ioeventfd Message-ID: <8fdfaf02767748eadab7ad8ab41da78f261824f2.1717630437.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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630639990100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonah Palmer Prevent the realization of a virtio device that attempts to use the VIRTIO_F_NOTIFICATION_DATA transport feature without disabling ioeventfd. Due to ioeventfd not being able to carry the extra data associated with this feature, having both enabled is a functional mismatch and therefore Qemu should not continue the device's realization process. Although the device does not yet know if the feature will be successfully negotiated, many devices using this feature wont actually work without this extra data and would fail FEATURES_OK anyway. If ioeventfd is able to work with the extra notification data in the future, this compatibility check can be removed. Signed-off-by: Jonah Palmer Message-Id: <20240315165557.26942-3-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index f7c99e3a96..28cd406e16 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2980,6 +2980,20 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t= val) return ret; } =20 +static void virtio_device_check_notification_compatibility(VirtIODevice *v= dev, + Error **errp) +{ + VirtioBusState *bus =3D VIRTIO_BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(bus); + DeviceState *proxy =3D DEVICE(BUS(bus)->parent); + + if (virtio_host_has_feature(vdev, VIRTIO_F_NOTIFICATION_DATA) && + k->ioeventfd_enabled(proxy)) { + error_setg(errp, + "notification_data=3Don without ioeventfd=3Doff is not = supported"); + } +} + size_t virtio_get_config_size(const VirtIOConfigSizeParams *params, uint64_t host_features) { @@ -3740,6 +3754,14 @@ static void virtio_device_realize(DeviceState *dev, = Error **errp) } } =20 + /* Devices should not use both ioeventfd and notification data feature= */ + virtio_device_check_notification_compatibility(vdev, &err); + if (err !=3D NULL) { + error_propagate(errp, err); + vdc->unrealize(dev); + return; + } + virtio_bus_device_plugged(vdev, &err); if (err !=3D NULL) { error_propagate(errp, err); --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630765; cv=none; d=zohomail.com; s=zohoarc; b=BZdeyT5y2qzXipINp0LVowKxkR83JN51uIFkhYmfm5fSkbgWQEbGl2KGMrUgCzPtb8zOyDmu84ZYQNvjw3ly/AeILKPHLRVEFlvYR1HzgML1mU/hcGUCEch/niILfhuiSgeJmhmtakhAYf7n8v9aCxF5HpKBhRSVHrm+j+BIQjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630765; 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=uByx4Oz+CQ80E+9HMb1HUHKkD83RXYCyv+000WUVwgE=; b=fwnH8n8PkNLybyklGQ+jdjCht6rECq8V/1Evt9vKRYn3e/lko/CrsFwCWgrW2bx9BubTONi9g/XTAF6OEAsDBHK1qa/xy8AWJbBtUyO3lEML7Rt66BhF9+xQLoSkCZsL6Ec0rSJWzaelGoOkp1HO3Ft6rfTI4OaYbQdDN4qmCfQ= 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+importer=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 1717630765168514.3491225615537; Wed, 5 Jun 2024 16:39:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF09u-0002sF-Qo; Wed, 05 Jun 2024 19:35:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09s-0002rU-Se for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09r-00051w-7D for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:08 -0400 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-664-v-6oZm69ObWuK11cPWh0uA-1; Wed, 05 Jun 2024 19:35:05 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a6c718150f8so44955366b.2 for ; Wed, 05 Jun 2024 16:35:04 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c805cd97csm6950466b.67.2024.06.05.16.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630506; h=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=uByx4Oz+CQ80E+9HMb1HUHKkD83RXYCyv+000WUVwgE=; b=gEjj1xLPugT4pw9YrfmCDe+sdQuRPDvf+zYxiEU3XT2iFqNAMbTmuypBTfhbw0fwBGk9re ElaaCAxJuSpocLE/9sQJNdvLrw9XsT3AOm7MZJDHqAvHrVbTar6qK21hCSo9XeT706CGJk 3WZOUg2tQMNq8MO3n4O3xKr2U9XEt5c= X-MC-Unique: v-6oZm69ObWuK11cPWh0uA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630503; x=1718235303; 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=uByx4Oz+CQ80E+9HMb1HUHKkD83RXYCyv+000WUVwgE=; b=rPTmRoG6AtBNuvkbmk5LQFomsCvOB7vuOB2HusZuXqd/AGYdrohO1iCh74ZwnyzIvK M0km+wrf15JFRHuHryIS4ZhLYeyLIEJmWDcNpbXTuo22xWCjkj61PdleAwwGV1HP3Jou c3RDM9Bp0wIV4wt4usuLmMAqlaYV/QBmBy7XO3kKro3hms4++vMCKvu5wbGFtRTdbDPC Y992iojGko4uMF4OTkKzwc7laNkRgZcXNduxDbjRa7YJTPam9Fm7CXH7krtUBeKJoWqD SBHZCMulZxMJELu2DA53N5+dZzfByDLG5b4O7/Rc3vYrJymnpGVvS4iDnMmRiW+xvC7y Macw== X-Gm-Message-State: AOJu0YyC7/wywPsIavqxa5NjAixzftZFDqE1FFAS0XzDYYheCeUkwOK2 ntlbjb1eg0s/ctXAzj6zd7C1qciNtQbjLLmRcfHcVWe/Xpbzm2Avdn0X52Ior7tVsIfl6h9pRRI PnEg9jaTtVboVAtvQBSpoREtkNZoaswNpIT5g+qPbmr3Kr/kw6/SjM9h5i70bHHENRGH/EWkg3u 9bewxLtYJKGhd8EwrrPsN5W99Rpr4ITg== X-Received: by 2002:a17:907:bb84:b0:a59:c23d:85ce with SMTP id a640c23a62f3a-a69a000e2bcmr301116766b.51.1717630503535; Wed, 05 Jun 2024 16:35:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERTiJxar1crypFhv8A4eLSChTdHPg/PnttrCEUjwAT9bmo+mlH+Z2RDHVHXTRg/f1S1knd4w== X-Received: by 2002:a17:907:bb84:b0:a59:c23d:85ce with SMTP id a640c23a62f3a-a69a000e2bcmr301115666b.51.1717630503029; Wed, 05 Jun 2024 16:35:03 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer Subject: [PULL v3 06/41] virtio-mmio: Handle extra notification data 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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630766496100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonah Palmer Add support to virtio-mmio devices for handling the extra data sent from the driver to the device when the VIRTIO_F_NOTIFICATION_DATA transport feature has been negotiated. The extra data that's passed to the virtio-mmio device when this feature is enabled varies depending on the device's virtqueue layout. The data passed to the virtio-mmio device is in the same format as the data passed to virtio-pci devices. Signed-off-by: Jonah Palmer Message-Id: <20240315165557.26942-4-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mmio.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 22f9fbcf5a..320428ac0d 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -248,6 +248,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offs= et, uint64_t value, { VirtIOMMIOProxy *proxy =3D (VirtIOMMIOProxy *)opaque; VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); + uint16_t vq_idx; =20 trace_virtio_mmio_write_offset(offset, value); =20 @@ -407,8 +408,14 @@ static void virtio_mmio_write(void *opaque, hwaddr off= set, uint64_t value, } break; case VIRTIO_MMIO_QUEUE_NOTIFY: - if (value < VIRTIO_QUEUE_MAX) { - virtio_queue_notify(vdev, value); + vq_idx =3D value; + if (vq_idx < VIRTIO_QUEUE_MAX && virtio_queue_get_num(vdev, vq_idx= )) { + if (virtio_vdev_has_feature(vdev, VIRTIO_F_NOTIFICATION_DATA))= { + VirtQueue *vq =3D virtio_get_queue(vdev, vq_idx); + + virtio_queue_set_shadow_avail_idx(vq, (value >> 16) & 0xFF= FF); + } + virtio_queue_notify(vdev, vq_idx); } break; case VIRTIO_MMIO_INTERRUPT_ACK: --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630575; cv=none; d=zohomail.com; s=zohoarc; b=UUOvyxAVPkVMFaYZYRFmuZzsrSifpArVdIJ0MuhPFsgLNaT4ZP0a+uGBpZnMIVtBdCPX9Jis7TaANDtXeEMxge8KWnD720sa97PQYyG17MgpgwEyTmgz1S8M5wAuG1u+XTSpzI4zZlMhQ+oFjdfThE6N51BSO1wg8Ijc9YaQw+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630575; 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=NfEypfhhzAT3jaOXKR+DgWb6iflUNTeNRcp9m8ElhrQ=; b=oChjJN6Frc/0hE+CBnwe0jH9F4cCaZTiq+JXs/NNi+ZAa8z5y599QMerlLfnw7pWBFb2qkoovBvjYsEDF3RbJYb1mHy7VXWUdXKhlMYl7SNoJJKiBUM59tZc7SVPjwFAe6F0R5vNFxv5TWfGO+LyFkQIpn4rVV3PDw802GzM6k4= 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+importer=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 1717630575251302.93885298525174; Wed, 5 Jun 2024 16:36:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF09y-0002ue-DH; Wed, 05 Jun 2024 19:35:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09x-0002u9-5M for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF09v-00053k-Je for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:12 -0400 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-66-d5Mk8XcsMKm5VfyumiqzrQ-1; Wed, 05 Jun 2024 19:35:09 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a592c35ac06so27557766b.0 for ; Wed, 05 Jun 2024 16:35:09 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c80582841sm7079666b.42.2024.06.05.16.35.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630511; h=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=NfEypfhhzAT3jaOXKR+DgWb6iflUNTeNRcp9m8ElhrQ=; b=INBZyVSy2RYwjiUjy+Ap4nfyJLXLB9IpfPXzk7APCzL2Vx/6I6wGUDkUhTaViDYsqUqlXX wpiRLh5pRzj9vWdar/CVDWFUEpoZQAO3BbCvngD/AU96phAno+xeZ85H0zPEX1Mpy2vXbk 83erGHwKuQZlVwVkXzJ13j3zmFLQwYk= X-MC-Unique: d5Mk8XcsMKm5VfyumiqzrQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630508; x=1718235308; 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=NfEypfhhzAT3jaOXKR+DgWb6iflUNTeNRcp9m8ElhrQ=; b=OHy34unNJ5bxM/8ZuiFb4z86xYxxTrWbBIQ/zsfDeh/pdlSXY6dSsYALJlLhxUkCjk mdwQH2aoTISoQVNDMHmKvNBdzdC/rvlADBlX+U/0VcjKAxDpgu7qclgwaXlErtN8asDt ZFsxv4pWf00UJ6fmx5IbyUAj753BJ6uRimsVAqU84O7y9wXX/Kt/4PvrA7oamYF3seeC z4OOndMMDro7o2+VFuPIqI3VpwRrecvDLQHEPPiDtqvLflnz6XQD030wiATB2csbT9RJ kNg4gp10qKAEPObMZ6wPAOIcfw5jmArX7FnIyO6qJ3iyJP9cbiaR2/bEI3gXSmI50pTE 1Xaw== X-Gm-Message-State: AOJu0YxXv24NQL0ZG20BUaw5UF+d7OZsQ/QPd3UK22QN4Dsxt7QFQr50 wF/N/OpBp6NAZyXJujFc9bPgoPI/PmS/JnvBI2TKtFAxffKx9IKps4lH9fMwUp9o/LnmqFZ1NX2 J7CFIv6qWye33ZZ7AVJzriE2eSuxFwu97Y35tK2sGSih5RWtDC4C4dh4eGhJkMyCXOdHL4qInxA V0Bh23iTpiuKIhveWgeAVnvFHzH59hTA== X-Received: by 2002:a17:906:add8:b0:a68:be46:742f with SMTP id a640c23a62f3a-a6c75f8edefmr88843366b.3.1717630507856; Wed, 05 Jun 2024 16:35:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8qjlS+udktv58GsuPwqZCLE2JugkraGrX6J5bR8VSSWhHp3rKl68z+JOewWk/FnZQ8pmpBQ== X-Received: by 2002:a17:906:add8:b0:a68:be46:742f with SMTP id a640c23a62f3a-a6c75f8edefmr88841266b.3.1717630507462; Wed, 05 Jun 2024 16:35:07 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:03 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Halil Pasic , Christian Borntraeger , Eric Farman , qemu-s390x@nongnu.org Subject: [PULL v3 07/41] virtio-ccw: Handle extra notification data 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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630575739100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonah Palmer Add support to virtio-ccw devices for handling the extra data sent from the driver to the device when the VIRTIO_F_NOTIFICATION_DATA transport feature has been negotiated. The extra data that's passed to the virtio-ccw device when this feature is enabled varies depending on the device's virtqueue layout. That data passed to the virtio-ccw device is in the same format as the data passed to virtio-pci devices. Signed-off-by: Jonah Palmer Message-Id: <20240315165557.26942-5-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/s390x/s390-virtio-ccw.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 3d0bc3e7f2..956ef7b98d 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -125,9 +125,11 @@ static void subsystem_reset(void) static int virtio_ccw_hcall_notify(const uint64_t *args) { uint64_t subch_id =3D args[0]; - uint64_t queue =3D args[1]; + uint64_t data =3D args[1]; SubchDev *sch; + VirtIODevice *vdev; int cssid, ssid, schid, m; + uint16_t vq_idx =3D data; =20 if (ioinst_disassemble_sch_ident(subch_id, &m, &cssid, &ssid, &schid))= { return -EINVAL; @@ -136,12 +138,19 @@ static int virtio_ccw_hcall_notify(const uint64_t *ar= gs) if (!sch || !css_subch_visible(sch)) { return -EINVAL; } - if (queue >=3D VIRTIO_QUEUE_MAX) { + + vdev =3D virtio_ccw_get_vdev(sch); + if (vq_idx >=3D VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, vq_idx= )) { return -EINVAL; } - virtio_queue_notify(virtio_ccw_get_vdev(sch), queue); - return 0; =20 + if (virtio_vdev_has_feature(vdev, VIRTIO_F_NOTIFICATION_DATA)) { + virtio_queue_set_shadow_avail_idx(virtio_get_queue(vdev, vq_idx), + (data >> 16) & 0xFFFF); + } + + virtio_queue_notify(vdev, vq_idx); + return 0; } =20 static int virtio_ccw_hcall_early_printk(const uint64_t *args) --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630703; cv=none; d=zohomail.com; s=zohoarc; b=YMv2/sTj0WwlUEI/4oOeoxp8YLkzPX87UeuRwtAKXl9vf2+d8KRdVZuppJpX0WcGlGxwdFbEI4MUVls/kbvG9fVYHdzrTe6GsOLk0VTydp1N82ZpvAGKBtiLqM6DmC/12sOJlbx3m9qyZa/miFabiPR7STDpUX+4EVAwG8kyWKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630703; 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=OCCVtvSfvqBAUBpNFi/zb/m65iBLwl7XEHTViiftxcE=; b=CksmTrPD/DsCox1XilOkSXu3VJ09vAeJMsAECXMKejOClfB1NOwj+o7fKdk8wcOC7QM8m6mQi7goyA1x8PQG2VS9ntDrjtRGI2LUkzm+RK9Ii/Hk1pQ1Am2Q6bmkGfEkfMae89rDezm7Ixf2Maws3FEa8KmY8ET8Dp5dBiPDVwY= 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+importer=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 1717630703775900.4067147714277; Wed, 5 Jun 2024 16:38:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0A5-0002w5-HI; Wed, 05 Jun 2024 19:35:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0A4-0002vR-1G for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0A2-00055j-1M for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:19 -0400 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-570-PRTuOYIGOuyAZPYradv10A-1; Wed, 05 Jun 2024 19:35:15 -0400 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-52b963aa3feso243143e87.2 for ; Wed, 05 Jun 2024 16:35:15 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae205bb0sm87994a12.67.2024.06.05.16.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630516; h=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=OCCVtvSfvqBAUBpNFi/zb/m65iBLwl7XEHTViiftxcE=; b=BzBtej76Q5+Qjdz79BuyPnEZRLGIZEmg2PxlXe3jlCSTcJlBKbF7d0LgLQpo6d0UgB6Knn 280/aWeC0LeHV5xb0cK16njkmTQBS8T/IRRl4Q9Xp+ORtXOASHKCp6Z+Yajp3VwjqminMB bwExgxX2yjgN+I0BxMQObee326LSnSw= X-MC-Unique: PRTuOYIGOuyAZPYradv10A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630514; x=1718235314; 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=OCCVtvSfvqBAUBpNFi/zb/m65iBLwl7XEHTViiftxcE=; b=Uz4KfC1c9eaLsyBrxgQCUcTc/n9snQIjiGr8nYo7rJPDdfNh+zsj4YpETYoALCl+gN cWgt+wQU3LHCXxHBOOQDqgRrq+tlsoaOfhp/zBTVU0YhwSXdsJGZui8HV0q7+caF4Gbj xEhlqkirCR0ZGE+paq5how0Df2qNgjVP5+AWNPZFdkgQ/DKCbZc8u6GIkVv0Tt8DU2ha J/3jGiXM/oSQcqJl2stFU5cZIIVA1sWNjF72twQ97MGziEWn9aGBSRb6epBtY/VUMuyM 1DM+IUJ3Bc+7XvG2kI9wJwldo212ppzm+vs+88TFd8MMSr+5GGBfQFq2JW72FJcF6h6Q 6B8A== X-Gm-Message-State: AOJu0YwB6QMZh0bQw/NkFRc9qMwyAsbw/q42mBCD91UlMtwofZWuaJcp wHyv3/rsHV8/gnju3l4MnWByKIl2tqjYrnt/Q77RmdfKKF9hMxutwjnaf9tt7RDSV0/BjL1f/2G HbAvt6c1A17A7HWxt+qhZSPFKXHYTy4bX6mNXB7q6J0bxXwtD1pM73cD3Q/OYTna/jPX4at5TEa HzBpmvsAjY0wSvYi0jxM1fr+LNnVo0RA== X-Received: by 2002:ac2:4c95:0:b0:52b:797d:efd4 with SMTP id 2adb3069b0e04-52bab4dcd3emr2290626e87.16.1717630513645; Wed, 05 Jun 2024 16:35:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJ1cJJUaCyUIk8ZNAMFL5MUyJsfbEE/Ub7b5mozNI9G7VXLnJ3/k/kD9XSV/i7/hLrdqpSmg== X-Received: by 2002:ac2:4c95:0:b0:52b:797d:efd4 with SMTP id 2adb3069b0e04-52bab4dcd3emr2290605e87.16.1717630513104; Wed, 05 Jun 2024 16:35:13 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Lei Yang , Eugenio =?utf-8?B?UMOpcmV6?= , Srujana Challa , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Jason Wang , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , qemu-block@nongnu.org, virtio-fs@lists.linux.dev Subject: [PULL v3 08/41] vhost/vhost-user: Add VIRTIO_F_NOTIFICATION_DATA to vhost feature bits Message-ID: <9ab25321437a88267be640a7d9d01d7c6389f6ad.1717630437.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+importer=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_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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630704318100001 From: Jonah Palmer Add support for the VIRTIO_F_NOTIFICATION_DATA feature across a variety of vhost devices. The inclusion of VIRTIO_F_NOTIFICATION_DATA in the feature bits arrays for these devices ensures that the backend is capable of offering and providing support for this feature, and that it can be disabled if the backend does not support it. Tested-by: Lei Yang Reviewed-by: Eugenio P=C3=A9rez Signed-off-by: Jonah Palmer Message-Id: <20240315165557.26942-6-jonah.palmer@oracle.com> Acked-by: Srujana Challa Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/block/vhost-user-blk.c | 1 + hw/net/vhost_net.c | 2 ++ hw/scsi/vhost-scsi.c | 1 + hw/scsi/vhost-user-scsi.c | 1 + hw/virtio/vhost-user-fs.c | 2 +- hw/virtio/vhost-user-vsock.c | 1 + net/vhost-vdpa.c | 1 + 7 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 9e6bbc6950..bc2677dbef 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -51,6 +51,7 @@ static const int user_feature_bits[] =3D { VIRTIO_F_RING_PACKED, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_RESET, + VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; =20 diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index fd1a93701a..18898afe81 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -48,6 +48,7 @@ static const int kernel_feature_bits[] =3D { VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, VIRTIO_F_RING_RESET, + VIRTIO_F_NOTIFICATION_DATA, VIRTIO_NET_F_HASH_REPORT, VHOST_INVALID_FEATURE_BIT }; @@ -55,6 +56,7 @@ static const int kernel_feature_bits[] =3D { /* Features supported by others. */ static const int user_feature_bits[] =3D { VIRTIO_F_NOTIFY_ON_EMPTY, + VIRTIO_F_NOTIFICATION_DATA, VIRTIO_RING_F_INDIRECT_DESC, VIRTIO_RING_F_EVENT_IDX, =20 diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index ae26bc19a4..3d5fe0994d 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -38,6 +38,7 @@ static const int kernel_feature_bits[] =3D { VIRTIO_RING_F_EVENT_IDX, VIRTIO_SCSI_F_HOTPLUG, VIRTIO_F_RING_RESET, + VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; =20 diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index a63b1f4948..0b050805a8 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -36,6 +36,7 @@ static const int user_feature_bits[] =3D { VIRTIO_RING_F_EVENT_IDX, VIRTIO_SCSI_F_HOTPLUG, VIRTIO_F_RING_RESET, + VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; =20 diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index cca2cd41be..ae48cc1c96 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -33,7 +33,7 @@ static const int user_feature_bits[] =3D { VIRTIO_F_RING_PACKED, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_RESET, - + VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; =20 diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 9431b9792c..802b44a07d 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -21,6 +21,7 @@ static const int user_feature_bits[] =3D { VIRTIO_RING_F_INDIRECT_DESC, VIRTIO_RING_F_EVENT_IDX, VIRTIO_F_NOTIFY_ON_EMPTY, + VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; =20 diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index eda714d1a4..daa38428c5 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -62,6 +62,7 @@ const int vdpa_feature_bits[] =3D { VIRTIO_F_RING_PACKED, VIRTIO_F_RING_RESET, VIRTIO_F_VERSION_1, + VIRTIO_F_NOTIFICATION_DATA, VIRTIO_NET_F_CSUM, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, VIRTIO_NET_F_CTRL_MAC_ADDR, --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630573; cv=none; d=zohomail.com; s=zohoarc; b=OzI/rE1VWsfuu+YX+Ckb1/TqB+sShqSaa0Vwr+n9B7TnJeeT0q6lhUFGQvaTP4ilKC/LPyEektc8tBN7KEYqheWaXbqgqmRH7QOp7N2clUOquxRO+zYUxcEtHzpSQynyMfY4JCOxZzYTUxchmkymWY3Yq1guzO8PK5XC+PJyCAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630573; 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=Q0Pfb548kulwNGCVafgBGSBiO4uWmp/hiUtG94za6C8=; b=RSYPZLs20nEZMltYhERHYe05vVfEVZsp5+FfnD2rBbwLDogPEfQhXFliIPugYkm/BBXmAveSr5padVWj95MXwF0ydLMu0Hwz0ISLYtya1t1Ai0oV9b8tC/hewY7RrFmoBzIrpJxESfZMXS9kjgcmfWsNTCGqVlne5bgvhTk4cew= 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+importer=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 1717630573968892.240328343169; Wed, 5 Jun 2024 16:36:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0A8-0002wV-M1; Wed, 05 Jun 2024 19:35:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0A6-0002w7-Qg for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0A4-00056U-SI for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:22 -0400 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-543-5AbZ8ib_Pxyo78TN08rAAg-1; Wed, 05 Jun 2024 19:35:18 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a68b4937c43so16638566b.2 for ; Wed, 05 Jun 2024 16:35:18 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c80728d18sm6312466b.198.2024.06.05.16.35.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630519; h=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=Q0Pfb548kulwNGCVafgBGSBiO4uWmp/hiUtG94za6C8=; b=GOHtIc2ujqNx/z9GfFcL80P/MDubX57e25/1z52AfeT3EnUSPVBg4qc4pe715Cg080nnXw u2RmMRRN2RSghiq923IRif+dxStYU/XTncz1t796OZw+0JlN1+Y97jAKpbsVADO2xpN8Qm 83Tx4ylgfE+vAVQ8MYUleQsYKYOmVVc= X-MC-Unique: 5AbZ8ib_Pxyo78TN08rAAg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630517; x=1718235317; 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=Q0Pfb548kulwNGCVafgBGSBiO4uWmp/hiUtG94za6C8=; b=KUuEAYdDXHV7KNu326aA0AQquuDVY/3Oev9ly++ftQQX+6r+rPvaq48AE1abMd6N6f d1eSB9ccd0PoJUDtZid1/S+Y1fvF3QD44xVz44otbtyPiH22xnlQkHzdCn2OExjdYoCw uwvl/KnKVZH8hlK4SlnRcDDVAQLcXvfCRfB1Np8rjm/HPhEQuMxq7e30DINpVT+JwZ8y udlqVpc7fBmcCEsl1FhUoZd6Xa/iWGXZZHxn3rJLyng17h3wGrk/tRZgMrokGtYGO6AB Y/FolZmYTPzFWuco2R/k5OQve7E1rVxTOHFGB0you75eiZ/YImf9wJJj5MJV8zB0J0eY 2+AA== X-Gm-Message-State: AOJu0YweC9HjgFsq7DehZqzR1HsnKv82JkPomgE+BiQQJ8my9OiP/4nx wI0fwFxlYW+yDpCKdhGx83gnWh4hnHNYSjOHRicLf0R620CAqXsb+dXAspomxN7g2BvStFemSkq YbWAQzkdveIqHTmPDttTGnKjhEYyukIg2LroCN2IES8X2Ci5t10OcYgAugihRHgJPfgkpJDggGB lOlmcHUKFifKo0yvxpbiSpGzvULFscEg== X-Received: by 2002:a17:906:2bd0:b0:a68:ece7:8db5 with SMTP id a640c23a62f3a-a699f562d6cmr224212666b.31.1717630517048; Wed, 05 Jun 2024 16:35:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGahZNBgxL1fwV0i1PzqjyC48R5iFl9fpV7OW4dJf8ZYZw1lm8ehkIRBh1PXle/lKomOuayEg== X-Received: by 2002:a17:906:2bd0:b0:a68:ece7:8db5 with SMTP id a640c23a62f3a-a699f562d6cmr224211866b.31.1717630516599; Wed, 05 Jun 2024 16:35:16 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Christian =?utf-8?Q?P=C3=B6tzsch?= Subject: [PULL v3 09/41] Fix vhost user assertion when sending more than one fd 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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630576022100005 From: Christian P=C3=B6tzsch If the client sends more than one region this assert triggers. The reason is that two fd's are 8 bytes and VHOST_MEMORY_BASELINE_NREGIONS is exactly 8. The assert is wrong because it should not test for the size of the fd array, but for the numbers of regions. Signed-off-by: Christian P=C3=B6tzsch Message-Id: <20240426083313.3081272-1-christian.poetzsch@kernkonzept.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index a879149fef..8adb277d54 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -568,7 +568,7 @@ vu_message_read_default(VuDev *dev, int conn_fd, VhostU= serMsg *vmsg) if (cmsg->cmsg_level =3D=3D SOL_SOCKET && cmsg->cmsg_type =3D=3D S= CM_RIGHTS) { fd_size =3D cmsg->cmsg_len - CMSG_LEN(0); vmsg->fd_num =3D fd_size / sizeof(int); - assert(fd_size < VHOST_MEMORY_BASELINE_NREGIONS); + assert(vmsg->fd_num <=3D VHOST_MEMORY_BASELINE_NREGIONS); memcpy(vmsg->fds, CMSG_DATA(cmsg), fd_size); break; } --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630654; cv=none; d=zohomail.com; s=zohoarc; b=GGFCrHUOet6LxSvJ9h0yOIVKnZGZYW5m10EmP4XoRzf54xaUMTmh4SPY4JA7dm7/RlLG2+oJdrOZFTJoV6ax8YOpuKRDo09UV9oIMl7yH0BiWE4MF4fJezUl1ShuYxY0l66oR8iwsIFOItO4bHYwX0JxrYz0yUa3aQYEufOFe4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630654; 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=QKgBtghpdntZCNxsubdg5dbN8fdbQsXq4OpajtHNP9c=; b=aLH45utGXW2YE3oieV0x4cVp7fHeCH0W9ZAShZX/7vCwWndrGbTnSRI3nwn1oyvc+PkGeLVbZL8vtVVdWl4gfLFr65fbLg/dUhVkXuYABqStJiMSlDi2WSwhbYoa+nOubbQJgQZFiqFok9J/Doqw3eK4ng6IkcJrMCz7KhMyXOo= 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+importer=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 171763065485255.578527257805376; Wed, 5 Jun 2024 16:37:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0AA-0002wn-Oy; Wed, 05 Jun 2024 19:35:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0A9-0002wf-Bl for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0A7-00058I-Q3 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:25 -0400 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-124-vyAoZxVyOeKOASzIWNQM_g-1; Wed, 05 Jun 2024 19:35:22 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-35dca4a8f2dso200592f8f.3 for ; Wed, 05 Jun 2024 16:35:21 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c8070ebeasm6363566b.181.2024.06.05.16.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630523; h=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=QKgBtghpdntZCNxsubdg5dbN8fdbQsXq4OpajtHNP9c=; b=KH3aog82e6y4eMGHrUbQOqqR2WFf3VOxJD/tlM7k4fp7d4mmpGIpmSipmzqI/KVXCUNV6J FuLnczQa7k+vuUB3E22svTx+FxrAZhoGtLY5oxhaBEvRKNuv5LHmuhz8LfNeWMw7ccqLnf FTIUFtrKxdpoN4EmjUUy7SPG5H7DGso= X-MC-Unique: vyAoZxVyOeKOASzIWNQM_g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630520; x=1718235320; 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=QKgBtghpdntZCNxsubdg5dbN8fdbQsXq4OpajtHNP9c=; b=WuzeKIuk0GjHnu/S6O2XoOeDgmzjT3NniHRDyVMMWO8sq50ezI4jxhGIinf4+Flgbo tpGNCceK9rFTk3anXT0O7A91ATS3yPQbf9ErOANMXc4NscPLLttBY5H9vLfyEG+CnJWh 7hoDa96kNzzQpZqWv626tZ+2ysD/dXuXF0dkGmOa3K4KTj7et7h/jVLWAcY+pmsvM8sV Gbbw5irCz8MyQV+ef9zz3EwWFmNBK/sOa7VUScRhECPhH6c860po/Euswe/CVxrmuGGy /kauqUV5KZNtCMlvAe8eZGX/kRwzldRwSGRoVJAKfSBEUrxy+ZPxB3tVb240ZA63ewrj Q8jA== X-Gm-Message-State: AOJu0YxWGyTITLlVrhdFemCW6YOIZRPFqkOKTiyM+0Nl1HrarAcigmv0 7kMNp2lDsB1kkPW+eJvW0X2IfEZf8RjRsgZqmmwbtLMpxedPwYu0wzjy4laEwUpEyHMTsjcmxG8 tgl4gxAPPzk3erw+9ea9qRgnn4KAc4lloL8c+gh4r5GEOCGMJP9PLuZm/tVhVrKCVlpq6JSaLjr l4QMB1MOrjQstqX5Q/cnuiLd9TZUeNfA== X-Received: by 2002:a5d:588e:0:b0:354:f38c:6d0b with SMTP id ffacd0b85a97d-35e8ef087abmr3503896f8f.37.1717630520430; Wed, 05 Jun 2024 16:35:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHB+qZ4UlcLGNxrDB/PojJu5NSA6tmO9Rl2SWJ+nqO7Kfho39j9GS78xJz0FFrc7RIwogL2/g== X-Received: by 2002:a5d:588e:0:b0:354:f38c:6d0b with SMTP id ffacd0b85a97d-35e8ef087abmr3503880f8f.37.1717630520015; Wed, 05 Jun 2024 16:35:20 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Halil Pasic , Marc Hartmayer Subject: [PULL v3 10/41] vhost-vsock: add VIRTIO_F_RING_PACKED to feature_bits Message-ID: <1ca9549c981cf118bc7a52dc7d5cebce75a918fa.1717630437.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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630656061100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Halil Pasic Not having VIRTIO_F_RING_PACKED in feature_bits[] is a problem when the vhost-vsock device does not offer the feature bit VIRTIO_F_RING_PACKED but the in QEMU device is configured to try to use the packed layout (the virtio property "packed" is on). As of today, the Linux kernel vhost-vsock device does not support the packed queue layout (as vhost does not support packed), and does not offer VIRTIO_F_RING_PACKED. Thus when for example a vhost-vsock-ccw is used with packed=3Don, VIRTIO_F_RING_PACKED ends up being negotiated, despite the fact that the device does not actually support it, and one gets to keep the pieces. Fixes: 74b3e46630 ("virtio: add property to enable packed virtqueue") Reported-by: Marc Hartmayer Signed-off-by: Halil Pasic Message-Id: <20240429113334.2454197-1-pasic@linux.ibm.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vsock-common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 12ea87d7a7..fd88df2560 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -22,6 +22,7 @@ const int feature_bits[] =3D { VIRTIO_VSOCK_F_SEQPACKET, VIRTIO_F_RING_RESET, + VIRTIO_F_RING_PACKED, VHOST_INVALID_FEATURE_BIT }; =20 --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630596; cv=none; d=zohomail.com; s=zohoarc; b=bdopESynMoClifF0WdVz1CLb54jwYJxzC5TYUKS208rcyJ3WJ74xakTbPFfp0Ghj0BEqHS2+3+wYik7GnHAw/Hxjayg8WptiQAWF94+h1TrQGfkT8NNVl49psUPO81KS9ZJ7Sy2T3ixA1q7YUuRgZzBiKifSP4eXzNSHtQVpNME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630596; 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=Bf3inGfH3C1OrX/KdJFaqQvDHDePnfUDWhDjBaZ52tk=; b=hmzdzb7Lrbfeg4vvsFAzFkLDl8TXIADegtAoL3Ac6M1f4dBeAxrH2miXvTjrBcaIgJ76M/3GhZzqGVnnsaGRVtHb4crqgFYIPxZJx/7v/Vbnr3LJ7ZTTLA1bMXlfiF63ho7RbELS5kgrw2YJGNl/9dhi2tUPJu90jXHRlKA5A+o= 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+importer=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 1717630596054359.51967443505987; Wed, 5 Jun 2024 16:36:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0AH-0002xs-5z; Wed, 05 Jun 2024 19:35:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0AF-0002xG-5s for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0AD-0005DI-9V for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:30 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-pnp4JZEWPQuMVEuB5fIKww-1; Wed, 05 Jun 2024 19:35:26 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a6861bb1c0bso15717766b.3 for ; Wed, 05 Jun 2024 16:35:26 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c805d0af8sm6951866b.87.2024.06.05.16.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630528; h=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=Bf3inGfH3C1OrX/KdJFaqQvDHDePnfUDWhDjBaZ52tk=; b=Q/5e2mmGQc8slo6iwP7eyjch3DOYqWmUBpJ0dzi8NhSBgM6wFUBX6lR+nCBM/aOFp++Mlb 3McoXrQOTLZZ1WiqWMtG6YeW5stZLIl2MJHAr75Ns3eVN/lCmlTAVF+cktPQ3kMWCDiiJi iK1pt9rdlCQAIn+kUiHR960bahaNcoc= X-MC-Unique: pnp4JZEWPQuMVEuB5fIKww-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630524; x=1718235324; 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=Bf3inGfH3C1OrX/KdJFaqQvDHDePnfUDWhDjBaZ52tk=; b=SaoCFzx1tBVYAIvS95oCeKotHd6NSIC2FHY7glZKaSLXXtUb3aa1Ye+ZvUpOW841HD U01HYrNivoCaxps59WfNcuMQlPdpfIWBHgBgW/mpEM2GzDY0V7VrQCC4s46qGJr5EBVN 8Amygy6pOW3evcXOTPu6ex2jJup+W5s2qgmf/z9PVIKPreQwnOtJ1emxzFYLC5TeBewo SOcao1JNOFobn6zTFtBmg58vtYBKpkrWwl3pNT/5YM0/Vn777gu+EBn0N2v2tcKbXanj ufjLdQc24KMIWykPKHTdfz1tW1LNRgJ2AqoIfds2uZm5ivV5C1zaQ19Jgeo3zxOUh7m7 JnXA== X-Gm-Message-State: AOJu0YwNt0wkyzStOYizzgoU5PdkHtBCLkJ2DqpzomBjClnF0fYTmCS7 oCrLouZ9TeY3t38ebHFDEX0NDJe4+EOUsqtDVk892Kn0iQbIrSG1eQ45sjc81nk0djq0z+MhF8t Jn4Mf8ydiQaya0NoBvNC7QMajBtAGlQOvaJ8QxDLVKc7lcpa/cKFpBaQau51H7C/TRgRdX9riuk ULUtpI7ppz23091BFgFuAdauK4OnseIQ== X-Received: by 2002:a17:907:bb99:b0:a68:b089:e27 with SMTP id a640c23a62f3a-a699f681b5amr246320366b.44.1717630524540; Wed, 05 Jun 2024 16:35:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+UsTvEZwZE0tcfwq8NLODBxUw9fNw/xSvLa6J+AHzduJeHN7HdkGiYjiFCtUQKXFBF/PfXg== X-Received: by 2002:a17:907:bb99:b0:a68:b089:e27 with SMTP id a640c23a62f3a-a699f681b5amr246319366b.44.1717630524087; Wed, 05 Jun 2024 16:35:24 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:20 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Wafer , Jason Wang , Eugenio =?utf-8?B?UMOpcmV6?= Subject: [PULL v3 11/41] hw/virtio: Fix obtain the buffer id from the last descriptor 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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630597907100003 From: Wafer The virtio-1.3 specification writes: 2.8.6 Next Flag: Descriptor Chaining Buffer ID is included in the last descriptor in the list. If the feature (_F_INDIRECT_DESC) has been negotiated, install only one descriptor in the virtqueue. Therefor the buffer id should be obtained from the first descriptor. In descriptor chaining scenarios, the buffer id should be obtained from the last descriptor. Fixes: 86044b24e8 ("virtio: basic packed virtqueue support") Signed-off-by: Wafer Reviewed-by: Jason Wang Reviewed-by: Eugenio P=C3=A9rez Acked-by: Jason Wang Message-Id: <20240510072753.26158-2-wafer@jaguarmicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 28cd406e16..3678ec2f88 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1745,6 +1745,11 @@ static void *virtqueue_packed_pop(VirtQueue *vq, siz= e_t sz) &indirect_desc_cache); } while (rc =3D=3D VIRTQUEUE_READ_DESC_MORE); =20 + if (desc_cache !=3D &indirect_desc_cache) { + /* Buffer ID is included in the last descriptor in the list. */ + id =3D desc.id; + } + /* Now copy what we have collected and mapped */ elem =3D virtqueue_alloc_element(sz, out_num, in_num); for (i =3D 0; i < out_num; i++) { --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630779; cv=none; d=zohomail.com; s=zohoarc; b=gnnINXIip0E3/l33GW6HcML6aunSSRijqpCciBmAEfJ2cCKvwcDPkohtPComItsxBavyCaxz7iREszTG44cOgrrxL9fok2gJU0FW90fhWKzNeS0oBrvfB1GlfsOZCJVddpFUOXcJR/iVPfuduzMjhRpLvn9lM4bMBmWjERBZ/Kg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630779; 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=B0HOmEGBKVd19MvX+tjutWxLYb9ToOXOEpHWAIoWqrE=; b=TLN1q2WYYcqbpC2w+yVHN/Z0inA8ZGb82jG1myh21DvkrfbRgW/i1yzd48lV5UtAHBw4TwCDJ54QWR9Wv1UBgEgGwsUGY/CQzUWs8tn1JQTNiglpQ0f2X7RA+OW2IUQWy4K0eornUQVZ2z8GUFkT9qTzrJGgsgPWegfzlQkBumY= 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+importer=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 171763077964158.87936006865584; Wed, 5 Jun 2024 16:39:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0B7-00067x-0d; Wed, 05 Jun 2024 19:36:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0B5-0005tI-0z for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Az-0005kC-RF for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:19 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-141-D9grAe2tMWqsaLh1J-Md3w-1; Wed, 05 Jun 2024 19:35:29 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a68ccd15540so12868166b.3 for ; Wed, 05 Jun 2024 16:35:29 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae13faccsm98396a12.54.2024.06.05.16.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630577; h=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=B0HOmEGBKVd19MvX+tjutWxLYb9ToOXOEpHWAIoWqrE=; b=Oao/dyYb8ndGRMBAnNFgXsQVNn5+ZV5HPBBlxeUtmAFzWEHdnkL+vijjwIexh2qMJzr6ND 3tyw42LK6cD9zLdqdL+ZgvHyFVl6HBDlOyl1iIrqSqgbfx/HMAGF/rq3OIDZQzpNRivFe0 GU5jUtSPh6BiNBbcEntk/pp9l+lDpU8= X-MC-Unique: D9grAe2tMWqsaLh1J-Md3w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630528; x=1718235328; 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=B0HOmEGBKVd19MvX+tjutWxLYb9ToOXOEpHWAIoWqrE=; b=tc1CFb2WaZsAKTMws+h3tHs1eOJHaII5VU8rFjJfJYAqMkNYqqwzL1xy1RpRNJrV+3 AQu/6frSD14MKpksBjIa4rofvfKLOaGU/iK9ev8jcih15F7ja4pImyyStSj2b+HPx4C1 ITStz8Q7g5j9jBLBIjfu+G9xeve68zzZWTdqUWY9yVzC3pLXZNkAJbBugvcKVWuZ73rD f83GlhhtmLZnH/7nwFmaH++sON57xHvIFcQa2bQc1z2UpQGuXOSuEd+5Xijem7/E7qm9 TY28/OFIdwTfS8q68J633vMKPOlQEBo6YGLUDeMN+FMnfOhBH7myfGiODghPbOBSQ3o8 hVrQ== X-Gm-Message-State: AOJu0Yy+ILH378YIb4AALpNiJTKb9jZ0u9GiJnk7US2hD/7ETfO1Teq1 IdMl5ZJARq6KS/jdwCR8Y52G61eThYV36yM9m91OIyxx2ofcckvenIAVh/Bb6HWmw6XfPhD+O8M E+4ZNEG8BeFtVJo2z4p2BQ+/EcWtOE9fDJ9lgceJteQjhifWrzfoNTqQZZo5t+OQFf18XfMao3+ fDyYYhr6RlsT6LYsxxWMYNbEVb+WIsnA== X-Received: by 2002:a50:8716:0:b0:57a:1e0a:379f with SMTP id 4fb4d7f45d1cf-57a8b6a7140mr2317180a12.16.1717630527956; Wed, 05 Jun 2024 16:35:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGJyjFyW6H/Q3W0BkX/oMTwdJK4eQgNH4e/EUTA9DQD+ofKAnk9ESGcTZvMWZAgOwZksdIZQ== X-Received: by 2002:a50:8716:0:b0:57a:1e0a:379f with SMTP id 4fb4d7f45d1cf-57a8b6a7140mr2317174a12.16.1717630527458; Wed, 05 Jun 2024 16:35:27 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jiqian Chen Subject: [PULL v3 12/41] virtio-pci: only reset pm state during resetting 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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630780592100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jiqian Chen Fix bug imported by 27ce0f3afc9dd ("fix Power Management Control Register f= or PCI Express virtio devices" After this change, observe that QEMU may erroneously clear the power status= of the device, or may erroneously clear non writable registers, such as NO_SOFT_RESET, etc. Only state of PM_CTRL is writable. Only when flag VIRTIO_PCI_FLAG_INIT_PM is set, need to reset state. Fixes: 27ce0f3afc9dd ("fix Power Management Control Register for PCI Expres= s virtio devices" Signed-off-by: Jiqian Chen Message-Id: <20240515073526.17297-2-Jiqian.Chen@amd.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index cffc7efcae..7d62e92365 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -2306,10 +2306,16 @@ static void virtio_pci_bus_reset_hold(Object *obj, = ResetType type) virtio_pci_reset(qdev); =20 if (pci_is_express(dev)) { + VirtIOPCIProxy *proxy =3D VIRTIO_PCI(dev); + pcie_cap_deverr_reset(dev); pcie_cap_lnkctl_reset(dev); =20 - pci_set_word(dev->config + dev->exp.pm_cap + PCI_PM_CTRL, 0); + if (proxy->flags & VIRTIO_PCI_FLAG_INIT_PM) { + pci_word_test_and_clear_mask( + dev->config + dev->exp.pm_cap + PCI_PM_CTRL, + PCI_PM_CTRL_STATE_MASK); + } } } =20 --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630623; cv=none; d=zohomail.com; s=zohoarc; b=agydEl9hWtjGbFygttiTNjccH/UW3sP3BTacSDL8tqygpEhK0M11BB7ll5lY3ObUcvVW/sSi5EayZnySzCZvclHOfe5FdvZP/YLFR+6xc5zpICf/7tvXLnHjPPGNt58ejKXJ1kHiUtmSpWIm2lUFYlR09tXsSPBFwx5IlAQktJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630623; 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=3bV+n5a+n2PubUhTQh2qtot7neovPmYiRH9+8WKEDSw=; b=lTrJNuPo8HivwkU+QxrLpIZkMZGVX+Ou2DtcF0ai5qHhavakY1xOIWRGe5RLrrQexA8AS6w9P/uTQOIivmGlECgomoMqPHb+FG4ai9V9FkNifMvRbz7VR1hE8hVay9RPeuBh47ErOpv3JnkjscRpuh5ikJPQleBqpmix3xnt5s4= 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+importer=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 1717630623718971.464872660463; Wed, 5 Jun 2024 16:37:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0AL-0002yU-Sh; Wed, 05 Jun 2024 19:35:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0AK-0002yE-Ri for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0AJ-0005Nm-Cl for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:36 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-vPn30kxJML-YYc-TwNqcfw-1; Wed, 05 Jun 2024 19:35:33 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a68b4937c43so16645466b.2 for ; Wed, 05 Jun 2024 16:35:32 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c80728893sm6269166b.191.2024.06.05.16.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630534; h=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=3bV+n5a+n2PubUhTQh2qtot7neovPmYiRH9+8WKEDSw=; b=IelX3q5Lk9b0PiUZp5TOltXoGgGXO3V4YT5654vOUsB+Aai18ujSj3Hq8oQSJkxJ18O65N hTfA9tO9H3NCthhYzuNJsO6nbGh5nPLB+oJ7pYCqVr0UWuilus9A3cC5nO41L/JeV89+mH N0/hQ9LzpOxTkaxkB3z9JsZZpx8Ij2k= X-MC-Unique: vPn30kxJML-YYc-TwNqcfw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630531; x=1718235331; 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=3bV+n5a+n2PubUhTQh2qtot7neovPmYiRH9+8WKEDSw=; b=JRcj22oYwxAxCpP0BfBqxyhyXh5HY3RNEDP2R0EAcTqUmTMAOYGW+hG7mWXuWMLxgF XF/SlCGAjqEuRVRm5e/amvGWZegghYHXUxlw/aszRo7mVJzI+dlLUjcodD+kfsAnSfOp G37a4a5Ymm8TPe685ABvKdEmubH/JBohpQobHcUyw7cLdDlHhlcehzlw15zKOpYHgNC0 XNfK+Ufcr3DQP+akYq2X9ppL+5fsxWT2+AECT/eICbXHsW062KzX0xCWznxQOlK3C2AX BJMdycy0UXQHnHLNcFLBFejDUtfSSzuzCDrOMKnzfza6YWoI7x/Fy2KGv+qSX5eOqKo0 MK3w== X-Gm-Message-State: AOJu0YwDW2Uw1YlEeZvloZbMmNAW/rU1e83w7Nh3epJwwDeijMlygFC1 9jz2iN3L+qfdMVaLVFT+GhHZuUQYSUbgmkE//jn9H0H0RXDWalbqmIVI/H3AtgO42KR2uVWNOZa zMlzpSigQem5rG+y5JLVz+mZB13VlwNb6ajabOrZZkltDMPRBWPq5F6FtMoGTLEPvrTjfMvTM7L 1Vqk/FcnOF5qybmKCwmdvMH6yhnzza5g== X-Received: by 2002:a17:906:119b:b0:a55:b272:ea02 with SMTP id a640c23a62f3a-a699fdff2d1mr244371866b.75.1717630531216; Wed, 05 Jun 2024 16:35:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHddrL6oLM79FgOu7BK2ubtdDcRV/cRfGgj1FDVEQ8et82fG1Up603+4dabJJXn6hyFwqDmJw== X-Received: by 2002:a17:906:119b:b0:a55:b272:ea02 with SMTP id a640c23a62f3a-a699fdff2d1mr244370866b.75.1717630530734; Wed, 05 Jun 2024 16:35:30 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Gerd Hoffmann Subject: [PULL v3 13/41] vhost-user-gpu: fix import of DMABUF Message-ID: <61d2299cc7baaa007120f6e1ce1db9d4af0a7ade.1717630437.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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630623916100001 From: Marc-Andr=C3=A9 Lureau When using vhost-user-gpu with GL, qemu -display gtk doesn't show output and prints: qemu: eglCreateImageKHR failed Since commit 9ac06df8b ("virtio-gpu-udmabuf: correct naming of QemuDmaBuf size properties"), egl_dmabuf_import_texture() uses backing_{width,height} for the texture dimension. Fixes: 9ac06df8b ("virtio-gpu-udmabuf: correct naming of QemuDmaBuf size pr= operties") Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20240515105237.1074116-1-marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/display/vhost-user-gpu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index e4b398d26c..63c64ddde6 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -281,8 +281,9 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUse= rGpuMsg *msg) modifier =3D m2->modifier; } =20 - dmabuf =3D qemu_dmabuf_new(m->fd_width, m->fd_height, - m->fd_stride, 0, 0, 0, 0, + dmabuf =3D qemu_dmabuf_new(m->width, m->height, + m->fd_stride, 0, 0, + m->fd_width, m->fd_height, m->fd_drm_fourcc, modifier, fd, false, m->fd_flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP); --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630783; cv=none; d=zohomail.com; s=zohoarc; b=V3biLy+EezzF2Sr9W9eOz8uONY/ZhVo4GeAV72u7BViC6kY5bumOQ1gUIVkcn1vNwlDyFj0qT6sGxMBfDyLdiGz9yTz69yZRCTlhqXQ16BMby5DU9toiMuh9f1Ki2910kqKOzaDt7Sn6NEaE41Zc9W/LdplYbehBj+d6koSgOno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630783; 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=+cVsXdQI2RthGLy7TxkQZRDMuYIrDeTU2bckWSqVXa0=; b=Soebbm3amjcT5HBM5RWauuv9TmcIAg7UtvmzMn9iiWwWGP5ED1yiDWmw1PNbUUCo/7jV96ufenCO0k/JKF5UaGDmzQpyUzp1GGfaVGovo8/JtksrnqVHJ3YG6rmgQFtOXVj2LzWOQZowiPPsf8JTKOknSmm/1O4JwKWJ0ISfycw= 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+importer=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 1717630783482712.7409807351298; Wed, 5 Jun 2024 16:39:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0AQ-0002zh-4I; Wed, 05 Jun 2024 19:35:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0AO-0002yu-D2 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0AM-0005Od-PE for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:40 -0400 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-448-St8WeufWNtOWh5NxdLzF0w-1; Wed, 05 Jun 2024 19:35:36 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57851ae6090so100895a12.3 for ; Wed, 05 Jun 2024 16:35:36 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae0c9f88sm100430a12.21.2024.06.05.16.35.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630538; h=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=+cVsXdQI2RthGLy7TxkQZRDMuYIrDeTU2bckWSqVXa0=; b=MmSw04r+oide3JfS3720rU8dGivTPcoEp61XPqY8K3LAfi47gt+UEB2+Aycw26f1mmGyiT 0LoN5wJu/z1l6Pgwww0J7vwN2MO7G1w9MW3a9ixsxCdvS5LPnNw7L7WQ+QNPqrIQSpxOcB ZXWyW1dKVyoRr0HZQqKw1iwvCQl4M2g= X-MC-Unique: St8WeufWNtOWh5NxdLzF0w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630535; x=1718235335; 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=+cVsXdQI2RthGLy7TxkQZRDMuYIrDeTU2bckWSqVXa0=; b=hAN0NUQU61wjoDW91SFE2ygFLZA+kxHUlk/hJw8z3f53vqkoXfQ3hIckmIcLavD5YR cGPOWcUig70V4gvr5MMTEPo/wOBTeOyUyDduJDrGQvLNq8ulTpkYxHDvNuGcjosRE7uL 5q/6aeAkA0BTMAdQMd4gmsKWAR5sgg6QQoTutNNne+XOlMk7P6vFB5r6/zFYIaXCByVk gP+6pJmOrRAC6xNM1TSd0ywctWiEW8UNK4ljoLTqKWl+di8GEv+j/LGEGbQIUlbZFBAp Ps+IEewXroIq3EBwIaK85mb20IWBw1VhG2RWBKdR6Jh0SdFm2WXC/bQHzb7EazdCA1De 36oQ== X-Gm-Message-State: AOJu0Yx6tv0WKfMOox5Zj7aJi/JmfeLSAsYwVcayBrTfKdgJXHj01wly 44ulOtRonukPQSQs2crIEf733bW3+zF0NQNV2gLkQD05UV74qWXVe20WaCV3P+GCDjrnP6Ev1Ly i33G6bjJ+pO/kZHXZ8GCxJW59S4F4YLeyanOtuauH1i2zJEmpZ+Mrfb6c8MmKZaL/PSPtjLnbQM 2RqaILzOGJGL/VAufSVeMAdYXbxF/i3w== X-Received: by 2002:a50:a416:0:b0:57a:1aa8:b49e with SMTP id 4fb4d7f45d1cf-57a8b67d88emr2961590a12.3.1717630535089; Wed, 05 Jun 2024 16:35:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5kPRorPYqkgHcbRBIqEqRrOQX5N+SwIBUn58ZGbZ10emRuaHI7OdCJie3xIsgrkw9XV2F0A== X-Received: by 2002:a50:a416:0:b0:57a:1aa8:b49e with SMTP id 4fb4d7f45d1cf-57a8b67d88emr2961575a12.3.1717630534675; Wed, 05 Jun 2024 16:35:34 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Li Feng , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Fam Zheng , Alex =?utf-8?Q?Benn=C3=A9e?= , qemu-block@nongnu.org Subject: [PULL v3 14/41] Revert "vhost-user: fix lost reconnect" Message-ID: <1c40946b1199f25c42057a6a7ed576c5af6d1933.1717630437.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+importer=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_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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630784629100015 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Li Feng This reverts commit f02a4b8e6431598612466f76aac64ab492849abf. Since the current patch cannot completely fix the lost reconnect problem, there is a scenario that is not considered: - When the virtio-blk driver is removed from the guest os, s->connected has no chance to be set to false, resulting in subsequent reconnection not being executed. The next patch will completely fix this issue with a better approach. Signed-off-by: Li Feng Message-Id: <20240516025753.130171-2-fengli@smartx.com> Reviewed-by: Raphael Norwitz Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user.h | 3 +-- hw/block/vhost-user-blk.c | 2 +- hw/scsi/vhost-user-scsi.c | 3 +-- hw/virtio/vhost-user-base.c | 2 +- hw/virtio/vhost-user.c | 10 ++-------- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index d7c09ffd34..324cd8663a 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -108,7 +108,6 @@ typedef void (*vu_async_close_fn)(DeviceState *cb); =20 void vhost_user_async_close(DeviceState *d, CharBackend *chardev, struct vhost_dev *vhost, - vu_async_close_fn cb, - IOEventHandler *event_cb); + vu_async_close_fn cb); =20 #endif diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index bc2677dbef..15cc24d017 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -385,7 +385,7 @@ static void vhost_user_blk_event(void *opaque, QEMUChrE= vent event) case CHR_EVENT_CLOSED: /* defer close until later to avoid circular close */ vhost_user_async_close(dev, &s->chardev, &s->dev, - vhost_user_blk_disconnect, vhost_user_blk_e= vent); + vhost_user_blk_disconnect); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 0b050805a8..421cd654f8 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -215,8 +215,7 @@ static void vhost_user_scsi_event(void *opaque, QEMUChr= Event event) case CHR_EVENT_CLOSED: /* defer close until later to avoid circular close */ vhost_user_async_close(dev, &vs->conf.chardev, &vsc->dev, - vhost_user_scsi_disconnect, - vhost_user_scsi_event); + vhost_user_scsi_disconnect); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index a83167191e..4b54255682 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -254,7 +254,7 @@ static void vub_event(void *opaque, QEMUChrEvent event) case CHR_EVENT_CLOSED: /* defer close until later to avoid circular close */ vhost_user_async_close(dev, &vub->chardev, &vub->vhost_dev, - vub_disconnect, vub_event); + vub_disconnect); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index cdf9af4a4b..c929097e87 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2776,7 +2776,6 @@ typedef struct { DeviceState *dev; CharBackend *cd; struct vhost_dev *vhost; - IOEventHandler *event_cb; } VhostAsyncCallback; =20 static void vhost_user_async_close_bh(void *opaque) @@ -2791,10 +2790,7 @@ static void vhost_user_async_close_bh(void *opaque) */ if (vhost->vdev) { data->cb(data->dev); - } else if (data->event_cb) { - qemu_chr_fe_set_handlers(data->cd, NULL, NULL, data->event_cb, - NULL, data->dev, NULL, true); - } + } =20 g_free(data); } @@ -2806,8 +2802,7 @@ static void vhost_user_async_close_bh(void *opaque) */ void vhost_user_async_close(DeviceState *d, CharBackend *chardev, struct vhost_dev *vhost, - vu_async_close_fn cb, - IOEventHandler *event_cb) + vu_async_close_fn cb) { if (!runstate_check(RUN_STATE_SHUTDOWN)) { /* @@ -2823,7 +2818,6 @@ void vhost_user_async_close(DeviceState *d, data->dev =3D d; data->cd =3D chardev; data->vhost =3D vhost; - data->event_cb =3D event_cb; =20 /* Disable any further notifications on the chardev */ qemu_chr_fe_set_handlers(chardev, --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630608; cv=none; d=zohomail.com; s=zohoarc; b=Zb8Z26vTEwoALh8xIwomSR2z33H2TbZmBm4reukd2dy12OEzSlwijlv3KYY+Bj++kdCY/J22xm7rsttryT3tBGxbzHxdyTO2y3UDiVr68x3BbkfXKrckikCZv1i+BBMeL7+ughheie9RG5QtobQ/ybrUo7xsfk36Nl9ZCfz1Ero= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630608; 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=cwZ47LpotxgqMUotTFYaru0nOsyfZI/sw2MfKtbkph8=; b=LS4/OY/SNPJh9BE+Gts9CiiaMU7c5AovInuPTg2utDpLNGDPBuyR39PtCTERPIq02Kx0kr6UQVk2/iJ8waM04+w/Hb18m8y6a+hj2s2wfl89HDCnXATQf6wGggQ0P+gqrRb4xP1aX21WSjKeCSWvtdgEc73O2gdZAXLst1K3mKU= 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+importer=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 1717630608181411.87330022914625; Wed, 5 Jun 2024 16:36:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0AX-000359-Gn; Wed, 05 Jun 2024 19:35:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0AW-00034i-Tc for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0AR-0005U4-JM for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:48 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-503-IQHaHu4dNz6aOO3WbVz3tw-1; Wed, 05 Jun 2024 19:35:41 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-57a52cb6d86so149883a12.1 for ; Wed, 05 Jun 2024 16:35:41 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c80728bf5sm6208566b.204.2024.06.05.16.35.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630542; h=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=cwZ47LpotxgqMUotTFYaru0nOsyfZI/sw2MfKtbkph8=; b=JWd+WZsdMCiIga4khluHifDJL1wsUOE4ER6Zm2jF2V2r0kfjCZK9Y4OVYwL90MNlT0xT7i ph4n5AQH+3cz49mf3vBAuvkzQwZx9B+gQOT3BQ2SshUKx7IOvxgu7dfHTNV3uygrW268Nj vvsHgLmKFWsNSdxu8pHEM2asHyy/rpI= X-MC-Unique: IQHaHu4dNz6aOO3WbVz3tw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630540; x=1718235340; 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=cwZ47LpotxgqMUotTFYaru0nOsyfZI/sw2MfKtbkph8=; b=W+tjpJwUNLwSbd5NKenOI7iF2AOXTFiiU6cRNGe6kXkRXRuY7OUIsKTzVUeCmJfvmz U2PAxcc5Ht8V8f0Wqf2mTKjPJkPYgrfz7ACLnUSSfIew3qBt8HoWJAZnF8p/sHz46fBq EFIpXFin1EbMT4gyrM3vKdlZRBGfsT3GzzCsHTtBKQRWlT4AeoGS1RuMGojwrLOCTS6r sat5RUeTiRWTzXzjhxn4ddgt6IlKLZisbpB/MeXQxJ+04Q6tjM0pT45mZRIJwVS1TJy0 s2k9nJIB21kRM+t3QHCGLwL15Nre9XlaDUJSQolBEOL0eOFYoM5fUBeAjhW1PebQ/nIP iHEA== X-Gm-Message-State: AOJu0Yx7E1BU5PwfVphLS4tWRFXVn08EZlV8HBywa75Vgu3CeV6YZTJh uDyXmrrtMN3bKalDM32Lpnl6sFALyq9tcnBeSVbbq0OsqCGayX0bmkT3dUISfxapw1IswyK2rWm 36OTQ0aogyH9BG+7f5piQCqXGmHwhYCGNkInqizGwOc5+5M+LVVk8gBpj610tWBBukcJHvCwMYg Zr0j5HpO6s09CAeOov1lqS/bRUI3eKvA== X-Received: by 2002:a17:906:e2d1:b0:a59:b098:7646 with SMTP id a640c23a62f3a-a699fe010bemr258359966b.54.1717630539861; Wed, 05 Jun 2024 16:35:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcaigRAT8EhlPwFX8EDYqCMpGFSEFI7ASeWGfSsERxy5g/BWGNbKWA9IJYOfN05ENfcA2irg== X-Received: by 2002:a17:906:e2d1:b0:a59:b098:7646 with SMTP id a640c23a62f3a-a699fe010bemr258357966b.54.1717630539248; Wed, 05 Jun 2024 16:35:39 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:35 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Li Feng , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Fam Zheng , Alex =?utf-8?Q?Benn=C3=A9e?= , qemu-block@nongnu.org Subject: [PULL v3 15/41] vhost-user: fix lost reconnect again 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+importer=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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630609894100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Li Feng When the vhost-user is reconnecting to the backend, and if the vhost-user f= ails at the get_features in vhost_dev_init(), then the reconnect will fail and it will not be retriggered forever. The reason is: When the vhost-user fail at get_features, the vhost_dev_cleanup will be cal= led immediately. vhost_dev_cleanup calls 'memset(hdev, 0, sizeof(struct vhost_dev))'. The reconnect path is: vhost_user_blk_event vhost_user_async_close(.. vhost_user_blk_disconnect ..) qemu_chr_fe_set_handlers <----- clear the notifier callback schedule vhost_user_async_close_bh The vhost->vdev is null, so the vhost_user_blk_disconnect will not be called, then the event fd callback will not be reinstalled. We need to ensure that even if vhost_dev_init initialization fails, the eve= nt handler still needs to be reinstalled when s->connected is false. All vhost-user devices have this issue, including vhost-user-blk/scsi. Fixes: 71e076a07d ("hw/virtio: generalise CHR_EVENT_CLOSED handling") Signed-off-by: Li Feng Message-Id: <20240516025753.130171-3-fengli@smartx.com> Reviewed-by: Raphael Norwitz Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/block/vhost-user-blk.c | 3 ++- hw/scsi/vhost-user-scsi.c | 3 ++- hw/virtio/vhost-user-base.c | 3 ++- hw/virtio/vhost-user.c | 10 +--------- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 15cc24d017..fdbc30b9ce 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -354,7 +354,7 @@ static void vhost_user_blk_disconnect(DeviceState *dev) VHostUserBlk *s =3D VHOST_USER_BLK(vdev); =20 if (!s->connected) { - return; + goto done; } s->connected =3D false; =20 @@ -362,6 +362,7 @@ static void vhost_user_blk_disconnect(DeviceState *dev) =20 vhost_dev_cleanup(&s->dev); =20 +done: /* Re-instate the event handler for new connections */ qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, vhost_user_blk_event, NULL, dev, NULL, true); diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 421cd654f8..cc91ade525 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -182,7 +182,7 @@ static void vhost_user_scsi_disconnect(DeviceState *dev) VirtIOSCSICommon *vs =3D VIRTIO_SCSI_COMMON(dev); =20 if (!s->connected) { - return; + goto done; } s->connected =3D false; =20 @@ -190,6 +190,7 @@ static void vhost_user_scsi_disconnect(DeviceState *dev) =20 vhost_dev_cleanup(&vsc->dev); =20 +done: /* Re-instate the event handler for new connections */ qemu_chr_fe_set_handlers(&vs->conf.chardev, NULL, NULL, vhost_user_scsi_event, NULL, dev, NULL, true); diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 4b54255682..11e72b1e3b 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -225,13 +225,14 @@ static void vub_disconnect(DeviceState *dev) VHostUserBase *vub =3D VHOST_USER_BASE(vdev); =20 if (!vub->connected) { - return; + goto done; } vub->connected =3D false; =20 vub_stop(vdev); vhost_dev_cleanup(&vub->vhost_dev); =20 +done: /* Re-instate the event handler for new connections */ qemu_chr_fe_set_handlers(&vub->chardev, NULL, NULL, vub_event, diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index c929097e87..c407ea8939 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2781,16 +2781,8 @@ typedef struct { static void vhost_user_async_close_bh(void *opaque) { VhostAsyncCallback *data =3D opaque; - struct vhost_dev *vhost =3D data->vhost; =20 - /* - * If the vhost_dev has been cleared in the meantime there is - * nothing left to do as some other path has completed the - * cleanup. - */ - if (vhost->vdev) { - data->cb(data->dev); - } + data->cb(data->dev); =20 g_free(data); } --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630601; cv=none; d=zohomail.com; s=zohoarc; b=DmAQperN4SEyj6XvyC+sw9nW07jPga7YmHJ0PU5R9x0zXwz+CD0z+kbfoa74WyTO9LpMJcM9ezC5dat1GhyGHu3BP8NteIAB3mExymB6+YVqHDCnQmTioiyaBC5PAvTPU8ZHqHFHijTiSlqt2HFyn5jLffpiDFClBlhxTmSS2UY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630601; 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=2dkENUzfzIIIcUTPF2EEwEXmUV3lpfWAm7D6XMdf5LE=; b=ig99kaZHHzLxqx00c63lgB0FiS1NNQoTM2WvANMDStqN4zK5lQx0HXVuhmpm+PJhlL1kJnyIwPK8Ss7Npq8xoLPcY6Ps3uGpGmRVji+7ruMKg96uQpcOcg8QFqvHY+ahRzJ1o8Smp7hEYm3KGxRNgOYAXXV/Y9DKbrEKXh1jHIQ= 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+importer=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 1717630601822465.27435643118326; Wed, 5 Jun 2024 16:36:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0AZ-00035w-04; Wed, 05 Jun 2024 19:35:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0AW-00034k-Uq for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0AV-0005W0-90 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:48 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-310-gmBMSoZtMca_9BS6ySEtiw-1; Wed, 05 Jun 2024 19:35:45 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-57a306c4b1eso128972a12.0 for ; Wed, 05 Jun 2024 16:35:44 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c8058272bsm7196166b.18.2024.06.05.16.35.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630546; h=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=2dkENUzfzIIIcUTPF2EEwEXmUV3lpfWAm7D6XMdf5LE=; b=eeEhhpKbBrVGq/tlFQDQ/bk9Nl+aHdV8MlNnPeovP3ZKVUcSQV/QwfsbtjctetjVdVEGmy oA+8+1m2fiEEI5O0rbFveE3PkY2c42fQ88w33d0CqTpTB7aYWpt6u+mMHDrLkaR81CH4yW nFcKMk98axwpq+uw5BhwOh71RZQlCJA= X-MC-Unique: gmBMSoZtMca_9BS6ySEtiw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630543; x=1718235343; 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=2dkENUzfzIIIcUTPF2EEwEXmUV3lpfWAm7D6XMdf5LE=; b=fi7htBuNbNYOxw5CxjIWC4vswbGVQHdsQGb+VHfhDtc4kdxRzbkRzVKDxFW130kJVY 1sZg/ui1gqPPhire70M/DTmaL7xEPuyLqD9Fs4smjPZm0VZebiVaG9PtaAxrMQgbuMDq 2kP+PX1cTHoMEMl+7d3faso01YgvLPNoz885hYwZ549bicrQFWiGKHoc/yF+YUqozI77 q4D0VqrLKEM7MSAkb0jexfyQZb6zunQy+ddYr8e0EdDx6a7U2KRw8ZifsOMHh2gq3MpN 2JIJh8pkjtmBeHFa8GrXGxsj4Yb6Fsl0rcY5v3rHXxyBW8c7hr6p/3rdbDEY4JK5W9SR gKlg== X-Gm-Message-State: AOJu0YzcvhR84Jgz4wOF1LYp1hgL+Dflpq6tehNlXys2LrbMYSCfNqia DkxzmOBrLqb+0gO3qYm8tQHPiOH+ePT9LwlpI3g6m7db6m1+OLYxsTO3YzhO58CvrdHv5w95Owc /TmcxglsqJlJELG4SoYLzYwI6b3aUc04nt6b4eTP83VBhflMYCm9aKBpnvirPdFrvngh5RXYELL YsHS5GJ+jAqTZJlTcPHHM2L+4GvCrMgQ== X-Received: by 2002:a17:906:410e:b0:a66:76f2:71bc with SMTP id a640c23a62f3a-a699fa9e0f4mr264693866b.24.1717630543380; Wed, 05 Jun 2024 16:35:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5MLggCZSot0KijJNh4rtbG9R8nxOFWS5h+P0EhcfEwp47I5KEmIMd1qQv9yRgBKUJq1kq8g== X-Received: by 2002:a17:906:410e:b0:a66:76f2:71bc with SMTP id a640c23a62f3a-a699fa9e0f4mr264692566b.24.1717630542788; Wed, 05 Jun 2024 16:35:42 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Gregory Price , Gregory Price , Jonathan Cameron , Fan Ni Subject: [PULL v3 16/41] hw/cxl/mailbox: change CCI cmd set structure to be a member, not a reference 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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630604128100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Gregory Price This allows devices to have fully customized CCIs, along with complex devices where wrapper devices can override or add additional CCI commands without having to replicate full command structures or pollute a base device with every command that might ever be used. Signed-off-by: Gregory Price Signed-off-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-2-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 2 +- hw/cxl/cxl-mailbox-utils.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 279b276bda..ccc4611875 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -164,7 +164,7 @@ typedef struct CXLEventLog { } CXLEventLog; =20 typedef struct CXLCCI { - const struct cxl_cmd (*cxl_cmd_set)[256]; + struct cxl_cmd cxl_cmd_set[256][256]; struct cel_log { uint16_t opcode; uint16_t effect; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index e5eb97cb91..2c9f50f0f9 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1447,10 +1447,21 @@ void cxl_init_cci(CXLCCI *cci, size_t payload_max) bg_timercb, cci); } =20 +static void cxl_copy_cci_commands(CXLCCI *cci, const struct cxl_cmd (*cxl_= cmds)[256]) +{ + for (int set =3D 0; set < 256; set++) { + for (int cmd =3D 0; cmd < 256; cmd++) { + if (cxl_cmds[set][cmd].handler) { + cci->cxl_cmd_set[set][cmd] =3D cxl_cmds[set][cmd]; + } + } + } +} + void cxl_initialize_mailbox_swcci(CXLCCI *cci, DeviceState *intf, DeviceState *d, size_t payload_max) { - cci->cxl_cmd_set =3D cxl_cmd_set_sw; + cxl_copy_cci_commands(cci, cxl_cmd_set_sw); cci->d =3D d; cci->intf =3D intf; cxl_init_cci(cci, payload_max); @@ -1458,7 +1469,7 @@ void cxl_initialize_mailbox_swcci(CXLCCI *cci, Device= State *intf, =20 void cxl_initialize_mailbox_t3(CXLCCI *cci, DeviceState *d, size_t payload= _max) { - cci->cxl_cmd_set =3D cxl_cmd_set; + cxl_copy_cci_commands(cci, cxl_cmd_set); cci->d =3D d; =20 /* No separation for PCI MB as protocol handled in PCI device */ @@ -1476,7 +1487,7 @@ static const struct cxl_cmd cxl_cmd_set_t3_ld[256][25= 6] =3D { 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; + cxl_copy_cci_commands(cci, cxl_cmd_set_t3_ld); cci->d =3D d; cci->intf =3D intf; cxl_init_cci(cci, payload_max); @@ -1496,7 +1507,7 @@ void cxl_initialize_t3_fm_owned_ld_mctpcci(CXLCCI *cc= i, DeviceState *d, DeviceState *intf, size_t payload_max) { - cci->cxl_cmd_set =3D cxl_cmd_set_t3_fm_owned_ld_mctp; + cxl_copy_cci_commands(cci, cxl_cmd_set_t3_fm_owned_ld_mctp); cci->d =3D d; cci->intf =3D intf; cxl_init_cci(cci, payload_max); --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630711; cv=none; d=zohomail.com; s=zohoarc; b=JZgor9MmNnLyr33tNyPmaPPVyFkyvQ6ulK0BE2wmrRaUD9mhsIoBApVPm1Ry8tgJFHU0SVgoWDINPr75LGNySPstCNJiigz1g4QYs4+6Fi1MFOYlHhtKTd+OSbwV9EQbbj6YGhJviWtdn5sVeqKqDzzYwquqgwhLB3lqKs2fZpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630711; 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=I7oOBawQ17ekJGPjTeJH6qenvWsB1BSkAwbq0wuPpCg=; b=cWCsppKqVfBlol3b6OskDKQS2Z38yL52SRrWN5KDEyFJqPqnPCqKAZx66zO1+Kxs9W6PPGEZGZUJAMbvlnud/LR8otwipOG78YT01DN5CcvaGtcd98mnCPb4ONhmcyBUlVMLETNzyg6KEaiWQjbWilhdjG72nsOaWq/vFRWIwEo= 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+importer=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 1717630711904404.2747698013868; Wed, 5 Jun 2024 16:38:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0An-0003zP-LE; Wed, 05 Jun 2024 19:36:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Al-0003jN-TF for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Ad-0005bc-8d for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:57 -0400 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-626-Rk_BtKQnMSKZ3x2OcstPAg-1; Wed, 05 Jun 2024 19:35:49 -0400 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-52b998cb52eso210332e87.3 for ; Wed, 05 Jun 2024 16:35:49 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c806eb641sm6591066b.111.2024.06.05.16.35.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630554; h=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=I7oOBawQ17ekJGPjTeJH6qenvWsB1BSkAwbq0wuPpCg=; b=LwnFSA+RaeLn0Zmjv9H2v8IXRq1ZXaSgtht1501WUAieNeAhdkoKdmMd9Y1NfKGEbssWOy MLxGD/NcMUhd/qsMwxSo8wjXOJsuyx1ryaaTsNkwF3j22tXamNT4ZR5CvUnIbQ8tXTLMqB u6FtpgprnaXYDV+4idYtmaBQjSO9SbU= X-MC-Unique: Rk_BtKQnMSKZ3x2OcstPAg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630547; x=1718235347; 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=I7oOBawQ17ekJGPjTeJH6qenvWsB1BSkAwbq0wuPpCg=; b=Z0rVxOo06tX7kJUjgkBJDn01Vdl6eng3dk30nblGGAxvgjdcF77YUEEslWaOoViSKg qfFdPd7Gk8PXfap29/f7qEDPnPymAdVLpy20XVFwOvWrtl2G0X2Q8Sb3iv5DNbxWFwyP GBfovuK8cJSmFSV54L7Tk4fXoiSR/5ndCciHnejyB3m/+2N8RL1g4G2r/mU/HlVr/0Cm ylozFaw+Wa4tAmroIinOWz4xvRjJsoQ7uGtavuMZwFmjcvX9BxBqJg2ubiO0iujj16EF Wi5U9dITP3jZIw2yyufvlFcClnqZW9gELy3LdQ+cTDQVb19FYyGTSpTs9Ncuk7mkUEZk 6Mqg== X-Gm-Message-State: AOJu0Yxs3GS92aIB46GsrMRel2K53MiCtirENd59mZ856srOkdL/4swS gyAv1VaIbyOW9XfMUmh8AXTGHyWHWklkrcL2/UPmTU7AaAfJDCuEajlU37j0xlVG6VHx7Ci2sqN OyTD/xvBHl4W+nLwbUFUvfokcxfbw9bwpRBLZbR5NUTGI9UQomGcP5xtcTPHGP9I/1aMvyo6CgA ZDdiRN8Db3poYwNfiMQCnrma8iYsEuHQ== X-Received: by 2002:ac2:4c92:0:b0:52b:84bd:344f with SMTP id 2adb3069b0e04-52bab4fa611mr2101390e87.53.1717630547263; Wed, 05 Jun 2024 16:35:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFFR/0LSCc+Uzk+dMIYa4HRFxxbYxU2HeYP4Q5/VGai6gbiuuWGPu/qGmHgIe/1CpJmmsC3xA== X-Received: by 2002:ac2:4c92:0:b0:52b:84bd:344f with SMTP id 2adb3069b0e04-52bab4fa611mr2101376e87.53.1717630546600; Wed, 05 Jun 2024 16:35:46 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Gregory Price , Gregory Price , Jonathan Cameron , Fan Ni Subject: [PULL v3 17/41] hw/cxl/mailbox: interface to add CCI commands to an existing CCI Message-ID: <7ef5a1800a2b2c0ec2207e32c8409f1214687d2a.1717630437.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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630712282100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Gregory Price This enables wrapper devices to customize the base device's CCI (for example, with custom commands outside the specification) without the need to change the base device. The also enabled the base device to dispatch those commands without requiring additional driver support. Heavily edited by Jonathan Cameron to increase code reuse Signed-off-by: Gregory Price Signed-off-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-3-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 2 ++ hw/cxl/cxl-mailbox-utils.c | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index ccc4611875..a5f8e25020 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -301,6 +301,8 @@ 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); +void cxl_add_cci_commands(CXLCCI *cci, const struct cxl_cmd (*cxl_cmd_set)= [256], + 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, size_t *len_out, uint8_t *pl_out, diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 2c9f50f0f9..2a64c58e2f 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1424,9 +1424,9 @@ static void bg_timercb(void *opaque) } } =20 -void cxl_init_cci(CXLCCI *cci, size_t payload_max) +static void cxl_rebuild_cel(CXLCCI *cci) { - cci->payload_max =3D payload_max; + cci->cel_size =3D 0; /* Reset for a fresh build */ for (int set =3D 0; set < 256; set++) { for (int cmd =3D 0; cmd < 256; cmd++) { if (cci->cxl_cmd_set[set][cmd].handler) { @@ -1440,6 +1440,13 @@ void cxl_init_cci(CXLCCI *cci, size_t payload_max) } } } +} + +void cxl_init_cci(CXLCCI *cci, size_t payload_max) +{ + cci->payload_max =3D payload_max; + cxl_rebuild_cel(cci); + cci->bg.complete_pct =3D 0; cci->bg.starttime =3D 0; cci->bg.runtime =3D 0; @@ -1458,6 +1465,14 @@ static void cxl_copy_cci_commands(CXLCCI *cci, const= struct cxl_cmd (*cxl_cmds)[ } } =20 +void cxl_add_cci_commands(CXLCCI *cci, const struct cxl_cmd (*cxl_cmd_set)= [256], + size_t payload_max) +{ + cci->payload_max =3D MAX(payload_max, cci->payload_max); + cxl_copy_cci_commands(cci, cxl_cmd_set); + cxl_rebuild_cel(cci); +} + void cxl_initialize_mailbox_swcci(CXLCCI *cci, DeviceState *intf, DeviceState *d, size_t payload_max) { --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630769; cv=none; d=zohomail.com; s=zohoarc; b=FY4y+x3zDXtSlSLO0ApTaWeF5SV8o5a/qBMAA57JXHp/RJqLDuFhnrdoJLtYTSjwrp8YizvRFuVUzIeyyu6Kyed0O9hpyN/o/N/H7g5sZXWok5vG9g9JD9L+qnqMYxvSwBVZUUdt2tvG5eSCdSyeRtXAF4Up/doXEXzApvhRHyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630769; 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=R2rkXgOWy7oaxjC82Fwhko4ewIXnfZhtW9KkNOPqa7A=; b=EDk+i/HR028RbGiscFhKnIph+Ptzf0KQStPnk4gTiQIo69IgHSKRLht8zqbPLhZzgedrLfR+dLt77p4NQAN3J6NLgNDS8OLvVuRFEjRZ9+V/kEN56zw+7ex/rTOyBjKNBwBahO2E9r48pwCumTZhBYO37knnyMBVtasWDGxjwwU= 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+importer=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 17176307690801020.7907444638365; Wed, 5 Jun 2024 16:39:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0Ah-0003R3-Bj; Wed, 05 Jun 2024 19:35:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Ad-0003H9-Sn for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Ac-0005bU-7W for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:35:55 -0400 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-674-iuQseTyZMbaif6El0OWXxQ-1; Wed, 05 Jun 2024 19:35:52 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a68ea01c455so8554866b.0 for ; Wed, 05 Jun 2024 16:35:52 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c806eab0asm6490866b.134.2024.06.05.16.35.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630553; h=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=R2rkXgOWy7oaxjC82Fwhko4ewIXnfZhtW9KkNOPqa7A=; b=gt3GpJHlXaw3NxGacEd7H0r5lTx+70gHHrzQ8l2D3eb9ROtOw8XlBgJYVEYnNSEjKbB24A 8fY3GTe7aXmvDQwMaQhsp52I7b5PRIgqsYc+55ySks1WNVV1Ypf+Po1d4q7uUAgYPzHPju eQu08SnJyrF6WzVcseu2l4sOf+EzldI= X-MC-Unique: iuQseTyZMbaif6El0OWXxQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630551; x=1718235351; 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=R2rkXgOWy7oaxjC82Fwhko4ewIXnfZhtW9KkNOPqa7A=; b=hglUIrFXdWmJ9+5u5bxcJWqgtI0SJuSORvLPSLK5+2Lluo9To80B8AlSv3IxvWWX99 RW68hFbzcuKqTp9NsrtmKChzO0NXxn7mFVQWxnpo+EKXx6tjVo5/QoQrNinhdKKDWGGW NXp/rs6vPLsibyl2fh3jYvQxiRST1sUGQJAq0Azmb+rdtjBSJ6zvejN4yRJ5EpKZmzrp 37o15jW4zMUeTxrbC9pX5uSiXcMsgq0ZcVkaD1VXnK2J12VNjpr54ngcbQZV/ro2bEAZ EoroiVbS8chSb5+cY1hp4+G4ZzPHElr+Mq3UcfGJXoSE9M1EM5uPTTIG3m/BWBz4XfF7 Thxw== X-Gm-Message-State: AOJu0Yw0jRXE2s1JqQL+e3efZ7xkUlLoSssmclNBGJljfTZlE+CxS3IZ 7pWmo8mhrPF3+prgui6XauigBc6uQfO8naYUs1mD4C2hLFAHFIMO9fqVN/OOLAfIZqUv6qHecUu dI2pnYGieYEwsDgnzhtDmWEeSDuWjM/Nd8bZkWuyumTXYlTLywJd9XZI8AlDHrf4K2sgJRLGX/7 MLPRcMeDc/i6GAKqMVnGQdQh1hIAmBlw== X-Received: by 2002:a17:906:bcda:b0:a68:f83b:22fa with SMTP id a640c23a62f3a-a699f34bfaamr257780666b.11.1717630550893; Wed, 05 Jun 2024 16:35:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsjN5Id0H8dtL24u2t9MhfHZ2YZ+LUfmZzW9KpyS/LTQxcvvuxYE/YTYUzvBq/BnO5pXRwEQ== X-Received: by 2002:a17:906:bcda:b0:a68:f83b:22fa with SMTP id a640c23a62f3a-a699f34bfaamr257779566b.11.1717630550404; Wed, 05 Jun 2024 16:35:50 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL v3 18/41] hw/cxl/cxl-mailbox-utils: Add dc_event_log_size field to output payload of identify memory device command Message-ID: <9cb633dc30908fd94762ea3694f117b60042ddc8.1717630437.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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630770507100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fan Ni Based on CXL spec r3.1 Table 8-127 (Identify Memory Device Output Payload), dynamic capacity event log size should be part of output of the Identify command. Add dc_event_log_size to the output payload for the host to get the info. Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-4-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 2a64c58e2f..626acc1d0d 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -21,6 +21,7 @@ #include "sysemu/hostmem.h" =20 #define CXL_CAPACITY_MULTIPLIER (256 * MiB) +#define CXL_DC_EVENT_LOG_SIZE 8 =20 /* * How to add a new command, example. The command set FOO, with cmd BAR. @@ -780,8 +781,9 @@ static CXLRetCode cmd_identify_memory_device(const stru= ct cxl_cmd *cmd, uint16_t inject_poison_limit; uint8_t poison_caps; uint8_t qos_telemetry_caps; + uint16_t dc_event_log_size; } QEMU_PACKED *id; - QEMU_BUILD_BUG_ON(sizeof(*id) !=3D 0x43); + QEMU_BUILD_BUG_ON(sizeof(*id) !=3D 0x45); CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); CXLType3Class *cvc =3D CXL_TYPE3_GET_CLASS(ct3d); CXLDeviceState *cxl_dstate =3D &ct3d->cxl_dstate; @@ -807,6 +809,7 @@ static CXLRetCode cmd_identify_memory_device(const stru= ct cxl_cmd *cmd, st24_le_p(id->poison_list_max_mer, 256); /* No limit - so limited by main poison record limit */ stw_le_p(&id->inject_poison_limit, 0); + stw_le_p(&id->dc_event_log_size, CXL_DC_EVENT_LOG_SIZE); =20 *len_out =3D sizeof(*id); return CXL_MBOX_SUCCESS; --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630739; cv=none; d=zohomail.com; s=zohoarc; b=VWmt2QNabofaDWXJxERUb8UBTLem53zULB5QjdkGfFAoZilmTQaJOZckIBb6Tjeo5QARTj1Tjwq86/ZYkYJDIKdwPIyIX/h4u4lxuaV8sRXGi/Kg/HWURoMoGjJapc0jgfGiZb/sQzLlB+HdIQTatphhwnwqYjseHjSqe9TVGD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630739; 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=Q5yMEJxQrvHs2013SKJXv7QWp1/VlpmqevozX2UnFx8=; b=YL0Gl6jI0uyx61N6jJa4ezHoFshfcOxfQyMjYssTEG08NJQkRpiewckNMeLbHbrdifF/2KC2zksZrH2JnIOuxy9n/IzqAigFM+B4IepXcYLWNS/6r4qIk7WSjEZDhnI78ppAEtwbMRFtI9i9cZLB07d23+eJvNEmWCBcwLv5lpg= 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+importer=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 1717630739371617.1058564344854; Wed, 5 Jun 2024 16:38:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0Aq-0004L7-H6; Wed, 05 Jun 2024 19:36:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0An-00040V-Oo for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Al-0005bu-EL for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:05 -0400 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-520-x_O_-WXcOkK2t_8qx8Z05g-1; Wed, 05 Jun 2024 19:35:55 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a68ce1ac733so15651366b.3 for ; Wed, 05 Jun 2024 16:35:55 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aadf9cf05sm102315a12.3.2024.06.05.16.35.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630557; h=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=Q5yMEJxQrvHs2013SKJXv7QWp1/VlpmqevozX2UnFx8=; b=XT6ehUYwbQy8TkdSGC0H9SKaqJ7FcuH2GgbCpOa9R52IYp+i1bCuE0+TbaRES+GZKhJJqg ffHAugLU/Itxb9BbGFcB+Xu0wyfE3xfLX6gREkgRryVvigoQCZsmZh18cVqLcsSLUnvm/H uy7qU4KCB3HVEkUAnX6qIbnv4C7zLYc= X-MC-Unique: x_O_-WXcOkK2t_8qx8Z05g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630554; x=1718235354; 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=Q5yMEJxQrvHs2013SKJXv7QWp1/VlpmqevozX2UnFx8=; b=kZYHGmPjLYapg2MjjVCe641ee9UcRNJEeZoZQjS2kip4UAeIZPZYHx9P6r+2MYxhFw O+vtSMHAXSP3qgqah/jTSbQ+NMlJxKbuFXeQyrERfcvKRYuMbVXDt3mynkPs94Pp3pWA +XXhocGphomeOQV8wdxLoXy/tQo8zw6UZ+TB40rNbsc+trdJpJooM0wNSv2OFWDV9Uof EEqvRNfsUeXYSWpGtccQjkn0zCoteNX2BeZTv7MtjGJE74oQ++IU8dHLq7qgu7fJvnKk 0X6JiGJXblKcqc3n5UFxY3G1GCp7SUtlypeAaF1YruBmn/WXTB2LO/nMKqoqEDRSyPEc Heow== X-Gm-Message-State: AOJu0YwlKm6enlHujqlbBgi3yEE5v4nO3571AEDFu6P5WJXKOvpzl8Q3 +Qt3EOwcq6uv2GGUQIrb9WqHxBXr6kQ5LwcFExIkUi1pIvLzHsaGxU8GT9FHNYzjTX967NXMlF8 PniHL/nVuAXZFE/0h/eua62dhqCkAsllhxefECHgVNTnQ/8IUDjz7WEif4TmDW+s6QwSTIB37k7 o+1+9g6R8Z7fGB8UsHzeQL9VfWk4+0Kg== X-Received: by 2002:a50:d517:0:b0:56e:238e:372c with SMTP id 4fb4d7f45d1cf-57a8bca192emr2388105a12.26.1717630554206; Wed, 05 Jun 2024 16:35:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQW+A6lezbalxgTWk0yBAxgDwxN4wTdhDewJsKVtaFHaApq8Ax6gpweKPd5zY+r1pFjI2EHw== X-Received: by 2002:a50:d517:0:b0:56e:238e:372c with SMTP id 4fb4d7f45d1cf-57a8bca192emr2388093a12.26.1717630553743; Wed, 05 Jun 2024 16:35:53 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:50 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL v3 19/41] hw/cxl/cxl-mailbox-utils: Add dynamic capacity region representative and mailbox command support Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630740407100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fan Ni Per cxl spec r3.1, add dynamic capacity (DC) region representative based on Table 8-165 and extend the cxl type3 device definition to include DC region information. Also, based on info in 8.2.9.9.9.1, add 'Get Dynamic Capacity Configuration' mailbox support. Note: we store region decode length as byte-wise length on the device, which should be divided by 256 * MiB before being returned to the host for "Get Dynamic Capacity Configuration" mailbox command per specification. Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-5-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 16 +++++++ hw/cxl/cxl-mailbox-utils.c | 96 +++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index a5f8e25020..e839370266 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -422,6 +422,17 @@ typedef struct CXLPoison { typedef QLIST_HEAD(, CXLPoison) CXLPoisonList; #define CXL_POISON_LIST_LIMIT 256 =20 +#define DCD_MAX_NUM_REGION 8 + +typedef struct CXLDCRegion { + uint64_t base; /* aligned to 256*MiB */ + uint64_t decode_len; /* aligned to 256*MiB */ + uint64_t len; + uint64_t block_size; + uint32_t dsmadhandle; + uint8_t flags; +} CXLDCRegion; + struct CXLType3Dev { /* Private */ PCIDevice parent_obj; @@ -454,6 +465,11 @@ struct CXLType3Dev { unsigned int poison_list_cnt; bool poison_list_overflowed; uint64_t poison_list_overflow_ts; + + struct dynamic_capacity { + uint8_t num_regions; /* 0-8 regions */ + CXLDCRegion regions[DCD_MAX_NUM_REGION]; + } dc; }; =20 #define TYPE_CXL_TYPE3 "cxl-type3" diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 626acc1d0d..bede28e3c8 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -22,6 +22,8 @@ =20 #define CXL_CAPACITY_MULTIPLIER (256 * MiB) #define CXL_DC_EVENT_LOG_SIZE 8 +#define CXL_NUM_EXTENTS_SUPPORTED 512 +#define CXL_NUM_TAGS_SUPPORTED 0 =20 /* * How to add a new command, example. The command set FOO, with cmd BAR. @@ -80,6 +82,8 @@ enum { #define GET_POISON_LIST 0x0 #define INJECT_POISON 0x1 #define CLEAR_POISON 0x2 + DCD_CONFIG =3D 0x48, + #define GET_DC_CONFIG 0x0 PHYSICAL_SWITCH =3D 0x51, #define IDENTIFY_SWITCH_DEVICE 0x0 #define GET_PHYSICAL_PORT_STATE 0x1 @@ -1238,6 +1242,88 @@ static CXLRetCode cmd_media_clear_poison(const struc= t cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 +/* + * CXL r3.1 section 8.2.9.9.9.1: Get Dynamic Capacity Configuration + * (Opcode: 4800h) + */ +static CXLRetCode cmd_dcd_get_dyn_cap_config(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); + struct { + uint8_t region_cnt; + uint8_t start_rid; + } QEMU_PACKED *in =3D (void *)payload_in; + struct { + uint8_t num_regions; + uint8_t regions_returned; + uint8_t rsvd1[6]; + struct { + uint64_t base; + uint64_t decode_len; + uint64_t region_len; + uint64_t block_size; + uint32_t dsmadhandle; + uint8_t flags; + uint8_t rsvd2[3]; + } QEMU_PACKED records[]; + } QEMU_PACKED *out =3D (void *)payload_out; + struct { + uint32_t num_extents_supported; + uint32_t num_extents_available; + uint32_t num_tags_supported; + uint32_t num_tags_available; + } QEMU_PACKED *extra_out; + uint16_t record_count; + uint16_t i; + uint16_t out_pl_len; + uint8_t start_rid; + + start_rid =3D in->start_rid; + if (start_rid >=3D ct3d->dc.num_regions) { + return CXL_MBOX_INVALID_INPUT; + } + + record_count =3D MIN(ct3d->dc.num_regions - in->start_rid, in->region_= cnt); + + out_pl_len =3D sizeof(*out) + record_count * sizeof(out->records[0]); + extra_out =3D (void *)(payload_out + out_pl_len); + out_pl_len +=3D sizeof(*extra_out); + assert(out_pl_len <=3D CXL_MAILBOX_MAX_PAYLOAD_SIZE); + + out->num_regions =3D ct3d->dc.num_regions; + out->regions_returned =3D record_count; + for (i =3D 0; i < record_count; i++) { + stq_le_p(&out->records[i].base, + ct3d->dc.regions[start_rid + i].base); + stq_le_p(&out->records[i].decode_len, + ct3d->dc.regions[start_rid + i].decode_len / + CXL_CAPACITY_MULTIPLIER); + stq_le_p(&out->records[i].region_len, + ct3d->dc.regions[start_rid + i].len); + stq_le_p(&out->records[i].block_size, + ct3d->dc.regions[start_rid + i].block_size); + stl_le_p(&out->records[i].dsmadhandle, + ct3d->dc.regions[start_rid + i].dsmadhandle); + out->records[i].flags =3D ct3d->dc.regions[start_rid + i].flags; + } + /* + * TODO: Assign values once extents and tags are introduced + * to use. + */ + stl_le_p(&extra_out->num_extents_supported, CXL_NUM_EXTENTS_SUPPORTED); + stl_le_p(&extra_out->num_extents_available, CXL_NUM_EXTENTS_SUPPORTED); + stl_le_p(&extra_out->num_tags_supported, CXL_NUM_TAGS_SUPPORTED); + stl_le_p(&extra_out->num_tags_available, CXL_NUM_TAGS_SUPPORTED); + + *len_out =3D out_pl_len; + return CXL_MBOX_SUCCESS; +} + #define IMMEDIATE_CONFIG_CHANGE (1 << 1) #define IMMEDIATE_DATA_CHANGE (1 << 2) #define IMMEDIATE_POLICY_CHANGE (1 << 3) @@ -1282,6 +1368,11 @@ 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_dcd[256][256] =3D { + [DCD_CONFIG][GET_DC_CONFIG] =3D { "DCD_GET_DC_CONFIG", + cmd_dcd_get_dyn_cap_config, 2, 0 }, +}; + 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", @@ -1487,7 +1578,12 @@ void cxl_initialize_mailbox_swcci(CXLCCI *cci, Devic= eState *intf, =20 void cxl_initialize_mailbox_t3(CXLCCI *cci, DeviceState *d, size_t payload= _max) { + CXLType3Dev *ct3d =3D CXL_TYPE3(d); + cxl_copy_cci_commands(cci, cxl_cmd_set); + if (ct3d->dc.num_regions) { + cxl_copy_cci_commands(cci, cxl_cmd_set_dcd); + } cci->d =3D d; =20 /* No separation for PCI MB as protocol handled in PCI device */ --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630741; cv=none; d=zohomail.com; s=zohoarc; b=X1im3q5sYYHdAsQbJuhW/SHD6JzcpHioyEPtnUFMD0sfV725+2F6Q3+sVN5ZHJ+jSbu26GEixcZ8QyHorSwm4/uqmnd2/yGCWFNqB5DJGc2r1Gg9UK+LVV/8jTbyjL/ScLcIqlEsnzcM1lZcHPlPEnVVhMTVE8FYI8lbJmTBFGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630741; 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=/tkdF9wBgRXJ0C7b2uR1oP4dL+2Be2HPdzcygUpss9I=; b=SITHA+3UBPOIoRSX9josfet9xdP+ge7StTOHpxIvXhvrrbBEAm5M3mAC3Aq/YKVbjobzSDZc+E2U1cmF4OwDZrGN4jWpGR2lPZ8fF2b76t671HiPK9lmkav5d6FBjboRQ2V3NaeRlVshjwMVemBkDA7oZrRmmub2Jn+KdfRi/FM= 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+importer=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 1717630741752981.6031254293483; Wed, 5 Jun 2024 16:39:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0Ar-0004Re-9i; Wed, 05 Jun 2024 19:36:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Ap-0004DC-6R for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Al-0005c9-Kh for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:06 -0400 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-347-2MkWQdtnPyu4Ja6igi81wA-1; Wed, 05 Jun 2024 19:35:59 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57a2fb28a23so174768a12.3 for ; Wed, 05 Jun 2024 16:35:59 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aadcbf568sm114869a12.0.2024.06.05.16.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630560; h=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=/tkdF9wBgRXJ0C7b2uR1oP4dL+2Be2HPdzcygUpss9I=; b=NMcLmDdoUVc6DsLKEoK1DpSnuMx7WjfIH25nGzEDbvuQWO4+k87I/JNcmm1QDILBCj13os Z4w4VQAMfXu1Dn+zHt6DZ7DjEufGPo7EL6H4bXOTqDctiyIxkUxuD3qa5FUp9OxDW73Ldo klUm2s/5TYbRKhQIE8+51rAzkJv4xoA= X-MC-Unique: 2MkWQdtnPyu4Ja6igi81wA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630557; x=1718235357; 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=/tkdF9wBgRXJ0C7b2uR1oP4dL+2Be2HPdzcygUpss9I=; b=PQJzShamGK1R+HAalNcbyRB66Jset9S8fAMr9i74X6yU5rxQIxPiWcRtnu8xzDVex/ LohAMqZPS8GzgBGw4hAZhFRiPaPIFYzMEA2Ynwxp9bm7zZFeZ7TcGr3QYJo3HZHw1RQu P7+2YQ0xPc7wXtxwAPxdcAd+ayW8znPsREWqYBfbR2hSRHQmLIh5XHucF1pSeyQ088LI emaS7A42U+Pa5Y4Ajd15BNlUl/r1HUlREHEQuw3lARWz3bgFn69VqIYQZjYl7PtYMovp q4DqTckqSGCrP4+lV2xBHHRhtQs/yveTJfF3ohKSPvaVT1cJHw9KotxUWv/qpTwNMgXJ av2Q== X-Gm-Message-State: AOJu0Yy5XlScDdC8Wbc6hFgANj0kgo/jhWN6meRZt+lq1YV87gq8pjTg 0jyRJdsuBWPCmfUOk/7Q+ud757Gk8ghG3uBlsYEy8khh3EHsh2vajJh0G4G5qkmbrqhEVhjRihe I+258eBg97mxWF4X2CuEzRy6M2d2on0VqODGKnifikb3mp5nXEIBZkJcksbStb08sQhe+vlvEfN KvAIrkOxQ6esfvfRE+wyKgAVrPVdkxJA== X-Received: by 2002:a50:ab59:0:b0:572:32e4:daca with SMTP id 4fb4d7f45d1cf-57a8b708a5emr2618927a12.25.1717630557534; Wed, 05 Jun 2024 16:35:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEE9AJGP7JnNu5WtiQf3A93qiRsEfgwgjRw5Cv4mlbrfpkNfgu9JdC403zDt2n9uae7Rg7SDA== X-Received: by 2002:a50:ab59:0:b0:572:32e4:daca with SMTP id 4fb4d7f45d1cf-57a8b708a5emr2618914a12.25.1717630557062; Wed, 05 Jun 2024 16:35:57 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL v3 20/41] include/hw/cxl/cxl_device: Rename mem_size as static_mem_size for type3 memory devices Message-ID: <40f913501a753dcf140a51406d3b6ebf89962df7.1717630437.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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630742387100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fan Ni Rename mem_size as static_mem_size for type3 memdev to cover static RAM and pmem capacity, preparing for the introduction of dynamic capacity to support dynamic capacity devices. Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-6-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 2 +- hw/cxl/cxl-mailbox-utils.c | 4 ++-- hw/mem/cxl_type3.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index e839370266..f7f56b44e3 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -234,7 +234,7 @@ typedef struct cxl_device_state { } timestamp; =20 /* memory region size, HDM */ - uint64_t mem_size; + uint64_t static_mem_size; uint64_t pmem_size; uint64_t vmem_size; =20 diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index bede28e3c8..b592473587 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -803,7 +803,7 @@ static CXLRetCode cmd_identify_memory_device(const stru= ct cxl_cmd *cmd, snprintf(id->fw_revision, 0x10, "BWFW VERSION %02d", 0); =20 stq_le_p(&id->total_capacity, - cxl_dstate->mem_size / CXL_CAPACITY_MULTIPLIER); + cxl_dstate->static_mem_size / CXL_CAPACITY_MULTIPLIER); stq_le_p(&id->persistent_capacity, cxl_dstate->pmem_size / CXL_CAPACITY_MULTIPLIER); stq_le_p(&id->volatile_capacity, @@ -1179,7 +1179,7 @@ static CXLRetCode cmd_media_clear_poison(const struct= cxl_cmd *cmd, 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) { + if (dpa + CXL_CACHE_LINE_SIZE > cxl_dstate->static_mem_size) { return CXL_MBOX_INVALID_PA; } =20 diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 3e42490b6c..7194c8f902 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -608,7 +608,7 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error *= *errp) } address_space_init(&ct3d->hostvmem_as, vmr, v_name); ct3d->cxl_dstate.vmem_size =3D memory_region_size(vmr); - ct3d->cxl_dstate.mem_size +=3D memory_region_size(vmr); + ct3d->cxl_dstate.static_mem_size +=3D memory_region_size(vmr); g_free(v_name); } =20 @@ -631,7 +631,7 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error *= *errp) } address_space_init(&ct3d->hostpmem_as, pmr, p_name); ct3d->cxl_dstate.pmem_size =3D memory_region_size(pmr); - ct3d->cxl_dstate.mem_size +=3D memory_region_size(pmr); + ct3d->cxl_dstate.static_mem_size +=3D memory_region_size(pmr); g_free(p_name); } =20 @@ -837,7 +837,7 @@ static int cxl_type3_hpa_to_as_and_dpa(CXLType3Dev *ct3= d, return -EINVAL; } =20 - if (*dpa_offset > ct3d->cxl_dstate.mem_size) { + if (*dpa_offset > ct3d->cxl_dstate.static_mem_size) { return -EINVAL; } =20 @@ -1010,7 +1010,7 @@ static bool set_cacheline(CXLType3Dev *ct3d, uint64_t= dpa_offset, uint8_t *data) return false; } =20 - if (dpa_offset + CXL_CACHE_LINE_SIZE > ct3d->cxl_dstate.mem_size) { + if (dpa_offset + CXL_CACHE_LINE_SIZE > ct3d->cxl_dstate.static_mem_siz= e) { return false; } =20 --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630796; cv=none; d=zohomail.com; s=zohoarc; b=SGrZpEBCo24jXV+HqqaZRNEmuguSTwnjaJtTnpZYxi5L23TP7qoF6lBD8l/AHCX4CQakxjRS999/RW+p+fDRDNLgly6ilmqSZsbx9dYHnXk83WVissWzz7bgrZ1MzJvcMSlQh+e5Idhg87Yt0NUC+mGjgjjNBIcW4g5EQo0a95g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630796; 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=1ElU1S3yGZ4jv6gdF/qOH23dlnO7FdnAYenskxuOvWI=; b=nSuzpCo0iXiCiok9zcDHJ1zasHrTOeybFi7L/BNXT1+ntg+H2xR7QfCGj8XvjIk93L1Qqz1TFIKWU9y5eoChErXVD+QNehZAMORZCOtRn3YOjvIwisg33+W/ny3vewYDPy9yRKnk0vvAm9eOZqBwYHllydquE1FC1WyWg1hT3Vc= 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+importer=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 1717630796452454.1872324233095; Wed, 5 Jun 2024 16:39:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0As-0004Z3-RY; Wed, 05 Jun 2024 19:36:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Ap-0004IN-Uy for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0An-0005dd-Tz for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:07 -0400 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-444-ZmkQucclMnmrfRsozdjGlQ-1; Wed, 05 Jun 2024 19:36:03 -0400 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a68f824c3b4so44762766b.3 for ; Wed, 05 Jun 2024 16:36:03 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c806eb101sm6565966b.121.2024.06.05.16.35.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630565; h=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=1ElU1S3yGZ4jv6gdF/qOH23dlnO7FdnAYenskxuOvWI=; b=Fthq+GNGFgofDO4BIvv6cglRNNNncISuE8d5/Jcoekn5b3NjK5Cd2yHLmzi4xdQhMbt3SV HUCPcasilabAwUmW1L+p+z5xnzvT2LW0aX4guprIT9B05gwOeWn3gvn148uj1j0r/bl2KF fFRfqS83LocDtjlmssrgAdMLRA23BOU= X-MC-Unique: ZmkQucclMnmrfRsozdjGlQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630561; x=1718235361; 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=1ElU1S3yGZ4jv6gdF/qOH23dlnO7FdnAYenskxuOvWI=; b=SBWe7blFJGC7zr/zZgmMmzhAPqVebXma1bVJ26a6SkNCoFeBNwiugF/LasujWGyg3S g6N6LtycB/QU6mHWRBE+1j7p9RzForeDjiQL6jl675IFwaR8da6zpMlPgtXhgNPffYGw tFwZKigz/0teyZFYE5ja+dEXh2KAH+Luyd3X6R2WLzB9kOykGS9Z71UnyGOKhOQcmVkG jRuLmuHXk0uDxnZq3eiEJCIbepEygZXptqvMDUvkqG/xJiS0F1Eknc0/ei/njHFC5zWh EN9xLfTjaO49C+uUPSVQRkOXJoKpU9C8BxClbxIAAqOdfLrsN92ICTFB0OJslgeqNMBs 4luA== X-Gm-Message-State: AOJu0YzXzvQR8YOyXyCIVnRW9VQfGZnZ06qXz7PVkMydzr6enE3js8AS QpF3h/ZMeczpgj2NfUDx4U+rU3/HYN0QilgLq5GXQEj/7rW/Hno2bLGUZgD0qCoAd9tS87FVh65 Kdybj96J4bTmVROtHwsS1V2KdWKS2+RPK7Jw4E30DKy13jx2zl3vSSuMSAoceuXm/hSqu/TZ9SO l64EhUwEHppIt1xWOTdtY7Vdrxj3DtpQ== X-Received: by 2002:a17:906:6c8d:b0:a6a:6ed0:fbdc with SMTP id a640c23a62f3a-a6a6ed0feb0mr212178466b.38.1717630561504; Wed, 05 Jun 2024 16:36:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMvZ3gFSOBPemBSK4GJiZT+jtkTjqaaLtFtR7sb0bHoyiZjEqf7MWRTOQAVqt05qpE/KNjvQ== X-Received: by 2002:a17:906:6c8d:b0:a6a:6ed0:fbdc with SMTP id a640c23a62f3a-a6a6ed0feb0mr212176866b.38.1717630560993; Wed, 05 Jun 2024 16:36:00 -0700 (PDT) Date: Wed, 5 Jun 2024 19:35:57 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron , Li Zhijian Subject: [PULL v3 21/41] hw/mem/cxl_type3: Add support to create DC regions to type3 memory devices Message-ID: <74920f586004fb9212343d417f9faa57ada8f37b.1717630437.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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630796686100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fan Ni With the change, when setting up memory for type3 memory device, we can create DC regions. A property 'num-dc-regions' is added to ct3_props to allow users to pass the number of DC regions to create. To make it easier, other region parameters like region base, length, and block size are hard coded. If needed, these parameters can be added easily. With the change, we can create DC regions with proper kernel side support like below: region=3D$(cat /sys/bus/cxl/devices/decoder0.0/create_dc_region) echo $region > /sys/bus/cxl/devices/decoder0.0/create_dc_region echo 256 > /sys/bus/cxl/devices/$region/interleave_granularity echo 1 > /sys/bus/cxl/devices/$region/interleave_ways echo "dc0" >/sys/bus/cxl/devices/decoder2.0/mode echo 0x40000000 >/sys/bus/cxl/devices/decoder2.0/dpa_size echo 0x40000000 > /sys/bus/cxl/devices/$region/size echo "decoder2.0" > /sys/bus/cxl/devices/$region/target0 echo 1 > /sys/bus/cxl/devices/$region/commit echo $region > /sys/bus/cxl/drivers/cxl_region/bind Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-7-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Li Zhijian --- hw/mem/cxl_type3.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 7194c8f902..06c6f9bb78 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -30,6 +30,7 @@ #include "hw/pci/msix.h" =20 #define DWORD_BYTE 4 +#define CXL_CAPACITY_MULTIPLIER (256 * MiB) =20 /* Default CDAT entries for a memory region */ enum { @@ -567,6 +568,50 @@ static void ct3d_reg_write(void *opaque, hwaddr offset= , uint64_t value, } } =20 +/* + * TODO: dc region configuration will be updated once host backend and add= ress + * space support is added for DCD. + */ +static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Error **errp) +{ + int i; + uint64_t region_base =3D 0; + uint64_t region_len =3D 2 * GiB; + uint64_t decode_len =3D 2 * GiB; + uint64_t blk_size =3D 2 * MiB; + CXLDCRegion *region; + MemoryRegion *mr; + + if (ct3d->hostvmem) { + mr =3D host_memory_backend_get_memory(ct3d->hostvmem); + region_base +=3D memory_region_size(mr); + } + if (ct3d->hostpmem) { + mr =3D host_memory_backend_get_memory(ct3d->hostpmem); + region_base +=3D memory_region_size(mr); + } + if (region_base % CXL_CAPACITY_MULTIPLIER !=3D 0) { + error_setg(errp, "DC region base not aligned to 0x%lx", + CXL_CAPACITY_MULTIPLIER); + return false; + } + + for (i =3D 0, region =3D &ct3d->dc.regions[0]; + i < ct3d->dc.num_regions; + i++, region++, region_base +=3D region_len) { + *region =3D (CXLDCRegion) { + .base =3D region_base, + .decode_len =3D decode_len, + .len =3D region_len, + .block_size =3D blk_size, + /* dsmad_handle set when creating CDAT table entries */ + .flags =3D 0, + }; + } + + return true; +} + static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) { DeviceState *ds =3D DEVICE(ct3d); @@ -635,6 +680,13 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error = **errp) g_free(p_name); } =20 + if (ct3d->dc.num_regions > 0) { + if (!cxl_create_dc_regions(ct3d, errp)) { + error_append_hint(errp, "setup DC regions failed"); + return false; + } + } + return true; } =20 @@ -930,6 +982,7 @@ static Property ct3_props[] =3D { HostMemoryBackend *), DEFINE_PROP_UINT64("sn", CXLType3Dev, sn, UI64_NULL), DEFINE_PROP_STRING("cdat", CXLType3Dev, cxl_cstate.cdat.filename), + DEFINE_PROP_UINT8("num-dc-regions", CXLType3Dev, dc.num_regions, 0), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630747; cv=none; d=zohomail.com; s=zohoarc; b=QHpn3pqDd8iH2nSeQpOKj7UtFRMTo7wzmQzFKUqYEq9mjlQargI/LXqU0ie+Dltl2suijfyoqFKVNvLuCMJWbo0Wvk2MeWbMWh5poOBlQFgW1XK7X0TNuenzcxsxTFYXhAEGjnKK3njb5rA4Mw6nob68o/fjn2px7T09IIGn9/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630747; 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=FMOgEcAe53x2nl/kUwLBbhwXiRFlv4+KNdbX+UZGPhI=; b=aa5FYzszaR6gMzKTAyBHzpSWs3UFUYsq4wbYNQxIyoVlk8eWr3Vu4PTM+7iVcJ1t0/MNWThb61erT8sQevaPJxODNtCfF/Cpi1V3bSsraOieLvsZwMsJUW417sokdoZvxNNdq1hC2F9PMQO0SDsy4gWdU53T6TDGe7N7QybLOuI= 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+importer=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 171763074734836.00998896893293; Wed, 5 Jun 2024 16:39:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0Au-0004uo-Rk; Wed, 05 Jun 2024 19:36:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0As-0004ec-W2 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Ar-0005ez-3k for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:10 -0400 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-471-Xk3IJwvtPGid_MpDOWADyw-1; Wed, 05 Jun 2024 19:36:06 -0400 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-57a941a787dso375830a12.3 for ; Wed, 05 Jun 2024 16:36:06 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae0ff792sm99934a12.40.2024.06.05.16.36.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630568; h=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=FMOgEcAe53x2nl/kUwLBbhwXiRFlv4+KNdbX+UZGPhI=; b=K0k400UbUN7WI9mrYGj/Fx4qxVx4/Lt+r5E8KPPfu3zWhQFccycgfcc/vixwh5/iV5312p mgPuuQ+6x4cwP1qLxbhtI47T4EeZi7/nrmoKQze7dHAMsFShNqVw8JkS370+9oNsvVeILR kwrFl33hrVo1AssRD7wyLqLpWi6l2dQ= X-MC-Unique: Xk3IJwvtPGid_MpDOWADyw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630565; x=1718235365; 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=FMOgEcAe53x2nl/kUwLBbhwXiRFlv4+KNdbX+UZGPhI=; b=NStNKOTmTKlQs4U/zcinwaks8dIP3eitk0lNLAyKEaxGirJGhtmEncZSO+z/l25DYQ jxReE4w6cCTjV6NIBdxvhmB3XRN9hMYKnJ+JmUT/4dbkrAueFKkjNaUmuU8Z4AxrLve7 YHFOBTiF9TX+M8MOcPc2gcF3vQz8io6ucZgx+XUSGKEew1O6YRQMXO1psKqIyZ0j/Ji9 KusTiJY2ML40q5XEDq3AkHz+kEdYltUeCdGV5Mhs9G+vBLha1o4Bm1oBicSCiN1p3qOv 085mslkncYnltXcIy44YD0Jkx4f6GpNWC90hmTcC+vv/c/TkEQ/PEnnFkb/viQErzM0h GAYg== X-Gm-Message-State: AOJu0YwLozg2WvDxMugFyikSuka0jeMLhblkx6VrNtaBPNzpgQl6/paF v1rHh+gsfVa3oW1AXWPWroL7FjDiQ8yatlveGea6lvNz3d8OnwP3hrn+83yULOahPb/u2CXZXiT jzzEKJhMd8kkcikAdxrX7uH4O7xQ6z9SEU+LJR59btWOensiBdNlDFj2lpcerxA/MUhMAauTHhV LtiGalaN5JJ1b1lAcMSFQUxiNEKgpavQ== X-Received: by 2002:a50:8d54:0:b0:579:c3f8:5923 with SMTP id 4fb4d7f45d1cf-57a8b6a8778mr2886648a12.13.1717630565125; Wed, 05 Jun 2024 16:36:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKuech8vINIo/RmiFFSd+bz+4xjcWAbx34aRwr59onCtphObcAur87eDhxEcTsXy0+Om8saA== X-Received: by 2002:a50:8d54:0:b0:579:c3f8:5923 with SMTP id 4fb4d7f45d1cf-57a8b6a8778mr2886626a12.13.1717630564441; Wed, 05 Jun 2024 16:36:04 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL v3 22/41] hw/mem/cxl-type3: Refactor ct3_build_cdat_entries_for_mr to take mr size instead of mr as argument Message-ID: <11c8c0c5281e984b186de1483da7fd934ea388f5.1717630437.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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630748412100004 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fan Ni The function ct3_build_cdat_entries_for_mr only uses size of the passed memory region argument, refactor the function definition to make the passed arguments more specific. Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-8-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/cxl_type3.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 06c6f9bb78..51be50ce87 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -44,7 +44,7 @@ enum { }; =20 static void ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, - int dsmad_handle, MemoryRegion *= mr, + int dsmad_handle, uint64_t size, bool is_pmem, uint64_t dpa_base) { CDATDsmas *dsmas; @@ -63,7 +63,7 @@ static void ct3_build_cdat_entries_for_mr(CDATSubHeader *= *cdat_table, .DSMADhandle =3D dsmad_handle, .flags =3D is_pmem ? CDAT_DSMAS_FLAG_NV : 0, .DPA_base =3D dpa_base, - .DPA_length =3D memory_region_size(mr), + .DPA_length =3D size, }; =20 /* For now, no memory side cache, plausiblish numbers */ @@ -132,7 +132,7 @@ static void ct3_build_cdat_entries_for_mr(CDATSubHeader= **cdat_table, */ .EFI_memory_type_attr =3D is_pmem ? 2 : 1, .DPA_offset =3D 0, - .DPA_length =3D memory_region_size(mr), + .DPA_length =3D size, }; =20 /* Header always at start of structure */ @@ -149,6 +149,7 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_t= able, void *priv) g_autofree CDATSubHeader **table =3D NULL; CXLType3Dev *ct3d =3D priv; MemoryRegion *volatile_mr =3D NULL, *nonvolatile_mr =3D NULL; + uint64_t vmr_size =3D 0, pmr_size =3D 0; int dsmad_handle =3D 0; int cur_ent =3D 0; int len =3D 0; @@ -163,6 +164,7 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_t= able, void *priv) return -EINVAL; } len +=3D CT3_CDAT_NUM_ENTRIES; + vmr_size =3D memory_region_size(volatile_mr); } =20 if (ct3d->hostpmem) { @@ -171,21 +173,22 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat= _table, void *priv) return -EINVAL; } len +=3D CT3_CDAT_NUM_ENTRIES; + pmr_size =3D memory_region_size(nonvolatile_mr); } =20 table =3D g_malloc0(len * sizeof(*table)); =20 /* Now fill them in */ if (volatile_mr) { - ct3_build_cdat_entries_for_mr(table, dsmad_handle++, volatile_mr, + ct3_build_cdat_entries_for_mr(table, dsmad_handle++, vmr_size, false, 0); cur_ent =3D CT3_CDAT_NUM_ENTRIES; } =20 if (nonvolatile_mr) { - uint64_t base =3D volatile_mr ? memory_region_size(volatile_mr) : = 0; + uint64_t base =3D vmr_size; ct3_build_cdat_entries_for_mr(&(table[cur_ent]), dsmad_handle++, - nonvolatile_mr, true, base); + pmr_size, true, base); cur_ent +=3D CT3_CDAT_NUM_ENTRIES; } assert(len =3D=3D cur_ent); --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630609; cv=none; d=zohomail.com; s=zohoarc; b=KmkanRYRkvPdxJMAKG38kGcSfjVP5QPETx/hgHZEtdAnL/cfARAtLloXkqMwZC30nzEubhl6gcqNQ8HDTi7j9DFBhIWR4m0Sql0J5wtfOUveLfO2Ov3ocKDi5Ku1WUnRuNhAw9o/lzAV/NQztVWU3xaodQ4GtQPxK7FbRrsKkHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630609; 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=eEQf5dMTcN0eNEr2HFQRzAcaAdzyZe0zdBh6kTUpqX4=; b=CSKEV1+kTrSyIKjJVgRem4Jq9FaolQ3+vrt3uXXHNKEVS+COOEl3238ZAmY6WiMHVgEtjsOLeNdmhBOWA8X4euQCvYyfNiNQ3ynOJSmqhfrashC6sUEjF7XmKtTIRiEwg3S+UUn3K/7Py35SzYxPfaItUSidjyXEVADzAX4c5bg= 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+importer=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 1717630609467749.6808308593695; Wed, 5 Jun 2024 16:36:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0Az-0005Sh-RZ; Wed, 05 Jun 2024 19:36:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Ax-0005Cv-Np for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Av-0005he-2S for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:15 -0400 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-556-6utXPRDGNpqWaqmSjQDNfg-1; Wed, 05 Jun 2024 19:36:11 -0400 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-52b91217fcfso212017e87.3 for ; Wed, 05 Jun 2024 16:36:10 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c8070fa73sm6447266b.186.2024.06.05.16.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630572; h=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=eEQf5dMTcN0eNEr2HFQRzAcaAdzyZe0zdBh6kTUpqX4=; b=izHpROqSzFUJ1vHYEYhemrq63em3NizzSG0tItHqC53xwTTPh6JWyS11rI25prv40OslpM 0fYWTdLsPDgXbcvlvET69nkVV4vMNX2Nop+YWrXb8L+pL5gJAF5u5fdgVa8oC+rk7Eo5uJ lGllIWx4czH/Xg+/QAXb29DoKS/GVCw= X-MC-Unique: 6utXPRDGNpqWaqmSjQDNfg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630569; x=1718235369; 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=eEQf5dMTcN0eNEr2HFQRzAcaAdzyZe0zdBh6kTUpqX4=; b=vK/QSsDsElffq8TL3wbDhH2X2BveFWcS35P28mtR5gn41/L4nm3QHQGwk4JLhtC79J JiejZmQXYtoAqmyLR10iW9yMqGvHUoAnEIZDA9nSMXqqG5twvnnz8vtXgiEV9UAAOJzY dZobxVCSwjST/kLnMytfU8lEHppnQiUMP88tRGQ2HJSFUwtfUP6xLCrqK7rPydMVmUza Nx75ffj/InfWZHCxXO+q1SXYotox3Y+EINAU+6ziCs0dHjDnNdFW7vNuc+Azjog8tMlP TXYq3D5f4Ylieb7hXb4oLezeHPdnwdv6cB5FsoVhlAxe6g16v5LSDJzQyATx1hUQok7G d0pg== X-Gm-Message-State: AOJu0Yx/tHwmv6JoGdeXJxtGp/jhwHksrOQOLd90fk0Oe3PQLUzrDo+l bSUNpp6DqXzGd9ieFSzuYuvF5hmzknEYXMlFEckpDCGaM9w3UDlJbmXvuI8nOzAbe6krSFa0UNo 4zSWBUQAuwIlH5qpklj2wurbod4w/b8uE+eR1D7N3c/Sm7ZmTCX29zyEdxYiYHfxa9qFt5rEFcM CQR96w9hWY2xyXI9pm1Pp7Ms/9/PMIBw== X-Received: by 2002:ac2:4313:0:b0:519:6953:2ffc with SMTP id 2adb3069b0e04-52bab4fb524mr2094324e87.42.1717630568876; Wed, 05 Jun 2024 16:36:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3D+q/imvPRQtKWelCZXEEWT63AL67q90IfGGFo/BeHcHZqkEB0Yfb1/OCsN9MeVwQfI0GlQ== X-Received: by 2002:ac2:4313:0:b0:519:6953:2ffc with SMTP id 2adb3069b0e04-52bab4fb524mr2094314e87.42.1717630568131; Wed, 05 Jun 2024 16:36:08 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL v3 23/41] hw/mem/cxl_type3: Add host backend and address space handling for DC regions Message-ID: <765128b3308bfaceeab501223b47b37912d4bead.1717630437.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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630609911100007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fan Ni Add (file/memory backed) host backend for DCD. All the dynamic capacity regions will share a single, large enough host backend. Set up address space for DC regions to support read/write operations to dynamic capacity for DCD. With the change, the following support is added: 1. Add a new property to type3 device "volatile-dc-memdev" to point to host memory backend for dynamic capacity. Currently, all DC regions share one host backend; 2. Add namespace for dynamic capacity for read/write support; 3. Create cdat entries for each dynamic capacity region. Reviewed-by: Gregory Price Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-9-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 8 ++ hw/cxl/cxl-mailbox-utils.c | 16 +++- hw/mem/cxl_type3.c | 177 +++++++++++++++++++++++++++++------- 3 files changed, 164 insertions(+), 37 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index f7f56b44e3..c2c3df0d2a 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -467,6 +467,14 @@ struct CXLType3Dev { uint64_t poison_list_overflow_ts; =20 struct dynamic_capacity { + HostMemoryBackend *host_dc; + AddressSpace host_dc_as; + /* + * total_capacity is equivalent to the dynamic capability + * memory region size. + */ + uint64_t total_capacity; /* 256M aligned */ + uint8_t num_regions; /* 0-8 regions */ CXLDCRegion regions[DCD_MAX_NUM_REGION]; } dc; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index b592473587..6ad227f112 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -622,7 +622,8 @@ static CXLRetCode cmd_firmware_update_get_info(const st= ruct cxl_cmd *cmd, size_t *len_out, CXLCCI *cci) { - CXLDeviceState *cxl_dstate =3D &CXL_TYPE3(cci->d)->cxl_dstate; + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + CXLDeviceState *cxl_dstate =3D &ct3d->cxl_dstate; struct { uint8_t slots_supported; uint8_t slot_info; @@ -636,7 +637,8 @@ static CXLRetCode cmd_firmware_update_get_info(const st= ruct cxl_cmd *cmd, QEMU_BUILD_BUG_ON(sizeof(*fw_info) !=3D 0x50); =20 if ((cxl_dstate->vmem_size < CXL_CAPACITY_MULTIPLIER) || - (cxl_dstate->pmem_size < CXL_CAPACITY_MULTIPLIER)) { + (cxl_dstate->pmem_size < CXL_CAPACITY_MULTIPLIER) || + (ct3d->dc.total_capacity < CXL_CAPACITY_MULTIPLIER)) { return CXL_MBOX_INTERNAL_ERROR; } =20 @@ -793,7 +795,8 @@ static CXLRetCode cmd_identify_memory_device(const stru= ct cxl_cmd *cmd, 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))= ) { + (!QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER))= || + (!QEMU_IS_ALIGNED(ct3d->dc.total_capacity, CXL_CAPACITY_MULTIPLIER= ))) { return CXL_MBOX_INTERNAL_ERROR; } =20 @@ -835,9 +838,11 @@ static CXLRetCode cmd_ccls_get_partition_info(const st= ruct cxl_cmd *cmd, uint64_t next_pmem; } QEMU_PACKED *part_info =3D (void *)payload_out; QEMU_BUILD_BUG_ON(sizeof(*part_info) !=3D 0x20); + CXLType3Dev *ct3d =3D container_of(cxl_dstate, CXLType3Dev, cxl_dstate= ); =20 if ((!QEMU_IS_ALIGNED(cxl_dstate->vmem_size, CXL_CAPACITY_MULTIPLIER))= || - (!QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER))= ) { + (!QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER))= || + (!QEMU_IS_ALIGNED(ct3d->dc.total_capacity, CXL_CAPACITY_MULTIPLIER= ))) { return CXL_MBOX_INTERNAL_ERROR; } =20 @@ -1179,7 +1184,8 @@ static CXLRetCode cmd_media_clear_poison(const struct= cxl_cmd *cmd, 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->static_mem_size) { + if (dpa + CXL_CACHE_LINE_SIZE > cxl_dstate->static_mem_size + + ct3d->dc.total_capacity) { return CXL_MBOX_INVALID_PA; } =20 diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 51be50ce87..658570aa1a 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -45,7 +45,8 @@ enum { =20 static void ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, int dsmad_handle, uint64_t size, - bool is_pmem, uint64_t dpa_base) + bool is_pmem, bool is_dynamic, + uint64_t dpa_base) { CDATDsmas *dsmas; CDATDslbis *dslbis0; @@ -61,7 +62,8 @@ static void ct3_build_cdat_entries_for_mr(CDATSubHeader *= *cdat_table, .length =3D sizeof(*dsmas), }, .DSMADhandle =3D dsmad_handle, - .flags =3D is_pmem ? CDAT_DSMAS_FLAG_NV : 0, + .flags =3D (is_pmem ? CDAT_DSMAS_FLAG_NV : 0) | + (is_dynamic ? CDAT_DSMAS_FLAG_DYNAMIC_CAP : 0), .DPA_base =3D dpa_base, .DPA_length =3D size, }; @@ -149,12 +151,13 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat= _table, void *priv) g_autofree CDATSubHeader **table =3D NULL; CXLType3Dev *ct3d =3D priv; MemoryRegion *volatile_mr =3D NULL, *nonvolatile_mr =3D NULL; + MemoryRegion *dc_mr =3D NULL; uint64_t vmr_size =3D 0, pmr_size =3D 0; int dsmad_handle =3D 0; int cur_ent =3D 0; int len =3D 0; =20 - if (!ct3d->hostpmem && !ct3d->hostvmem) { + if (!ct3d->hostpmem && !ct3d->hostvmem && !ct3d->dc.num_regions) { return 0; } =20 @@ -176,21 +179,54 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat= _table, void *priv) pmr_size =3D memory_region_size(nonvolatile_mr); } =20 + if (ct3d->dc.num_regions) { + if (!ct3d->dc.host_dc) { + return -EINVAL; + } + dc_mr =3D host_memory_backend_get_memory(ct3d->dc.host_dc); + if (!dc_mr) { + return -EINVAL; + } + len +=3D CT3_CDAT_NUM_ENTRIES * ct3d->dc.num_regions; + } + table =3D g_malloc0(len * sizeof(*table)); =20 /* Now fill them in */ if (volatile_mr) { ct3_build_cdat_entries_for_mr(table, dsmad_handle++, vmr_size, - false, 0); + false, false, 0); cur_ent =3D CT3_CDAT_NUM_ENTRIES; } =20 if (nonvolatile_mr) { uint64_t base =3D vmr_size; ct3_build_cdat_entries_for_mr(&(table[cur_ent]), dsmad_handle++, - pmr_size, true, base); + pmr_size, true, false, base); cur_ent +=3D CT3_CDAT_NUM_ENTRIES; } + + if (dc_mr) { + int i; + uint64_t region_base =3D vmr_size + pmr_size; + + /* + * We assume the dynamic capacity to be volatile for now. + * Non-volatile dynamic capacity will be added if needed in the + * future. + */ + for (i =3D 0; i < ct3d->dc.num_regions; i++) { + ct3_build_cdat_entries_for_mr(&(table[cur_ent]), + dsmad_handle++, + ct3d->dc.regions[i].len, + false, true, region_base); + ct3d->dc.regions[i].dsmadhandle =3D dsmad_handle - 1; + + cur_ent +=3D CT3_CDAT_NUM_ENTRIES; + region_base +=3D ct3d->dc.regions[i].len; + } + } + assert(len =3D=3D cur_ent); =20 *cdat_table =3D g_steal_pointer(&table); @@ -301,10 +337,17 @@ static void build_dvsecs(CXLType3Dev *ct3d) range2_size_lo =3D (2 << 5) | (2 << 2) | 0x3 | (ct3d->hostpmem->size & 0xF0000000); } - } else { + } else if (ct3d->hostpmem) { range1_size_hi =3D ct3d->hostpmem->size >> 32; range1_size_lo =3D (2 << 5) | (2 << 2) | 0x3 | (ct3d->hostpmem->size & 0xF0000000); + } else { + /* + * For DCD with no static memory, set memory active, memory class = bits. + * No range is set. + */ + range1_size_hi =3D 0; + range1_size_lo =3D (2 << 5) | (2 << 2) | 0x3; } =20 dvsec =3D (uint8_t *)&(CXLDVSECDevice){ @@ -579,11 +622,29 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, = Error **errp) { int i; uint64_t region_base =3D 0; - uint64_t region_len =3D 2 * GiB; - uint64_t decode_len =3D 2 * GiB; + uint64_t region_len; + uint64_t decode_len; uint64_t blk_size =3D 2 * MiB; CXLDCRegion *region; MemoryRegion *mr; + uint64_t dc_size; + + mr =3D host_memory_backend_get_memory(ct3d->dc.host_dc); + dc_size =3D memory_region_size(mr); + region_len =3D DIV_ROUND_UP(dc_size, ct3d->dc.num_regions); + + if (dc_size % (ct3d->dc.num_regions * CXL_CAPACITY_MULTIPLIER) !=3D 0)= { + error_setg(errp, + "backend size is not multiple of region len: 0x%" PRIx6= 4, + region_len); + return false; + } + if (region_len % CXL_CAPACITY_MULTIPLIER !=3D 0) { + error_setg(errp, "DC region size is unaligned to 0x%" PRIx64, + CXL_CAPACITY_MULTIPLIER); + return false; + } + decode_len =3D region_len; =20 if (ct3d->hostvmem) { mr =3D host_memory_backend_get_memory(ct3d->hostvmem); @@ -594,7 +655,7 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Er= ror **errp) region_base +=3D memory_region_size(mr); } if (region_base % CXL_CAPACITY_MULTIPLIER !=3D 0) { - error_setg(errp, "DC region base not aligned to 0x%lx", + error_setg(errp, "DC region base not aligned to 0x%" PRIx64, CXL_CAPACITY_MULTIPLIER); return false; } @@ -610,6 +671,7 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Er= ror **errp) /* dsmad_handle set when creating CDAT table entries */ .flags =3D 0, }; + ct3d->dc.total_capacity +=3D region->len; } =20 return true; @@ -619,7 +681,8 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error *= *errp) { DeviceState *ds =3D DEVICE(ct3d); =20 - if (!ct3d->hostmem && !ct3d->hostvmem && !ct3d->hostpmem) { + if (!ct3d->hostmem && !ct3d->hostvmem && !ct3d->hostpmem + && !ct3d->dc.num_regions) { error_setg(errp, "at least one memdev property must be set"); return false; } else if (ct3d->hostmem && ct3d->hostpmem) { @@ -683,7 +746,37 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error = **errp) g_free(p_name); } =20 + ct3d->dc.total_capacity =3D 0; if (ct3d->dc.num_regions > 0) { + MemoryRegion *dc_mr; + char *dc_name; + + if (!ct3d->dc.host_dc) { + error_setg(errp, "dynamic capacity must have a backing device"= ); + return false; + } + + dc_mr =3D host_memory_backend_get_memory(ct3d->dc.host_dc); + if (!dc_mr) { + error_setg(errp, "dynamic capacity must have a backing device"= ); + return false; + } + + /* + * Set DC regions as volatile for now, non-volatile support can + * be added in the future if needed. + */ + memory_region_set_nonvolatile(dc_mr, false); + memory_region_set_enabled(dc_mr, true); + host_memory_backend_set_mapped(ct3d->dc.host_dc, true); + if (ds->id) { + dc_name =3D g_strdup_printf("cxl-dcd-dpa-dc-space:%s", ds->id); + } else { + dc_name =3D g_strdup("cxl-dcd-dpa-dc-space"); + } + address_space_init(&ct3d->dc.host_dc_as, dc_mr, dc_name); + g_free(dc_name); + if (!cxl_create_dc_regions(ct3d, errp)) { error_append_hint(errp, "setup DC regions failed"); return false; @@ -779,6 +872,9 @@ err_release_cdat: err_free_special_ops: g_free(regs->special_ops); err_address_space_free: + if (ct3d->dc.host_dc) { + address_space_destroy(&ct3d->dc.host_dc_as); + } if (ct3d->hostpmem) { address_space_destroy(&ct3d->hostpmem_as); } @@ -797,6 +893,9 @@ static void ct3_exit(PCIDevice *pci_dev) pcie_aer_exit(pci_dev); cxl_doe_cdat_release(cxl_cstate); g_free(regs->special_ops); + if (ct3d->dc.host_dc) { + address_space_destroy(&ct3d->dc.host_dc_as); + } if (ct3d->hostpmem) { address_space_destroy(&ct3d->hostpmem_as); } @@ -875,16 +974,23 @@ static int cxl_type3_hpa_to_as_and_dpa(CXLType3Dev *c= t3d, AddressSpace **as, uint64_t *dpa_offset) { - MemoryRegion *vmr =3D NULL, *pmr =3D NULL; + MemoryRegion *vmr =3D NULL, *pmr =3D NULL, *dc_mr =3D NULL; + uint64_t vmr_size =3D 0, pmr_size =3D 0, dc_size =3D 0; =20 if (ct3d->hostvmem) { vmr =3D host_memory_backend_get_memory(ct3d->hostvmem); + vmr_size =3D memory_region_size(vmr); } if (ct3d->hostpmem) { pmr =3D host_memory_backend_get_memory(ct3d->hostpmem); + pmr_size =3D memory_region_size(pmr); + } + if (ct3d->dc.host_dc) { + dc_mr =3D host_memory_backend_get_memory(ct3d->dc.host_dc); + dc_size =3D memory_region_size(dc_mr); } =20 - if (!vmr && !pmr) { + if (!vmr && !pmr && !dc_mr) { return -ENODEV; } =20 @@ -892,19 +998,18 @@ static int cxl_type3_hpa_to_as_and_dpa(CXLType3Dev *c= t3d, return -EINVAL; } =20 - if (*dpa_offset > ct3d->cxl_dstate.static_mem_size) { + if (*dpa_offset >=3D vmr_size + pmr_size + dc_size) { return -EINVAL; } =20 - if (vmr) { - if (*dpa_offset < memory_region_size(vmr)) { - *as =3D &ct3d->hostvmem_as; - } else { - *as =3D &ct3d->hostpmem_as; - *dpa_offset -=3D memory_region_size(vmr); - } - } else { + if (*dpa_offset < vmr_size) { + *as =3D &ct3d->hostvmem_as; + } else if (*dpa_offset < vmr_size + pmr_size) { *as =3D &ct3d->hostpmem_as; + *dpa_offset -=3D vmr_size; + } else { + *as =3D &ct3d->dc.host_dc_as; + *dpa_offset -=3D (vmr_size + pmr_size); } =20 return 0; @@ -986,6 +1091,8 @@ static Property ct3_props[] =3D { DEFINE_PROP_UINT64("sn", CXLType3Dev, sn, UI64_NULL), DEFINE_PROP_STRING("cdat", CXLType3Dev, cxl_cstate.cdat.filename), DEFINE_PROP_UINT8("num-dc-regions", CXLType3Dev, dc.num_regions, 0), + DEFINE_PROP_LINK("volatile-dc-memdev", CXLType3Dev, dc.host_dc, + TYPE_MEMORY_BACKEND, HostMemoryBackend *), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -1052,33 +1159,39 @@ static void set_lsa(CXLType3Dev *ct3d, const void *= buf, uint64_t size, =20 static bool set_cacheline(CXLType3Dev *ct3d, uint64_t dpa_offset, uint8_t = *data) { - MemoryRegion *vmr =3D NULL, *pmr =3D NULL; + MemoryRegion *vmr =3D NULL, *pmr =3D NULL, *dc_mr =3D NULL; AddressSpace *as; + uint64_t vmr_size =3D 0, pmr_size =3D 0, dc_size =3D 0; =20 if (ct3d->hostvmem) { vmr =3D host_memory_backend_get_memory(ct3d->hostvmem); + vmr_size =3D memory_region_size(vmr); } if (ct3d->hostpmem) { pmr =3D host_memory_backend_get_memory(ct3d->hostpmem); + pmr_size =3D memory_region_size(pmr); } + if (ct3d->dc.host_dc) { + dc_mr =3D host_memory_backend_get_memory(ct3d->dc.host_dc); + dc_size =3D memory_region_size(dc_mr); + } =20 - if (!vmr && !pmr) { + if (!vmr && !pmr && !dc_mr) { return false; } =20 - if (dpa_offset + CXL_CACHE_LINE_SIZE > ct3d->cxl_dstate.static_mem_siz= e) { + if (dpa_offset + CXL_CACHE_LINE_SIZE > vmr_size + pmr_size + dc_size) { return false; } =20 - if (vmr) { - if (dpa_offset < memory_region_size(vmr)) { - as =3D &ct3d->hostvmem_as; - } else { - as =3D &ct3d->hostpmem_as; - dpa_offset -=3D memory_region_size(vmr); - } - } else { + if (dpa_offset < vmr_size) { + as =3D &ct3d->hostvmem_as; + } else if (dpa_offset < vmr_size + pmr_size) { as =3D &ct3d->hostpmem_as; + dpa_offset -=3D vmr_size; + } else { + as =3D &ct3d->dc.host_dc_as; + dpa_offset -=3D (vmr_size + pmr_size); } =20 address_space_write(as, dpa_offset, MEMTXATTRS_UNSPECIFIED, &data, --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630611; cv=none; d=zohomail.com; s=zohoarc; b=L89PzjXOy7Kgf/lie3nG8zd1QibuIjPLkzE9iACrfl/T6mmLqGJBPiEIL7yh0P7MTywIma9CzNCTxaQZ8dbHJyg3GKkhJMidndM0IcDJm3lEdBBAHyFVX4Lvpp6h2LJD4MxXXGFF1kz6UZ0bxgdx41fM9e71lNkp8qe+YnOAJbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630611; 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=Y6BvONQ3xHQ5Uc0x7v2hZbGWG9V5fJeg5muDy0KhuLY=; b=nxMfqcwzkjNbIYixLnTD/naZ3RzUhNl74tc4mUSqB9wbKz3PxPy/8Zx8pbGuGDYmYBV1qmlNrQbew+gQVdh2DV2yGA/xeUtomZB08Xvmgu8PIvEYwkrbMaE/U5z5vDanpYyAC0Z24S1R5hHePQYrrXtxOQy8VyABApAbx5Psnt0= 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+importer=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 171763061128570.5506120571356; Wed, 5 Jun 2024 16:36:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0B4-0005n7-Qz; Wed, 05 Jun 2024 19:36:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0B0-0005WM-99 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Ay-0005jl-7F for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:18 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-39-73pRdBLoMvSvRnPn1OPNsw-1; Wed, 05 Jun 2024 19:36:14 -0400 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-57a941a787dso375872a12.3 for ; Wed, 05 Jun 2024 16:36:14 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae0cc36bsm100101a12.26.2024.06.05.16.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630575; h=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=Y6BvONQ3xHQ5Uc0x7v2hZbGWG9V5fJeg5muDy0KhuLY=; b=IctZZr/Ew+qQ7jgjsj+G3boZROmS5kGv4UHlRZAAljpzbmmOlsjT9g9IVgrWCIvDjH8Z7v EGJIM+npO3jyfLe6RgcGe6aqcYg3TUbfGSaLWijsrmj9toyBJAy3Z8/VquvX7YQY4Y4Q4n rpW1iSEnYQKVYEIOyFSxzEuyCgBcEoY= X-MC-Unique: 73pRdBLoMvSvRnPn1OPNsw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630572; x=1718235372; 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=Y6BvONQ3xHQ5Uc0x7v2hZbGWG9V5fJeg5muDy0KhuLY=; b=PbEE76uTV0O5gLrWtV/5m6oF3HRJMu4Ye4934C9P79lO6ml1v48i3pvKX7KmCHvfqC oYPjta7vnSgUwjY4ZQjlTRrqgRzQ8D0uKpExkTyVJA/kVhFIFiDz+1M6GZjv8FhnZC55 v33jAvfNIHsrtE9HurL+idmk8u01NnRAohdgT5CHwGaOrvpIRODOhKSCOCa5avTsSO9Y 4XrR7I9iZjJMcvCa5gGzeKZ81Cwzmr5ASLa88w4kJv/YH47mT1iKEYWfAl1YpxxXr6lQ JCYkMgkyBswfG0wwNUIuFEOKfFImlBUV8uRnnhRqDe+o5fzDY930laBTVKF8tW5t/kND tJ9w== X-Gm-Message-State: AOJu0YzC/z9XpWPORAaP4GtLjgFIG0WXyDMZXegFp6/j0NIk/1VIQAuB DG8K8ErYJU+ku6W1SPwULp4B/2+oNI6p5YwiQEVT+V7J7CrwiJ7o5J1WE+wPFzg+F8x10nTXFhs hPxXtDqc+3DOetEoIesPD0u8tb3gmqoWaDhAe2TLsqutKvseK2mYYt+3/oC/XIy2sR3YdaQ5Gjv 4LCIvQJKaifwR1YnQhQxE6u6LS/FqYLw== X-Received: by 2002:a50:d654:0:b0:574:f27a:b3ec with SMTP id 4fb4d7f45d1cf-57a8b6a8922mr2752688a12.16.1717630572366; Wed, 05 Jun 2024 16:36:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFx3JjaeLabtSUV+gD9Xyp+xVDoBRro/rmE74XprfYgMLf88utOeKh/FlrArj6ON/wNLjxdRw== X-Received: by 2002:a50:d654:0:b0:574:f27a:b3ec with SMTP id 4fb4d7f45d1cf-57a8b6a8922mr2752673a12.16.1717630571857; Wed, 05 Jun 2024 16:36:11 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Jonathan Cameron Subject: [PULL v3 24/41] hw/mem/cxl_type3: Add DC extent list representative and get DC extent list mailbox support Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630611856100015 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fan Ni Add dynamic capacity extent list representative to the definition of CXLType3Dev and implement get DC extent list mailbox command per CXL.spec.3.1:.8.2.9.9.9.2. Tested-by: Svetly Todorov Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-10-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 22 +++++++++++ hw/cxl/cxl-mailbox-utils.c | 73 ++++++++++++++++++++++++++++++++++++- hw/mem/cxl_type3.c | 1 + 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index c2c3df0d2a..6aec6ac983 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -424,6 +424,25 @@ typedef QLIST_HEAD(, CXLPoison) CXLPoisonList; =20 #define DCD_MAX_NUM_REGION 8 =20 +typedef struct CXLDCExtentRaw { + uint64_t start_dpa; + uint64_t len; + uint8_t tag[0x10]; + uint16_t shared_seq; + uint8_t rsvd[0x6]; +} QEMU_PACKED CXLDCExtentRaw; + +typedef struct CXLDCExtent { + uint64_t start_dpa; + uint64_t len; + uint8_t tag[0x10]; + uint16_t shared_seq; + uint8_t rsvd[0x6]; + + QTAILQ_ENTRY(CXLDCExtent) node; +} CXLDCExtent; +typedef QTAILQ_HEAD(, CXLDCExtent) CXLDCExtentList; + typedef struct CXLDCRegion { uint64_t base; /* aligned to 256*MiB */ uint64_t decode_len; /* aligned to 256*MiB */ @@ -474,6 +493,9 @@ struct CXLType3Dev { * memory region size. */ uint64_t total_capacity; /* 256M aligned */ + CXLDCExtentList extents; + uint32_t total_extent_count; + uint32_t ext_list_gen_seq; =20 uint8_t num_regions; /* 0-8 regions */ CXLDCRegion regions[DCD_MAX_NUM_REGION]; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 6ad227f112..7872d2f3e6 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -84,6 +84,7 @@ enum { #define CLEAR_POISON 0x2 DCD_CONFIG =3D 0x48, #define GET_DC_CONFIG 0x0 + #define GET_DYN_CAP_EXT_LIST 0x1 PHYSICAL_SWITCH =3D 0x51, #define IDENTIFY_SWITCH_DEVICE 0x0 #define GET_PHYSICAL_PORT_STATE 0x1 @@ -1322,7 +1323,8 @@ static CXLRetCode cmd_dcd_get_dyn_cap_config(const st= ruct cxl_cmd *cmd, * to use. */ stl_le_p(&extra_out->num_extents_supported, CXL_NUM_EXTENTS_SUPPORTED); - stl_le_p(&extra_out->num_extents_available, CXL_NUM_EXTENTS_SUPPORTED); + stl_le_p(&extra_out->num_extents_available, CXL_NUM_EXTENTS_SUPPORTED - + ct3d->dc.total_extent_count); stl_le_p(&extra_out->num_tags_supported, CXL_NUM_TAGS_SUPPORTED); stl_le_p(&extra_out->num_tags_available, CXL_NUM_TAGS_SUPPORTED); =20 @@ -1330,6 +1332,72 @@ static CXLRetCode cmd_dcd_get_dyn_cap_config(const s= truct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 +/* + * CXL r3.1 section 8.2.9.9.9.2: + * Get Dynamic Capacity Extent List (Opcode 4801h) + */ +static CXLRetCode cmd_dcd_get_dyn_cap_ext_list(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); + struct { + uint32_t extent_cnt; + uint32_t start_extent_id; + } QEMU_PACKED *in =3D (void *)payload_in; + struct { + uint32_t count; + uint32_t total_extents; + uint32_t generation_num; + uint8_t rsvd[4]; + CXLDCExtentRaw records[]; + } QEMU_PACKED *out =3D (void *)payload_out; + uint32_t start_extent_id =3D in->start_extent_id; + CXLDCExtentList *extent_list =3D &ct3d->dc.extents; + uint16_t record_count =3D 0, i =3D 0, record_done =3D 0; + uint16_t out_pl_len, size; + CXLDCExtent *ent; + + if (start_extent_id > ct3d->dc.total_extent_count) { + return CXL_MBOX_INVALID_INPUT; + } + + record_count =3D MIN(in->extent_cnt, + ct3d->dc.total_extent_count - start_extent_id); + size =3D CXL_MAILBOX_MAX_PAYLOAD_SIZE - sizeof(*out); + record_count =3D MIN(record_count, size / sizeof(out->records[0])); + out_pl_len =3D sizeof(*out) + record_count * sizeof(out->records[0]); + + stl_le_p(&out->count, record_count); + stl_le_p(&out->total_extents, ct3d->dc.total_extent_count); + stl_le_p(&out->generation_num, ct3d->dc.ext_list_gen_seq); + + if (record_count > 0) { + CXLDCExtentRaw *out_rec =3D &out->records[record_done]; + + QTAILQ_FOREACH(ent, extent_list, node) { + if (i++ < start_extent_id) { + continue; + } + stq_le_p(&out_rec->start_dpa, ent->start_dpa); + stq_le_p(&out_rec->len, ent->len); + memcpy(&out_rec->tag, ent->tag, 0x10); + stw_le_p(&out_rec->shared_seq, ent->shared_seq); + + record_done++; + if (record_done =3D=3D record_count) { + break; + } + } + } + + *len_out =3D out_pl_len; + return CXL_MBOX_SUCCESS; +} + #define IMMEDIATE_CONFIG_CHANGE (1 << 1) #define IMMEDIATE_DATA_CHANGE (1 << 2) #define IMMEDIATE_POLICY_CHANGE (1 << 3) @@ -1377,6 +1445,9 @@ static const struct cxl_cmd cxl_cmd_set[256][256] =3D= { static const struct cxl_cmd cxl_cmd_set_dcd[256][256] =3D { [DCD_CONFIG][GET_DC_CONFIG] =3D { "DCD_GET_DC_CONFIG", cmd_dcd_get_dyn_cap_config, 2, 0 }, + [DCD_CONFIG][GET_DYN_CAP_EXT_LIST] =3D { + "DCD_GET_DYNAMIC_CAPACITY_EXTENT_LIST", cmd_dcd_get_dyn_cap_ext_li= st, + 8, 0 }, }; =20 static const struct cxl_cmd cxl_cmd_set_sw[256][256] =3D { diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 658570aa1a..2075846b1b 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -673,6 +673,7 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Er= ror **errp) }; ct3d->dc.total_capacity +=3D region->len; } + QTAILQ_INIT(&ct3d->dc.extents); =20 return true; } --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630608; cv=none; d=zohomail.com; s=zohoarc; b=PxEUegMwiC7j2w8Q6qd6ZWhvqQdlxHmx6MZSwXpdtxZl8upNwALe0nF3EvBvGZxGZ2NHhl6vTL8LUQfZHwf75f7TKu5Z5UFRLd/kH+rMKcvPOLDzp9gmG8/TUwfR156ln73WzcYpbk7zkIyEeDWXSy6WkXjzWZMXZ0OjFMtuac8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630608; 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=OLpu8QtF+gouN+ualw24jfsLt/1sw7VC0fnWp2szNZc=; b=UfUTYz5SJaHy0AbQfzkTanL3Mo8vcoo2tbk8Vh/a2ujdxgxGnscfc8uYT7P2ZEIERWkZdeFVPfFInF71S7PSvb/yAnJZTkYGgVTZBQXg9TbQZrNktY9/9l0Ifge15jh68sPdNlRobcRgxrFUxKTo3Eui9i/Pt+pP4YYVCCATH0s= 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+importer=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 1717630608478558.4093290889111; Wed, 5 Jun 2024 16:36:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0B9-0006UG-P8; Wed, 05 Jun 2024 19:36:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0B8-0006IE-60 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0B4-0005kh-Mh for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:25 -0400 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-185-xLa1qy-8PsWIQqJncEqoDQ-1; Wed, 05 Jun 2024 19:36:18 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a6905050583so16377566b.0 for ; Wed, 05 Jun 2024 16:36:17 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c805cd97csm7057466b.67.2024.06.05.16.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630579; h=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=OLpu8QtF+gouN+ualw24jfsLt/1sw7VC0fnWp2szNZc=; b=J5mh4RcZNK9Y1tRaz7ziwFhWuZ/qRkEa/1K/g2ho5uOCcbFgzSTKXS2GAhUb3Y5nLf74HS rK50EhQ88RyBGui1PULikmUmma6j+OD4td6aU/ryLTQz9Qs5D76BO/IT7DQMB1JbVQsYro B6iRmCc1j49eCUklOXK/8U0jVx4C6G4= X-MC-Unique: xLa1qy-8PsWIQqJncEqoDQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630576; x=1718235376; 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=OLpu8QtF+gouN+ualw24jfsLt/1sw7VC0fnWp2szNZc=; b=arKrHz/wosB7P9cH/66RVCgWEbdLKDBGPOpSBoT7QAKkoYxKX77N6OONodKQPvoWnM ENLO+Ge0ZCoroP7WNDF+2VepcI8FbqNHDZqsUvY5f2csjELo1FFMrDs8VXw34VvxZ10t 5/z4YmUskFOGRnMv8q8DSl7utBOAYTNGpENkaCIpnC6mjcGhDkKeZ0U0+CM8sjj/67lg McXoxrAh3IveaFB+CK2YpI5hXfU9/FFqpCIVEJO5O1iVXjAuHbMn5D95DoT7WeBtMHLd AAWSUtQzMQXShXggoGd+sVOk7u8g+njT8MjeggH4GE9kzYaEdYwMbav06yC+1ghVs+P0 0j5w== X-Gm-Message-State: AOJu0Yy4yl7cm9sTg3l5gMzWbdg1cQhFAkgko8PDtG72mS2+gAsSBE/N MheeiMR6yM+KEtWl04+CTevyksN8ufa0bvYGyOZ43UPeiJEwrZuf8gT3s8kNsQ/Nj08xn/TyY9e nDubJOP4GZ/ASxJtl2tKJ2PCv+jNrmMFgPqqgsufNi/dFqKUC03sGcMEH+chzVyWBihj4E856CV YWGQH+9OEEvV70FxZDlpvECNi1wVcznQ== X-Received: by 2002:a17:906:7c51:b0:a68:7b9b:5176 with SMTP id a640c23a62f3a-a699fcdf994mr248616566b.44.1717630576058; Wed, 05 Jun 2024 16:36:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUsLF63MQVGSfBFHRS8AQrnIgRyLtiXk1VV2PecjDmFXjiPLOe+awrPmbWUqigUoWwi2JRGA== X-Received: by 2002:a17:906:7c51:b0:a68:7b9b:5176 with SMTP id a640c23a62f3a-a699fcdf994mr248615266b.44.1717630575494; Wed, 05 Jun 2024 16:36:15 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:12 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron Subject: [PULL v3 25/41] hw/cxl/cxl-mailbox-utils: Add mailbox commands to support add/release dynamic capacity response 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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630609909100006 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fan Ni Per CXL spec 3.1, two mailbox commands are implemented: Add Dynamic Capacity Response (Opcode 4802h) 8.2.9.9.9.3, and Release Dynamic Capacity (Opcode 4803h) 8.2.9.9.9.4. For the process of the above two commands, we use two-pass approach. Pass 1: Check whether the input payload is valid or not; if not, skip Pass 2 and return mailbox process error. Pass 2: Do the real work--add or release extents, respectively. Tested-by: Svetly Todorov Reviewed-by: Gregory Price Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-11-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 4 + hw/cxl/cxl-mailbox-utils.c | 394 ++++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3.c | 11 + 3 files changed, 409 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 6aec6ac983..df3511e91b 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -551,4 +551,8 @@ void cxl_event_irq_assert(CXLType3Dev *ct3d); =20 void cxl_set_poison_list_overflowed(CXLType3Dev *ct3d); =20 +CXLDCRegion *cxl_find_dc_region(CXLType3Dev *ct3d, uint64_t dpa, uint64_t = len); + +void cxl_remove_extent_from_extent_list(CXLDCExtentList *list, + CXLDCExtent *extent); #endif diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 7872d2f3e6..e322407fb3 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -19,6 +19,7 @@ #include "qemu/units.h" #include "qemu/uuid.h" #include "sysemu/hostmem.h" +#include "qemu/range.h" =20 #define CXL_CAPACITY_MULTIPLIER (256 * MiB) #define CXL_DC_EVENT_LOG_SIZE 8 @@ -85,6 +86,8 @@ enum { DCD_CONFIG =3D 0x48, #define GET_DC_CONFIG 0x0 #define GET_DYN_CAP_EXT_LIST 0x1 + #define ADD_DYN_CAP_RSP 0x2 + #define RELEASE_DYN_CAP 0x3 PHYSICAL_SWITCH =3D 0x51, #define IDENTIFY_SWITCH_DEVICE 0x0 #define GET_PHYSICAL_PORT_STATE 0x1 @@ -1398,6 +1401,391 @@ static CXLRetCode cmd_dcd_get_dyn_cap_ext_list(cons= t struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 +/* + * Check whether any bit between addr[nr, nr+size) is set, + * return true if any bit is set, otherwise return false + */ +static bool test_any_bits_set(const unsigned long *addr, unsigned long nr, + unsigned long size) +{ + unsigned long res =3D find_next_bit(addr, size + nr, nr); + + return res < nr + size; +} + +CXLDCRegion *cxl_find_dc_region(CXLType3Dev *ct3d, uint64_t dpa, uint64_t = len) +{ + int i; + CXLDCRegion *region =3D &ct3d->dc.regions[0]; + + if (dpa < region->base || + dpa >=3D region->base + ct3d->dc.total_capacity) { + return NULL; + } + + /* + * CXL r3.1 section 9.13.3: Dynamic Capacity Device (DCD) + * + * Regions are used in increasing-DPA order, with Region 0 being used = for + * the lowest DPA of Dynamic Capacity and Region 7 for the highest DPA. + * So check from the last region to find where the dpa belongs. Extent= s that + * cross multiple regions are not allowed. + */ + for (i =3D ct3d->dc.num_regions - 1; i >=3D 0; i--) { + region =3D &ct3d->dc.regions[i]; + if (dpa >=3D region->base) { + if (dpa + len > region->base + region->len) { + return NULL; + } + return region; + } + } + + return NULL; +} + +static void cxl_insert_extent_to_extent_list(CXLDCExtentList *list, + uint64_t dpa, + uint64_t len, + uint8_t *tag, + uint16_t shared_seq) +{ + CXLDCExtent *extent; + + extent =3D g_new0(CXLDCExtent, 1); + extent->start_dpa =3D dpa; + extent->len =3D len; + if (tag) { + memcpy(extent->tag, tag, 0x10); + } + extent->shared_seq =3D shared_seq; + + QTAILQ_INSERT_TAIL(list, extent, node); +} + +void cxl_remove_extent_from_extent_list(CXLDCExtentList *list, + CXLDCExtent *extent) +{ + QTAILQ_REMOVE(list, extent, node); + g_free(extent); +} + +/* + * CXL r3.1 Table 8-168: Add Dynamic Capacity Response Input Payload + * CXL r3.1 Table 8-170: Release Dynamic Capacity Input Payload + */ +typedef struct CXLUpdateDCExtentListInPl { + uint32_t num_entries_updated; + uint8_t flags; + uint8_t rsvd[3]; + /* CXL r3.1 Table 8-169: Updated Extent */ + struct { + uint64_t start_dpa; + uint64_t len; + uint8_t rsvd[8]; + } QEMU_PACKED updated_entries[]; +} QEMU_PACKED CXLUpdateDCExtentListInPl; + +/* + * For the extents in the extent list to operate, check whether they are v= alid + * 1. The extent should be in the range of a valid DC region; + * 2. The extent should not cross multiple regions; + * 3. The start DPA and the length of the extent should align with the blo= ck + * size of the region; + * 4. The address range of multiple extents in the list should not overlap. + */ +static CXLRetCode cxl_detect_malformed_extent_list(CXLType3Dev *ct3d, + const CXLUpdateDCExtentListInPl *in) +{ + uint64_t min_block_size =3D UINT64_MAX; + CXLDCRegion *region; + CXLDCRegion *lastregion =3D &ct3d->dc.regions[ct3d->dc.num_regions - 1= ]; + g_autofree unsigned long *blk_bitmap =3D NULL; + uint64_t dpa, len; + uint32_t i; + + for (i =3D 0; i < ct3d->dc.num_regions; i++) { + region =3D &ct3d->dc.regions[i]; + min_block_size =3D MIN(min_block_size, region->block_size); + } + + blk_bitmap =3D bitmap_new((lastregion->base + lastregion->len - + ct3d->dc.regions[0].base) / min_block_size); + + for (i =3D 0; i < in->num_entries_updated; i++) { + dpa =3D in->updated_entries[i].start_dpa; + len =3D in->updated_entries[i].len; + + region =3D cxl_find_dc_region(ct3d, dpa, len); + if (!region) { + return CXL_MBOX_INVALID_PA; + } + + dpa -=3D ct3d->dc.regions[0].base; + if (dpa % region->block_size || len % region->block_size) { + return CXL_MBOX_INVALID_EXTENT_LIST; + } + /* the dpa range already covered by some other extents in the list= */ + if (test_any_bits_set(blk_bitmap, dpa / min_block_size, + len / min_block_size)) { + return CXL_MBOX_INVALID_EXTENT_LIST; + } + bitmap_set(blk_bitmap, dpa / min_block_size, len / min_block_size); + } + + return CXL_MBOX_SUCCESS; +} + +static CXLRetCode cxl_dcd_add_dyn_cap_rsp_dry_run(CXLType3Dev *ct3d, + const CXLUpdateDCExtentListInPl *in) +{ + uint32_t i; + CXLDCExtent *ent; + uint64_t dpa, len; + Range range1, range2; + + for (i =3D 0; i < in->num_entries_updated; i++) { + dpa =3D in->updated_entries[i].start_dpa; + len =3D in->updated_entries[i].len; + + range_init_nofail(&range1, dpa, len); + + /* + * TODO: once the pending extent list is added, check against + * the list will be added here. + */ + + /* to-be-added range should not overlap with range already accepte= d */ + QTAILQ_FOREACH(ent, &ct3d->dc.extents, node) { + range_init_nofail(&range2, ent->start_dpa, ent->len); + if (range_overlaps_range(&range1, &range2)) { + return CXL_MBOX_INVALID_PA; + } + } + } + return CXL_MBOX_SUCCESS; +} + +/* + * CXL r3.1 section 8.2.9.9.9.3: Add Dynamic Capacity Response (Opcode 480= 2h) + * An extent is added to the extent list and becomes usable only after the + * response is processed successfully. + */ +static CXLRetCode cmd_dcd_add_dyn_cap_rsp(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + CXLUpdateDCExtentListInPl *in =3D (void *)payload_in; + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + CXLDCExtentList *extent_list =3D &ct3d->dc.extents; + uint32_t i; + uint64_t dpa, len; + CXLRetCode ret; + + if (in->num_entries_updated =3D=3D 0) { + /* + * TODO: once the pending list is introduced, extents in the begin= ning + * will get wiped out. + */ + return CXL_MBOX_SUCCESS; + } + + /* Adding extents causes exceeding device's extent tracking ability. */ + if (in->num_entries_updated + ct3d->dc.total_extent_count > + CXL_NUM_EXTENTS_SUPPORTED) { + return CXL_MBOX_RESOURCES_EXHAUSTED; + } + + ret =3D cxl_detect_malformed_extent_list(ct3d, in); + if (ret !=3D CXL_MBOX_SUCCESS) { + return ret; + } + + ret =3D cxl_dcd_add_dyn_cap_rsp_dry_run(ct3d, in); + if (ret !=3D CXL_MBOX_SUCCESS) { + return ret; + } + + for (i =3D 0; i < in->num_entries_updated; i++) { + dpa =3D in->updated_entries[i].start_dpa; + len =3D in->updated_entries[i].len; + + cxl_insert_extent_to_extent_list(extent_list, dpa, len, NULL, 0); + ct3d->dc.total_extent_count +=3D 1; + /* + * TODO: we will add a pending extent list based on event log reco= rd + * and process the list accordingly here. + */ + } + + return CXL_MBOX_SUCCESS; +} + +/* + * Copy extent list from src to dst + * Return value: number of extents copied + */ +static uint32_t copy_extent_list(CXLDCExtentList *dst, + const CXLDCExtentList *src) +{ + uint32_t cnt =3D 0; + CXLDCExtent *ent; + + if (!dst || !src) { + return 0; + } + + QTAILQ_FOREACH(ent, src, node) { + cxl_insert_extent_to_extent_list(dst, ent->start_dpa, ent->len, + ent->tag, ent->shared_seq); + cnt++; + } + return cnt; +} + +static CXLRetCode cxl_dc_extent_release_dry_run(CXLType3Dev *ct3d, + const CXLUpdateDCExtentListInPl *in, CXLDCExtentList *updated_list, + uint32_t *updated_list_size) +{ + CXLDCExtent *ent, *ent_next; + uint64_t dpa, len; + uint32_t i; + int cnt_delta =3D 0; + CXLRetCode ret =3D CXL_MBOX_SUCCESS; + + QTAILQ_INIT(updated_list); + copy_extent_list(updated_list, &ct3d->dc.extents); + + for (i =3D 0; i < in->num_entries_updated; i++) { + Range range; + + dpa =3D in->updated_entries[i].start_dpa; + len =3D in->updated_entries[i].len; + + while (len > 0) { + QTAILQ_FOREACH(ent, updated_list, node) { + range_init_nofail(&range, ent->start_dpa, ent->len); + + if (range_contains(&range, dpa)) { + uint64_t len1, len2 =3D 0, len_done =3D 0; + uint64_t ent_start_dpa =3D ent->start_dpa; + uint64_t ent_len =3D ent->len; + + len1 =3D dpa - ent->start_dpa; + /* Found the extent or the subset of an existing exten= t */ + if (range_contains(&range, dpa + len - 1)) { + len2 =3D ent_start_dpa + ent_len - dpa - len; + } else { + /* + * TODO: we reject the attempt to remove an extent + * that overlaps with multiple extents in the devi= ce + * for now. We will allow it once superset release + * support is added. + */ + ret =3D CXL_MBOX_INVALID_PA; + goto free_and_exit; + } + len_done =3D ent_len - len1 - len2; + + cxl_remove_extent_from_extent_list(updated_list, ent); + cnt_delta--; + + if (len1) { + cxl_insert_extent_to_extent_list(updated_list, + ent_start_dpa, + len1, NULL, 0); + cnt_delta++; + } + if (len2) { + cxl_insert_extent_to_extent_list(updated_list, + dpa + len, + len2, NULL, 0); + cnt_delta++; + } + + if (cnt_delta + ct3d->dc.total_extent_count > + CXL_NUM_EXTENTS_SUPPORTED) { + ret =3D CXL_MBOX_RESOURCES_EXHAUSTED; + goto free_and_exit; + } + + len -=3D len_done; + /* len =3D=3D 0 here until superset release is added */ + break; + } + } + if (len) { + ret =3D CXL_MBOX_INVALID_PA; + goto free_and_exit; + } + } + } +free_and_exit: + if (ret !=3D CXL_MBOX_SUCCESS) { + QTAILQ_FOREACH_SAFE(ent, updated_list, node, ent_next) { + cxl_remove_extent_from_extent_list(updated_list, ent); + } + *updated_list_size =3D 0; + } else { + *updated_list_size =3D ct3d->dc.total_extent_count + cnt_delta; + } + + return ret; +} + +/* + * CXL r3.1 section 8.2.9.9.9.4: Release Dynamic Capacity (Opcode 4803h) + */ +static CXLRetCode cmd_dcd_release_dyn_cap(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + CXLUpdateDCExtentListInPl *in =3D (void *)payload_in; + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + CXLDCExtentList updated_list; + CXLDCExtent *ent, *ent_next; + uint32_t updated_list_size; + CXLRetCode ret; + + if (in->num_entries_updated =3D=3D 0) { + return CXL_MBOX_INVALID_INPUT; + } + + ret =3D cxl_detect_malformed_extent_list(ct3d, in); + if (ret !=3D CXL_MBOX_SUCCESS) { + return ret; + } + + ret =3D cxl_dc_extent_release_dry_run(ct3d, in, &updated_list, + &updated_list_size); + if (ret !=3D CXL_MBOX_SUCCESS) { + return ret; + } + + /* + * If the dry run release passes, the returned updated_list will + * be the updated extent list and we just need to clear the extents + * in the accepted list and copy extents in the updated_list to accept= ed + * list and update the extent count; + */ + QTAILQ_FOREACH_SAFE(ent, &ct3d->dc.extents, node, ent_next) { + cxl_remove_extent_from_extent_list(&ct3d->dc.extents, ent); + } + copy_extent_list(&ct3d->dc.extents, &updated_list); + QTAILQ_FOREACH_SAFE(ent, &updated_list, node, ent_next) { + cxl_remove_extent_from_extent_list(&updated_list, ent); + } + ct3d->dc.total_extent_count =3D updated_list_size; + + return CXL_MBOX_SUCCESS; +} + #define IMMEDIATE_CONFIG_CHANGE (1 << 1) #define IMMEDIATE_DATA_CHANGE (1 << 2) #define IMMEDIATE_POLICY_CHANGE (1 << 3) @@ -1448,6 +1836,12 @@ static const struct cxl_cmd cxl_cmd_set_dcd[256][256= ] =3D { [DCD_CONFIG][GET_DYN_CAP_EXT_LIST] =3D { "DCD_GET_DYNAMIC_CAPACITY_EXTENT_LIST", cmd_dcd_get_dyn_cap_ext_li= st, 8, 0 }, + [DCD_CONFIG][ADD_DYN_CAP_RSP] =3D { + "DCD_ADD_DYNAMIC_CAPACITY_RESPONSE", cmd_dcd_add_dyn_cap_rsp, + ~0, IMMEDIATE_DATA_CHANGE }, + [DCD_CONFIG][RELEASE_DYN_CAP] =3D { + "DCD_RELEASE_DYNAMIC_CAPACITY", cmd_dcd_release_dyn_cap, + ~0, IMMEDIATE_DATA_CHANGE }, }; =20 static const struct cxl_cmd cxl_cmd_set_sw[256][256] =3D { diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 2075846b1b..db5191b3b7 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -678,6 +678,15 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, E= rror **errp) return true; } =20 +static void cxl_destroy_dc_regions(CXLType3Dev *ct3d) +{ + CXLDCExtent *ent, *ent_next; + + QTAILQ_FOREACH_SAFE(ent, &ct3d->dc.extents, node, ent_next) { + cxl_remove_extent_from_extent_list(&ct3d->dc.extents, ent); + } +} + static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) { DeviceState *ds =3D DEVICE(ct3d); @@ -874,6 +883,7 @@ err_free_special_ops: g_free(regs->special_ops); err_address_space_free: if (ct3d->dc.host_dc) { + cxl_destroy_dc_regions(ct3d); address_space_destroy(&ct3d->dc.host_dc_as); } if (ct3d->hostpmem) { @@ -895,6 +905,7 @@ static void ct3_exit(PCIDevice *pci_dev) cxl_doe_cdat_release(cxl_cstate); g_free(regs->special_ops); if (ct3d->dc.host_dc) { + cxl_destroy_dc_regions(ct3d); address_space_destroy(&ct3d->dc.host_dc_as); } if (ct3d->hostpmem) { --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630625; cv=none; d=zohomail.com; s=zohoarc; b=AB8oLwgU3MD25sNh1kBvbE1Wv/242/J/08HSNf+XM4r+9yskPF3lxNyKqyU1biVIecYVuNDtEtaZurzh/DFKczfsgCafecKrWj38VWl7RW8bOMwsqzosPziqHnI0irPeYdYvPC03jCHMJEiccJH4x191thh4nAYD8LsW54++ecU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630625; 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=luTRPHAeeb1OyXMCpOc0nu4ARMny/qSptOQ/dYaP6qI=; b=BCpd0U/90fQjIlxdU11HvUwObOsycbM9hCOqo1L+8DTnKcjc1Vq+kdqhBbUqt87p4gqKqw8OJf+boPJaiV7PZg2QHwK8rl+C73qLGpbsBIx6BB6kqEb0/qMhbBU8qnjUkHeI5StVM5VZUbkNK6AFQ969MgnjyIK2pu3TCYMLwEc= 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+importer=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 1717630625183862.3604643088644; Wed, 5 Jun 2024 16:37:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0BB-0006e9-Aj; Wed, 05 Jun 2024 19:36:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0B9-0006UY-Pv for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0B6-0005oB-Ev for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:27 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-345-GUvApylGPJ66KrQdjfQ_Wg-1; Wed, 05 Jun 2024 19:36:22 -0400 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-57a69a573a4so72564a12.2 for ; Wed, 05 Jun 2024 16:36:21 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aadf9d2a1sm100068a12.20.2024.06.05.16.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630583; h=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=luTRPHAeeb1OyXMCpOc0nu4ARMny/qSptOQ/dYaP6qI=; b=fiFOAje4kFtW7ymDztgf1CwRUnFStPAYPhJqIiNjryIMNBZT3Ddp8Fi5WBSMSDrZpuK7gH EbDgCQooYECt4n5217TOuyEnmqjFziGsvAQ0eawNgXmlPvYfzQkcy1KQ1K1VmNtLurH1FZ A4UTdC7Xhf3ip4DRw/QIc+2aVHtHLRY= X-MC-Unique: GUvApylGPJ66KrQdjfQ_Wg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630580; x=1718235380; 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=luTRPHAeeb1OyXMCpOc0nu4ARMny/qSptOQ/dYaP6qI=; b=ILtjbO8Ta2GgMR3J5iS/1xn8VTctSgMZcJijUoaz6sqiAJy7KkvMpyKz5uzCex+Y66 N2+syU95afhUyG5qtoZaLBBdcGpqCFDbwlCy36ggUQaxAWvux55Yy+w888RK/XZVN9Jd NWiGctduKYIPAl/RxCPXepmIhdQFa5bXbWqZs6iaJueQ5f/IifWaIeMbivs5XYE05EDG Yc62iLQ4ObtJEL0kPPaXlun482u0MuY3hoHge7Ap/gjG5/qma4196c3C5mROO9OMY5Cf y9Vpe1XubcirlzYqj4iuBaFHvgKrYCCAwJWZCEzp26FuqpO/+3APAZrZHLfUsl08C8/w zhqw== X-Gm-Message-State: AOJu0YzV4qIYuLeo91Y0eal15Q8x64OGCiUhvRkHKLgqqPZ2gKUXwuMv 8oB0AOrjmoXPojWqxqkZ9okLNuHUySOqY8VamUIopDNJ0K/mhuQ2ACNVBtSmHNT0d5o12YDhK1+ A4sGiQNeOdxFvyIm/Etg5ppGmm2lxbOzrP50LC39Qh38uBTYHyKTHgkk/urjMHKYF4cv22UioQW /J3wqcoxY8mUBRyIYl0YNBfo6EZMrLwQ== X-Received: by 2002:a50:cdd9:0:b0:57a:322c:b1a5 with SMTP id 4fb4d7f45d1cf-57a8bcc8347mr2291339a12.38.1717630580074; Wed, 05 Jun 2024 16:36:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHeAhnzzL51rQLDe19H7X/Ak/kmhayNP0F6jnvFpdOSpMCAtipMZ2la2n0sb4zQdp2vvWToeA== X-Received: by 2002:a50:cdd9:0:b0:57a:322c:b1a5 with SMTP id 4fb4d7f45d1cf-57a8bcc8347mr2291322a12.38.1717630579361; Wed, 05 Jun 2024 16:36:19 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron , Eric Blake , Markus Armbruster Subject: [PULL v3 26/41] hw/cxl/events: Add qmp interfaces to add/release dynamic capacity extents Message-ID: <9388abe89d2af7df80e885bd5b580165d77bdd86.1717630437.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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630626002100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fan Ni To simulate FM functionalities for initiating Dynamic Capacity Add (Opcode 5604h) and Dynamic Capacity Release (Opcode 5605h) as in CXL spec r3.1 7.6.7.6.5 and 7.6.7.6.6, we implemented two QMP interfaces to issue add/release dynamic capacity extents requests. With the change, we allow to release an extent only when its DPA range is contained by a single accepted extent in the device. That is to say, extent superset release is not supported yet. 1. Add dynamic capacity extents: For example, the command to add two continuous extents (each 128MiB long) to region 0 (starting at DPA offset 0) looks like below: { "execute": "qmp_capabilities" } { "execute": "cxl-add-dynamic-capacity", "arguments": { "path": "/machine/peripheral/cxl-dcd0", "host-id": 0, "selection-policy": "prescriptive", "region": 0, "extents": [ { "offset": 0, "len": 134217728 }, { "offset": 134217728, "len": 134217728 } ] } } 2. Release dynamic capacity extents: For example, the command to release an extent of size 128MiB from region 0 (DPA offset 128MiB) looks like below: { "execute": "cxl-release-dynamic-capacity", "arguments": { "path": "/machine/peripheral/cxl-dcd0", "host-id": 0, "removal-policy":"prescriptive", "region": 0, "extents": [ { "offset": 134217728, "len": 134217728 } ] } } Tested-by: Svetly Todorov Reviewed-by: Gregory Price Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-12-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/cxl.json | 143 +++++++++++++++++ include/hw/cxl/cxl_device.h | 22 +++ include/hw/cxl/cxl_events.h | 18 +++ hw/cxl/cxl-mailbox-utils.c | 62 ++++++-- hw/mem/cxl_type3.c | 306 +++++++++++++++++++++++++++++++++++- hw/mem/cxl_type3_stubs.c | 25 +++ 6 files changed, 563 insertions(+), 13 deletions(-) diff --git a/qapi/cxl.json b/qapi/cxl.json index 4281726dec..57d9f82014 100644 --- a/qapi/cxl.json +++ b/qapi/cxl.json @@ -361,3 +361,146 @@ ## {'command': 'cxl-inject-correctable-error', 'data': {'path': 'str', 'type': 'CxlCorErrorType'}} + +## +# @CXLDynamicCapacityExtent: +# +# A single dynamic capacity extent +# +# @offset: The offset (in bytes) to the start of the region +# where the extent belongs to. +# +# @len: The length of the extent in bytes. +# +# Since: 9.1 +## +{ 'struct': 'CXLDynamicCapacityExtent', + 'data': { + 'offset':'uint64', + 'len': 'uint64' + } +} + +## +# @CXLExtSelPolicy: +# +# The policy to use for selecting which extents comprise the added +# capacity, as defined in cxl spec r3.1 Table 7-70. +# +# @free: 0h =3D Free +# +# @contiguous: 1h =3D Continuous +# +# @prescriptive: 2h =3D Prescriptive +# +# @enable-shared-access: 3h =3D Enable Shared Access +# +# Since: 9.1 +## +{ 'enum': 'CXLExtSelPolicy', + 'data': ['free', + 'contiguous', + 'prescriptive', + 'enable-shared-access'] +} + +## +# @cxl-add-dynamic-capacity: +# +# Command to initiate to add dynamic capacity extents to a host. It +# simulates operations defined in cxl spec r3.1 7.6.7.6.5. +# +# @path: CXL DCD canonical QOM path. +# +# @host-id: The "Host ID" field as defined in cxl spec r3.1 +# Table 7-70. +# +# @selection-policy: The "Selection Policy" bits as defined in +# cxl spec r3.1 Table 7-70. It specifies the policy to use for +# selecting which extents comprise the added capacity. +# +# @region: The "Region Number" field as defined in cxl spec r3.1 +# Table 7-70. The dynamic capacity region where the capacity +# is being added. Valid range is from 0-7. +# +# @tag: The "Tag" field as defined in cxl spec r3.1 Table 7-70. +# +# @extents: The "Extent List" field as defined in cxl spec r3.1 +# Table 7-70. +# +# Since : 9.1 +## +{ 'command': 'cxl-add-dynamic-capacity', + 'data': { 'path': 'str', + 'host-id': 'uint16', + 'selection-policy': 'CXLExtSelPolicy', + 'region': 'uint8', + '*tag': 'str', + 'extents': [ 'CXLDynamicCapacityExtent' ] + } +} + +## +# @CXLExtRemovalPolicy: +# +# The policy to use for selecting which extents comprise the released +# capacity, defined in the "Flags" field in cxl spec r3.1 Table 7-71. +# +# @tag-based: value =3D 0h. Extents are selected by the device based +# on tag, with no requirement for contiguous extents. +# +# @prescriptive: value =3D 1h. Extent list of capacity to release is +# included in the request payload. +# +# Since: 9.1 +## +{ 'enum': 'CXLExtRemovalPolicy', + 'data': ['tag-based', + 'prescriptive'] +} + +## +# @cxl-release-dynamic-capacity: +# +# Command to initiate to release dynamic capacity extents from a +# host. It simulates operations defined in cxl spec r3.1 7.6.7.6.6. +# +# @path: CXL DCD canonical QOM path. +# +# @host-id: The "Host ID" field as defined in cxl spec r3.1 +# Table 7-71. +# +# @removal-policy: Bit[3:0] of the "Flags" field as defined in cxl +# spec r3.1 Table 7-71. +# +# @forced-removal: Bit[4] of the "Flags" field in cxl spec r3.1 +# Table 7-71. When set, device does not wait for a Release +# Dynamic Capacity command from the host. Host immediately +# loses access to released capacity. +# +# @sanitize-on-release: Bit[5] of the "Flags" field in cxl spec r3.1 +# Table 7-71. When set, device should sanitize all released +# capacity as a result of this request. +# +# @region: The "Region Number" field as defined in cxl spec r3.1 +# Table 7-71. The dynamic capacity region where the capacity +# is being added. Valid range is from 0-7. +# +# @tag: The "Tag" field as defined in cxl spec r3.1 Table 7-71. +# +# @extents: The "Extent List" field as defined in cxl spec r3.1 +# Table 7-71. +# +# Since : 9.1 +## +{ 'command': 'cxl-release-dynamic-capacity', + 'data': { 'path': 'str', + 'host-id': 'uint16', + 'removal-policy': 'CXLExtRemovalPolicy', + '*forced-removal': 'bool', + '*sanitize-on-release': 'bool', + 'region': 'uint8', + '*tag': 'str', + 'extents': [ 'CXLDynamicCapacityExtent' ] + } +} diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index df3511e91b..c69ff6b5de 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -443,6 +443,12 @@ typedef struct CXLDCExtent { } CXLDCExtent; typedef QTAILQ_HEAD(, CXLDCExtent) CXLDCExtentList; =20 +typedef struct CXLDCExtentGroup { + CXLDCExtentList list; + QTAILQ_ENTRY(CXLDCExtentGroup) node; +} CXLDCExtentGroup; +typedef QTAILQ_HEAD(, CXLDCExtentGroup) CXLDCExtentGroupList; + typedef struct CXLDCRegion { uint64_t base; /* aligned to 256*MiB */ uint64_t decode_len; /* aligned to 256*MiB */ @@ -494,6 +500,7 @@ struct CXLType3Dev { */ uint64_t total_capacity; /* 256M aligned */ CXLDCExtentList extents; + CXLDCExtentGroupList extents_pending; uint32_t total_extent_count; uint32_t ext_list_gen_seq; =20 @@ -555,4 +562,19 @@ CXLDCRegion *cxl_find_dc_region(CXLType3Dev *ct3d, uin= t64_t dpa, uint64_t len); =20 void cxl_remove_extent_from_extent_list(CXLDCExtentList *list, CXLDCExtent *extent); +void cxl_insert_extent_to_extent_list(CXLDCExtentList *list, uint64_t dpa, + uint64_t len, uint8_t *tag, + uint16_t shared_seq); +bool test_any_bits_set(const unsigned long *addr, unsigned long nr, + unsigned long size); +bool cxl_extents_contains_dpa_range(CXLDCExtentList *list, + uint64_t dpa, uint64_t len); +CXLDCExtentGroup *cxl_insert_extent_to_extent_group(CXLDCExtentGroup *grou= p, + uint64_t dpa, + uint64_t len, + uint8_t *tag, + uint16_t shared_seq); +void cxl_extent_group_list_insert_tail(CXLDCExtentGroupList *list, + CXLDCExtentGroup *group); +void cxl_extent_group_list_delete_front(CXLDCExtentGroupList *list); #endif diff --git a/include/hw/cxl/cxl_events.h b/include/hw/cxl/cxl_events.h index 5170b8dbf8..38cadaa0f3 100644 --- a/include/hw/cxl/cxl_events.h +++ b/include/hw/cxl/cxl_events.h @@ -166,4 +166,22 @@ typedef struct CXLEventMemoryModule { uint8_t reserved[0x3d]; } QEMU_PACKED CXLEventMemoryModule; =20 +/* + * CXL r3.1 section Table 8-50: Dynamic Capacity Event Record + * All fields little endian. + */ +typedef struct CXLEventDynamicCapacity { + CXLEventRecordHdr hdr; + uint8_t type; + uint8_t validity_flags; + uint16_t host_id; + uint8_t updated_region_id; + uint8_t flags; + uint8_t reserved2[2]; + uint8_t dynamic_capacity_extent[0x28]; /* defined in cxl_device.h */ + uint8_t reserved[0x18]; + uint32_t extents_avail; + uint32_t tags_avail; +} QEMU_PACKED CXLEventDynamicCapacity; + #endif /* CXL_EVENTS_H */ diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index e322407fb3..64387f34ce 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1405,7 +1405,7 @@ static CXLRetCode cmd_dcd_get_dyn_cap_ext_list(const = struct cxl_cmd *cmd, * Check whether any bit between addr[nr, nr+size) is set, * return true if any bit is set, otherwise return false */ -static bool test_any_bits_set(const unsigned long *addr, unsigned long nr, +bool test_any_bits_set(const unsigned long *addr, unsigned long nr, unsigned long size) { unsigned long res =3D find_next_bit(addr, size + nr, nr); @@ -1444,7 +1444,7 @@ CXLDCRegion *cxl_find_dc_region(CXLType3Dev *ct3d, ui= nt64_t dpa, uint64_t len) return NULL; } =20 -static void cxl_insert_extent_to_extent_list(CXLDCExtentList *list, +void cxl_insert_extent_to_extent_list(CXLDCExtentList *list, uint64_t dpa, uint64_t len, uint8_t *tag, @@ -1470,6 +1470,44 @@ void cxl_remove_extent_from_extent_list(CXLDCExtentL= ist *list, g_free(extent); } =20 +/* + * Add a new extent to the extent "group" if group exists; + * otherwise, create a new group + * Return value: the extent group where the extent is inserted. + */ +CXLDCExtentGroup *cxl_insert_extent_to_extent_group(CXLDCExtentGroup *grou= p, + uint64_t dpa, + uint64_t len, + uint8_t *tag, + uint16_t shared_seq) +{ + if (!group) { + group =3D g_new0(CXLDCExtentGroup, 1); + QTAILQ_INIT(&group->list); + } + cxl_insert_extent_to_extent_list(&group->list, dpa, len, + tag, shared_seq); + return group; +} + +void cxl_extent_group_list_insert_tail(CXLDCExtentGroupList *list, + CXLDCExtentGroup *group) +{ + QTAILQ_INSERT_TAIL(list, group, node); +} + +void cxl_extent_group_list_delete_front(CXLDCExtentGroupList *list) +{ + CXLDCExtent *ent, *ent_next; + CXLDCExtentGroup *group =3D QTAILQ_FIRST(list); + + QTAILQ_REMOVE(list, group, node); + QTAILQ_FOREACH_SAFE(ent, &group->list, node, ent_next) { + cxl_remove_extent_from_extent_list(&group->list, ent); + } + g_free(group); +} + /* * CXL r3.1 Table 8-168: Add Dynamic Capacity Response Input Payload * CXL r3.1 Table 8-170: Release Dynamic Capacity Input Payload @@ -1541,6 +1579,7 @@ static CXLRetCode cxl_dcd_add_dyn_cap_rsp_dry_run(CXL= Type3Dev *ct3d, { uint32_t i; CXLDCExtent *ent; + CXLDCExtentGroup *ext_group; uint64_t dpa, len; Range range1, range2; =20 @@ -1551,9 +1590,13 @@ static CXLRetCode cxl_dcd_add_dyn_cap_rsp_dry_run(CX= LType3Dev *ct3d, range_init_nofail(&range1, dpa, len); =20 /* - * TODO: once the pending extent list is added, check against - * the list will be added here. + * The host-accepted DPA range must be contained by the first exte= nt + * group in the pending list */ + ext_group =3D QTAILQ_FIRST(&ct3d->dc.extents_pending); + if (!cxl_extents_contains_dpa_range(&ext_group->list, dpa, len)) { + return CXL_MBOX_INVALID_PA; + } =20 /* to-be-added range should not overlap with range already accepte= d */ QTAILQ_FOREACH(ent, &ct3d->dc.extents, node) { @@ -1586,10 +1629,7 @@ static CXLRetCode cmd_dcd_add_dyn_cap_rsp(const stru= ct cxl_cmd *cmd, CXLRetCode ret; =20 if (in->num_entries_updated =3D=3D 0) { - /* - * TODO: once the pending list is introduced, extents in the begin= ning - * will get wiped out. - */ + cxl_extent_group_list_delete_front(&ct3d->dc.extents_pending); return CXL_MBOX_SUCCESS; } =20 @@ -1615,11 +1655,9 @@ static CXLRetCode cmd_dcd_add_dyn_cap_rsp(const stru= ct cxl_cmd *cmd, =20 cxl_insert_extent_to_extent_list(extent_list, dpa, len, NULL, 0); ct3d->dc.total_extent_count +=3D 1; - /* - * TODO: we will add a pending extent list based on event log reco= rd - * and process the list accordingly here. - */ } + /* Remove the first extent group in the pending list */ + cxl_extent_group_list_delete_front(&ct3d->dc.extents_pending); =20 return CXL_MBOX_SUCCESS; } diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index db5191b3b7..f53bcca6d3 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -674,6 +674,7 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Er= ror **errp) ct3d->dc.total_capacity +=3D region->len; } QTAILQ_INIT(&ct3d->dc.extents); + QTAILQ_INIT(&ct3d->dc.extents_pending); =20 return true; } @@ -681,10 +682,19 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, = Error **errp) static void cxl_destroy_dc_regions(CXLType3Dev *ct3d) { CXLDCExtent *ent, *ent_next; + CXLDCExtentGroup *group, *group_next; =20 QTAILQ_FOREACH_SAFE(ent, &ct3d->dc.extents, node, ent_next) { cxl_remove_extent_from_extent_list(&ct3d->dc.extents, ent); } + + QTAILQ_FOREACH_SAFE(group, &ct3d->dc.extents_pending, node, group_next= ) { + QTAILQ_REMOVE(&ct3d->dc.extents_pending, group, node); + QTAILQ_FOREACH_SAFE(ent, &group->list, node, ent_next) { + cxl_remove_extent_from_extent_list(&group->list, ent); + } + g_free(group); + } } =20 static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) @@ -1449,7 +1459,6 @@ static int ct3d_qmp_cxl_event_log_enc(CxlEventLog log) return CXL_EVENT_TYPE_FAIL; case CXL_EVENT_LOG_FATAL: return CXL_EVENT_TYPE_FATAL; -/* DCD not yet supported */ default: return -EINVAL; } @@ -1700,6 +1709,301 @@ void qmp_cxl_inject_memory_module_event(const char = *path, CxlEventLog log, } } =20 +/* CXL r3.1 Table 8-50: Dynamic Capacity Event Record */ +static const QemuUUID dynamic_capacity_uuid =3D { + .data =3D UUID(0xca95afa7, 0xf183, 0x4018, 0x8c, 0x2f, + 0x95, 0x26, 0x8e, 0x10, 0x1a, 0x2a), +}; + +typedef enum CXLDCEventType { + DC_EVENT_ADD_CAPACITY =3D 0x0, + DC_EVENT_RELEASE_CAPACITY =3D 0x1, + DC_EVENT_FORCED_RELEASE_CAPACITY =3D 0x2, + DC_EVENT_REGION_CONFIG_UPDATED =3D 0x3, + DC_EVENT_ADD_CAPACITY_RSP =3D 0x4, + DC_EVENT_CAPACITY_RELEASED =3D 0x5, +} CXLDCEventType; + +/* + * Check whether the range [dpa, dpa + len - 1] has overlaps with extents = in + * the list. + * Return value: return true if has overlaps; otherwise, return false + */ +static bool cxl_extents_overlaps_dpa_range(CXLDCExtentList *list, + uint64_t dpa, uint64_t len) +{ + CXLDCExtent *ent; + Range range1, range2; + + if (!list) { + return false; + } + + range_init_nofail(&range1, dpa, len); + QTAILQ_FOREACH(ent, list, node) { + range_init_nofail(&range2, ent->start_dpa, ent->len); + if (range_overlaps_range(&range1, &range2)) { + return true; + } + } + return false; +} + +/* + * Check whether the range [dpa, dpa + len - 1] is contained by extents in + * the list. + * Will check multiple extents containment once superset release is added. + * Return value: return true if range is contained; otherwise, return false + */ +bool cxl_extents_contains_dpa_range(CXLDCExtentList *list, + uint64_t dpa, uint64_t len) +{ + CXLDCExtent *ent; + Range range1, range2; + + if (!list) { + return false; + } + + range_init_nofail(&range1, dpa, len); + QTAILQ_FOREACH(ent, list, node) { + range_init_nofail(&range2, ent->start_dpa, ent->len); + if (range_contains_range(&range2, &range1)) { + return true; + } + } + return false; +} + +static bool cxl_extent_groups_overlaps_dpa_range(CXLDCExtentGroupList *lis= t, + uint64_t dpa, uint64_t le= n) +{ + CXLDCExtentGroup *group; + + if (!list) { + return false; + } + + QTAILQ_FOREACH(group, list, node) { + if (cxl_extents_overlaps_dpa_range(&group->list, dpa, len)) { + return true; + } + } + return false; +} + +/* + * The main function to process dynamic capacity event with extent list. + * Currently DC extents add/release requests are processed. + */ +static void qmp_cxl_process_dynamic_capacity_prescriptive(const char *path, + uint16_t hid, CXLDCEventType type, uint8_t rid, + CXLDynamicCapacityExtentList *records, Error **errp) +{ + Object *obj; + CXLEventDynamicCapacity dCap =3D {}; + CXLEventRecordHdr *hdr =3D &dCap.hdr; + CXLType3Dev *dcd; + uint8_t flags =3D 1 << CXL_EVENT_TYPE_INFO; + uint32_t num_extents =3D 0; + CXLDynamicCapacityExtentList *list; + CXLDCExtentGroup *group =3D NULL; + g_autofree CXLDCExtentRaw *extents =3D NULL; + uint8_t enc_log =3D CXL_EVENT_TYPE_DYNAMIC_CAP; + uint64_t dpa, offset, len, block_size; + g_autofree unsigned long *blk_bitmap =3D NULL; + int i; + + obj =3D object_resolve_path_type(path, TYPE_CXL_TYPE3, NULL); + if (!obj) { + error_setg(errp, "Unable to resolve CXL type 3 device"); + return; + } + + dcd =3D CXL_TYPE3(obj); + if (!dcd->dc.num_regions) { + error_setg(errp, "No dynamic capacity support from the device"); + return; + } + + + if (rid >=3D dcd->dc.num_regions) { + error_setg(errp, "region id is too large"); + return; + } + block_size =3D dcd->dc.regions[rid].block_size; + blk_bitmap =3D bitmap_new(dcd->dc.regions[rid].len / block_size); + + /* Sanity check and count the extents */ + list =3D records; + while (list) { + offset =3D list->value->offset; + len =3D list->value->len; + dpa =3D offset + dcd->dc.regions[rid].base; + + if (len =3D=3D 0) { + error_setg(errp, "extent with 0 length is not allowed"); + return; + } + + if (offset % block_size || len % block_size) { + error_setg(errp, "dpa or len is not aligned to region block si= ze"); + return; + } + + if (offset + len > dcd->dc.regions[rid].len) { + error_setg(errp, "extent range is beyond the region end"); + return; + } + + /* No duplicate or overlapped extents are allowed */ + if (test_any_bits_set(blk_bitmap, offset / block_size, + len / block_size)) { + error_setg(errp, "duplicate or overlapped extents are detected= "); + return; + } + bitmap_set(blk_bitmap, offset / block_size, len / block_size); + + if (type =3D=3D DC_EVENT_RELEASE_CAPACITY) { + if (cxl_extent_groups_overlaps_dpa_range(&dcd->dc.extents_pend= ing, + dpa, len)) { + error_setg(errp, + "cannot release extent with pending DPA range"); + return; + } + if (!cxl_extents_contains_dpa_range(&dcd->dc.extents, dpa, len= )) { + error_setg(errp, + "cannot release extent with non-existing DPA ra= nge"); + return; + } + } else if (type =3D=3D DC_EVENT_ADD_CAPACITY) { + if (cxl_extents_overlaps_dpa_range(&dcd->dc.extents, dpa, len)= ) { + error_setg(errp, + "cannot add DPA already accessible to the same = LD"); + return; + } + if (cxl_extent_groups_overlaps_dpa_range(&dcd->dc.extents_pend= ing, + dpa, len)) { + error_setg(errp, + "cannot add DPA again while still pending"); + return; + } + } + list =3D list->next; + num_extents++; + } + + /* Create extent list for event being passed to host */ + i =3D 0; + list =3D records; + extents =3D g_new0(CXLDCExtentRaw, num_extents); + while (list) { + offset =3D list->value->offset; + len =3D list->value->len; + dpa =3D dcd->dc.regions[rid].base + offset; + + extents[i].start_dpa =3D dpa; + extents[i].len =3D len; + memset(extents[i].tag, 0, 0x10); + extents[i].shared_seq =3D 0; + if (type =3D=3D DC_EVENT_ADD_CAPACITY) { + group =3D cxl_insert_extent_to_extent_group(group, + extents[i].start_dpa, + extents[i].len, + extents[i].tag, + extents[i].shared_se= q); + } + + list =3D list->next; + i++; + } + if (group) { + cxl_extent_group_list_insert_tail(&dcd->dc.extents_pending, group); + } + + /* + * CXL r3.1 section 8.2.9.2.1.6: Dynamic Capacity Event Record + * + * All Dynamic Capacity event records shall set the Event Record Sever= ity + * field in the Common Event Record Format to Informational Event. All + * Dynamic Capacity related events shall be logged in the Dynamic Capa= city + * Event Log. + */ + cxl_assign_event_header(hdr, &dynamic_capacity_uuid, flags, sizeof(dCa= p), + cxl_device_get_timestamp(&dcd->cxl_dstate)); + + dCap.type =3D type; + /* FIXME: for now, validity flag is cleared */ + dCap.validity_flags =3D 0; + stw_le_p(&dCap.host_id, hid); + /* only valid for DC_REGION_CONFIG_UPDATED event */ + dCap.updated_region_id =3D 0; + dCap.flags =3D 0; + for (i =3D 0; i < num_extents; i++) { + memcpy(&dCap.dynamic_capacity_extent, &extents[i], + sizeof(CXLDCExtentRaw)); + + if (i < num_extents - 1) { + /* Set "More" flag */ + dCap.flags |=3D BIT(0); + } + + if (cxl_event_insert(&dcd->cxl_dstate, enc_log, + (CXLEventRecordRaw *)&dCap)) { + cxl_event_irq_assert(dcd); + } + } +} + +void qmp_cxl_add_dynamic_capacity(const char *path, uint16_t host_id, + CXLExtSelPolicy sel_policy, uint8_t regi= on, + const char *tag, + CXLDynamicCapacityExtentList *extents, + Error **errp) +{ + switch (sel_policy) { + case CXL_EXT_SEL_POLICY_PRESCRIPTIVE: + qmp_cxl_process_dynamic_capacity_prescriptive(path, host_id, + DC_EVENT_ADD_CAPACIT= Y, + region, extents, err= p); + return; + default: + error_setg(errp, "Selection policy not supported"); + return; + } +} + +void qmp_cxl_release_dynamic_capacity(const char *path, uint16_t host_id, + CXLExtRemovalPolicy removal_policy, + bool has_forced_removal, + bool forced_removal, + bool has_sanitize_on_release, + bool sanitize_on_release, + uint8_t region, + const char *tag, + CXLDynamicCapacityExtentList *exten= ts, + Error **errp) +{ + CXLDCEventType type =3D DC_EVENT_RELEASE_CAPACITY; + + if (has_forced_removal && forced_removal) { + /* TODO: enable forced removal in the future */ + type =3D DC_EVENT_FORCED_RELEASE_CAPACITY; + error_setg(errp, "Forced removal not supported yet"); + return; + } + + switch (removal_policy) { + case CXL_EXT_REMOVAL_POLICY_PRESCRIPTIVE: + qmp_cxl_process_dynamic_capacity_prescriptive(path, host_id, type, + region, extents, err= p); + return; + default: + error_setg(errp, "Removal policy not supported"); + return; + } +} + static void ct3_class_init(ObjectClass *oc, void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); diff --git a/hw/mem/cxl_type3_stubs.c b/hw/mem/cxl_type3_stubs.c index 3e1851e32b..45419bbefe 100644 --- a/hw/mem/cxl_type3_stubs.c +++ b/hw/mem/cxl_type3_stubs.c @@ -67,3 +67,28 @@ void qmp_cxl_inject_correctable_error(const char *path, = CxlCorErrorType type, { error_setg(errp, "CXL Type 3 support is not compiled in"); } + +void qmp_cxl_add_dynamic_capacity(const char *path, + uint16_t host_id, + CXLExtSelPolicy sel_policy, + uint8_t region, + const char *tag, + CXLDynamicCapacityExtentList *extents, + Error **errp) +{ + error_setg(errp, "CXL Type 3 support is not compiled in"); +} + +void qmp_cxl_release_dynamic_capacity(const char *path, uint16_t host_id, + CXLExtRemovalPolicy removal_policy, + bool has_forced_removal, + bool forced_removal, + bool has_sanitize_on_release, + bool sanitize_on_release, + uint8_t region, + const char *tag, + CXLDynamicCapacityExtentList *extent= s, + Error **errp) +{ + error_setg(errp, "CXL Type 3 support is not compiled in"); +} --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630772; cv=none; d=zohomail.com; s=zohoarc; b=J48MkUSQuDTLmO94VKhIryNUo2rEGMDlOlOi+rKAyxK3jNKmzGhs9Y2lP7DJ1QUV7c4sxt2+a9FoGJNQ8rBxWI07Aw8z9S8xXkjcnQP0WGsIYZFlVkCIqDZVyGseXo1EshZx/mlwcn6DOCKok8rrDV2K5MCt1yt4YTb5I6KpDyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630772; 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=J5j8n04Q1gRbmovO7PmlswqpHPYyPExcO8mAPNVjzhI=; b=DAJt7SGzCJOdtDmn7sbaysa54GJC8UXj414Hn5/mxDsshzTv1VUkWRw8xDFI1XU5cDLPmlaHRsQrJPJCkOmArxUctFOebyXnXw8KeM49LFjHE5i2t/ecxjYiljUEfzKHpNFoFz8nrIA2IKAMGVvvA2QArl0kw94m6+NheRzeELc= 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+importer=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 1717630772655618.6473659605853; Wed, 5 Jun 2024 16:39:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0BE-0006ur-QM; Wed, 05 Jun 2024 19:36:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BC-0006lO-NS for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BA-0005r8-Rl for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:30 -0400 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-47-u4xPBN-kOMSpMU-7ij1Cyg-1; Wed, 05 Jun 2024 19:36:26 -0400 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-52baa2e4ab1so322388e87.0 for ; Wed, 05 Jun 2024 16:36:26 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c80581989sm7292266b.30.2024.06.05.16.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630587; h=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=J5j8n04Q1gRbmovO7PmlswqpHPYyPExcO8mAPNVjzhI=; b=VM/CYZl+g/YYSg2Y4Uo4H2xOftjOnp8ES1MFUk9X6ggr6DzoRB5fkdFsXCm8J5eUiESp/e WBo44UETTVT0AL9Ft1Kj9AdO6l63FN6F7O7kKVDto49YWMsq/zw+KwanMCKwzNFKnVGIBH 5ASeiipJavwqcDlCW2CjgQ7kZBwMH5E= X-MC-Unique: u4xPBN-kOMSpMU-7ij1Cyg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630584; x=1718235384; 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=J5j8n04Q1gRbmovO7PmlswqpHPYyPExcO8mAPNVjzhI=; b=lsyPE60uEDBF2491+artK/3oSfp3gEC6dTp8smpYwZBtfBrWjsmz5xA3iPHp5Gjqag ahuwd75hX/U2QUAmZprQRDh4L9XYdUN+I5A+OzehXFbtXR/FWKNEuGfv0Pr8hcSMWHFw 2ltopennOWCHMP6Pi8yFfNxiNlhlix6MmzFuZm2kjVQy80CsGoYj6Alovv0JW+KKeHv2 m7zmAWA1ZkJ5PzCBr+m4r0kn4oodDfMm/hUT+J4Ba0TOD6l0WpZoEO2OOZEAhXERbtyt rQ0nvUkI+mjRxitA1i2Fd5R3uFB5uuB+DnD5e2aeRO50wAqvo4cq42/t/LOdf1WZn2Kr DfXA== X-Gm-Message-State: AOJu0YzqR2P1aEqwKuc/8dh4o+c6FHn+Ja8xT8+vcAG31kE5b+utdwJn mUHwVJXTf7qrWYGl5EGFCDjI3JuE9MiQ/0CaJL4aNs8JadUktbSkflKnYRzJLqEzb5wm1DjySeH xuSYhT77wEK9/IKKn+d2VNMS8A2K1+vyUMj31Wbf1yvIxRaB6sAuoGF4CyISLzju6seIXRHRT8C kiWm1gEloIYCJr7qAFUirvabWHK11DGA== X-Received: by 2002:a05:6512:1152:b0:52b:959c:1dc7 with SMTP id 2adb3069b0e04-52bab4fca3emr3892784e87.42.1717630584142; Wed, 05 Jun 2024 16:36:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwHh62mUa+chCVe+h363wz7gi1cl9+rtn7oX+t7HnZ26efMkXyf8yQWUyyJgWtkjDZdxyYnA== X-Received: by 2002:a05:6512:1152:b0:52b:959c:1dc7 with SMTP id 2adb3069b0e04-52bab4fca3emr3892771e87.42.1717630583572; Wed, 05 Jun 2024 16:36:23 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:20 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron Subject: [PULL v3 27/41] hw/mem/cxl_type3: Add DPA range validation for accesses to DC regions Message-ID: <926c82fba0bf9917bdeae518420bff13904516da.1717630437.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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630774546100007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fan Ni All DPA ranges in the DC regions are invalid to access until an extent covering the range has been successfully accepted by the host. A bitmap is added to each region to record whether a DC block in the region has been backed by a DC extent. Each bit in the bitmap represents a DC block. When a DC extent is accepted, all the bits representing the blocks in the extent are set, which will be cleared when the extent is released. Tested-by: Svetly Todorov Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-13-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 7 ++++ hw/cxl/cxl-mailbox-utils.c | 3 ++ hw/mem/cxl_type3.c | 76 +++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index c69ff6b5de..0a4fcb2800 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -456,6 +456,7 @@ typedef struct CXLDCRegion { uint64_t block_size; uint32_t dsmadhandle; uint8_t flags; + unsigned long *blk_bitmap; } CXLDCRegion; =20 struct CXLType3Dev { @@ -577,4 +578,10 @@ CXLDCExtentGroup *cxl_insert_extent_to_extent_group(CX= LDCExtentGroup *group, void cxl_extent_group_list_insert_tail(CXLDCExtentGroupList *list, CXLDCExtentGroup *group); void cxl_extent_group_list_delete_front(CXLDCExtentGroupList *list); +void ct3_set_region_block_backed(CXLType3Dev *ct3d, uint64_t dpa, + uint64_t len); +void ct3_clear_region_block_backed(CXLType3Dev *ct3d, uint64_t dpa, + uint64_t len); +bool ct3_test_region_block_backed(CXLType3Dev *ct3d, uint64_t dpa, + uint64_t len); #endif diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 64387f34ce..c4852112fe 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1655,6 +1655,7 @@ static CXLRetCode cmd_dcd_add_dyn_cap_rsp(const struc= t cxl_cmd *cmd, =20 cxl_insert_extent_to_extent_list(extent_list, dpa, len, NULL, 0); ct3d->dc.total_extent_count +=3D 1; + ct3_set_region_block_backed(ct3d, dpa, len); } /* Remove the first extent group in the pending list */ cxl_extent_group_list_delete_front(&ct3d->dc.extents_pending); @@ -1813,10 +1814,12 @@ static CXLRetCode cmd_dcd_release_dyn_cap(const str= uct cxl_cmd *cmd, * list and update the extent count; */ QTAILQ_FOREACH_SAFE(ent, &ct3d->dc.extents, node, ent_next) { + ct3_clear_region_block_backed(ct3d, ent->start_dpa, ent->len); cxl_remove_extent_from_extent_list(&ct3d->dc.extents, ent); } copy_extent_list(&ct3d->dc.extents, &updated_list); QTAILQ_FOREACH_SAFE(ent, &updated_list, node, ent_next) { + ct3_set_region_block_backed(ct3d, ent->start_dpa, ent->len); cxl_remove_extent_from_extent_list(&updated_list, ent); } ct3d->dc.total_extent_count =3D updated_list_size; diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index f53bcca6d3..0d18259ec0 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -672,6 +672,7 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Er= ror **errp) .flags =3D 0, }; ct3d->dc.total_capacity +=3D region->len; + region->blk_bitmap =3D bitmap_new(region->len / region->block_size= ); } QTAILQ_INIT(&ct3d->dc.extents); QTAILQ_INIT(&ct3d->dc.extents_pending); @@ -683,6 +684,8 @@ static void cxl_destroy_dc_regions(CXLType3Dev *ct3d) { CXLDCExtent *ent, *ent_next; CXLDCExtentGroup *group, *group_next; + int i; + CXLDCRegion *region; =20 QTAILQ_FOREACH_SAFE(ent, &ct3d->dc.extents, node, ent_next) { cxl_remove_extent_from_extent_list(&ct3d->dc.extents, ent); @@ -695,6 +698,11 @@ static void cxl_destroy_dc_regions(CXLType3Dev *ct3d) } g_free(group); } + + for (i =3D 0; i < ct3d->dc.num_regions; i++) { + region =3D &ct3d->dc.regions[i]; + g_free(region->blk_bitmap); + } } =20 static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) @@ -926,6 +934,70 @@ static void ct3_exit(PCIDevice *pci_dev) } } =20 +/* + * Mark the DPA range [dpa, dap + len - 1] to be backed and accessible. Th= is + * happens when a DC extent is added and accepted by the host. + */ +void ct3_set_region_block_backed(CXLType3Dev *ct3d, uint64_t dpa, + uint64_t len) +{ + CXLDCRegion *region; + + region =3D cxl_find_dc_region(ct3d, dpa, len); + if (!region) { + return; + } + + bitmap_set(region->blk_bitmap, (dpa - region->base) / region->block_si= ze, + len / region->block_size); +} + +/* + * Check whether the DPA range [dpa, dpa + len - 1] is backed with DC exte= nts. + * Used when validating read/write to dc regions + */ +bool ct3_test_region_block_backed(CXLType3Dev *ct3d, uint64_t dpa, + uint64_t len) +{ + CXLDCRegion *region; + uint64_t nbits; + long nr; + + region =3D cxl_find_dc_region(ct3d, dpa, len); + if (!region) { + return false; + } + + nr =3D (dpa - region->base) / region->block_size; + nbits =3D DIV_ROUND_UP(len, region->block_size); + /* + * if bits between [dpa, dpa + len) are all 1s, meaning the DPA range = is + * backed with DC extents, return true; else return false. + */ + return find_next_zero_bit(region->blk_bitmap, nr + nbits, nr) =3D=3D n= r + nbits; +} + +/* + * Mark the DPA range [dpa, dap + len - 1] to be unbacked and inaccessible. + * This happens when a dc extent is released by the host. + */ +void ct3_clear_region_block_backed(CXLType3Dev *ct3d, uint64_t dpa, + uint64_t len) +{ + CXLDCRegion *region; + uint64_t nbits; + long nr; + + region =3D cxl_find_dc_region(ct3d, dpa, len); + if (!region) { + return; + } + + nr =3D (dpa - region->base) / region->block_size; + nbits =3D len / region->block_size; + bitmap_clear(region->blk_bitmap, nr, nbits); +} + static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *d= pa) { int hdm_inc =3D R_CXL_HDM_DECODER1_BASE_LO - R_CXL_HDM_DECODER0_BASE_L= O; @@ -1030,6 +1102,10 @@ static int cxl_type3_hpa_to_as_and_dpa(CXLType3Dev *= ct3d, *as =3D &ct3d->hostpmem_as; *dpa_offset -=3D vmr_size; } else { + if (!ct3_test_region_block_backed(ct3d, *dpa_offset, size)) { + return -ENODEV; + } + *as =3D &ct3d->dc.host_dc_as; *dpa_offset -=3D (vmr_size + pmr_size); } --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630657; cv=none; d=zohomail.com; s=zohoarc; b=OPGl3WzBOt5Rjw/ycbHgEDZsbHIVWvL/ogGOkq4daudm/z+eco2HW91uTscZ6m9wPzFIPSPpqHX2ktH4+uA5Vy6AoPuC+2mpxdUuIxLbXbnOZx5SMGXoZdTP5+Ix53Cxm2ltnQbBwTivEVLQNAqOVVRnmDwwTeF1M0VaDmlxla0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630657; 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=QuE+o0AC9wdLKXlzVTnODsdNe5/ti8zXK/7OKFfOYUM=; b=jlbWsay02sBfINjhqPeShhGCxjiFl72ZxUBYIB0St+pO3Zuf7/aV5hw53wyc51C2Fi11QSloXZQxxDmezlVCUhiKyGkGAnpI/s/E4IU0oIvjRzgaZKEaH6MLQIb2SqWMcuklz6++ReMkP4QY373V2mm/EuWXfCJtB2UooIadzTk= 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+importer=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 1717630657329205.27462554928877; Wed, 5 Jun 2024 16:37:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0BF-0006yI-F7; Wed, 05 Jun 2024 19:36:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BE-0006sE-9y for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BC-0005sH-M1 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:32 -0400 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-592-lZ7d28d5MfSUjS6Crv3nUQ-1; Wed, 05 Jun 2024 19:36:28 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57a941a787dso375941a12.3 for ; Wed, 05 Jun 2024 16:36:28 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae23a0d7sm91917a12.95.2024.06.05.16.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630590; h=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=QuE+o0AC9wdLKXlzVTnODsdNe5/ti8zXK/7OKFfOYUM=; b=fZzzDE7ayuDzpcUHa7CTM4N3nhfjtg8hZoph8url2s5tl75o/8Z7NlUQU/VcfdDlR5RgV+ VK069ly/d3/AOisNXHzFykRit0WXvv3UiNayFTqDkNevFcExVUiGxIgSR/X8kLwIrcUYIP ngsh2Oti0batk2sOWuDtFz6TwYP9x8E= X-MC-Unique: lZ7d28d5MfSUjS6Crv3nUQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630587; x=1718235387; 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=QuE+o0AC9wdLKXlzVTnODsdNe5/ti8zXK/7OKFfOYUM=; b=FlmtjvdzEL4FCZSPe81Kkt225nw5HShfbtYWvmke7JoRt/7gd+wVmp/lgNxVvuK2GH buFBM9QQTSa84LNK8kkjkb2tMM7yso1NTnTZqQsplcjUg3FYgNW6vKZAgPTlETMIBp6s +DELTVRXxdLz5rYk3pk5IFptcCmKzAbgy4UlaqZSaApO6DeXgBDWYpwkABCCE5Lna+Bt 9A6qWIUOtinJWn2L+xgPpxXiYd5ay4hU+CF8XjNMmyVhDZEW3ljn/1MC1sUkND4IS9iT 4U0Aqrhw/GqK+nmrDGBJHC5oRv09a/naV9cKOa9XISIhWGaIpdE13atgRgJpGSu9yvHG 709Q== X-Gm-Message-State: AOJu0YzLKj/RryuusXtJ8u9Gr1K0nV+F1Kt4H2JyJ0BapklnpoWLGnPO qFVZLO/W3rUQzx5l9WHlJjG4Ow7D0fwpkIKQpq0tC8/zLP9KNbGCK0ByilOu/BfEXtz7RCvEYV/ 0oiXhNYKhg4wvlPDHCcyYzaivAByvbrbSi89TKQO+hyGjo6PTHH0tvf4dB4XMKEpCHP6QrmF2Ou g5/MSFiA2vTaHEJRK3305iohkzq5Kmog== X-Received: by 2002:a50:bb03:0:b0:57a:1c44:581c with SMTP id 4fb4d7f45d1cf-57a8bc91223mr3180058a12.32.1717630587196; Wed, 05 Jun 2024 16:36:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUGQTqUQCcPO2wRAfy0GXBR/uwMiRv5mZR6w2lI9QLLukUeSoiVCPlO/QrFqi1VcYrG4916g== X-Received: by 2002:a50:bb03:0:b0:57a:1c44:581c with SMTP id 4fb4d7f45d1cf-57a8bc91223mr3180040a12.32.1717630586655; Wed, 05 Jun 2024 16:36:26 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:23 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron Subject: [PULL v3 28/41] hw/cxl/cxl-mailbox-utils: Add superset extent release mailbox support Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630658074100006 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fan Ni With the change, we extend the extent release mailbox command processing to allow more flexible release. As long as the DPA range of the extent to release is covered by accepted extent(s) in the device, the release can be performed. Tested-by: Svetly Todorov Reviewed-by: Gregory Price Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-14-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index c4852112fe..74eeb6fde7 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1704,6 +1704,13 @@ static CXLRetCode cxl_dc_extent_release_dry_run(CXLT= ype3Dev *ct3d, dpa =3D in->updated_entries[i].start_dpa; len =3D in->updated_entries[i].len; =20 + /* Check if the DPA range is not fully backed with valid extents */ + if (!ct3_test_region_block_backed(ct3d, dpa, len)) { + ret =3D CXL_MBOX_INVALID_PA; + goto free_and_exit; + } + + /* After this point, extent overflow is the only error can happen = */ while (len > 0) { QTAILQ_FOREACH(ent, updated_list, node) { range_init_nofail(&range, ent->start_dpa, ent->len); @@ -1718,14 +1725,7 @@ static CXLRetCode cxl_dc_extent_release_dry_run(CXLT= ype3Dev *ct3d, if (range_contains(&range, dpa + len - 1)) { len2 =3D ent_start_dpa + ent_len - dpa - len; } else { - /* - * TODO: we reject the attempt to remove an extent - * that overlaps with multiple extents in the devi= ce - * for now. We will allow it once superset release - * support is added. - */ - ret =3D CXL_MBOX_INVALID_PA; - goto free_and_exit; + dpa =3D ent_start_dpa + ent_len; } len_done =3D ent_len - len1 - len2; =20 @@ -1752,14 +1752,9 @@ static CXLRetCode cxl_dc_extent_release_dry_run(CXLT= ype3Dev *ct3d, } =20 len -=3D len_done; - /* len =3D=3D 0 here until superset release is added */ break; } } - if (len) { - ret =3D CXL_MBOX_INVALID_PA; - goto free_and_exit; - } } } free_and_exit: --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630719; cv=none; d=zohomail.com; s=zohoarc; b=mDvYteQZ7v6TAwXLu564FGD8qImzgtddqHhkAehcK6LTebJgRCNOllBd89timO2BaakfJtVbc8NpbMZzQDyJwp69IXjF4a9j5A8oBXmsJXTLgzM2OFZKPcy9Evx6WnckAPsQfb8qJUu7V7BxT+QKYPFlBCJAiHpiK7Ds8HmbZ0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630719; 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=WFUPapk07PnJ8CLhVhbjjsuC+NoP2UxN6SJb+Hfxl60=; b=WO/8XVyWy/4cDM0Lw13V9INdOaT4KxnPsjFVctY0nx0LQF8NPcPDD12J5OD/dTM/Y27z1sCfIttx6Y4IlYracxn6bON2z8X/sCfCpS5L97Ck3Tg/m2L6D+/WrRAv9ywQDdfnNGdGh/ejwi+/c+pchqQjjjc+qLDYoELBdV3MP+4= 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+importer=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 1717630719482486.5859944736436; Wed, 5 Jun 2024 16:38:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0BO-0007wY-7O; Wed, 05 Jun 2024 19:36:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BL-0007j9-Pk for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BH-0005sw-CQ for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:39 -0400 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-317-DC4zDshaPK-9K2eY8xNbtQ-1; Wed, 05 Jun 2024 19:36:32 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a6c72164f46so14653866b.1 for ; Wed, 05 Jun 2024 16:36:31 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c805d2882sm7047266b.90.2024.06.05.16.36.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630594; h=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=WFUPapk07PnJ8CLhVhbjjsuC+NoP2UxN6SJb+Hfxl60=; b=Ft46ietRFaHn9v2FBrBYdj5mCl+VSZdd/vxRJwrWbB33HOfqJCRNGfGdA/0DrSf1LCGc7s X7ANIHlnivaAMEFZSd5BjkoDhYtYI8ufsTT0IzAqLDu0wY7xUbddo/NcxpN/JTxXlWMqeb d20Wct+gnrQ+/8UaPLjIzq8sqzeWYdI= X-MC-Unique: DC4zDshaPK-9K2eY8xNbtQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630590; x=1718235390; 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=WFUPapk07PnJ8CLhVhbjjsuC+NoP2UxN6SJb+Hfxl60=; b=YsRogNU6OjJP82wHYkwiojP4JQWiPcSO6DrrLhPZeG30VvwOot10NuZ/FbAI5WDqy/ L8mYVd9KRIBXiWYCRiXMvUvEK7bY3TYeJWe+OpCi59O4wD8MTj4tgNt76DTRMPLVNJut 8HflEdek9v3eg/4UVvT4qHSjCsqMUgVNhzIZeXrR1fSXr9WPdXRlLchV3sXfeHYfUE68 /fmTijOQX1p40zluSdpQ/XCh3HaGxon107YFZdo3MPdLWbhuj9bnNtBgvhrIm37ec+Wd ruEQpOVSRXxzSmtDDSCywwUJrgPRwpE+7TaFk/LXzaDT0eQqQdVAswSBQTWI5ex/dVw1 qgDA== X-Gm-Message-State: AOJu0YxOjPwTo/jMXX6qhOnF2QT9pLljgywFCBq75uowJF8itR8QWLj1 j8EKJ6nQXr4Osg5GnNqbIyKaEvUweljOUFHTJxXaDdu5BxhiZqzG+fDzY1LsB0G6GyFHJVJPSV9 aKoKTc1rpcTaBmtVGV+MUF5cHEctUwE2p14ryha3IchS623p5ZxFVkdMcbcgTIt193MUbO1PcwZ IwflTi3QwMxn2R8xnLeJh4EvX9EQzU0Q== X-Received: by 2002:a17:906:fc01:b0:a68:f6b7:1fe3 with SMTP id a640c23a62f3a-a699fcf3563mr260036466b.43.1717630590395; Wed, 05 Jun 2024 16:36:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+UdcTmmXiKcFmzjKBFsEzkh6+bdd4qVh6x5/J7GAk1xNI240aTztcOcdEzm5PVvASfMYPdQ== X-Received: by 2002:a17:906:fc01:b0:a68:f6b7:1fe3 with SMTP id a640c23a62f3a-a699fcf3563mr260035666b.43.1717630589890; Wed, 05 Jun 2024 16:36:29 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron Subject: [PULL v3 29/41] hw/mem/cxl_type3: Allow to release extent superset in QMP interface Message-ID: <80ac9548a10f6fb3b9dcbc941e77bf1ca0616e7e.1717630437.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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630720289100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fan Ni Before the change, the QMP interface used for add/release DC extents only allows to release an extent whose DPA range is contained by a single accepted extent in the device. With the change, we relax the constraints. As long as the DPA range of the extent is covered by accepted extents, we allow the release. Tested-by: Svetly Todorov Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-15-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/cxl_type3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 0d18259ec0..5d4a1276be 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1947,7 +1947,7 @@ static void qmp_cxl_process_dynamic_capacity_prescrip= tive(const char *path, "cannot release extent with pending DPA range"); return; } - if (!cxl_extents_contains_dpa_range(&dcd->dc.extents, dpa, len= )) { + if (!ct3_test_region_block_backed(dcd, dpa, len)) { error_setg(errp, "cannot release extent with non-existing DPA ra= nge"); return; --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630765; cv=none; d=zohomail.com; s=zohoarc; b=XJvFV05EL7C8x5Xr3bv9BT9pmMsBYTVV2xJjJay2G6M4UzR4UfgopPNLZ/4+mhCVIen/YbowdZgR9aD4AXOHhdU0yH+pDHVhwtppjUrhwCKIiN66QAcnTK+vkFWIgSifMD3cjVYeg1bUFsglZoKaBUA+DHSB5pCusUMOtf+LetI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630765; 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=VYKkp6fHZoal2oiYNWaG4icBm491Zje1r86kUs5B3ls=; b=GcviBXYiDQ99H+wVw7nwlfqXVjLlsgecSqPJ5ApIwy+9J6QxuOgkdpcFqPsxhxNqCcCU4b1i7c3EYawZvBu40SZAqQQm8Ywy4WmBSFqHGIlH9fZPXR8OpVehkStWV4hY3y9qgIIb8Welvdt/ovxkKyutg4+Fu8AWlrYQPuIfIxY= 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+importer=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 171763076540788.741056802873; Wed, 5 Jun 2024 16:39:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0BP-00088k-FN; Wed, 05 Jun 2024 19:36:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BN-0007rH-Ae for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BL-0005tL-MV for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:40 -0400 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-312-ce_dIIxZMyCxDRzqDL0yag-1; Wed, 05 Jun 2024 19:36:36 -0400 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-57a7946685aso128866a12.2 for ; Wed, 05 Jun 2024 16:36:36 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae11a98csm98999a12.48.2024.06.05.16.36.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630598; h=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=VYKkp6fHZoal2oiYNWaG4icBm491Zje1r86kUs5B3ls=; b=ZzH41aHY/cT0KruGUsNz2mH8vB/57VRDlYGmIaUGDgZD8rFGHDBggF0J3bYalT66BGkFQm J3zRxT8BaWGJn57V2n2MD2iQTcUNEBP9l8RyEoFx22ymRqayjTquLdPZx37zj9G7UiXW5G hn4DOyO2oxbbaCtoYSTh9A+yAcEF72s= X-MC-Unique: ce_dIIxZMyCxDRzqDL0yag-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630594; x=1718235394; 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=VYKkp6fHZoal2oiYNWaG4icBm491Zje1r86kUs5B3ls=; b=jiQMzQ43+hIUcpSNW3OujR6cYMgbvahMCCQmLUX5bLu9tA+VXyMckrJscL3WFTgUid 3uS5MQPXSBBG/Na9Yl5OlOwjmnI3FIjf3wD9t+GHzMTY2tHSrFuZpQaUAczKJqoEHb3T UmLRr4CNtaD7dU+6vJ6Y05/yQX1ZDEQzESQu4/T0nThr2kQVltEmYevJB+a4/GuLOael RPEm51n0YSeAc1WECOXSGAwQETni/ILoegJh1rA9+DCe7SGZgouI33KYCvLtXfOfmvR6 RO0ukcgLLQ6DRXaLSuOGzBy9kxGJ1sFhnwx5ktfmsynXk7r3jxg0VAhviPv0y4ytQ2mJ utGg== X-Gm-Message-State: AOJu0Yz5toSMb/97HiuiVthF+vC/DRm99MOZFvmtc0pzKOWToxyG/E3H wyohiErTliTur3JX7hReDFHNgayMSsyaoHUryIeefpYRnCzqzq1YxaFrtsyM0kO/PV7zR6MeQQ6 /qWsDaDeVhoKn+WLW+v6T380HXSwyG4J7GqQnhKJ/YTO+1aiBodnvyST0cr7ZPEjx0f8D8OQIxV KQ2zcE+ydaKK6P9LAkn7x3yhL14ZbvBg== X-Received: by 2002:a50:f69d:0:b0:57a:79c2:e9d7 with SMTP id 4fb4d7f45d1cf-57a8b7c6141mr2531867a12.27.1717630594222; Wed, 05 Jun 2024 16:36:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqDL5XbCU5fqlEGdBT3VAnL6174hRz+Kbaud0YHpoylqwlOVNg+ayQGc3yGA8kSZ3smxm1cQ== X-Received: by 2002:a50:f69d:0:b0:57a:79c2:e9d7 with SMTP id 4fb4d7f45d1cf-57a8b7c6141mr2531849a12.27.1717630593817; Wed, 05 Jun 2024 16:36:33 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Ankit Agrawal , Igor Mammedov , Ani Sinha , Michael Tokarev , Laurent Vivier , qemu-trivial@nongnu.org Subject: [PULL v3 30/41] hw/acpi/GI: Fix trivial parameter alignment issue. Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (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+importer=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_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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630766502100006 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Before making additional modification, tidy up this misleading indentation. Reviewed-by: Ankit Agrawal Signed-off-by: Jonathan Cameron Message-Id: <20240524100507.32106-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/acpi_generic_initiator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/acpi_generic_initiator.c b/hw/acpi/acpi_generic_initia= tor.c index 17b9a052f5..18a939b0e5 100644 --- a/hw/acpi/acpi_generic_initiator.c +++ b/hw/acpi/acpi_generic_initiator.c @@ -132,7 +132,7 @@ static int build_all_acpi_generic_initiators(Object *ob= j, void *opaque) =20 dev_handle.segment =3D 0; dev_handle.bdf =3D PCI_BUILD_BDF(pci_bus_num(pci_get_bus(pci_dev)), - pci_dev->devfn); + pci_dev->devfn); =20 build_srat_generic_pci_initiator_affinity(table_data, gi->node, &dev_handle); --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630631; cv=none; d=zohomail.com; s=zohoarc; b=LWw34cuOlVdW2teH/7Z7bRLgi3L178jk5DdszTmEWjnPtVbVSYw+MhRlCQgJrC0mWyNg8lkV6O7UUCQs0PRd8ulmaH8AJnCEYp0TaT7Pq1XPFek41yNO6NSYPckvz+xakTtNuKA65BiaShocne6RwHulHYn0wAd7pWCA6dTD6ag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630631; 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=Rl1nDigpJRwgGE3w/iYUa7vmMKH4nemfm7NPNL/7aBE=; b=SkQI76ss0OzQWXz3Wmf936jm981pb1rFmd1gdnPD25vDoQbO+VCo6s31m2z3u2mFi0BZKIQoCDDuBx+eRCtL0p65fY7Gzynf0QjSB3n46jnx6CV8HOsX+00EW7VALiEXnRpYI4CxfAo4zCTs9D6pCsOGd9RCGvxq29mEK9jFerA= 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+importer=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 1717630631777643.7886598887076; Wed, 5 Jun 2024 16:37:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0BR-0008Ny-8G; Wed, 05 Jun 2024 19:36:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BP-00088V-8c for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BN-0005tn-1w for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:42 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-584-RR7TZH6NP2ypI4J55HhLow-1; Wed, 05 Jun 2024 19:36:39 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a68ea01c455so8569566b.0 for ; Wed, 05 Jun 2024 16:36:39 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c8072a737sm6378966b.224.2024.06.05.16.36.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630600; h=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=Rl1nDigpJRwgGE3w/iYUa7vmMKH4nemfm7NPNL/7aBE=; b=eWfJFAHkRJZwt6KeFOoYKYHlhcCfEgX4y8QTPguwD/uil1h3YJ4nOTwYItX5wtpzXWDwZq 84PaNdrK2Tl5trxIn6BILcANIJ5BJH1hkNfRK4pMLzCzY04NmHlEo3WoHZP2LmM9+oD1vw vFWosFtmanZv0A4c69a9/s0YZz1Urmo= X-MC-Unique: RR7TZH6NP2ypI4J55HhLow-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630598; x=1718235398; 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=Rl1nDigpJRwgGE3w/iYUa7vmMKH4nemfm7NPNL/7aBE=; b=YGbyRPdU5VSxoQxtu/8XLqtPIu1+58nNlIc9+ZZk2LZZjOltWtHfeEA/ztkJRZy5xZ 0WVllG6pFGuBc/FrCaNPlDaWTzEmdI3LcJRcE0yVhGzF8E6uonNBj4o1pimCQ5TnOQMF v980pfXDue0Y9w6glp+uQTudw+aa6kzhkjDst7i4DoiLSLWHYY1elZgWG+8/QIqMq6gc MKQTm7uDi1FHLjBRb8ylC5T8yXPIJHvnwLRs/Rw/dN9o/FS1GTKiQdoT6G0cd/894yZV DJhlL1sIsU/W36TvtrBf5k2eXamn+GK5kAeXDCv3wBFPpXbEIWzuUaEOAgmRjCw/3psm Djsw== X-Gm-Message-State: AOJu0YzvIv0SS4ukcxojrPZ9B/MsMBMO3KzarYCCv8a7ISU85IcQdqqt qikDVN/qeQnih7hzBDUNl06uMbn7B/Sl5feW3c3fJIlCc8k98O88PJvbflO7OXHUaEvpZ41I6v9 zF/RLPEcxw02qp8/6tVBz0XfkPLfdz9TWoOicxge3GJlW9s7TjsZwg0OTo12lXsmUoUtrC1QgNR t6yJlb4Zkpk3hLZSlUv/eZTLRPDQIXjg== X-Received: by 2002:a17:906:25d3:b0:a68:875e:e36f with SMTP id a640c23a62f3a-a699f34e209mr257565166b.16.1717630597677; Wed, 05 Jun 2024 16:36:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKtnOJAAjArcJYUWegX9PtiPKFIEDkLERc8RCRcvJKDga5aXXaTBvyivDjODQAnJ8ho43EGg== X-Received: by 2002:a17:906:25d3:b0:a68:875e:e36f with SMTP id a640c23a62f3a-a699f34e209mr257564466b.16.1717630597166; Wed, 05 Jun 2024 16:36:37 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , Ani Sinha Subject: [PULL v3 31/41] hw/acpi: Insert an acpi-generic-node base under acpi-generic-initiator Message-ID: <424d0612ffbb091dbc6bc1f18fb09f71069b3fc3.1717630437.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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630631950100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron This will simplify reuse when adding acpi-generic-port. Note that some error_printf() messages will now print acpi-generic-node whereas others will move to type specific cases in next patch so are left alone for now. Signed-off-by: Jonathan Cameron Message-Id: <20240524100507.32106-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi_generic_initiator.h | 15 ++++- hw/acpi/acpi_generic_initiator.c | 80 +++++++++++++++--------- 2 files changed, 63 insertions(+), 32 deletions(-) diff --git a/include/hw/acpi/acpi_generic_initiator.h b/include/hw/acpi/acp= i_generic_initiator.h index a304bad73e..dd4be19c8f 100644 --- a/include/hw/acpi/acpi_generic_initiator.h +++ b/include/hw/acpi/acpi_generic_initiator.h @@ -8,15 +8,26 @@ =20 #include "qom/object_interfaces.h" =20 -#define TYPE_ACPI_GENERIC_INITIATOR "acpi-generic-initiator" +/* + * Abstract type to be used as base for + * - acpi-generic-initiator + * - acpi-generic-port + */ +#define TYPE_ACPI_GENERIC_NODE "acpi-generic-node" =20 -typedef struct AcpiGenericInitiator { +typedef struct AcpiGenericNode { /* private */ Object parent; =20 /* public */ char *pci_dev; uint16_t node; +} AcpiGenericNode; + +#define TYPE_ACPI_GENERIC_INITIATOR "acpi-generic-initiator" + +typedef struct AcpiGenericInitiator { + AcpiGenericNode parent; } AcpiGenericInitiator; =20 /* diff --git a/hw/acpi/acpi_generic_initiator.c b/hw/acpi/acpi_generic_initia= tor.c index 18a939b0e5..c054e0e27d 100644 --- a/hw/acpi/acpi_generic_initiator.c +++ b/hw/acpi/acpi_generic_initiator.c @@ -10,45 +10,61 @@ #include "hw/pci/pci_device.h" #include "qemu/error-report.h" =20 -typedef struct AcpiGenericInitiatorClass { +typedef struct AcpiGenericNodeClass { ObjectClass parent_class; +} AcpiGenericNodeClass; + +typedef struct AcpiGenericInitiatorClass { + AcpiGenericNodeClass parent_class; } AcpiGenericInitiatorClass; =20 +OBJECT_DEFINE_ABSTRACT_TYPE(AcpiGenericNode, acpi_generic_node, + ACPI_GENERIC_NODE, OBJECT) + +OBJECT_DECLARE_SIMPLE_TYPE(AcpiGenericNode, ACPI_GENERIC_NODE) + OBJECT_DEFINE_TYPE_WITH_INTERFACES(AcpiGenericInitiator, acpi_generic_init= iator, - ACPI_GENERIC_INITIATOR, OBJECT, + ACPI_GENERIC_INITIATOR, ACPI_GENERIC_NODE, { TYPE_USER_CREATABLE }, { NULL }) =20 OBJECT_DECLARE_SIMPLE_TYPE(AcpiGenericInitiator, ACPI_GENERIC_INITIATOR) =20 +static void acpi_generic_node_init(Object *obj) +{ + AcpiGenericNode *gn =3D ACPI_GENERIC_NODE(obj); + + gn->node =3D MAX_NODES; + gn->pci_dev =3D NULL; +} + static void acpi_generic_initiator_init(Object *obj) { - AcpiGenericInitiator *gi =3D ACPI_GENERIC_INITIATOR(obj); +} =20 - gi->node =3D MAX_NODES; - gi->pci_dev =3D NULL; +static void acpi_generic_node_finalize(Object *obj) +{ + AcpiGenericNode *gn =3D ACPI_GENERIC_NODE(obj); + + g_free(gn->pci_dev); } =20 static void acpi_generic_initiator_finalize(Object *obj) { - AcpiGenericInitiator *gi =3D ACPI_GENERIC_INITIATOR(obj); - - g_free(gi->pci_dev); } =20 -static void acpi_generic_initiator_set_pci_device(Object *obj, const char = *val, - Error **errp) +static void acpi_generic_node_set_pci_device(Object *obj, const char *val, + Error **errp) { - AcpiGenericInitiator *gi =3D ACPI_GENERIC_INITIATOR(obj); + AcpiGenericNode *gn =3D ACPI_GENERIC_NODE(obj); =20 - gi->pci_dev =3D g_strdup(val); + gn->pci_dev =3D g_strdup(val); } - -static void acpi_generic_initiator_set_node(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) +static void acpi_generic_node_set_node(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) { - AcpiGenericInitiator *gi =3D ACPI_GENERIC_INITIATOR(obj); + AcpiGenericNode *gn =3D ACPI_GENERIC_NODE(obj); MachineState *ms =3D MACHINE(qdev_get_machine()); uint32_t value; =20 @@ -58,20 +74,24 @@ static void acpi_generic_initiator_set_node(Object *obj= , Visitor *v, =20 if (value >=3D MAX_NODES) { error_printf("%s: Invalid NUMA node specified\n", - TYPE_ACPI_GENERIC_INITIATOR); + TYPE_ACPI_GENERIC_NODE); exit(1); } =20 - gi->node =3D value; - ms->numa_state->nodes[gi->node].has_gi =3D true; + gn->node =3D value; + ms->numa_state->nodes[gn->node].has_gi =3D true; +} + +static void acpi_generic_node_class_init(ObjectClass *oc, void *data) +{ + object_class_property_add_str(oc, "pci-dev", NULL, + acpi_generic_node_set_pci_device); + object_class_property_add(oc, "node", "int", NULL, + acpi_generic_node_set_node, NULL, NULL); } =20 static void acpi_generic_initiator_class_init(ObjectClass *oc, void *data) { - object_class_property_add_str(oc, "pci-dev", NULL, - acpi_generic_initiator_set_pci_device); - object_class_property_add(oc, "node", "int", NULL, - acpi_generic_initiator_set_node, NULL, NULL); } =20 /* @@ -104,9 +124,9 @@ build_srat_generic_pci_initiator_affinity(GArray *table= _data, int node, static int build_all_acpi_generic_initiators(Object *obj, void *opaque) { MachineState *ms =3D MACHINE(qdev_get_machine()); - AcpiGenericInitiator *gi; GArray *table_data =3D opaque; PCIDeviceHandle dev_handle; + AcpiGenericNode *gn; PCIDevice *pci_dev; Object *o; =20 @@ -114,14 +134,14 @@ static int build_all_acpi_generic_initiators(Object *= obj, void *opaque) return 0; } =20 - gi =3D ACPI_GENERIC_INITIATOR(obj); - if (gi->node >=3D ms->numa_state->num_nodes) { + gn =3D ACPI_GENERIC_NODE(obj); + if (gn->node >=3D ms->numa_state->num_nodes) { error_printf("%s: Specified node %d is invalid.\n", - TYPE_ACPI_GENERIC_INITIATOR, gi->node); + TYPE_ACPI_GENERIC_INITIATOR, gn->node); exit(1); } =20 - o =3D object_resolve_path_type(gi->pci_dev, TYPE_PCI_DEVICE, NULL); + o =3D object_resolve_path_type(gn->pci_dev, TYPE_PCI_DEVICE, NULL); if (!o) { error_printf("%s: Specified device must be a PCI device.\n", TYPE_ACPI_GENERIC_INITIATOR); @@ -135,7 +155,7 @@ static int build_all_acpi_generic_initiators(Object *ob= j, void *opaque) pci_dev->devfn); =20 build_srat_generic_pci_initiator_affinity(table_data, - gi->node, &dev_handle); + gn->node, &dev_handle); =20 return 0; } --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630700; cv=none; d=zohomail.com; s=zohoarc; b=K9fXuvnBjlGW8V/CiivkiD2OWBENq+uc/GVYN0Pw7qpnwfqbJ3YYZSWGYNHzPyv3UgqAwv8on/NGlCKOOftCt4PsGIfr+1kivW4FDQgy59GTPH9S8vouR96XQJhTRslki77ojuWZX/Z6Nw3tPwDHG1KALVUBV+tseFRS8ZcPSvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630700; 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=PiQRSKV88pDHIzL/embxb6ck9gnapJtoEwzBqZXK5wg=; b=m701/od+AkthF2lIs6cie7NuXgF2wrlUqCTCqXkw3dvhaI5KlDEMawGCzWIw4DqFZTcdbKzwUOu89lPWiCRnuTgEbr0bgQ5zOtkxgnH2S1ukvtqgG4vnGSP7PcqlfuYZg28h153Hah6qtD4Gvl1se9+4r0iK/7J4nHUNG4nGOzA= 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+importer=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 1717630700580983.241715968273; Wed, 5 Jun 2024 16:38:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0BU-0000Qa-Fx; Wed, 05 Jun 2024 19:36:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BS-0000B4-GM for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BQ-0005ui-KY for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:46 -0400 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-660-rLbs8pqIPQ--Yg3SfsG0VQ-1; Wed, 05 Jun 2024 19:36:42 -0400 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2eaa806df17so1849121fa.2 for ; Wed, 05 Jun 2024 16:36:42 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae201a6esm94218a12.71.2024.06.05.16.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630604; h=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=PiQRSKV88pDHIzL/embxb6ck9gnapJtoEwzBqZXK5wg=; b=duYjxbxG54nwpDwG5uETchjcmK0HTWyAKbsB/aaZEBj9hWARKz1B35WSAQIqG/F8OAY/m0 ZGQZS1KZ95ufvO3M76JMUmYd6zXZUxxqHDB42U/Z314DXjnHVBReSf4jMkY9Ev5ov6wcgK ufu69UdH6iSwt6Fks9HuqdEIoBsH8WQ= X-MC-Unique: rLbs8pqIPQ--Yg3SfsG0VQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630601; x=1718235401; 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=PiQRSKV88pDHIzL/embxb6ck9gnapJtoEwzBqZXK5wg=; b=Q/Gr7lg9lBdsXLgTdbcyI5SO33d8jR5sX9WnQCIsyOI1R2c/9NfD7oAAGt4901Jd2d M9OzUjjo2PWU+Y6XNEkUS4J2Ajkqi3OAYIZaXSOIQaYoRl/+GfhHEHF3DjY1RF1x7ep1 hTKnWMqLpWlwCBQjdMjxbrGdJeCHajN9/dusxpF+Fs4SQmB49GjaIIpmz924oasvtr7T /OP1/g5lrahExHeWu0BUphkEk+p5WDGN74kcAAAHbm/KaPv219XexaspNWe0Rqa4+o/J q+8ya/MHMEYcWmNS5SRRwe4rEuxGztfC26VLyTulfYxUNUExCRHDN34C6HewDVrMJfkq wYNg== X-Gm-Message-State: AOJu0YxNNUEEQUtplZq0FUTbcy1MwcJGrIOhLxQq6Tb9vEW2xgTniEqB ScKDixOPGqbM0P2/t+s/CshYqZpe0u4sNsPg7gIpPfJkxDRaok29ZICCwN+vAATAg4Dso/NAsMh L9Olmr+EcycpL0PGi4EHpIlNcx6AtvKcd12fM2uKHZrWUWgPyxrM82wOvu+apwIOui+8OqACdFF tp56kwMTIQEeUCDKRGJl10ZtxYHvDpEQ== X-Received: by 2002:a2e:2c06:0:b0:2ea:bc8d:3a43 with SMTP id 38308e7fff4ca-2eac7aace3bmr20897761fa.43.1717630600926; Wed, 05 Jun 2024 16:36:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF002q5CRfYJKtGq/CJm/lyEtHjtvPmWOWPb4tSY4hYBp77ZRbkRgyBfE8hfne09EMPbs+wOA== X-Received: by 2002:a2e:2c06:0:b0:2ea:bc8d:3a43 with SMTP id 38308e7fff4ca-2eac7aace3bmr20897631fa.43.1717630600454; Wed, 05 Jun 2024 16:36:40 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Thomas Huth , Cornelia Huck , Paolo Bonzini Subject: [PULL v3 32/41] scripts/update-linux-headers: Copy setup_data.h to correct directory Message-ID: <22df9cd2eac6404888df74e9a44f151681f31051.1717630437.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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630702230100003 From: Thomas Wei=C3=9Fschuh Add the missing "include/" path component, so the files ends up in the correct place like the other headers. Fixes: 66210a1a30f2 ("scripts/update-linux-headers: Add setup_data.h to imp= ort list") Signed-off-by: Thomas Wei=C3=9Fschuh Message-Id: <20240527-pvpanic-shutdown-v8-1-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Thomas Huth --- scripts/update-linux-headers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers= .sh index 8963c39189..a148793bd5 100755 --- a/scripts/update-linux-headers.sh +++ b/scripts/update-linux-headers.sh @@ -158,7 +158,7 @@ for arch in $ARCHLIST; do cp_portable "$hdrdir/bootparam.h" \ "$output/include/standard-headers/asm-$arch" cp_portable "$hdrdir/include/asm/setup_data.h" \ - "$output/standard-headers/asm-x86" + "$output/include/standard-headers/asm-x86" fi if [ $arch =3D riscv ]; then cp "$hdrdir/include/asm/ptrace.h" "$output/linux-headers/asm-riscv= /" --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630742; cv=none; d=zohomail.com; s=zohoarc; b=hMUChN1nZoRgOkmvSvYZIG/91kQNtdzygIHVuc1W2TGikVYV5bDhsHZyB7DelKTcNqZicKLsAHXH4Qio4MbBT1oM8Rp1u1XxBpC/olib6Ey4UUYIumzxZgmweAZiPT1iwl9/EaLnrwNgyhhIh6Bzpfmgls+w2InF9broddX8bj0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630742; 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=htiGewZQePeDM6wJgWhT3oGJySGerAHDxg1IujevkYQ=; b=CsYeg8rcliHMJRAAGRmIWVJ1Ae2ZrBDUpKLZ3vYxIhbTR1jIdQQiFtG0X41XtIF139vlAoW1YzUnqtNuooWZsCJQ1QxgbxJO/5Ov672Yt/ZJ8sTirk3PCHAjcKvkTkL06kYigpnc5Z9xstUXP4bvreCdodQNuGEs7zj1LLn9pNI= 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+importer=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 1717630742134771.5182307190294; Wed, 5 Jun 2024 16:39:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0Bd-0001kj-Ug; Wed, 05 Jun 2024 19:36:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Ba-0001SZ-VS for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BW-0005vU-1m for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:54 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-599-tEU_X0VsO4imJ-BpSSCLHg-1; Wed, 05 Jun 2024 19:36:48 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a68cc214ac7so10617866b.2 for ; Wed, 05 Jun 2024 16:36:46 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c806ebd21sm6620166b.100.2024.06.05.16.36.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630609; h=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=htiGewZQePeDM6wJgWhT3oGJySGerAHDxg1IujevkYQ=; b=AmiVIkZdIjjX+CyuIXvTxu33JgkTrl2cTmuzudLoy6nbjhI7sQy/b19U7ELk8CPBdmU4mW to0kC4nadBxSyzAL6d3zZF0J1zLNq3L/akb54emhjHgORaMs8fT/w/bY8yYKoor7R2pJl6 IESYOdIBauoJ/d8R8agSyk9PNrblVXY= X-MC-Unique: tEU_X0VsO4imJ-BpSSCLHg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630605; x=1718235405; 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=htiGewZQePeDM6wJgWhT3oGJySGerAHDxg1IujevkYQ=; b=f1kFH6mKE5W1VPZpmGTDb8E85/ep6Rros+GmYrwb6w9Ow0SNPiW7pjZyITCKzZ8VfU q9TRWGvf5LgWghCuO88hIB9CQ40PfSd2h08TKSHmTQN9SK/gmHIYAc0TUiO33XoiNh/Y S3ruRfH2O8Y8Bh4egE7ab4bhtHLvxqG9lIQT9P7VxH6PEPlspRxSbEdYMO0B5fXm4YoB stjBad1oCHrN2vflY3Bxj6NPQ7jAfVxaQVQ2oTw2vVM4l8LqqHhhxnDb/0HGO9CnijXo tJKEAHcv7xG50NxBrzY2aWaHn5A8G8IeBrPY1CCwcm8e04j3pRDqj4GbJr+ytz/OS9L3 lHjw== X-Gm-Message-State: AOJu0YwsN5GDCH2zVYfzJw3hxi34xymcbQMKfMzF7KSZ48FOU65nrZ8B Lko0oxWIqQFs00uKIiMelTLzo7n+DEp57lY54idSBShJKy1cLTL24AaDBP/qnJqwxXgdmjECNej s6dedn4D+ou2W+KFakinGh1JfL+H4H/+9WLAp7GbGFWgihtp69+h9raB2Wcn2wCejeyjIr47Kty skNSsIMRhaWFQgpbQmntOpJmjKV1Oi4g== X-Received: by 2002:a17:906:c44d:b0:a6b:c993:7ede with SMTP id a640c23a62f3a-a6bc9938015mr169635266b.11.1717630605047; Wed, 05 Jun 2024 16:36:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+zgkPZz3vc+Dw7Xd1Pg1Nztsc44ooOcRtuFwwOa7eQ+vg7I9UVfbzCMN0ultwPlZ6NiPx7g== X-Received: by 2002:a17:906:c44d:b0:a6b:c993:7ede with SMTP id a640c23a62f3a-a6bc9938015mr169634066b.11.1717630604397; Wed, 05 Jun 2024 16:36:44 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:40 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Cornelia Huck , Paolo Bonzini , kvm@vger.kernel.org Subject: [PULL v3 33/41] linux-headers: update to 6.10-rc1 Message-ID: <40876c584a7f355963b81b32e81d623b353c3cb8.1717630437.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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630742455100008 From: Thomas Wei=C3=9Fschuh Signed-off-by: Thomas Wei=C3=9Fschuh Message-Id: <20240527-pvpanic-shutdown-v8-2-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/standard-headers/linux/ethtool.h | 55 ++++++++ include/standard-headers/linux/pci_regs.h | 6 + include/standard-headers/linux/pvpanic.h | 7 +- include/standard-headers/linux/virtio_bt.h | 1 - include/standard-headers/linux/virtio_mem.h | 2 + include/standard-headers/linux/virtio_net.h | 143 ++++++++++++++++++++ linux-headers/asm-generic/unistd.h | 5 +- linux-headers/asm-loongarch/kvm.h | 4 + linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-riscv/kvm.h | 1 + linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/kvm.h | 4 +- linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 2 + linux-headers/linux/kvm.h | 4 +- linux-headers/linux/stddef.h | 8 ++ linux-headers/linux/vhost.h | 15 +- 23 files changed, 252 insertions(+), 14 deletions(-) diff --git a/include/standard-headers/linux/ethtool.h b/include/standard-he= aders/linux/ethtool.h index 01503784d2..b0b4b68410 100644 --- a/include/standard-headers/linux/ethtool.h +++ b/include/standard-headers/linux/ethtool.h @@ -752,6 +752,61 @@ enum ethtool_module_power_mode { ETHTOOL_MODULE_POWER_MODE_HIGH, }; =20 +/** + * enum ethtool_pse_types - Types of PSE controller. + * @ETHTOOL_PSE_UNKNOWN: Type of PSE controller is unknown + * @ETHTOOL_PSE_PODL: PSE controller which support PoDL + * @ETHTOOL_PSE_C33: PSE controller which support Clause 33 (PoE) + */ +enum ethtool_pse_types { + ETHTOOL_PSE_UNKNOWN =3D 1 << 0, + ETHTOOL_PSE_PODL =3D 1 << 1, + ETHTOOL_PSE_C33 =3D 1 << 2, +}; + +/** + * enum ethtool_c33_pse_admin_state - operational state of the PoDL PSE + * functions. IEEE 802.3-2022 30.9.1.1.2 aPSEAdminState + * @ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN: state of PSE functions is unknown + * @ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED: PSE functions are disabled + * @ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED: PSE functions are enabled + */ +enum ethtool_c33_pse_admin_state { + ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN =3D 1, + ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED, + ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED, +}; + +/** + * enum ethtool_c33_pse_pw_d_status - power detection status of the PSE. + * IEEE 802.3-2022 30.9.1.1.3 aPoDLPSEPowerDetectionStatus: + * @ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN: PSE status is unknown + * @ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED: The enumeration "disabled" + * indicates that the PSE State diagram is in the state DISABLED. + * @ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING: The enumeration "searching" + * indicates the PSE State diagram is in a state other than those + * listed. + * @ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING: The enumeration + * "deliveringPower" indicates that the PSE State diagram is in the + * state POWER_ON. + * @ETHTOOL_C33_PSE_PW_D_STATUS_TEST: The enumeration "test" indicates that + * the PSE State diagram is in the state TEST_MODE. + * @ETHTOOL_C33_PSE_PW_D_STATUS_FAULT: The enumeration "fault" indicates t= hat + * the PSE State diagram is in the state TEST_ERROR. + * @ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT: The enumeration "otherFault" + * indicates that the PSE State diagram is in the state IDLE due to + * the variable error_condition =3D true. + */ +enum ethtool_c33_pse_pw_d_status { + ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN =3D 1, + ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED, + ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING, + ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING, + ETHTOOL_C33_PSE_PW_D_STATUS_TEST, + ETHTOOL_C33_PSE_PW_D_STATUS_FAULT, + ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT, +}; + /** * enum ethtool_podl_pse_admin_state - operational state of the PoDL PSE * functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-h= eaders/linux/pci_regs.h index a39193213f..94c00996e6 100644 --- a/include/standard-headers/linux/pci_regs.h +++ b/include/standard-headers/linux/pci_regs.h @@ -1144,8 +1144,14 @@ #define PCI_DOE_DATA_OBJECT_HEADER_2_LENGTH 0x0003ffff =20 #define PCI_DOE_DATA_OBJECT_DISC_REQ_3_INDEX 0x000000ff +#define PCI_DOE_DATA_OBJECT_DISC_REQ_3_VER 0x0000ff00 #define PCI_DOE_DATA_OBJECT_DISC_RSP_3_VID 0x0000ffff #define PCI_DOE_DATA_OBJECT_DISC_RSP_3_PROTOCOL 0x00ff0000 #define PCI_DOE_DATA_OBJECT_DISC_RSP_3_NEXT_INDEX 0xff000000 =20 +/* Compute Express Link (CXL r3.1, sec 8.1.5) */ +#define PCI_DVSEC_CXL_PORT 3 +#define PCI_DVSEC_CXL_PORT_CTL 0x0c +#define PCI_DVSEC_CXL_PORT_CTL_UNMASK_SBR 0x00000001 + #endif /* LINUX_PCI_REGS_H */ diff --git a/include/standard-headers/linux/pvpanic.h b/include/standard-he= aders/linux/pvpanic.h index 54b7485390..b115094431 100644 --- a/include/standard-headers/linux/pvpanic.h +++ b/include/standard-headers/linux/pvpanic.h @@ -3,7 +3,10 @@ #ifndef __PVPANIC_H__ #define __PVPANIC_H__ =20 -#define PVPANIC_PANICKED (1 << 0) -#define PVPANIC_CRASH_LOADED (1 << 1) +#include "standard-headers/linux/const.h" + +#define PVPANIC_PANICKED _BITUL(0) +#define PVPANIC_CRASH_LOADED _BITUL(1) +#define PVPANIC_SHUTDOWN _BITUL(2) =20 #endif /* __PVPANIC_H__ */ diff --git a/include/standard-headers/linux/virtio_bt.h b/include/standard-= headers/linux/virtio_bt.h index a11ecc3f92..6f0dee7e32 100644 --- a/include/standard-headers/linux/virtio_bt.h +++ b/include/standard-headers/linux/virtio_bt.h @@ -13,7 +13,6 @@ =20 enum virtio_bt_config_type { VIRTIO_BT_CONFIG_TYPE_PRIMARY =3D 0, - VIRTIO_BT_CONFIG_TYPE_AMP =3D 1, }; =20 enum virtio_bt_config_vendor { diff --git a/include/standard-headers/linux/virtio_mem.h b/include/standard= -headers/linux/virtio_mem.h index 18c74c527c..6bfa41bd8b 100644 --- a/include/standard-headers/linux/virtio_mem.h +++ b/include/standard-headers/linux/virtio_mem.h @@ -90,6 +90,8 @@ #define VIRTIO_MEM_F_ACPI_PXM 0 /* unplugged memory must not be accessed */ #define VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE 1 +/* plugged memory will remain plugged when suspending+resuming */ +#define VIRTIO_MEM_F_PERSISTENT_SUSPEND 2 =20 =20 /* --- virtio-mem: guest -> host requests --- */ diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard= -headers/linux/virtio_net.h index 0f88417742..fc594fe5fc 100644 --- a/include/standard-headers/linux/virtio_net.h +++ b/include/standard-headers/linux/virtio_net.h @@ -56,6 +56,7 @@ #define VIRTIO_NET_F_MQ 22 /* Device supports Receive Flow * Steering */ #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ +#define VIRTIO_NET_F_DEVICE_STATS 50 /* Device can provide device-level st= atistics. */ #define VIRTIO_NET_F_VQ_NOTF_COAL 52 /* Device supports virtqueue notifica= tion coalescing */ #define VIRTIO_NET_F_NOTF_COAL 53 /* Device supports notifications coalesc= ing */ #define VIRTIO_NET_F_GUEST_USO4 54 /* Guest can handle USOv4 in. */ @@ -406,4 +407,146 @@ struct virtio_net_ctrl_coal_vq { struct virtio_net_ctrl_coal coal; }; =20 +/* + * Device Statistics + */ +#define VIRTIO_NET_CTRL_STATS 8 +#define VIRTIO_NET_CTRL_STATS_QUERY 0 +#define VIRTIO_NET_CTRL_STATS_GET 1 + +struct virtio_net_stats_capabilities { + +#define VIRTIO_NET_STATS_TYPE_CVQ (1ULL << 32) + +#define VIRTIO_NET_STATS_TYPE_RX_BASIC (1ULL << 0) +#define VIRTIO_NET_STATS_TYPE_RX_CSUM (1ULL << 1) +#define VIRTIO_NET_STATS_TYPE_RX_GSO (1ULL << 2) +#define VIRTIO_NET_STATS_TYPE_RX_SPEED (1ULL << 3) + +#define VIRTIO_NET_STATS_TYPE_TX_BASIC (1ULL << 16) +#define VIRTIO_NET_STATS_TYPE_TX_CSUM (1ULL << 17) +#define VIRTIO_NET_STATS_TYPE_TX_GSO (1ULL << 18) +#define VIRTIO_NET_STATS_TYPE_TX_SPEED (1ULL << 19) + + uint64_t supported_stats_types[1]; +}; + +struct virtio_net_ctrl_queue_stats { + struct { + uint16_t vq_index; + uint16_t reserved[3]; + uint64_t types_bitmap[1]; + } stats[1]; +}; + +struct virtio_net_stats_reply_hdr { +#define VIRTIO_NET_STATS_TYPE_REPLY_CVQ 32 + +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC 0 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM 1 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO 2 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_SPEED 3 + +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC 16 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM 17 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO 18 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_SPEED 19 + uint8_t type; + uint8_t reserved; + uint16_t vq_index; + uint16_t reserved1; + uint16_t size; +}; + +struct virtio_net_stats_cvq { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t command_num; + uint64_t ok_num; +}; + +struct virtio_net_stats_rx_basic { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t rx_notifications; + + uint64_t rx_packets; + uint64_t rx_bytes; + + uint64_t rx_interrupts; + + uint64_t rx_drops; + uint64_t rx_drop_overruns; +}; + +struct virtio_net_stats_tx_basic { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t tx_notifications; + + uint64_t tx_packets; + uint64_t tx_bytes; + + uint64_t tx_interrupts; + + uint64_t tx_drops; + uint64_t tx_drop_malformed; +}; + +struct virtio_net_stats_rx_csum { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t rx_csum_valid; + uint64_t rx_needs_csum; + uint64_t rx_csum_none; + uint64_t rx_csum_bad; +}; + +struct virtio_net_stats_tx_csum { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t tx_csum_none; + uint64_t tx_needs_csum; +}; + +struct virtio_net_stats_rx_gso { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t rx_gso_packets; + uint64_t rx_gso_bytes; + uint64_t rx_gso_packets_coalesced; + uint64_t rx_gso_bytes_coalesced; +}; + +struct virtio_net_stats_tx_gso { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t tx_gso_packets; + uint64_t tx_gso_bytes; + uint64_t tx_gso_segments; + uint64_t tx_gso_segments_bytes; + uint64_t tx_gso_packets_noseg; + uint64_t tx_gso_bytes_noseg; +}; + +struct virtio_net_stats_rx_speed { + struct virtio_net_stats_reply_hdr hdr; + + /* rx_{packets,bytes}_allowance_exceeded are too long. So rename to + * short name. + */ + uint64_t rx_ratelimit_packets; + uint64_t rx_ratelimit_bytes; +}; + +struct virtio_net_stats_tx_speed { + struct virtio_net_stats_reply_hdr hdr; + + /* tx_{packets,bytes}_allowance_exceeded are too long. So rename to + * short name. + */ + uint64_t tx_ratelimit_packets; + uint64_t tx_ratelimit_bytes; +}; + #endif /* _LINUX_VIRTIO_NET_H */ diff --git a/linux-headers/asm-generic/unistd.h b/linux-headers/asm-generic= /unistd.h index 75f00965ab..d983c48a3b 100644 --- a/linux-headers/asm-generic/unistd.h +++ b/linux-headers/asm-generic/unistd.h @@ -842,8 +842,11 @@ __SYSCALL(__NR_lsm_set_self_attr, sys_lsm_set_self_att= r) #define __NR_lsm_list_modules 461 __SYSCALL(__NR_lsm_list_modules, sys_lsm_list_modules) =20 +#define __NR_mseal 462 +__SYSCALL(__NR_mseal, sys_mseal) + #undef __NR_syscalls -#define __NR_syscalls 462 +#define __NR_syscalls 463 =20 /* * 32 bit systems traditionally used different diff --git a/linux-headers/asm-loongarch/kvm.h b/linux-headers/asm-loongarc= h/kvm.h index 109785922c..f9abef3823 100644 --- a/linux-headers/asm-loongarch/kvm.h +++ b/linux-headers/asm-loongarch/kvm.h @@ -17,6 +17,8 @@ #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 #define KVM_DIRTY_LOG_PAGE_OFFSET 64 =20 +#define KVM_GUESTDBG_USE_SW_BP 0x00010000 + /* * for KVM_GET_REGS and KVM_SET_REGS */ @@ -72,6 +74,8 @@ struct kvm_fpu { =20 #define KVM_REG_LOONGARCH_COUNTER (KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U6= 4 | 1) #define KVM_REG_LOONGARCH_VCPU_RESET (KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE= _U64 | 2) +/* Debugging: Special instruction for software breakpoint */ +#define KVM_REG_LOONGARCH_DEBUG_INST (KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE= _U64 | 3) =20 #define LOONGARCH_REG_SHIFT 3 #define LOONGARCH_REG_64(TYPE, REG) (TYPE | KVM_REG_SIZE_U64 | (REG << LOO= NGARCH_REG_SHIFT)) diff --git a/linux-headers/asm-mips/unistd_n32.h b/linux-headers/asm-mips/u= nistd_n32.h index ce2e050a9b..fc93b3be30 100644 --- a/linux-headers/asm-mips/unistd_n32.h +++ b/linux-headers/asm-mips/unistd_n32.h @@ -390,5 +390,6 @@ #define __NR_lsm_get_self_attr (__NR_Linux + 459) #define __NR_lsm_set_self_attr (__NR_Linux + 460) #define __NR_lsm_list_modules (__NR_Linux + 461) +#define __NR_mseal (__NR_Linux + 462) =20 #endif /* _ASM_UNISTD_N32_H */ diff --git a/linux-headers/asm-mips/unistd_n64.h b/linux-headers/asm-mips/u= nistd_n64.h index 5bfb3733ff..e72a3eb2c9 100644 --- a/linux-headers/asm-mips/unistd_n64.h +++ b/linux-headers/asm-mips/unistd_n64.h @@ -366,5 +366,6 @@ #define __NR_lsm_get_self_attr (__NR_Linux + 459) #define __NR_lsm_set_self_attr (__NR_Linux + 460) #define __NR_lsm_list_modules (__NR_Linux + 461) +#define __NR_mseal (__NR_Linux + 462) =20 #endif /* _ASM_UNISTD_N64_H */ diff --git a/linux-headers/asm-mips/unistd_o32.h b/linux-headers/asm-mips/u= nistd_o32.h index 02eaecd020..b86eb0786c 100644 --- a/linux-headers/asm-mips/unistd_o32.h +++ b/linux-headers/asm-mips/unistd_o32.h @@ -436,5 +436,6 @@ #define __NR_lsm_get_self_attr (__NR_Linux + 459) #define __NR_lsm_set_self_attr (__NR_Linux + 460) #define __NR_lsm_list_modules (__NR_Linux + 461) +#define __NR_mseal (__NR_Linux + 462) =20 #endif /* _ASM_UNISTD_O32_H */ diff --git a/linux-headers/asm-powerpc/unistd_32.h b/linux-headers/asm-powe= rpc/unistd_32.h index bbab08d6ec..28627b6546 100644 --- a/linux-headers/asm-powerpc/unistd_32.h +++ b/linux-headers/asm-powerpc/unistd_32.h @@ -443,6 +443,7 @@ #define __NR_lsm_get_self_attr 459 #define __NR_lsm_set_self_attr 460 #define __NR_lsm_list_modules 461 +#define __NR_mseal 462 =20 =20 #endif /* _ASM_UNISTD_32_H */ diff --git a/linux-headers/asm-powerpc/unistd_64.h b/linux-headers/asm-powe= rpc/unistd_64.h index af34cde70f..1fc42a8300 100644 --- a/linux-headers/asm-powerpc/unistd_64.h +++ b/linux-headers/asm-powerpc/unistd_64.h @@ -415,6 +415,7 @@ #define __NR_lsm_get_self_attr 459 #define __NR_lsm_set_self_attr 460 #define __NR_lsm_list_modules 461 +#define __NR_mseal 462 =20 =20 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-riscv/kvm.h b/linux-headers/asm-riscv/kvm.h index b1c503c295..e878e7cc39 100644 --- a/linux-headers/asm-riscv/kvm.h +++ b/linux-headers/asm-riscv/kvm.h @@ -167,6 +167,7 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_ZFA, KVM_RISCV_ISA_EXT_ZTSO, KVM_RISCV_ISA_EXT_ZACAS, + KVM_RISCV_ISA_EXT_SSCOFPMF, KVM_RISCV_ISA_EXT_MAX, }; =20 diff --git a/linux-headers/asm-s390/unistd_32.h b/linux-headers/asm-s390/un= istd_32.h index a3ece69d82..7706c21b87 100644 --- a/linux-headers/asm-s390/unistd_32.h +++ b/linux-headers/asm-s390/unistd_32.h @@ -434,5 +434,6 @@ #define __NR_lsm_get_self_attr 459 #define __NR_lsm_set_self_attr 460 #define __NR_lsm_list_modules 461 +#define __NR_mseal 462 =20 #endif /* _ASM_S390_UNISTD_32_H */ diff --git a/linux-headers/asm-s390/unistd_64.h b/linux-headers/asm-s390/un= istd_64.h index 8c5fd93495..62082d592d 100644 --- a/linux-headers/asm-s390/unistd_64.h +++ b/linux-headers/asm-s390/unistd_64.h @@ -382,5 +382,6 @@ #define __NR_lsm_get_self_attr 459 #define __NR_lsm_set_self_attr 460 #define __NR_lsm_list_modules 461 +#define __NR_mseal 462 =20 #endif /* _ASM_S390_UNISTD_64_H */ diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index 31c95c2dfe..b4e2e8d220 100644 --- a/linux-headers/asm-x86/kvm.h +++ b/linux-headers/asm-x86/kvm.h @@ -709,7 +709,9 @@ struct kvm_sev_cmd { struct kvm_sev_init { __u64 vmsa_features; __u32 flags; - __u32 pad[9]; + __u16 ghcb_version; + __u16 pad1; + __u32 pad2[8]; }; =20 struct kvm_sev_launch_start { diff --git a/linux-headers/asm-x86/unistd_32.h b/linux-headers/asm-x86/unis= td_32.h index 5c9c329e93..fb7b8b169b 100644 --- a/linux-headers/asm-x86/unistd_32.h +++ b/linux-headers/asm-x86/unistd_32.h @@ -452,6 +452,7 @@ #define __NR_lsm_get_self_attr 459 #define __NR_lsm_set_self_attr 460 #define __NR_lsm_list_modules 461 +#define __NR_mseal 462 =20 =20 #endif /* _ASM_UNISTD_32_H */ diff --git a/linux-headers/asm-x86/unistd_64.h b/linux-headers/asm-x86/unis= td_64.h index d9aab7ae87..da439afee1 100644 --- a/linux-headers/asm-x86/unistd_64.h +++ b/linux-headers/asm-x86/unistd_64.h @@ -374,6 +374,7 @@ #define __NR_lsm_get_self_attr 459 #define __NR_lsm_set_self_attr 460 #define __NR_lsm_list_modules 461 +#define __NR_mseal 462 =20 =20 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-x86/unistd_x32.h b/linux-headers/asm-x86/uni= std_x32.h index 63cdd1ee43..4fcb607c72 100644 --- a/linux-headers/asm-x86/unistd_x32.h +++ b/linux-headers/asm-x86/unistd_x32.h @@ -318,6 +318,7 @@ #define __NR_set_mempolicy_home_node (__X32_SYSCALL_BIT + 450) #define __NR_cachestat (__X32_SYSCALL_BIT + 451) #define __NR_fchmodat2 (__X32_SYSCALL_BIT + 452) +#define __NR_map_shadow_stack (__X32_SYSCALL_BIT + 453) #define __NR_futex_wake (__X32_SYSCALL_BIT + 454) #define __NR_futex_wait (__X32_SYSCALL_BIT + 455) #define __NR_futex_requeue (__X32_SYSCALL_BIT + 456) @@ -326,6 +327,7 @@ #define __NR_lsm_get_self_attr (__X32_SYSCALL_BIT + 459) #define __NR_lsm_set_self_attr (__X32_SYSCALL_BIT + 460) #define __NR_lsm_list_modules (__X32_SYSCALL_BIT + 461) +#define __NR_mseal (__X32_SYSCALL_BIT + 462) #define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512) #define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513) #define __NR_ioctl (__X32_SYSCALL_BIT + 514) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 038731cdef..c93876ca0b 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1217,9 +1217,9 @@ struct kvm_vfio_spapr_tce { /* Available with KVM_CAP_SPAPR_RESIZE_HPT */ #define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize= _hpt) #define KVM_PPC_RESIZE_HPT_COMMIT _IOR(KVMIO, 0xae, struct kvm_ppc_resize= _hpt) -/* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 */ +/* Available with KVM_CAP_PPC_MMU_RADIX or KVM_CAP_PPC_MMU_HASH_V3 */ #define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_= cfg) -/* Available with KVM_CAP_PPC_RADIX_MMU */ +/* Available with KVM_CAP_PPC_MMU_RADIX */ #define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_inf= o) /* Available with KVM_CAP_PPC_GET_CPU_CHAR */ #define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char) diff --git a/linux-headers/linux/stddef.h b/linux-headers/linux/stddef.h index bf9749dd14..96aa341942 100644 --- a/linux-headers/linux/stddef.h +++ b/linux-headers/linux/stddef.h @@ -55,4 +55,12 @@ #define __counted_by(m) #endif =20 +#ifndef __counted_by_le +#define __counted_by_le(m) +#endif + +#ifndef __counted_by_be +#define __counted_by_be(m) +#endif + #endif /* _LINUX_STDDEF_H */ diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h index bea6973906..b95dd84eef 100644 --- a/linux-headers/linux/vhost.h +++ b/linux-headers/linux/vhost.h @@ -179,12 +179,6 @@ /* Get the config size */ #define VHOST_VDPA_GET_CONFIG_SIZE _IOR(VHOST_VIRTIO, 0x79, __u32) =20 -/* Get the count of all virtqueues */ -#define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32) - -/* Get the number of virtqueue groups. */ -#define VHOST_VDPA_GET_GROUP_NUM _IOR(VHOST_VIRTIO, 0x81, __u32) - /* Get the number of address spaces. */ #define VHOST_VDPA_GET_AS_NUM _IOR(VHOST_VIRTIO, 0x7A, unsigned int) =20 @@ -228,10 +222,17 @@ #define VHOST_VDPA_GET_VRING_DESC_GROUP _IOWR(VHOST_VIRTIO, 0x7F, \ struct vhost_vring_state) =20 + +/* Get the count of all virtqueues */ +#define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32) + +/* Get the number of virtqueue groups. */ +#define VHOST_VDPA_GET_GROUP_NUM _IOR(VHOST_VIRTIO, 0x81, __u32) + /* Get the queue size of a specific virtqueue. * userspace set the vring index in vhost_vring_state.index * kernel set the queue size in vhost_vring_state.num */ -#define VHOST_VDPA_GET_VRING_SIZE _IOWR(VHOST_VIRTIO, 0x80, \ +#define VHOST_VDPA_GET_VRING_SIZE _IOWR(VHOST_VIRTIO, 0x82, \ struct vhost_vring_state) #endif --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630647; cv=none; d=zohomail.com; s=zohoarc; b=gqFLH3A72a1luryzc23dXziUeIeMouWrg5Pg42gjuwd+HwhLHo/2qpOw7fugx9ZxTOtYssvX8dXsvpEf2QDp5tgBvIGmUfbS7Yo9ZiW+vaOjmz8CeHGBjuowvEX65Pe5CBpXhM4ZWrNPxWD393S8/kUIG2Kf53ucFa+q++DRRf0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630647; 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=COb9qMgVhyWcfSZ4kcRJbOToHu92CV+3NurJg9nrDAw=; b=hW8+8na2W535G3dkrwCspqBCw5ZUobhuzin4ee04rWcWltPozG6h7rh4pC5MONrYoyOhpmUO/Vl47bgvFKCWbrsb8U3OdC8fwSeYSlzkNVuww9FKeclgPGPdQUM1stSRdjScKHkGqCu07M6HI7drcBYH9BsD5VuXX9bxN9d6zvc= 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+importer=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 1717630647784675.0755397859654; Wed, 5 Jun 2024 16:37:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0Bc-0001cQ-TP; Wed, 05 Jun 2024 19:36:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bb-0001TC-4T for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0BY-0005vo-He for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:54 -0400 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-605-Pkp3bEDcPhWsChW2toE7Tg-1; Wed, 05 Jun 2024 19:36:50 -0400 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57a32f2f782so79499a12.1 for ; Wed, 05 Jun 2024 16:36:50 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aadcbf568sm115672a12.0.2024.06.05.16.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630611; h=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=COb9qMgVhyWcfSZ4kcRJbOToHu92CV+3NurJg9nrDAw=; b=MyWj2E51GI2DUEBHsXjaLE9F2mXUB+uejiLfUdP0AnpF7p8aSk6oEUnTBeWY4Ig9v57wqG /lpXG5jYFCatQEe6fbQyi8tgT7ZLhum8WebT4T34t66t0w4gN3L50C3CV63YVA0syP06Pz B2DPjaFKJZpCtHPY1nXScQF8CVk4paI= X-MC-Unique: Pkp3bEDcPhWsChW2toE7Tg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630609; x=1718235409; 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=COb9qMgVhyWcfSZ4kcRJbOToHu92CV+3NurJg9nrDAw=; b=pTzAQMfWg6L6q/BpXR1DNsdvvVNbgVkp7ExN1v7KTdQewIjjUsEbT8KC3I/QxbFR4c 3aynDqmJ268cPfeDltEmvk8h4ixxJJggQ7A2ud8GyVvACKLTd6JynYx5z0JeZ1OCklSK ZGJCMZ64XCf0/AHEls/T+3wqg+QMNNCBH4hwSCZRFROf6g+YlAjV0pEpvDdePTIS72I/ pjscyWRpCZ3OhBkIC0fw0ZQMrraWstt4DOrll5THS9wasLAKUzbaVeoIdHmlOnqJUsl9 PIbBIdKk6Hm6Cn5VWx1aaNRNR1ND9bmg+MRDjFVtA+n24kZr19fcvNY2zY+jS1jufWha CaJQ== X-Gm-Message-State: AOJu0Yyr7kF+lAHKHcClY1NzyQThZuPqFxlZpAwEoyXVQKyKRZYOZfJQ UBgSaL8g2umzOJnrDxEceFOxnxRlQx7QRJJs9DJ/K2h34FQzZFYbqQ42jUZ5D/dHzQDvrk+WPcS X9fL6sYnSwavai5sQnX+krhdLvl4eus+uGHCUKlyrnEdTbFhggzeACB+Aocox29ut6CSnsUb/8A P6N/53SS+IXJVktyK5al/Q4SaeTGXKzA== X-Received: by 2002:a50:9984:0:b0:57a:3114:7d04 with SMTP id 4fb4d7f45d1cf-57a8b521cf3mr2362960a12.0.1717630608997; Wed, 05 Jun 2024 16:36:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHuimANNW6EivpmFR3ECoQ8t63ipZllWIyVpqQ8sqpB5UyZ/Efvs8mViTqfdZ4WelfNul9cuA== X-Received: by 2002:a50:9984:0:b0:57a:3114:7d04 with SMTP id 4fb4d7f45d1cf-57a8b521cf3mr2362945a12.0.1717630608376; Wed, 05 Jun 2024 16:36:48 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:44 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Thomas Huth , Cornelia Huck , Anthony PERARD , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Subject: [PULL v3 34/41] hw/misc/pvpanic: centralize definition of supported events Message-ID: <4423917dc920670d8866fc7d835ca4226d4b8cf8.1717630437.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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630648031100001 From: Thomas Wei=C3=9Fschuh The different components of pvpanic duplicate the list of supported events. Move it to the shared header file to minimize changes when new events are added. Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck Signed-off-by: Thomas Wei=C3=9Fschuh Message-Id: <20240527-pvpanic-shutdown-v8-3-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/misc/pvpanic.h | 4 ++++ hw/misc/pvpanic-isa.c | 3 +-- hw/misc/pvpanic-pci.c | 3 +-- hw/misc/pvpanic.c | 3 +-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h index fab94165d0..947468b81b 100644 --- a/include/hw/misc/pvpanic.h +++ b/include/hw/misc/pvpanic.h @@ -18,6 +18,10 @@ #include "exec/memory.h" #include "qom/object.h" =20 +#include "standard-headers/linux/pvpanic.h" + +#define PVPANIC_EVENTS (PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) + #define TYPE_PVPANIC_ISA_DEVICE "pvpanic" #define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci" =20 diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c index ccec50f61b..9a923b7869 100644 --- a/hw/misc/pvpanic-isa.c +++ b/hw/misc/pvpanic-isa.c @@ -21,7 +21,6 @@ #include "hw/misc/pvpanic.h" #include "qom/object.h" #include "hw/isa/isa.h" -#include "standard-headers/linux/pvpanic.h" #include "hw/acpi/acpi_aml_interface.h" =20 OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE) @@ -102,7 +101,7 @@ static void build_pvpanic_isa_aml(AcpiDevAmlIf *adev, A= ml *scope) static Property pvpanic_isa_properties[] =3D { DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505= ), DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events, - PVPANIC_PANICKED | PVPANIC_CRASH_LOADED), + PVPANIC_EVENTS), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c index 83be95d0d2..603c5c7600 100644 --- a/hw/misc/pvpanic-pci.c +++ b/hw/misc/pvpanic-pci.c @@ -21,7 +21,6 @@ #include "hw/misc/pvpanic.h" #include "qom/object.h" #include "hw/pci/pci_device.h" -#include "standard-headers/linux/pvpanic.h" =20 OBJECT_DECLARE_SIMPLE_TYPE(PVPanicPCIState, PVPANIC_PCI_DEVICE) =20 @@ -55,7 +54,7 @@ static void pvpanic_pci_realizefn(PCIDevice *dev, Error *= *errp) =20 static Property pvpanic_pci_properties[] =3D { DEFINE_PROP_UINT8("events", PVPanicPCIState, pvpanic.events, - PVPANIC_PANICKED | PVPANIC_CRASH_LOADED), + PVPANIC_EVENTS), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index 1540e9091a..a4982cc592 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -21,13 +21,12 @@ #include "hw/qdev-properties.h" #include "hw/misc/pvpanic.h" #include "qom/object.h" -#include "standard-headers/linux/pvpanic.h" =20 static void handle_event(int event) { static bool logged; =20 - if (event & ~(PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) && !logged) { + if (event & ~PVPANIC_EVENTS && !logged) { qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", ev= ent); logged =3D true; } --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630672; cv=none; d=zohomail.com; s=zohoarc; b=Er7nhosZC1erlBtO11KD/VSJho8kCPSMfxj52J+aBF5aEwl/EUZuczcp5Rm0hCv7foZxOWW7d1+Z1G0w9TComY1ScjoUkmMbx6rGyN+FXIoU6FwzW9n1xjjW9hxJ8vvzqSKIPjiRHPgSuzx6FtDadIsZWUxyRQoZ/PaA3eZWJAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630672; 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=3+zh1wfaSmmaGh+SRQcFGybC5BaSt211Udvwvhl5h14=; b=SNZc//Sny747IPrpENNXUSitobCMdvBC9CnC5ZNSXCYkoeeiZtsrp8QxRKdUYew6Aopum+BVDA6+Moh4gNjuXi21qiYgV/HgOKelTnZeO3RJRXMS+TNieja2lGEddw2SyBf58lx0JXy/y5F7YT+Kt089GDIdi7UOmKqbw7QtS9M= 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+importer=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 171763067226457.0610310629861; Wed, 5 Jun 2024 16:37:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0Bg-00029C-GE; Wed, 05 Jun 2024 19:37:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Be-0001nu-Ii for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bc-0005wa-MZ for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:36:58 -0400 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-607-rnQyNVC-OoSbBUjST9rf-g-1; Wed, 05 Jun 2024 19:36:54 -0400 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-52b998cb52eso210605e87.3 for ; Wed, 05 Jun 2024 16:36:54 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae234204sm93697a12.87.2024.06.05.16.36.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630616; h=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=3+zh1wfaSmmaGh+SRQcFGybC5BaSt211Udvwvhl5h14=; b=OTLV8ZE6zloo1txuXF6XUH5E648R8viqhzc2KsmUdDSrwE9u+xi2ZDbJ95GMav5qaWcpQu 332dhL4lt+x2xquSaBCWDjHYMSUcUqgGSRMvg0gxJjJHTX07lJBq4urMXE+5k4h7p7xMgc oCJgOpzenxSR3zjGx8Ju5K0kBUK6+cA= X-MC-Unique: rnQyNVC-OoSbBUjST9rf-g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630613; x=1718235413; 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=3+zh1wfaSmmaGh+SRQcFGybC5BaSt211Udvwvhl5h14=; b=piv6i8MO7FQweWG97kA5QyxSU4rYLT/UE2jwS3GlN+zoRTiOGMuFo9j6rLMHBSPaOs Y6SRz095SHYWgboORh4EWMA/1GaZePL83DtIa6j87mP00HaY9N5wUieJR4LIdzJpC4Vv G3UQ2LvaOTmRTkpuYFwjDt82bZANqGA95nBJloOQSKq25AU8s1ZHh3+p6IU751pbi21l 7x6oBLAM/B89/V9dPJS6gC6Thha1LNIkzPnaKLd9j0upJhwRCWWUy4E+xSX/dN3zAiSd 4I/3sYfT1hwfqDYFarQxJFI7SQDClBZuv8+kCAhYM4QnOfDolcXimZ0Tofi59KDFx0EW Th4w== X-Gm-Message-State: AOJu0Yyn95AzvpFrMDkJBX7DnPOJgIHDZMeodL3T31cad9AOh6kWTin6 MfD4xuBe9IR3nSTxrYguzgmPaT5aeiRNNEx3z+UFcokjLpph4ByXD/PcPLmXACBKN4qaG1O5/+C cTc0ix0KLCCTEeUqGtzNQu1/0qbFtPPZ5CnNnEg10wHeeYzaqf/KryYhS7jes9M0RH7A+X+0wzX uAq/noGF5wasHB64LzSkP4dKk8W7ZXpg== X-Received: by 2002:ac2:4c92:0:b0:52b:84bd:344f with SMTP id 2adb3069b0e04-52bab4fa611mr2102103e87.53.1717630612874; Wed, 05 Jun 2024 16:36:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvcl/tkwEcRJdvqS7hQhSJJ7eEYBG3IYOUSkxtH98bhFr9GJWsmh0OrM7jd0ibtjEKXwzjnw== X-Received: by 2002:ac2:4c92:0:b0:52b:84bd:344f with SMTP id 2adb3069b0e04-52bab4fa611mr2102090e87.53.1717630612226; Wed, 05 Jun 2024 16:36:52 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Thomas Huth , Cornelia Huck , Laurent Vivier , Paolo Bonzini Subject: [PULL v3 35/41] tests/qtest/pvpanic: use centralized definition of supported events Message-ID: <10856cc3ef6a9c296edaea46f2b0b7a46b7f755d.1717630437.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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630674106100003 From: Thomas Wei=C3=9Fschuh Avoid the necessity to update all tests when new events are added to the device. Acked-by: Thomas Huth Reviewed-by: Cornelia Huck Signed-off-by: Thomas Wei=C3=9Fschuh Message-Id: <20240527-pvpanic-shutdown-v8-4-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/pvpanic-pci-test.c | 5 +++-- tests/qtest/pvpanic-test.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c index 2c05b376ba..b372caf41d 100644 --- a/tests/qtest/pvpanic-pci-test.c +++ b/tests/qtest/pvpanic-pci-test.c @@ -16,6 +16,7 @@ #include "qapi/qmp/qdict.h" #include "libqos/pci.h" #include "libqos/pci-pc.h" +#include "hw/misc/pvpanic.h" #include "hw/pci/pci_regs.h" =20 static void test_panic_nopause(void) @@ -34,7 +35,7 @@ static void test_panic_nopause(void) bar =3D qpci_iomap(dev, 0, NULL); =20 qpci_memread(dev, bar, 0, &val, sizeof(val)); - g_assert_cmpuint(val, =3D=3D, 3); + g_assert_cmpuint(val, =3D=3D, PVPANIC_EVENTS); =20 val =3D 1; qpci_memwrite(dev, bar, 0, &val, sizeof(val)); @@ -67,7 +68,7 @@ static void test_panic(void) bar =3D qpci_iomap(dev, 0, NULL); =20 qpci_memread(dev, bar, 0, &val, sizeof(val)); - g_assert_cmpuint(val, =3D=3D, 3); + g_assert_cmpuint(val, =3D=3D, PVPANIC_EVENTS); =20 val =3D 1; qpci_memwrite(dev, bar, 0, &val, sizeof(val)); diff --git a/tests/qtest/pvpanic-test.c b/tests/qtest/pvpanic-test.c index 78f1cf8186..ccc603472f 100644 --- a/tests/qtest/pvpanic-test.c +++ b/tests/qtest/pvpanic-test.c @@ -10,6 +10,7 @@ #include "qemu/osdep.h" #include "libqtest.h" #include "qapi/qmp/qdict.h" +#include "hw/misc/pvpanic.h" =20 static void test_panic_nopause(void) { @@ -20,7 +21,7 @@ static void test_panic_nopause(void) qts =3D qtest_init("-device pvpanic -action panic=3Dnone"); =20 val =3D qtest_inb(qts, 0x505); - g_assert_cmpuint(val, =3D=3D, 3); + g_assert_cmpuint(val, =3D=3D, PVPANIC_EVENTS); =20 qtest_outb(qts, 0x505, 0x1); =20 @@ -43,7 +44,7 @@ static void test_panic(void) qts =3D qtest_init("-device pvpanic -action panic=3Dpause"); =20 val =3D qtest_inb(qts, 0x505); - g_assert_cmpuint(val, =3D=3D, 3); + g_assert_cmpuint(val, =3D=3D, PVPANIC_EVENTS); =20 qtest_outb(qts, 0x505, 0x1); =20 --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630657; cv=none; d=zohomail.com; s=zohoarc; b=bGWKSXUPNkl2okVnlV8R7p4CY2yZV0BJf4x3V70gEaRIGzKq6eeGNkOv4qgUGGUBbJT3TEBLvDaMSnO5MfJamSFlyctrefCHRr6jjPuhnaYDIrt9rF5JSC0LX1nDF3Pm7XvttGvvvfghSJBRqUw81/IDRMAPiVd6icXIMB9aSZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630657; 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=QnECcJhOM1bFNsQiTjayj70I6F2El0gKTbsx9XEyPm8=; b=L93/c64/HAGdsxzxALHRAQ42BlXfxfgiZbUruFV7+bGerpsCBsvP8ZKyMxjI0b5B2maVy/KSrJfLOIosGdZJ7lehMzgR/Dsvj866wHayQn/w+asg3EslbpAD5IzCs8154dfKuBDXpAs8aNFYJkyUzFJr+UGvNfvTzueyVcQ7d1U= 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+importer=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 1717630657902720.1084098134618; Wed, 5 Jun 2024 16:37:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0Bi-0002NB-Qq; Wed, 05 Jun 2024 19:37:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bg-0002CI-So for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:37:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bf-0005x0-84 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:37:00 -0400 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-466-4XyD6xl6PTyuMlAACDMgYQ-1; Wed, 05 Jun 2024 19:36:57 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a68c70ab413so22955366b.1 for ; Wed, 05 Jun 2024 16:36:57 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c8072a4b3sm6363166b.200.2024.06.05.16.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630618; h=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=QnECcJhOM1bFNsQiTjayj70I6F2El0gKTbsx9XEyPm8=; b=HyENxY+rHOne+Lh8XT0fE/rHvcELIkEl/ca+7AlScULJYWJD/CEYKBXjcxBTnF3iCC2jkl ++hDSWosNF6zbSCPqs8U85Te67Lf/e967D2UbquwpUfnbwGi34/LSVqxn8U7usmRLrcWko RZjZvEi7NAv23kIRMS+DyMsBns9acbU= X-MC-Unique: 4XyD6xl6PTyuMlAACDMgYQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630616; x=1718235416; 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=QnECcJhOM1bFNsQiTjayj70I6F2El0gKTbsx9XEyPm8=; b=c95QGgv3ZnAWSWQMdgW2o7DE/ItZALCuguW49MBjzwbEmetVWpIfkjJrm1PgwFmE2v riBSumrh7DSS+wbnKReV9veJMMXWVypV6F6tQT7+ccQETC6l1cj9Vq6e5nTsW/wXRTaT qu1zRxC5gOpAPjJwqSKvdxthRKfGtudzqldVeKzVFmAD6BhnXbU++vVm3h/PD5XrmGfx FXurobQcGz/ussVTOG/jPcMm26nG1h5PYcAZik/zpd48d6j90hWgf6kecJ4ZUFfFHjBA nMqN2Jb6Htk1EFemt2cUvBS5u0NJ8sggwF9tHSY3ys5PPyqBXgbZ8g3iGz7qSN6dqiy1 ALYQ== X-Gm-Message-State: AOJu0YyHohYIIEKz2UNJ19kP55M7o6nNTHfU2AwAAcSTDQL+BQ0xTwu/ hXzINvYfwMcxPNO84gt6TPEsFkhHp4gCTPYoWUFscXx5tyfBYE2vgr46QseA66KmaN6Mt3obQEv guBhvJqR63GmrkDnJrEnizLJgpqSa7EQ117QLeczktLtbMUFYjIGONB7TJ9FzcTDLsTQGkMQfl8 HEcvFqBDGsh1VFGVFivrseMBDe/QkSYQ== X-Received: by 2002:a17:906:270d:b0:a68:f6b8:5239 with SMTP id a640c23a62f3a-a6c75fadd7dmr87076066b.13.1717630616165; Wed, 05 Jun 2024 16:36:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqE6efF9YUDghgFRUjvdEt0MVx+5k8YmpWeKKdEDUz++R+lERaz+EC3O9nxJIr7QZMRO/xzA== X-Received: by 2002:a17:906:270d:b0:a68:f6b8:5239 with SMTP id a640c23a62f3a-a6c75fadd7dmr87074866b.13.1717630615613; Wed, 05 Jun 2024 16:36:55 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Cornelia Huck , Paolo Bonzini Subject: [PULL v3 36/41] hw/misc/pvpanic: add support for normal shutdowns Message-ID: <72b448b0eb1521e4583a2b2a7746db9704a379b7.1717630437.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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630658050100005 From: Thomas Wei=C3=9Fschuh Shutdown requests are normally hardware dependent. By extending pvpanic to also handle shutdown requests, guests can submit such requests with an easily implementable and cross-platform mechanism. Acked-by: Cornelia Huck Signed-off-by: Thomas Wei=C3=9Fschuh Message-Id: <20240527-pvpanic-shutdown-v8-5-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/misc/pvpanic.h | 4 +++- include/sysemu/runstate.h | 1 + hw/misc/pvpanic.c | 5 +++++ system/runstate.c | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h index 947468b81b..04986537af 100644 --- a/include/hw/misc/pvpanic.h +++ b/include/hw/misc/pvpanic.h @@ -20,7 +20,9 @@ =20 #include "standard-headers/linux/pvpanic.h" =20 -#define PVPANIC_EVENTS (PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) +#define PVPANIC_EVENTS (PVPANIC_PANICKED | \ + PVPANIC_CRASH_LOADED | \ + PVPANIC_SHUTDOWN) =20 #define TYPE_PVPANIC_ISA_DEVICE "pvpanic" #define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci" diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 0117d243c4..e210a37abf 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -104,6 +104,7 @@ void qemu_system_killed(int signal, pid_t pid); void qemu_system_reset(ShutdownCause reason); void qemu_system_guest_panicked(GuestPanicInformation *info); void qemu_system_guest_crashloaded(GuestPanicInformation *info); +void qemu_system_guest_pvshutdown(void); bool qemu_system_dump_in_progress(void); =20 #endif diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index a4982cc592..0e9505451a 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -40,6 +40,11 @@ static void handle_event(int event) qemu_system_guest_crashloaded(NULL); return; } + + if (event & PVPANIC_SHUTDOWN) { + qemu_system_guest_pvshutdown(); + return; + } } =20 /* return supported events on read */ diff --git a/system/runstate.c b/system/runstate.c index cb4905a40f..83055f3278 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -585,6 +585,11 @@ void qemu_system_guest_crashloaded(GuestPanicInformati= on *info) qapi_free_GuestPanicInformation(info); } =20 +void qemu_system_guest_pvshutdown(void) +{ + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); +} + void qemu_system_reset_request(ShutdownCause reason) { if (reboot_action =3D=3D REBOOT_ACTION_SHUTDOWN && --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630748; cv=none; d=zohomail.com; s=zohoarc; b=gmvEy3nPWP2krybc1fb4vfkaIFB/N3fd3GQatjzb/CvspRRem+0OT3HNHT96vfryYj0NLyCakosWicgjhC3Aj7W7EzcxuC5DS24kfZj3rzwxsXdepi5D3TdA4+XotpdYBSybG3cacOh+kgjTQ7nwKurFZ23vgYdZg9+U2uKnVA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630748; 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=kgYXT9TqVXX9/BRZFmbWBgRNk9wpbHrKyLXkpZBaJss=; b=adNtYaJn2TxV/wfuoVqnJ83fN+0L93SuMSEn0BaECA3RnzBCiytTIvp+JuDJrA2SRh3X8hR9A/O/FyGpedJIWIUqeQp666PbD0jB3Dv4VO/QyJY1AnAlGfHrqWBTuCZ/MUcAel4GbOBTjyhxTDSs++AP3tcSKMxxAU968yk2AQg= 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+importer=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 1717630748019684.0207936257742; Wed, 5 Jun 2024 16:39:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0Bm-0002mh-9X; Wed, 05 Jun 2024 19:37:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bl-0002fZ-B2 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:37:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bj-0005xc-O0 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:37:05 -0400 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-345-BUjRHvrkP-CR60Y7VvTODw-1; Wed, 05 Jun 2024 19:37:02 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-35dca0dc826so240591f8f.1 for ; Wed, 05 Jun 2024 16:37:01 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c80582016sm7121466b.20.2024.06.05.16.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:36:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630623; h=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=kgYXT9TqVXX9/BRZFmbWBgRNk9wpbHrKyLXkpZBaJss=; b=VqTR4Xs6oE5iHuDABmn2/BjUNETIh10UWLCmvHaPMNn3RB9mPL8hSssJzoVUudTUqOvcEu KYnjPrG83T1eqw6uaDYMZYwbkeGstuhIpqTdE4hYQY3YeTxE1ioe3duGx+xuZJq8vF70mj M/ObOb7N767nBdL96tM6X70cVwT4MfI= X-MC-Unique: BUjRHvrkP-CR60Y7VvTODw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630620; x=1718235420; 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=kgYXT9TqVXX9/BRZFmbWBgRNk9wpbHrKyLXkpZBaJss=; b=RzGPy/wlILB7/YTuWgz6U41OjtTLRzYFhV38klpwj8AwvC8RhpYiQPVAzIxvMBvphr 0CjwtljwfDlYCj/cBgGrD/RttgoW1Ie9wlHS61fVHZDBjvySSnewLonaTKvhfU1tleQv aYJReLdu0M3fupqlnA4rzwYq6kvPaP7gTdAGlwDaJfIUROmiMwTC6qV+5npSSaPb7rLR qlUvWpXp7JipBEUd1DGIbW+JRfrcgQpMCG0fwj+T9utWnQ6DhWJaJ66BOQXooXi9I9ln xEKx9pkEH1cfbfr2dSxGOYD8j9FFnrFtc2MJE1dmGih31yr+P4FuiHqE+CtiN9cSq7f2 0nEA== X-Gm-Message-State: AOJu0YwkbzqHmHykyoLfo3ivSmD311zvQSyG+N8QDLMNKmv65vA0BQFp AcM/0x7yq2DoHYpbR3VuEBLYw+K090grtFnUb/W0HozgZRB9+OgWioux1Y/fJtIYM0esUED9ACO bLQzUqxW2/yE9IxJ/nIF9wCLYip5fe4hj6aVLv9gSnEuiZycfihlSvcEdbmozWZ48NU6Y92kXfH asTeZTfKeNgdl+WpnHHW/wwtnrwAvVtA== X-Received: by 2002:a5d:64c4:0:b0:354:f7a4:7862 with SMTP id ffacd0b85a97d-35e883383bamr3125921f8f.19.1717630620303; Wed, 05 Jun 2024 16:37:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTn7lpYkgyQDTjc4R8v7mottzHj4Tj5yDZvbrsiaRQLlK1AuJmylfDT93c/JbXxLtTg0iWrQ== X-Received: by 2002:a5d:64c4:0:b0:354:f7a4:7862 with SMTP id ffacd0b85a97d-35e883383bamr3125907f8f.19.1717630619852; Wed, 05 Jun 2024 16:36:59 -0700 (PDT) Date: Wed, 5 Jun 2024 19:36:55 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Eric Blake , Markus Armbruster Subject: [PULL v3 37/41] pvpanic: Emit GUEST_PVSHUTDOWN QMP event on pvpanic shutdown signal Message-ID: <7572581002c9b8a74b4c4cf4f775652321068e56.1717630437.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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630748412100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez Emit a QMP event on receiving a PVPANIC_SHUTDOWN event. Even though a typic= al SHUTDOWN event will be sent, it will be indistinguishable from a shutdown originating from other cases (e.g. KVM exit due to KVM_SYSTEM_EVENT_SHUTDOW= N) that also issue the guest-shutdown cause. A management layer application can detect the new GUEST_PVSHUTDOWN event to determine if the guest is using the pvpanic interface to request shutdowns. Signed-off-by: Alejandro Jimenez Message-Id: <20240527-pvpanic-shutdown-v8-6-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/run-state.json | 14 ++++++++++++++ system/runstate.c | 1 + 2 files changed, 15 insertions(+) diff --git a/qapi/run-state.json b/qapi/run-state.json index f8773f23b2..5ac0fec852 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -462,6 +462,20 @@ { 'event': 'GUEST_CRASHLOADED', 'data': { 'action': 'GuestPanicAction', '*info': 'GuestPanicInformation'= } } =20 +## +# @GUEST_PVSHUTDOWN: +# +# Emitted when guest submits a shutdown request via pvpanic interface +# +# Since: 9.1 +# +# Example: +# +# <- { "event": "GUEST_PVSHUTDOWN", +# "timestamp": { "seconds": 1648245259, "microseconds": 893771 } } +## +{ 'event': 'GUEST_PVSHUTDOWN' } + ## # @GuestPanicAction: # diff --git a/system/runstate.c b/system/runstate.c index 83055f3278..c149b1ab4b 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -587,6 +587,7 @@ void qemu_system_guest_crashloaded(GuestPanicInformatio= n *info) =20 void qemu_system_guest_pvshutdown(void) { + qapi_event_send_guest_pvshutdown(); qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); } =20 --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630773; cv=none; d=zohomail.com; s=zohoarc; b=DqKPNhslWO1HROVvCILJDHutMMjNLsYA5zcnHNbF8DrdAXgu7oGdfWakdlWW1DjIltOycSgS2Le0dTkqlcvDOoBPAqz34pzM35WTPY97vj/ntYkgt7MoCMYaJ+byDTY6dplxEkhZ/o4GB4jRb7CQRqT9RI/o7EPG1B8C0HaPGkQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630773; 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=qGhmwqguo7pIYQaZC7WOHDuKcF1Cau7swIzTfVk8co4=; b=Z9dtHmSGPZ6VlCUmJWUpmkM1/l7fXMWK/vY7xV8GNDFu+aLfcUV4un1JgNjnLii9SyAanK6i4D3sG8F4R4mqbdDtg0CMfx2e7L/Si1CGzeUkFTPWkmm/gu9jWg+Crvls+yNycYSRRQN6l/ydiCeG6e+dceZQX/feWO/3tRo7gSE= 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+importer=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 1717630773151261.35149635557354; Wed, 5 Jun 2024 16:39:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0Br-0003Xm-Gg; Wed, 05 Jun 2024 19:37:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bp-0003Kt-Uq for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:37:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bo-0005yZ-3h for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:37:09 -0400 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-503-QeIByTx8O5uzjUBZ5tAPVA-1; Wed, 05 Jun 2024 19:37:06 -0400 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-52b83657cc3so267617e87.0 for ; Wed, 05 Jun 2024 16:37:05 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c8070e80dsm6603866b.175.2024.06.05.16.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:37:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630627; h=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=qGhmwqguo7pIYQaZC7WOHDuKcF1Cau7swIzTfVk8co4=; b=T1ULlpmkosCkUwFHjOnZr03KX7TJfe4C3TcQJX6FFkYJRqmsjPEHYnOC1Jz9dSMHcBaClP EE0+xUZy1ld6CCrX6UhB2NzojZRbbvDyyBpu4WUmzIUiMVay2RgCaOFEtAnGOYjYW+UV9y 2ZeI3XffOmJsdeOUcbsflzqsZLUd5aM= X-MC-Unique: QeIByTx8O5uzjUBZ5tAPVA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630624; x=1718235424; 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=qGhmwqguo7pIYQaZC7WOHDuKcF1Cau7swIzTfVk8co4=; b=WZlBL9TO3AG+Xx8GAqnQiEFDg/MTNTkLeNx6RKOEs8y3N9oljfa+32csdtoxq2cQtZ UCnewYHXgyuophdGopBRXUnE5jXX22KGYzf9qn42DEf18leeaeXnDpO3dI0mq5PrxXtT cHsZoVN5I/wiibTTAGTAr3Rpl1K9j9OI5VMn9bLJav4JNJys0uEdhh4668FFZ21ABrJK UjCCmN/t/UN5cBcRSWsVe8MNjI6S0dzYC/pacNbPWIqSfUW6axC0eZfl8hNtVv6+q1n0 0KzrBUyqVnYfrhAr6POPLZ+hqsOBn95ruI5mj2jFVFUcw3mgxTgjuW0nnzmAy3SAM0Le UwmA== X-Gm-Message-State: AOJu0YzgaeSPPCC6a+t2iATOL6rKyPtiqL1Ne6Fi+H6GEmRmmWx0ABVW o3GBVfGzmr5PZlwa/Ni6S+pWaaUv/tv/Sr98jHqhW2fBIGedWrtnup0hA5my62zvarXBMpdOf1W PDf1J38BDrHmNWZ4iTspTpGk0p3vfv6lme4WhKaapf017T6AnJ0aJvUC1aFj3T9qe8n4NSLcANz bKWLLk3A0WmAYaSPJMMflhj9ljRBtDew== X-Received: by 2002:a05:6512:3e01:b0:529:593f:3f39 with SMTP id 2adb3069b0e04-52bab4d7fc5mr3004949e87.35.1717630624081; Wed, 05 Jun 2024 16:37:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAVyNbLm+6cCNbrSnWunv7Ff1ZhYxquVYrLQxOSM2SpU55aqcaOIHcd7pAfyJIyKnBlZNeQg== X-Received: by 2002:a05:6512:3e01:b0:529:593f:3f39 with SMTP id 2adb3069b0e04-52bab4d7fc5mr3004934e87.35.1717630623550; Wed, 05 Jun 2024 16:37:03 -0700 (PDT) Date: Wed, 5 Jun 2024 19:37:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL v3 38/41] tests/qtest/pvpanic: add tests for pvshutdown event 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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630774509100005 From: Thomas Wei=C3=9Fschuh Validate that a shutdown via the pvpanic device emits the correct QMP events. Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Thomas Huth Message-Id: <20240527-pvpanic-shutdown-v8-7-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/pvpanic-pci-test.c | 39 ++++++++++++++++++++++++++++++++++ tests/qtest/pvpanic-test.c | 29 +++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c index b372caf41d..dc021c2fdf 100644 --- a/tests/qtest/pvpanic-pci-test.c +++ b/tests/qtest/pvpanic-pci-test.c @@ -85,11 +85,50 @@ static void test_panic(void) qtest_quit(qts); } =20 +static void test_pvshutdown(void) +{ + uint8_t val; + QDict *response, *data; + QTestState *qts; + QPCIBus *pcibus; + QPCIDevice *dev; + QPCIBar bar; + + qts =3D qtest_init("-device pvpanic-pci,addr=3D04.0"); + pcibus =3D qpci_new_pc(qts, NULL); + dev =3D qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0)); + qpci_device_enable(dev); + bar =3D qpci_iomap(dev, 0, NULL); + + qpci_memread(dev, bar, 0, &val, sizeof(val)); + g_assert_cmpuint(val, =3D=3D, PVPANIC_EVENTS); + + val =3D PVPANIC_SHUTDOWN; + qpci_memwrite(dev, bar, 0, &val, sizeof(val)); + + response =3D qtest_qmp_eventwait_ref(qts, "GUEST_PVSHUTDOWN"); + qobject_unref(response); + + response =3D qtest_qmp_eventwait_ref(qts, "SHUTDOWN"); + g_assert(qdict_haskey(response, "data")); + data =3D qdict_get_qdict(response, "data"); + g_assert(qdict_haskey(data, "guest")); + g_assert(qdict_get_bool(data, "guest")); + g_assert(qdict_haskey(data, "reason")); + g_assert_cmpstr(qdict_get_str(data, "reason"), =3D=3D, "guest-shutdown= "); + qobject_unref(response); + + g_free(dev); + qpci_free_pc(pcibus); + qtest_quit(qts); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); qtest_add_func("/pvpanic-pci/panic", test_panic); qtest_add_func("/pvpanic-pci/panic-nopause", test_panic_nopause); + qtest_add_func("/pvpanic-pci/pvshutdown", test_pvshutdown); =20 return g_test_run(); } diff --git a/tests/qtest/pvpanic-test.c b/tests/qtest/pvpanic-test.c index ccc603472f..d49d2ba931 100644 --- a/tests/qtest/pvpanic-test.c +++ b/tests/qtest/pvpanic-test.c @@ -58,11 +58,40 @@ static void test_panic(void) qtest_quit(qts); } =20 +static void test_pvshutdown(void) +{ + uint8_t val; + QDict *response, *data; + QTestState *qts; + + qts =3D qtest_init("-device pvpanic"); + + val =3D qtest_inb(qts, 0x505); + g_assert_cmpuint(val, =3D=3D, PVPANIC_EVENTS); + + qtest_outb(qts, 0x505, PVPANIC_SHUTDOWN); + + response =3D qtest_qmp_eventwait_ref(qts, "GUEST_PVSHUTDOWN"); + qobject_unref(response); + + response =3D qtest_qmp_eventwait_ref(qts, "SHUTDOWN"); + g_assert(qdict_haskey(response, "data")); + data =3D qdict_get_qdict(response, "data"); + g_assert(qdict_haskey(data, "guest")); + g_assert(qdict_get_bool(data, "guest")); + g_assert(qdict_haskey(data, "reason")); + g_assert_cmpstr(qdict_get_str(data, "reason"), =3D=3D, "guest-shutdown= "); + qobject_unref(response); + + qtest_quit(qts); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); qtest_add_func("/pvpanic/panic", test_panic); qtest_add_func("/pvpanic/panic-nopause", test_panic_nopause); + qtest_add_func("/pvpanic/pvshutdown", test_pvshutdown); =20 return g_test_run(); } --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630782; cv=none; d=zohomail.com; s=zohoarc; b=e3fJ2HCdSyvVIbTgnF1Z9pooV9rOHYSp6ljrr+xRkEGpK1Vk79XkALdia1VGTRVyKql27gO80CD7iUvBo+8NySLFAZaOs2JjRplQfIcMdix81Q7j8wWh1aT3VUe45mIZ20zOybJMnaSM0LbhuODq/vGXT2x5yZvAd6E0I0Kqsyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630782; 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=g4UiaVaJHqFRMzcgj8Lsoa2O3CKB9KU5Hs0p0vn09PA=; b=ZD0rbDn7dqULebeRo31gIqc7RxzTvZ7FFjAUaa4W3nP7xVhdCDufmzndhC42Y9py/lDtvsW9X1OhS+tl7jcwLQwInvFBDcUF9D4emhxE9vIyzs5BD62xW5UMZa+PnIEUDiK+5BDjfYXgTcJ5ssHb739IdPPIx/y924Ep2kC6zCo= 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+importer=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 1717630782301985.8426253102849; Wed, 5 Jun 2024 16:39:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0Bu-0003x2-SA; Wed, 05 Jun 2024 19:37:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bs-0003kT-OG for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:37:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bq-0005yr-QB for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:37:12 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-SbfYliuFOvSrKmKgrtaWHg-1; Wed, 05 Jun 2024 19:37:09 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-57a306c4b1eso129320a12.0 for ; Wed, 05 Jun 2024 16:37:08 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae201a6esm94575a12.71.2024.06.05.16.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630630; h=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=g4UiaVaJHqFRMzcgj8Lsoa2O3CKB9KU5Hs0p0vn09PA=; b=W3T3/mYqvI9roFRJFZU6CehW/wI5SpTVksBd9cGp/v8WEgNTuITy/C+SfxCSMzp5gNorHi B5QapFliQVmz+LReKTLChEloTki3uHnADY2kAC3bCEu9mQy/cMZxHLRdsNTruKOBrFZyhY z/VCrfNZkqdqnIQXb/f+RZqbQ9X0dtI= X-MC-Unique: SbfYliuFOvSrKmKgrtaWHg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630627; x=1718235427; 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=g4UiaVaJHqFRMzcgj8Lsoa2O3CKB9KU5Hs0p0vn09PA=; b=haHxiSXh41s3hYwkWEi58wa6hsLJMF43icZLYAbYKe/MDYsmfiOJQlPbUHhxHwR4Pw Zho0TMgBmP13s2Kep8SNUin/qDPYf2irvtWTNo4m5VhnIIU3Z0ggkhcNhwaur76cJ62e 1U2RZtXGAM0UEqKyH6dolFvGu/qWYTtH7S2hK4BgdKcCt73F9N+sbqnQVBQtQ2i+t/iK xdYdIvd87spU+kMwaL8oBhemGlzLejsTnHVZ/FDEG71WuumkYs/RZz5yeT37yc1r4S7P CK2jgGfihmV6w/HhCK7WxUtkT9plEG6rpAm1ouXl+9qp0XVaEj+ePCCnm4U6n8xwB1CU 5NHw== X-Gm-Message-State: AOJu0YyteF49wKdzYLyKDTWM1VIkNlY2Kqz8iulERz9cx1E6CicAkz+3 bdZ7HpqWj5CjWhaLbQI24kPAd6RLe/82LcKO+oajqqdJXz59xU2gGsDko7mZlEAomtiYBfdI6JX F5ZS8S0e52cNhppusnTA++E8GpK7mQ5ZrOo3N68NGUb3qQ0t6y9Au1gC9WQaXbVj6PmqX9IVv3D itxbKoLEf9sq4sLHeZojbPCFyZZDOmTA== X-Received: by 2002:a50:8d1c:0:b0:579:d01e:bc4a with SMTP id 4fb4d7f45d1cf-57a8b6f0fcamr2488076a12.23.1717630627424; Wed, 05 Jun 2024 16:37:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbgOibedZ86c6XPLojH5Srm+ffFsLXJaUTl/mdoQQBFjBkzpWcuzjgSZdRCihBWzNlCKiRTQ== X-Received: by 2002:a50:8d1c:0:b0:579:d01e:bc4a with SMTP id 4fb4d7f45d1cf-57a8b6f0fcamr2488065a12.23.1717630626888; Wed, 05 Jun 2024 16:37:06 -0700 (PDT) Date: Wed, 5 Jun 2024 19:37:03 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Subject: [PULL v3 39/41] Revert "docs/specs/pvpanic: mark shutdown event as not implemented" 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+importer=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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630782605100006 From: Thomas Wei=C3=9Fschuh The missing functionality has been implemented now. This reverts commit e739d1935c461d0668057e9dbba9d06f728d29ec. Signed-off-by: Thomas Wei=C3=9Fschuh Message-Id: <20240527-pvpanic-shutdown-v8-8-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/specs/pvpanic.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/specs/pvpanic.rst b/docs/specs/pvpanic.rst index b0f27860ec..61a80480ed 100644 --- a/docs/specs/pvpanic.rst +++ b/docs/specs/pvpanic.rst @@ -29,7 +29,7 @@ bit 1 a guest panic has happened and will be handled by the guest; the host should record it or report it, but should not affect the execution of the guest. -bit 2 (to be implemented) +bit 2 a regular guest shutdown has happened and should be processed by the host =20 PCI Interface --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630782; cv=none; d=zohomail.com; s=zohoarc; b=T+TRTsQ1UUeEi6KbiCpWN0KeTQ51+TS9JjDfQkV5cstqC4ttmJKpGJ1P6J2Pk2u0FA3kDVYKeT0C6rftsBet2o7eQsJmc1ZI5yxqhHE/yK9ZEv9lzJP2DNvhTWktkT95iJFpD7XcTnp4k4lzc0EVXhbaukr7xgFyNsBfA2bld6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630782; 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=PMqT3UA862JsOGcigX9iEr1iG7UpaUmQpd1D/p7t/1Y=; b=EXfyludGwoXoNoabxisCk4e95jPmRU8hwyMaVCu24WDxJlvf0Vy3j3pFj44GBIA7xKXmAOK0jSYjzUF5NYZXR8FubQe149RVtjB8LuiMyrKJiFwkprQzTC6T661JwL6b2Bl0A3nIz27UhLSiyP+Sk2hGiRVtwHgKDh3Zaqnh/1g= 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+importer=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 17176307822981000.7931185502447; Wed, 5 Jun 2024 16:39:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0By-00045d-Fz; Wed, 05 Jun 2024 19:37:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bw-00042t-S0 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:37:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bu-0005zd-J4 for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:37:16 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-QslGs5HEMLaROMgX6DBifA-1; Wed, 05 Jun 2024 19:37:12 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a6912c4ddb1so13149666b.1 for ; Wed, 05 Jun 2024 16:37:12 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6c8058272bsm7331466b.18.2024.06.05.16.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630633; h=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=PMqT3UA862JsOGcigX9iEr1iG7UpaUmQpd1D/p7t/1Y=; b=QPDTphPx5tSPVQlK+rOKgqPz2OFCQLjGxUtb9YnLGUfu0SUyjq93/tKCEesLQhOGijz39N 4UVubpW6appNrB4qUF2VUd2fJKL2bYk56ZROcYYJqRtQvsUIRPtqjmSvrDlE120PeH31CR pxFWDeGt7GD1DlJIo5gKEi8xVg7quos= X-MC-Unique: QslGs5HEMLaROMgX6DBifA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630631; x=1718235431; 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=PMqT3UA862JsOGcigX9iEr1iG7UpaUmQpd1D/p7t/1Y=; b=YcvdIUtW5SGtNqGLLab53grbJ7VSYfMPdb0BN9NGyH6RM2FAOMGx9CGYVKMTepiDhe UvZLLc2X4+Wb8nYg589oMW0jz/qotBIGFnF6MAaH8+bccpyFmtjgd96MyWUICYDEg1C8 Dy3DoBWtsdOB08gCQ5jyVG1EYNzffO9xag1V3CrLMKfLv8PWDvo+XHoUdJGs8KUr6jch a2U5Bb92B/FJVgf/MnX7NvEpQARqDXXs2Oi6k+Vjt8UTZ15ZgAMsiR2UQ2RKz/Rm1Viq AYLn/asQxsazzJXdgfqg6ltYUY1SIRolur0UL3EA7+N9xFtj8VbOKZAjM/tV7oI21nD2 AmYA== X-Gm-Message-State: AOJu0YyDpTFdhEJXMngvxRYV5JjIl/A2cCOXAE6xXCEjoZLTF5KKaGDG 4HCJLLKHtD2xTEp0lDFz43FK/cQ4w+7sDvlbB//Jlrd6x+OdXCnXtQPim5sHkDzBaj0zINKoXiB EPxTgQZEuYoy+kA0nz62zW/xRfByvWmWZ6d8mZlxg+pGGqYqNUEv2AD0Ow5XDSJ6Tp7x8UZJhyO PI0fXqWsvd9lMjDMIT0HofI255ohtD0Q== X-Received: by 2002:a17:906:d110:b0:a59:9c58:763a with SMTP id a640c23a62f3a-a699f88ad1bmr249822066b.46.1717630630905; Wed, 05 Jun 2024 16:37:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzcKHMzicOsYtJEO7oAR4sTC6yaeh8nAVnUGNsazR6tS0Nqiq+vWPS/M5sOj/96dCNT2aZuw== X-Received: by 2002:a17:906:d110:b0:a59:9c58:763a with SMTP id a640c23a62f3a-a699f88ad1bmr249821266b.46.1717630630310; Wed, 05 Jun 2024 16:37:10 -0700 (PDT) Date: Wed, 5 Jun 2024 19:37:07 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Cindy Lu , qemu-stable@nongnu.org Subject: [PULL v3 40/41] virtio-pci: Fix the failure process in kvm_virtio_pci_vector_use_one() Message-ID: <07f799c8136c57913223930aed41dc6bef1854a4.1717630437.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+importer=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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630782603100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu In function kvm_virtio_pci_vector_use_one(), the function will only use the irqfd/vector for itself. Therefore, in the undo label, the failing process is incorrect. To fix this, we can just remove this label. Fixes: f9a09ca3ea ("vhost: add support for configure interrupt") Cc: qemu-stable@nongnu.org Signed-off-by: Cindy Lu Message-Id: <20240528084840.194538-1-lulu@redhat.com> Reviewed-by: Peter Maydell Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 7d62e92365..5941f1a94d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -898,7 +898,7 @@ static int kvm_virtio_pci_vector_use_one(VirtIOPCIProxy= *proxy, int queue_no) } ret =3D kvm_virtio_pci_vq_vector_use(proxy, vector); if (ret < 0) { - goto undo; + return ret; } /* * If guest supports masking, set up irqfd now. @@ -908,25 +908,11 @@ static int kvm_virtio_pci_vector_use_one(VirtIOPCIPro= xy *proxy, int queue_no) ret =3D kvm_virtio_pci_irqfd_use(proxy, n, vector); if (ret < 0) { kvm_virtio_pci_vq_vector_release(proxy, vector); - goto undo; + return ret; } } =20 return 0; -undo: - - vector =3D virtio_queue_vector(vdev, queue_no); - if (vector >=3D msix_nr_vectors_allocated(dev)) { - return ret; - } - if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - ret =3D virtio_pci_get_notifier(proxy, queue_no, &n, &vector); - if (ret < 0) { - return ret; - } - kvm_virtio_pci_irqfd_release(proxy, n, vector); - } - return ret; } static int kvm_virtio_pci_vector_vq_use(VirtIOPCIProxy *proxy, int nvqs) { --=20 MST From nobody Mon Nov 25 02:49:08 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717630695; cv=none; d=zohomail.com; s=zohoarc; b=dst5STKezK2QPgLhC+AnbwhZIBGDnmsIKHfq0+S8jZXlt/SvID56CJkq4W3RNU7V53T1GBxHTNWrrH3mk6tdzQOdseHbS10N5oSJ8aHt1BBzN/Li7cUz+GCeOrkXVEbieOeZtQ1fWvjHOIl6oABFMnZKkHF+Iim9j3L+Sfsr0Cc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717630695; 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=NEpjbSqv96acXddAF0b5elzpuXpH+2dtKbhhCEe0wtQ=; b=mzyrbnYn0Cir7qnW13D3LZJIyq0lnw0g1wz4NuU2MRt8zU8ak8wZYbcGCBLAApYGLv75JCJpVJpIG7sTs3IXfdDHAWu0vnTFzGplmQ6XRbmoGZa1tWmpAAvXePWsYJ9EuvtO0g91qxwtU1M9yZXQV0rF90uxQ/no0g1f4Kyuw44= 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+importer=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 171763069593136.624574374705276; Wed, 5 Jun 2024 16:38:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sF0C0-0004KY-Ve; Wed, 05 Jun 2024 19:37:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bz-0004Ck-Ct for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:37:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sF0Bx-000608-OT for qemu-devel@nongnu.org; Wed, 05 Jun 2024 19:37:19 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-395-APeOamKoOwmtussc24GMpw-1; Wed, 05 Jun 2024 19:37:16 -0400 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-57a5af3e160so123053a12.2 for ; Wed, 05 Jun 2024 16:37:15 -0700 (PDT) Received: from redhat.com ([2.55.56.67]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57aae232981sm94523a12.83.2024.06.05.16.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:37:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717630637; h=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=NEpjbSqv96acXddAF0b5elzpuXpH+2dtKbhhCEe0wtQ=; b=dw6mLnElFjyzh2XFScvqDECHKhh0jp/2NSi0pxz6kjGMVYUaqebuh4LpWeUQfgcZDxc4dn N11zgTYdfpnaXk4O7Ishbhzmt/hliB3p7Z1roDgb799TUpMbw8t5G2P8bkztKT/xGox2le vKZctlUHg9OVmeLHEXahcdQBfNosa7E= X-MC-Unique: APeOamKoOwmtussc24GMpw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717630634; x=1718235434; 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=NEpjbSqv96acXddAF0b5elzpuXpH+2dtKbhhCEe0wtQ=; b=X8ELUM5X8JYC/4jHL3OhZNimEWwwGzdqE3OAL1vfKoWzfb+AavGF6P0axZHCJjVBqq w2Dv6ePIjvS1gbO7MGTAFTlMUqTmLhCnklP/mPBB0FYOLNPJKFqTn8MFR0H2jZaXYklO XPFd8qMcAT2dcLstg6IERG4Om4srvpcvYj5lU7/fM7O6vAEhMnTMcordfhSaAbzyY8zZ 7OoGM2zWytKJcVQJDbaDcYR6R3dAz91X7E4XzLnOFQx5pAfGyEsO6O+TyrDDivBymp3h XcTVOUIz9tWAojEv5uOgBnjgELxPI/zp0CPfOXg8mekRcOlitSXumeuIV784JOf2JO3A bqSg== X-Gm-Message-State: AOJu0YzMTocPyXbo4XzCIiaghPiQ0V0csQ/qXFaLoVrZBgx+5c4cnjSt yMhy9HOqTaZ2O/OFl1kbo2xPG1PKPnRls7WEmatHTQQarh8JlJSLmzTK3O10rtutqfiHFz+ADh/ pJ1hXFYROdUUSDzuKbFp6lNqFX7A9OK6Sw2dBWH6vX+OyTQS9mFatNOhOSCnQYf513FgDXhQwXp F5CmLsNOH+Tak735EwaRDdz+iUTTI8cQ== X-Received: by 2002:a50:d65c:0:b0:578:6242:d4b0 with SMTP id 4fb4d7f45d1cf-57a8bcb4ca9mr2059814a12.40.1717630634418; Wed, 05 Jun 2024 16:37:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhi2me5gPKMEG9l56JsDuYLeU4ReoKd1933zdsMlTCTE/dDagUJYZgm3KlVapvCJL3Qj72IQ== X-Received: by 2002:a50:d65c:0:b0:578:6242:d4b0 with SMTP id 4fb4d7f45d1cf-57a8bcb4ca9mr2059805a12.40.1717630633937; Wed, 05 Jun 2024 16:37:13 -0700 (PDT) Date: Wed, 5 Jun 2024 19:37:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ira Weiny , Jonathan Cameron , Fan Ni Subject: [PULL v3 41/41] hw/cxl: Fix read from bogus memory 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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717630696203100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ira Weiny Peter and coverity report: We've passed '&data' to address_space_write(), which means "read from the address on the stack where the function argument 'data' lives", so instead of writing 64 bytes of data to the guest , we'll write 64 bytes which start with a host pointer value and then continue with whatever happens to be on the host stack after that. Indeed the intention was to write 64 bytes of data at the address given. Fix the parameter to address_space_write(). Reported-by: Peter Maydell Link: https://lore.kernel.org/all/CAFEAcA-u4sytGwTKsb__Y+_+0O2-WwARntm3x8WN= hvL1WfHOBg@mail.gmail.com/ Fixes: 6bda41a69bdc ("hw/cxl: Add clear poison mailbox command support.") Cc: Jonathan Cameron Signed-off-by: Ira Weiny Message-Id: <20240531-fix-poison-set-cacheline-v1-1-e3bc7e8f1158@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/cxl_type3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 5d4a1276be..3274e5dcbb 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1292,7 +1292,7 @@ static bool set_cacheline(CXLType3Dev *ct3d, uint64_t= dpa_offset, uint8_t *data) dpa_offset -=3D (vmr_size + pmr_size); } =20 - address_space_write(as, dpa_offset, MEMTXATTRS_UNSPECIFIED, &data, + address_space_write(as, dpa_offset, MEMTXATTRS_UNSPECIFIED, data, CXL_CACHE_LINE_SIZE); return true; } --=20 MST