From nobody Mon Nov 25 02:29:59 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=1717528025; cv=none; d=zohomail.com; s=zohoarc; b=fbCAePL5xHfRv5L19HeNs5zpb3dqNBBqQ6+8OsIzb9W3t6vOYGn7p635gvScDo81qsdI2ynyyP7dxOivCb9nbunFpT431w4tR2pjBfjA+tC+T37jAAKcfrv5tcoFqCt4UYJDId5/X1X5nWqRQs4J69PAcrEJnDpACkk4PBDZ/es= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528025; 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=VkVXaP0CQIGx0w6scuQhuBPd6sxOS695DxxRZ+3vlgeCMz0/OsP6v+k2kbkR+SF68AfCmrpf6tSKgSBJXW/PT846/Ztm3q9zMDrKw4FeHczKMqy88dFgCGD5J0Rw5B3EVI5kswnNu1cHRlpGeY/K8HmylR+pJWYBIGr3giNypc4= 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 1717528025438222.6223050947566; Tue, 4 Jun 2024 12:07:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZU5-0004xz-H7; Tue, 04 Jun 2024 15:06:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZU2-0004xH-Us for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZU1-0000gr-Am for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:10 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-470-hArG0UZaOTagcJQ8XjIjYg-1; Tue, 04 Jun 2024 15:06:07 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-35dca355ffaso3517561f8f.1 for ; Tue, 04 Jun 2024 12:06:07 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35e7e07d7besm2777211f8f.18.2024.06.04.12.06.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717527968; h=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=GdHye96uTOtEpCtgGtHa1xVgQ1i7cSXRSSzdb22g475+UHNfO2u2RvySIHWHq799sd9iFA PO8B+lL2M7HBpRK2Vs1bsHYMMstXkfVZF4Vz3fmKlr9uIgZPBqRoLajpkSvBa7qwriG63l CtO+F9AcrzpxDwUAHG+wusAlxL9n+Qc= X-MC-Unique: hArG0UZaOTagcJQ8XjIjYg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717527965; x=1718132765; 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=UkdPE7RGMP4Vh/ZW7zd0ttra8G6T8eDeULppt7Hu9wKUwk97SHpWeJWJER/7REp2tr SEs08TcG6XERq+VUeRlWJwpbiJtgdboz2yketX+RCyEiuzWCfCyYLFNkYdMaRXnEUohQ cfj5vdnvNYEMQZdT6yH5dgvPFbGHfxcYi96kwoLCZLsgy6P1/4am54wCHFWdGic7vmD/ rkzCZ8BNHBnxX7tEjeZmDxbscB5NeHkefCSITKgRDSu5XqOEZ/nc3rnOslMMNo7jMIpD ybZh2AvA2YPHQay686CENtKsRdG04E2McrRKTkW+jnJZTFWfEdkcc97sZsMlD8771dm4 ZfxQ== X-Gm-Message-State: AOJu0YzU/4xnwbEKYKuPIM0bDamQmw/stCR3oRMcjrfps4Fm/LbEVwJI HZsdiuiWrLct5ReEjFOTUT55Q5dwpHDPUps6YgUIjj/4Jap3kHiZHe2JdOR8xyFwHnblPtqf4qB 8oL7OxXURQ1fZPV1+JcGXqf/dLyR50Qt6crhLjQdDvYhn8Db4qxJopbYkeIErzkHfzwMZXxIMvq rcfCsEIDzMnuZF8U/AZBPeen5qMUiT9A== X-Received: by 2002:a5d:4e8f:0:b0:35e:5b2a:1191 with SMTP id ffacd0b85a97d-35e840678f7mr230996f8f.18.1717527965345; Tue, 04 Jun 2024 12:06:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOlKd+Sx9HuvNacLdaJyPkWeq0f6MFm6oxM6nspWlljSJryAxVZnZo6ksCGJhsM0n5My5Ixg== X-Received: by 2002:a5d:4e8f:0:b0:35e:5b2a:1191 with SMTP id ffacd0b85a97d-35e840678f7mr230969f8f.18.1717527964668; Tue, 04 Jun 2024 12:06:04 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Si-Wei Liu Subject: [PULL 01/46] vhost: dirty log should be per backend type Message-ID: <0b7ca10a059089caef535e86c6523991240e5f29.1717527933.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: 1717528025675100001 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:29:59 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=1717528046; cv=none; d=zohomail.com; s=zohoarc; b=Uy4CP1ssc1j/YFYy8L350+i2HllqtKjviSO5ZxPRN+3QJr40jnnryIiydlfVjBRkiNzlJ+BZ2g13xz8DJeu0nwMP12y9O4QeelH0p3v1Yvu25sbUfsZg9nBECvGMsZRznKfRGCLsUfSubWkYG6kckQA92dCYV6lQmqGax0mZnuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528046; 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=dLjAm1wsnDHM5gs1RJjNiWMe9XJJqtEIOVcr5RRyOQOnbPJAfTp4QjQ0hT01xMZyH0XIYNWWq+dxavB7YXeMHUjxsGQphc4U8uyvE88XOMKJjqaQSC8+sqLowqavJdGA0tLH1yfUS9ZYYlw3JiASW1UDCJGhI/45vbdK+blrGBo= 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 171752804651235.48038110844152; Tue, 4 Jun 2024 12:07:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZU9-00057D-2k; Tue, 04 Jun 2024 15:06: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 1sEZU7-00053Y-Qn for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06: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 1sEZU5-0000h7-Fi for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:15 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-237-zu0S4yi2PCGTzxMdWdIqMQ-1; Tue, 04 Jun 2024 15:06:10 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4212abc353dso35565385e9.0 for ; Tue, 04 Jun 2024 12:06:10 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4213b9ef46asm92011215e9.41.2024.06.04.12.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717527971; h=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=M0q0UG4tBCtE9P6DQnIwZvcFsV+JXY0qjsyPHRbzFyFr2sjSORvpGR/T6obqep4mSH/EK3 WigJbXI289VSZT0DNx5c4wLCBoHFz9vPTmj8Z9+kARSnewV9E46r2/zdaec5UYW6EnNO1I 9jRE0Xis7IsB1EULmTV4FcpI7zlUiEQ= X-MC-Unique: zu0S4yi2PCGTzxMdWdIqMQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717527969; x=1718132769; 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=AVxwj0KUiAIBzxhm33VR5L0pArL5lyuIM9T4eR4Z34cWa88ohNJl7SPHihA0tqybQn aOlB+8l21Ljna7DhjAC8/3SlC695R7EGGxaIR8rPR17QHZ4B/m/ITRvp2k6VNNxSIqlB nDmzPT3MEW6uwVQyrPVjJlXN+F+V+/ZY4egg59XP4t3YGNuzQ1/gHMJ0sHR/3nPhmJSu rNy5YcmNJAjsdNxwrvAxdaZmizEtDjy26ZrB1KHoOy6FrUOWHG7snqZCyfWqcDE9WBx2 X1pdPTSg8c8Rh2VNyXqPJdu/o0DQAkhByGGDRXe9hTMxJJqjnwhL9+THAvHnf7QS6xTI yfLg== X-Gm-Message-State: AOJu0Yx7SwZtfus2eT3JpgzF73/AWokeCDbZWyvoV5tZUEXYhA6TQ6UB R2jqWPzdHRB6Q3Ww6N0PI/5Qd9ovoKxsYVPUwyrucv2OrqbMerOiQz32PFv8yEe/hsr4ulam6mV tidlEf2GgIz9CoAaRtpluL/Y+ofjku8bcC+uHHape+TmsGJt/A6n8fVOolsFbShNU2Ilbt0Ny0+ 4y91fKtWFAqV+hWCHsP+A4z3kSrtT58w== X-Received: by 2002:a05:600c:19d3:b0:421:2a49:cf34 with SMTP id 5b1f17b1804b1-421562d4742mr3894855e9.5.1717527968798; Tue, 04 Jun 2024 12:06:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGtBfwHnGTTIHRoK9/nX3K1E2quhQS3O2K0SJyofP18sr8x/iPbw+iMxmogic0DpC0EBn/suQ== X-Received: by 2002:a05:600c:19d3:b0:421:2a49:cf34 with SMTP id 5b1f17b1804b1-421562d4742mr3894605e9.5.1717527968307; Tue, 04 Jun 2024 12:06:08 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Si-Wei Liu , Joao Martins , Jason Wang Subject: [PULL 02/46] vhost: Perform memory section dirty scans once per iteration Message-ID: <1775c641d54dcb24bc485ac5c871c97e85f985d8.1717527933.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: 1717528047840100001 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:29:59 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=1717528105; cv=none; d=zohomail.com; s=zohoarc; b=W7DAtTsByFbNoB3tubkoMTwuhq8/RVZKCWYfDmCg9xZjns3eH9gzKB2KDGwnwEoUXOMqwGRCrdapLDG2jCWHtPnV4JrFehFIs7X1AtfLri5yMaYRy5wreLtkaRWNFwMwP7srG99aDWuBzrEE22f3B9GkEJKkPEw4SS2xL/d95dI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528105; 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=hs/LS9HNVREhvpWEgCOzgwXTTZ5sc+B5uMU5qFtMd1+6W5bVbTmDc/pC5Ccqtgx00CR0cg61ginDkoQEDfxFRwAxHcJU9T/1rMMo1BALJFjC7CjqCRtHSbkvH6XH0eEx3D93lULw0wWFyK/U3m/+thwVHOJA9xNX3z+V0iwt4Ns= 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 171752810522550.36513438663383; Tue, 4 Jun 2024 12:08:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUE-0005Yq-Bv; Tue, 04 Jun 2024 15:06: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 1sEZUC-0005PY-LE for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06: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 1sEZUA-0000im-1w for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:20 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-336-0NRGOMprOlm5Utu7VIXHhA-1; Tue, 04 Jun 2024 15:06:14 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-42135f6012fso26193135e9.3 for ; Tue, 04 Jun 2024 12:06:14 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4214186ccdcsm55364295e9.16.2024.06.04.12.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717527976; h=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=huibwigyarAOcnqRZY9U2tDhRYPRITk/YBopXc56wEHHoZB8khT3hiwY4zyGPV2/QP9bRL k7WnC1YaScnFqGwVfUok/Sninas4OFJctDdcTlKxqjRx7O2o4D/liSTgAJVfEH0LRv+f7p p1ZxaVN4HceK3N0pz/KDJSsR+wW7d/E= X-MC-Unique: 0NRGOMprOlm5Utu7VIXHhA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717527973; x=1718132773; 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=YYdRVlbH3Rs8QZTxM6/QRnotCTLKuWWEYG+qP8usNjZmuTu/CbAAR623GY1kE6D/M0 mEr/TnK0EHVtPAA1TJLRCCVCO67nM2Jd0Wd4useq6Y/wMeaUxc75r9k3Sz4WCO3ZhdDk Mj6rOGNBqDEjwqalNSvaxBvVaEMj3aOxWT133SnNgKby0uV89/t5dAe+605pTjzrrMg1 TSGAa2TSc8OCbOg7ey2nZOHBLSspyCPoRiK9cbSyHImwhIZGeLTCadW7xQi55MOmOnPy cUJuBQmlEGnFAuPK+pr1w19nHWIGEwHx2iNkkOmoyPYcD31TIGISjoSDrZnRFdPKDGz6 4DXQ== X-Gm-Message-State: AOJu0YxEf0xT5svcenPTelNsXTVRvvQznAaHO5mbRAVRnm4nTwECR16D w9HUZbvV/QBN90tILG9txsrOaHuMcr9RofqhUiWCVyA2zAdn4sL2AZU6tuGW2C1duaccQLzGU9A K9Xl/F9EIDwKtyU/olFEsYqvYvlXtGgO5WM66PLNxX3FALTXkmG1frsMTW9ShfJBiRcgFejFLJL n++MXL9VGpDl0KRCLnoR3lx6o5xxIqFw== X-Received: by 2002:a7b:cd85:0:b0:420:ed93:bca0 with SMTP id 5b1f17b1804b1-421562e9366mr3550055e9.20.1717527972750; Tue, 04 Jun 2024 12:06:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4VzW6OR+uKxY3UrzoPpk1qfCMov4uHjG7C23bOqVItncYMFhOCI4rDhAVCXwerrB74gWJiA== X-Received: by 2002:a7b:cd85:0:b0:420:ed93:bca0 with SMTP id 5b1f17b1804b1-421562e9366mr3549915e9.20.1717527972251; Tue, 04 Jun 2024 12:06:12 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:08 -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 03/46] vhost-vdpa: check vhost_vdpa_set_vring_ready() return value Message-ID: <982ae85fe81e3849e27d9eacad85c2ffc131d7e3.1717527933.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: 1717528106099100001 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:29:59 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=1717528070; cv=none; d=zohomail.com; s=zohoarc; b=Fk0zpm+RIZkA7xdIHEBgMMQPJYNuyDBR6n2Hc6aRNhkKqfvDQC1rt/TzW80dTeEoqXMof3W9M+pR+MtorWhC9rkmHKW/ZcTPY3fxc/opXZ/OGlQyDA429Mcovzq0uNnzl9xeDKIsi+MhcuKdhUaxuMb0X565WO9UgLOBrpNVm3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528070; 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=m2Wvy0LGpm4pxtnl88LpvbhL/o1XmX9DIATppvWqzCs=; b=QxjDNub44cT5CpJCGI4FOkl2o5e04XXBsMjPK+KAXCWK12COD3T5ggZEeY0dzoQD+RuSGntUb6UDWc6/Cn/sLuOHN4etOqGxZZxyjARmgnsJNkTiQ4NGIxgAMELr+1Lzpn83um0GfLFNUdNtIaT0WRc3jcvSMNhaaA9J9hUGx30= 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 1717528070689552.144108470791; Tue, 4 Jun 2024 12:07:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUI-0005iB-6v; Tue, 04 Jun 2024 15:06:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZUG-0005gh-CP for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZUD-0000jJ-P9 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:23 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-573-wwLki5eDOgOrX8tzsZX_2w-1; Tue, 04 Jun 2024 15:06:17 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42129affd18so29150885e9.1 for ; Tue, 04 Jun 2024 12:06:17 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42148ae3262sm40513905e9.7.2024.06.04.12.06.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717527979; h=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=m2Wvy0LGpm4pxtnl88LpvbhL/o1XmX9DIATppvWqzCs=; b=RCz7Y62+qN/S2XORY8iNbU7XJaB2Z+pt9NtqsGk/DfM3LkZCm16Qrp8p74hMofaRvNX0ML h0/fHcfp2QJVUM7CvXzkxH9C0bvogG2hNaHAVCzAEm5vdmlV0WiA4YK4YKvvoeFux1Ppb2 CoJDjXCKGcQAxZZ3xPUu+bN4JZQJLb0= X-MC-Unique: wwLki5eDOgOrX8tzsZX_2w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717527976; x=1718132776; 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=m2Wvy0LGpm4pxtnl88LpvbhL/o1XmX9DIATppvWqzCs=; b=BTq0mgOWTwCNJyhJ7H64qw/z8vKOjec85jAinm50wt1d5IF0EQyikoeD7LRjAp9p7H SlSMpxCBkgwIYjWs5pvQFBy5VXNaAUvNflFUwbDHaRQkZ0Z9qBkCzqbvXWrAwOQNKb0k XZORZOADoCwwlfUgnkUHwLnr/LMRATUxt/ee6NYffAScFl1mEIQ7x/nJk4IpabLWo7Fp ZlveRBvFHBgPz6c4eKNXpfNOLTkwLvlg9Mvv/a3hnqTnHUcJQneYsnFgBG6YiiamwCPC VovOoPz2fFJbKAzKK9v9eG8ULjCv2VjZ1QTplIxGtgjGOnxn/RyK3wy+/reoXKbYgJ6q 5WQg== X-Gm-Message-State: AOJu0YxiQBQaXwUfGMkb7Xb8+SJSqucj2kD23o5Br4UVfQIMip4KVWmS R//cI5GMIbmZAot/mMCgVlzX0qiF4PuwXQQ5HKwpNSa/tePZPPkPiPRStjbx5KCQvKvL3XJMwfK vb1DwL51Yrtx4e3VWeUAOoqFtxEriPdMI4GwPCDRM4G14NdMN87kVW2dNDw9naNZNdM19QZk1XR 8RIF8a48a5b87bmC6ZcD2/Q20n/Xliig== X-Received: by 2002:a05:600c:3d8c:b0:41b:f979:e19b with SMTP id 5b1f17b1804b1-42156354bf2mr3566275e9.39.1717527975902; Tue, 04 Jun 2024 12:06:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmLiVd5yPSkOWa/vx0BNdG7irCuPKIAPteu5qGfNJGDptGsgBDi5QIFQqenEsSOSgWApwpZQ== X-Received: by 2002:a05:600c:3d8c:b0:41b:f979:e19b with SMTP id 5b1f17b1804b1-42156354bf2mr3566095e9.39.1717527975438; Tue, 04 Jun 2024 12:06:15 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:12 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Cindy Lu , qemu-stable@nongnu.org, Jason Wang Subject: [PULL 04/46] virtio-pci: Fix the use of an uninitialized irqfd. Message-ID: <7eeb62b0ce3a8f64647bf53f93903abd1fbb0b94.1717527933.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: 1717528071965100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cindy Lu The crash was reported in MAC OS and NixOS, here is the link for this bug https://gitlab.com/qemu-project/qemu/-/issues/2334 https://gitlab.com/qemu-project/qemu/-/issues/2321 The root cause is that the function virtio_pci_set_guest_notifiers() only initializes the irqfd when the use_guest_notifier_mask and guest_notifier_m= ask are set. However, this check is missing in virtio_pci_set_vector(). So the fix is to add this check. This fix is verified in vyatta,MacOS,NixOS,fedora system. The bt tree for this bug is: Thread 6 "CPU 0/KVM" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7c817be006c0 (LWP 1269146)] kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:817 817 if (irqfd->users =3D=3D 0) { (gdb) thread apply all bt ... Thread 6 (Thread 0x7c817be006c0 (LWP 1269146) "CPU 0/KVM"): 0 kvm_virtio_pci_vq_vector_use () at ../qemu-9.0.0/hw/virtio/virtio-pci.c:= 817 1 kvm_virtio_pci_vector_use_one () at ../qemu-9.0.0/hw/virtio/virtio-pci.c= :893 2 0x00005983657045e2 in memory_region_write_accessor () at ../qemu-9.0.0/s= ystem/memory.c:497 3 0x0000598365704ba6 in access_with_adjusted_size () at ../qemu-9.0.0/syst= em/memory.c:573 4 0x0000598365705059 in memory_region_dispatch_write () at ../qemu-9.0.0/s= ystem/memory.c:1528 5 0x00005983659b8e1f in flatview_write_continue_step.isra.0 () at ../qemu-= 9.0.0/system/physmem.c:2713 6 0x000059836570ba7d in flatview_write_continue () at ../qemu-9.0.0/system= /physmem.c:2743 7 flatview_write () at ../qemu-9.0.0/system/physmem.c:2774 8 0x000059836570bb76 in address_space_write () at ../qemu-9.0.0/system/phy= smem.c:2894 9 0x0000598365763afe in address_space_rw () at ../qemu-9.0.0/system/physme= m.c:2904 10 kvm_cpu_exec () at ../qemu-9.0.0/accel/kvm/kvm-all.c:2917 11 0x000059836576656e in kvm_vcpu_thread_fn () at ../qemu-9.0.0/accel/kvm/k= vm-accel-ops.c:50 12 0x0000598365926ca8 in qemu_thread_start () at ../qemu-9.0.0/util/qemu-th= read-posix.c:541 13 0x00007c8185bcd1cf in ??? () at /usr/lib/libc.so.6 14 0x00007c8185c4e504 in clone () at /usr/lib/libc.so.6 Fixes: 2ce6cff94d ("virtio-pci: fix use of a released vector") Cc: qemu-stable@nongnu.org Signed-off-by: Cindy Lu Message-Id: <20240522051042.985825-1-lulu@redhat.com> Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index b1d02f4b3d..a7faee5b33 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1431,6 +1431,7 @@ static void virtio_pci_set_vector(VirtIODevice *vdev, { bool kvm_irqfd =3D (vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) && msix_enabled(&proxy->pci_dev) && kvm_msi_via_irqfd_enabled(); + VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); =20 if (new_vector =3D=3D old_vector) { return; @@ -1441,7 +1442,8 @@ static void virtio_pci_set_vector(VirtIODevice *vdev, * set, we need to release the old vector and set up the new one. * Otherwise just need to set the new vector on the device. */ - if (kvm_irqfd && old_vector !=3D VIRTIO_NO_VECTOR) { + if (kvm_irqfd && old_vector !=3D VIRTIO_NO_VECTOR && + vdev->use_guest_notifier_mask && k->guest_notifier_mask) { kvm_virtio_pci_vector_release_one(proxy, queue_no); } /* Set the new vector on the device. */ @@ -1451,7 +1453,8 @@ static void virtio_pci_set_vector(VirtIODevice *vdev, virtio_queue_set_vector(vdev, queue_no, new_vector); } /* If the new vector changed need to set it up. */ - if (kvm_irqfd && new_vector !=3D VIRTIO_NO_VECTOR) { + if (kvm_irqfd && new_vector !=3D VIRTIO_NO_VECTOR && + vdev->use_guest_notifier_mask && k->guest_notifier_mask) { kvm_virtio_pci_vector_use_one(proxy, queue_no); } } --=20 MST From nobody Mon Nov 25 02:29:59 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=1717528032; cv=none; d=zohomail.com; s=zohoarc; b=g8CkPo2SSUPKv+tbHRN3ehX25Ta0V0oR335ZWBMKlXX/50tBM92rWo3Yvkq9R0seUO6iGhrXKiU17pV/doCiOLqvCA6VoOhFmpzHKCpuDrJS5KpUTqcmLI8mCJnirlxWeproBKiNMHCbslnsNDuB4+R2N3YJO+pRhSAST+zlBms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528032; 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=dtEoeRDSt/hukSx1+wwR8G88DQKSruaP42MuHd75N3g=; b=IfPsK1/gobUODEZjAubQ7K0oVqTOl8oUgNFEGTzr1Jsp/G608h8UDlrG+GEuvBRiM1QcFjiVhAToNM80PwV+0EskTyqDORv6eMY2xJ0HUmkqLjOAm+Ss/3yW5oTYXNWKBntNpANxeKXpnYiOvOnakUTWubxsbTLvu0E/x9CoT0g= 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 1717528032872818.7639531473678; Tue, 4 Jun 2024 12:07:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUM-0005nF-Id; Tue, 04 Jun 2024 15:06:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZUL-0005lR-DU for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZUJ-0000k1-MD for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:29 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-257-yLBNVmXRMUu1GmcSb2HnAQ-1; Tue, 04 Jun 2024 15:06:20 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4210d151c5bso45057765e9.3 for ; Tue, 04 Jun 2024 12:06:20 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4212b51082dsm165919005e9.0.2024.06.04.12.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717527986; h=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=dtEoeRDSt/hukSx1+wwR8G88DQKSruaP42MuHd75N3g=; b=M9ceiOLG0+ejlioM8+Cm16buY+3L/s2JmO8aQXSJMYg6lRAoeeD7YfEBpI+FFzliHDcQ3o XTn7rR1+3BBLfh7J2XcM1mK0e2KGkJ0pTB4VgbvQsUC8uAMD2S1KLw1Cb+BxJNIQqpq6E6 zEU+TQpfWbTmvF5+XvF6inii5FJtMSg= X-MC-Unique: yLBNVmXRMUu1GmcSb2HnAQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717527979; x=1718132779; 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=dtEoeRDSt/hukSx1+wwR8G88DQKSruaP42MuHd75N3g=; b=OnWNk4QM3BfTmunQ6CwzouLS+A/LjVt4+MTwq9f3EWbIkGf2p6pCJjKWb4E4FR3xa4 6d/tCv3IxDgnYi8rbDXPfX09LYvV29z+BGuzpBCC8Vn/+IyQhcJrJTlQvBRjE4tFSRAP 1XE6YzxoCpC0be1U1qQD/wzoBncLarB+eNZEzx0itympkmm2pOFQZS3DpBb33HnCAiwH ADg4pIJFCu9ngFgu3sb5QAUzhsvbbrsuucfyWrKAqMuHhq3kB3H9zhZ9z4H+Qr1VuZ2b wguEyTqpo4yOlFDEDlamj7w03qtdhZfL6CiR+jC4KOc4MdSk0s7ypVolylB+GWEwNf5P P1WQ== X-Gm-Message-State: AOJu0Ywcpr26kjznbHPmr5OEMCzNZoDYkAM9GklESGUMxepDRiXJSGFo gKE50JS4R9AbtXNIUuRzGcS+oCSJtKw0Rtg34aW86tX8KBgXfqQQ1JB1gGeM1H17LHt1gdh2xR+ BvpnrfF4iPskiwXsQiqZBgJa5jdw9i4WGjTTK77NE821FKpIGlUiZyaFT7VjGwqkgqeuxONXKR8 eeB+AFHU63YkPRSSgKbRlLUgrKX8VtTg== X-Received: by 2002:a05:600c:1e02:b0:41a:41c8:d8e7 with SMTP id 5b1f17b1804b1-421562df1f7mr3461275e9.3.1717527979007; Tue, 04 Jun 2024 12:06:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGp44H/nTfoe/dcDLPcW4ennQ5FlRwdnvKJHPvztIvpNJKMenwvWTFpITCNQjOjcw36itU2Bw== X-Received: by 2002:a05:600c:1e02:b0:41a:41c8:d8e7 with SMTP id 5b1f17b1804b1-421562df1f7mr3461095e9.3.1717527978459; Tue, 04 Jun 2024 12:06:18 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?B?UMOpcmV6?= Subject: [PULL 05/46] virtio/virtio-pci: Handle extra notification data 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: 1717528033756100001 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 a7faee5b33..ad0035952f 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:29:59 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=1717528257; cv=none; d=zohomail.com; s=zohoarc; b=Y0fQhPaGrazbF2tY9HW2mLv2ov8CA32NYVJO1/cce2eQyYOB7xq890ISS/WgpMCdT1+e1Z3y03Q+ihZQnslmtIbMuMqgLjzxtYsKmNtAzvf8O4/MkvQTt8xhaBUFFGCkhlhs5Ud6CNDisWoOnIYwFd/xbOO8Z+EDkWGGzqup8Bw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528257; 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=PdBJGAhU3J0etQNKWT7eutagcvmhlRSp8ItY0Klzot8xE3xNTF+0IZB+/Iz5yAvX3jESNSnjfYKRy57imhbVYZqpCKJNKuGq+iMofqShEpS5sCibT4arzfoYLDG0fbec7MVfs7RLy8lSxAp39QIPNAGa6U+eswqBhXD4Ah9XvQs= 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 1717528257520199.23590518112974; Tue, 4 Jun 2024 12:10:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUP-0005oz-Gl; Tue, 04 Jun 2024 15:06: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 1sEZUK-0005j7-UR for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZUJ-0000jz-C4 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:28 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-131-umM9Qt1dMomw87cg1k3CTA-1; Tue, 04 Jun 2024 15:06:23 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42135f6012fso26193965e9.3 for ; Tue, 04 Jun 2024 12:06:23 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4213cd1c075sm87369035e9.0.2024.06.04.12.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717527984; h=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=hE6FYKzDC667y/6z06qVEU4c2Lc4Xmn5Cczhjdz6cdWzgyKWLrik37jnZndMidQHPsaTeM pZaCYgG7QCcO7uRnDUIA18Qtt/1I0Rt5WbUQnDqhuV6MgFrscoB8NqzI/qxTlJUQE3Lyru LoFJ0qS3nsT4LOXO/NxLTT6Hx0G2oQ4= X-MC-Unique: umM9Qt1dMomw87cg1k3CTA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717527982; x=1718132782; 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=WpnhbJOvEyq3MB35dUSz+0e0qejBjQE8NPPzCODhqdQeB+hPTYxIrR05VuQi5RD4qQ EYhSprtvIU3Vo3RmgiNnzLrcyxSw8v0pqjmzyE1lVUrRoHuCbkNwiF8l8pi/Ocsec/P4 81UFvLa0wVr0OtieoMEYkz2rRxDXRYN6yCMm2fpT35oonOyrKmzW1qApP6UVWH4cATAC Iw0eEOj6hcg4ck6d0TOjBrOPpqVn0vTRIq2fONKpc7QjgZDKt3uwutVj6qwWiWG3gZoB ZXbRY904csxIVYF3F5XSNFY746wWd8rMpw5nQBGH9CWKPYaOEZYP94jNtWFAI1tPOqW4 wWlA== X-Gm-Message-State: AOJu0YyI2YQ9YbSp5aa4nTvbuPFceRLEnexe8CuqovyefY9Tp2de0AMn 8ueJuhMLdSnCOZGaYk4hzPOQ3Or5kqDVbNm9iNh22xGSVPsnszBtGETYkFRU9y10LVwrK0UU2Sk GHY/9tLF4xBiH0QoC9MP0tMbKFWCX/6mfAP6/b094VExR+Q9hCbtcmlJwATmYOp9xjIPioskyoR A6zWU591Y9ayLl59CUsFBuNKW/hNITjw== X-Received: by 2002:a05:600c:4503:b0:421:1e47:f80a with SMTP id 5b1f17b1804b1-4215635c0a1mr3063715e9.41.1717527981746; Tue, 04 Jun 2024 12:06:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHB886PrhILTURkp9QKh0LH8D3iJNhV0Pb0rydXzO/KNMcw+3s+1DZnhJHdghmNemRMjZo5Ng== X-Received: by 2002:a05:600c:4503:b0:421:1e47:f80a with SMTP id 5b1f17b1804b1-4215635c0a1mr3063525e9.41.1717527981187; Tue, 04 Jun 2024 12:06:21 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:18 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer Subject: [PULL 06/46] virtio: Prevent creation of device using notification-data with ioeventfd Message-ID: <1c854365ece00579e5bfe19c1ce04e80a76f4a0b.1717527933.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: 1717528258820100001 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:29:59 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=1717528242; cv=none; d=zohomail.com; s=zohoarc; b=PnrDzrS58Xd9eu8iefk78pJQe/30S4Xmjd+A4ajW5uZV+DPUgq0LOGpfHbybJLXlsSuG7lAkHie6vHXhFch7cNXF9UhelV+nQBLo6UW5KH7RL4ctzQ8GFuX8EJx4DQNMPuGb3kFHZ+brDsjDHlV65HdRL5v2RIraGb4ZFwpV4Hk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528242; 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=lioucGPCJ3b5ASlBd1XWAPlwoCdGFLg3tbEU6hwRHDdDujOWFKleAIPMVmJ68ugJZgGsW6tTfumLW0v5NSoOV17lntBmgjzV9iooQQdHjPCdnOw0qCM7N5/puM+bh2bz+Hje/HbiYsJvhe5Xg0FFJz2bX+MFkQxNLFPu6UiWiJI= 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 171752824245861.38286150891713; Tue, 4 Jun 2024 12:10:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUP-0005p0-Gr; Tue, 04 Jun 2024 15:06: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 1sEZUM-0005mv-Dn for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZUK-0000k7-H4 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:30 -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-620-YwX_07PCPXmQagG2w7IFbw-1; Tue, 04 Jun 2024 15:06:26 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-35e50fe93a5so2483978f8f.3 for ; Tue, 04 Jun 2024 12:06:26 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd04cac3esm12321635f8f.39.2024.06.04.12.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717527987; h=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=Y22q+/BormzcpVg9XH0zgyGa0/TOOnVcHeDfzFetmBp4SWDHLkO/Q67rmZWoJovEswILFJ 9eNBleFPSunntRekgUoji/H1fjmz07sKmlHK2GY56kbF10MhcTN8FXAFgxLRy6901wy90g B+gef46r8GlbaeKjqBp2O6kurTZQFxQ= X-MC-Unique: YwX_07PCPXmQagG2w7IFbw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717527985; x=1718132785; 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=Hxg3K4AwCMR9LFikj8eJ2LKytYZYJQh89KsFZevGj7dj8pTNBoeVQJjffTbdi/b4CZ QDzu+dRCAkfzSCM9T6mGcCYw6XWaFJFgHZBelxSsYPf3YW77lDEfl1qHVdsxzzXqusyT Rrhejv1kMdfv6JBYltAWCG74c/p0Wl+J2bvP5lvMtXOkimTYOdxMTYliVvykuHx4AVrA MJP9vNIGXE36A/uYOZm/HQW0TRYROPjAnzUCvzr344ib6hlNvlWMzzqvxwOUt6+haVcd 6TWvwco5WFmAm2nVI8r0cHR/k4vVhhsVrymrtUVxzmCR1RnWi7/SBcZxa3Q6YXTBAisb Bc+g== X-Gm-Message-State: AOJu0YxEGNV/EVuMQzO6y6VLJxt5A+A5XUT5E1eNEY3wAuV9bW4K4K9+ jurgyoD3zVBTAsDcmmOHzz/g29Pfb2J4iXXjiKVTVBoxVtsUT6EiUq6sFTYBZDubHhcJ3BtHSl0 VUVGD3x+yxXWgtCAwAsei2wPHQ5AaZBHHyO783LoZsysoatHPJR8IKt0fWJbrSHcnK/vJ1e0j5z QLNJB0PANgDrehbrOprU5Grv/O+S+icw== X-Received: by 2002:a5d:5f4a:0:b0:356:4bb7:b205 with SMTP id ffacd0b85a97d-35e84049474mr313008f8f.1.1717527985025; Tue, 04 Jun 2024 12:06:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvt3wYWcLLINEPJx3l8wBE2H84xtjFgTjoE0jyCMI/f45rgHJg/ZLiTHTDi+a3B2cQYB3bDA== X-Received: by 2002:a5d:5f4a:0:b0:356:4bb7:b205 with SMTP id ffacd0b85a97d-35e84049474mr312989f8f.1.1717527984609; Tue, 04 Jun 2024 12:06:24 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer Subject: [PULL 07/46] virtio-mmio: Handle extra notification data Message-ID: <552a973267cb99e09630094b23cf126bd0d57352.1717527933.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: 1717528242696100005 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:29:59 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=1717528052; cv=none; d=zohomail.com; s=zohoarc; b=gIhypluHDfRBWG7zWXZXRoJBGH7u7CNnZ5/w6dQvVIrT+EgxBUA6lF644MAIyXfonduVA2SziYlfQCQBLoXh70wuGnHhXYvRgOhw9QdQt9wOrGNpk7nKL++dw0Ouz9TrDAyjiYvn3/y0H3FMBKG83TuQ/QFsJHIxDHAV/hE0ZzE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528052; 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=Lb0Dgpw8fSQtuh8ueP6oBPVggMok7KS2Qwa9iFDWIANZ3eh0/F5nooRtgedG3TJ8CbJcVRy+wdG+A8iph0oR+DvGmNHuu4GnjOk1zig2vwpzUa7MyEh2KVtlrUlSvWNsnsSWRcFe2zX1YPNJRrcW1nu3Dmk3xBZBG1Fj98C743Q= 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 1717528052334780.3557219350705; Tue, 4 Jun 2024 12:07:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUS-0005tj-Py; Tue, 04 Jun 2024 15:06:36 -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 1sEZUQ-0005ro-7v for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZUO-0000mf-M7 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:33 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-184-m8VLoBvxP-6FfGnFpeAAMQ-1; Tue, 04 Jun 2024 15:06:30 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-42133ebdf24so30279775e9.1 for ; Tue, 04 Jun 2024 12:06:30 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4212b2bc975sm167129025e9.29.2024.06.04.12.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717527992; h=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=AHYfmk514QjuTsSRBvrQrWE+5Ca+GGviDFFGz6IGeOSS8JDlULJr8M1VcnnLkvU7awSkTt 8ASDLO9cHJi7TQRnQEWR8YFcWxYKPC5qeDYIqPYhk21JO+SASdV+h1RVNKeeVEJnb47tt2 3cqQ/nQEh/hXw1U6XhMsYKcwekwTeuw= X-MC-Unique: m8VLoBvxP-6FfGnFpeAAMQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717527989; x=1718132789; 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=h7gApYspqSQhbqwBjtIaE3yB8u6CUnbkMIiryCJVzwqdZLHMICsOqvAAVtlUS+ELGn R08bytiF5vnpVG7vUQTmrZ/fdBGGIWJBPwO2e64X2j+QVMnQFhvVNvhBmGm8adyW3sr/ qB1+Cm2ymtbxl3syzmtHo9uLOjQln5qID27UZ4numi/iIAhAazIeW4z8ebvHY93ns7eJ EKxoUwdg2e/tP0F/J6OcfoOAWuRCl3+pBR2TT9VE03yfHn+1XdaSumgJR5/tYUHW2ir1 LP9G+JHMnJg+T+DW0/lcwNRb5RlpnPHynrxZp+qP33Iw6itdvKY+nZtf5zY5jbDcKzlJ YbRw== X-Gm-Message-State: AOJu0Yz4A+KeAGKaMSJI4AN1wuapwbWbp9ArwomMr7DdlKP0FYhM3SKZ E21bL3VCv4zhfgpxPqfHAXv1AXup5zQY7ycbjQrQgOxKKChTvzFHR0N2mWaup3Y6ZfbA+VZe2JH dfG9N4GLLnGFTSVdrWxrscV5lRkkUlVbwYrlOSwx2UkjPkCUW90wxb9by2YHJTt6wdzkGghpfhC u5NMVpPlfsOZ4WwSNZpDHjRiPKEbs/HQ== X-Received: by 2002:a05:600c:1e02:b0:421:2abe:54e3 with SMTP id 5b1f17b1804b1-421562cf532mr3657555e9.2.1717527989143; Tue, 04 Jun 2024 12:06:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrYtXW3SXZZutia2Gnd2Ndi0MgR6E3ecaxE7N4GvQ7ruxjGS26hHcLdNrdpEuDz5DUekK6tw== X-Received: by 2002:a05:600c:1e02:b0:421:2abe:54e3 with SMTP id 5b1f17b1804b1-421562cf532mr3657345e9.2.1717527988678; Tue, 04 Jun 2024 12:06:28 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:24 -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 08/46] virtio-ccw: Handle extra notification data Message-ID: <4a42e11bc57832000fb4da43347a4419e07ea583.1717527933.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: 1717528053911100001 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:29:59 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=1717528032; cv=none; d=zohomail.com; s=zohoarc; b=M6oo3fgQESwZYT4ujbjNPRIeg5kK+HkaCQxBVWwR2JPy3jf9BHgByHya76XtvqoTJOPpErSBvOPP8Yy/4dweiGNjCxMdV4EVCtkKdviIGHu87dYeN1bA913vczNVEEF8JafhUNbFHWRLOW5L/0DWOYvGl92cIO4gKWgayXjN7/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528032; 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=JxbB1CMeggwG0GAc0foJJratIId3/G6Qz66dTMTRYkQUfnwZ9UBlUIKhSszc6RrIatiWN3ZTpvv8hQ4a3PDUpJRkDLZU1jFE2V7mdEqevnTxU1Zdp0FAJm59TVoy8c9kN2mit9fpwjanp6NRD+6IZ8UKTwE609hB7atgUkRWYdA= 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 1717528032979594.7161852984775; Tue, 4 Jun 2024 12:07:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUW-0005xd-Qf; Tue, 04 Jun 2024 15:06:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZUV-0005v0-9V for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06: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 1sEZUT-0000nq-Jr for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:39 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-LRem79UqNseIIeC7uk7v5g-1; Tue, 04 Jun 2024 15:06:35 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-35dbf83bb20so3575852f8f.2 for ; Tue, 04 Jun 2024 12:06:35 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd04c0e84sm12415306f8f.13.2024.06.04.12.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717527996; h=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=c7hAk2HEwlGyghTALHp7ytXyy2nnv+mEhbjvPNcr3OpI82ruEU9oCLfHg0ZmtQt4NdfD9N ZKNUChb/wsqpgUU5N4sR/ZcZ57RuH6/JrsHjmhcd8UrU1WXy6OvK8b9C2ZYHnvGGyHHwJp V//39dGKCbcpOYYhZkrB4tMKP7yq0Ko= X-MC-Unique: LRem79UqNseIIeC7uk7v5g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717527994; x=1718132794; 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=hTwgcJRQcMNvGGVdvkkByV1b6rftvMTszzfMPUcV/4FpbdPks0WjcnxJMcZzHf/2K1 SsdA3k16sG0bpp8tuY9zO0o9bai8WjyOlgg+AKTGwQxWDADSOJIeKss6sMKI67KyQKdt hc23FCo6hnDRKQpt8w+7D/2oG/xR+5KEW3t0VyFYGYhe6T8zXF3lmxuHNarGp0IvampM QNhZfObIkrZpB8eI7PsmsEUIJXA3ODw++hjvn6NZB585MWwghQqwlOHJZaTqu2TSIQTt G0WEDlRAkbfHAKxJM/EDux97Tf1z2WnrV0VXPCXzfYiS/i/QuvN6pxoNwCdYbm2UvcNS a9CA== X-Gm-Message-State: AOJu0YyXWxE8pcrGFWrdD3YzwA/ElSlOX7A123NC3smLdnxAPYDcqjZY ilRTrgWI1b6aNkk2H2MTzjv0gRkHwOUl+/kBbgEyw6R15C35YBSnEg8+a+1wz30ueqWm6kMk3ZS XZCiBEnF1meJsY8rS0SKPGkvNV9s2j37LNhyKy435DIc91z6ypAuhxMm13V9bRN0CHGjld1tVRT vC9zqLSwh7L4+H93VhOhBTbi1obE1FzA== X-Received: by 2002:a5d:66cf:0:b0:35e:5be5:fbb with SMTP id ffacd0b85a97d-35e8ef8ec1bmr213106f8f.67.1717527993889; Tue, 04 Jun 2024 12:06:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlxcGzgfMyv1oXCA/eCPMq7OxdfCxVeK3UxTeT30HVafbwgGv3cusaR71zAWthsSz/YFutNA== X-Received: by 2002:a5d:66cf:0:b0:35e:5be5:fbb with SMTP id ffacd0b85a97d-35e8ef8ec1bmr213075f8f.67.1717527993350; Tue, 04 Jun 2024 12:06:33 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:29 -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 09/46] vhost/vhost-user: Add VIRTIO_F_NOTIFICATION_DATA to vhost feature bits 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: 1717528033804100003 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:29:59 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=1717528041; cv=none; d=zohomail.com; s=zohoarc; b=Kdl1YZuUGcefodNHgHNOP21R8AioZHnRvRyYB4hmTEN9sa1uVxxYfX32+ql8D6bSs1BYxCMGiRih9Eh25ByKjp+7Bkqf9c5myXlg38nmb5GUoMwGWRQgs9Nvit7OJvVSMJ+jz03iLpEiU4ImZujpff1NWoXyuW90jhzH2u/wilc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528041; 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=NUQBl4pFiUNQdhwF8TyoXtrLZfXXvveGBs+AE0QqmMU+srPTT6EeNQ14q5wPKTztncQNI0DU/V4l8i714Sglx2qclDPGn+15tAz1f3QjIDdkDs5+ccRBEAEgRoLLnkzpOf2+sGb82LGrXm63B2oBswqhj9aQoIaDr+8O+4dt+Gc= 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 1717528041444627.4809244296758; Tue, 4 Jun 2024 12:07:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUc-00067A-FC; Tue, 04 Jun 2024 15:06:46 -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 1sEZUZ-00060i-8s for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06: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 1sEZUX-0000oV-NO for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:42 -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-324-XYug-GCzPqWRbSBiab-4YA-1; Tue, 04 Jun 2024 15:06:39 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-35dbf83bb20so3575873f8f.2 for ; Tue, 04 Jun 2024 12:06:39 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd04c0d98sm12348319f8f.24.2024.06.04.12.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528000; h=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=X0htI3c3S9ddjcHw/5rJWjFtawIzyLaF/y17bdx1OdutGcwRrpRU7RTgLJh4Wq2YuOFtnS T4RW/s9gQk/dtLcJhsELl9hFqIsz8avLNXHx9Cq9vvA+x21a/wxR6LGtIRIFrnmxOVsyph W3wpx7ultQVQJimnJ9LWXgmXEvAtx+k= X-MC-Unique: XYug-GCzPqWRbSBiab-4YA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717527997; x=1718132797; 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=gKFYwkluTPo/cJIa3cLk76gsYf0/wlVgf8hE2k2jX8AK7K3tVxw+3GaiOugWTGM7WJ IJj5KONN2bGxSIueXR+RuqipH85XzjQ2YRMDayBIs+fJq4Rmg5DRyqWY5jpZPJWBadw5 on00ZgguXi/4pY/+efUlw7MCIBthG7yvFCQfvTXg9GWRJNHHy75nTCEw6k5A4xBtXCm8 vsXlJVGspakMIkf9F56zZfafQ8EJ4Q8Ql+p0GSUccCu2KP95hpjmQ8zyJpHrVEMkmIKK zvIweqpfGJM7SaaYb/zjkbIicIX2FXYHgWDMJNtym3oQosv3qy+vIgGClOnvqxIKFFsf tpEg== X-Gm-Message-State: AOJu0YwvuL53jGarwHRVjIxEVP+4v7Ds4884epc1dQW00vX1F6bfyn6I XDIfhSy3afbDdQVttDsVzDsqS5tOj2742NTeZpSOuoMirYLrDGwcd3bMzoUE0gWV7BXYKAsw8ma PpHaeAciXcDh+F1H4sv23hnfzcGzc/B/OYSFakaGiMwNLvaFXL9BoNIDgSpPsRbrUT+fKxR9rjB +dlfvvKQjHf7NetzbpAkqaKAvkoTKxMg== X-Received: by 2002:adf:9bd8:0:b0:354:fb1f:8b5e with SMTP id ffacd0b85a97d-35e89835ae4mr237419f8f.33.1717527997480; Tue, 04 Jun 2024 12:06:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgnPbP9kEvZBHOfBML5qv5TFA8fs0/jSRaXkQbhBSUohua/5VHBE2ascE0uXHv7Llb5gB7rQ== X-Received: by 2002:adf:9bd8:0:b0:354:fb1f:8b5e with SMTP id ffacd0b85a97d-35e89835ae4mr237399f8f.33.1717527996892; Tue, 04 Jun 2024 12:06:36 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:33 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Christian =?utf-8?Q?P=C3=B6tzsch?= Subject: [PULL 10/46] Fix vhost user assertion when sending more than one fd Message-ID: <1fc2bf2d1fc50c78515b1484b4d578bfb373df54.1717527933.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: 1717528042066100005 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:29:59 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=1717528042; cv=none; d=zohomail.com; s=zohoarc; b=TUqmcmxRczUMZdsS3XRrdpmmDfk52S5lh3bW3LYE06IkAEVTKeyELdiVmPRNpgOZlBLU8rmsCuuxQs1/9O9sKUR0KPr0+eWLvlObrA36HWqkdmYjrSCTAb22GuItz23pLpD5WtsZw+HWVEV55WdxeprWnZIR0OaQf/V6bD0sjIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528042; 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=EDVlcZ6Qrr62tyaw3k57TmU4zyLU00RDnlw87Qk92/ZoYjjpT/dnVX5TR6PT2BMbRTu0bmzh/EJBtRx81O/6cVlKyilz1bQbtv1ySxIWRrIagCCgkLighZEvZrCXg8FObbmZ0zNTziPz80tVchhzJ5wMOIYwBjPyr8kmV9bpy2s= 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 1717528042937988.5050451330796; Tue, 4 Jun 2024 12:07:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUe-0006DF-Ka; Tue, 04 Jun 2024 15:06: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 1sEZUc-000679-2B for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06: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 1sEZUa-0000ol-F3 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:45 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-84-6f1MFBaeMfiBqbAXGXYvcg-1; Tue, 04 Jun 2024 15:06:42 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-35dc02b991eso3395561f8f.0 for ; Tue, 04 Jun 2024 12:06:42 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd04c4388sm12550573f8f.14.2024.06.04.12.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528003; h=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=PhDMsLucHuY5Lkub302iKa0Rg9mkPyVNysxC8MDCHkYkzsXYmpEyDqCvzSyr9JtDjtTvSV uf6cHTtdDK2KbjSblQWhQuH4PqCN6HCgy9gfW9tIXy3pVel47ICLmnTIOO3wEg3EWcJgQt V8dKK+QG7cJLHCV/H5ZICCXnBqJNumI= X-MC-Unique: 6f1MFBaeMfiBqbAXGXYvcg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528000; x=1718132800; 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=pYdhMTBhdmRVQBKgvLKKT1M/R7m0LuAu8xhufBcFlkFGvSzHPUMV25A1qvToy2fXis 1TZ1U6OGrnmvSSRLUVHKJrcT0vYud2zNaNJ1BrpBtMJpgtpr2iJOsbTlV+xG11jcRdff NNbRe69tKi8kKzUOroxCa7yMMl5qy9ugbGHSUFSlAUW70YwbFWt4x3uzKCfRwszhibDD 6PXsMWCkQFmWq2Nlyke7a1JPurGWX0BMKidH72Iu/kZm75KTf8K3LPhvD/bowEoChCp+ cjlCDVuXS5nOBAYlQO8DYeKUnu2KJ1WNAjZUZbGyn9d0qMeg1a7qnuvcGvRIbmXEs2v6 WCGg== X-Gm-Message-State: AOJu0YwGKvhvQxjQxow8CsHm22FoBiq+ROkggOyAbyGvAoJ0nINZMQk9 0ZAW0s0zxZfeOsERoekxlM/j9TWmfSgI12SxblacVOgm9U2mKPTtcD3rYz0jZeD5ncLbth3tVfa 0dbXmtT6v2iLXLoU+Ix8bO16SniyZ7ysNDVu753RcaGIsri71ivvOSa+KYkvQlRg7fFC2b5WHR5 kYOd4ewv8Bgmadkhh4+PlHA0vIsYTT1Q== X-Received: by 2002:adf:f9d0:0:b0:357:e5a0:fbf9 with SMTP id ffacd0b85a97d-35e84070d90mr225318f8f.19.1717528000507; Tue, 04 Jun 2024 12:06:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHn3X4+EEySlXq6LaHpFrWsVF6Yl15lAKC2UfAU4GM0ENPXcl7wCuTQkL947OmO5Lbq6ZGEhw== X-Received: by 2002:adf:f9d0:0:b0:357:e5a0:fbf9 with SMTP id ffacd0b85a97d-35e84070d90mr225301f8f.19.1717528000030; Tue, 04 Jun 2024 12:06:40 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Halil Pasic , Marc Hartmayer Subject: [PULL 11/46] vhost-vsock: add VIRTIO_F_RING_PACKED to feature_bits Message-ID: <1c4b7415ec4136a090973ff4a457474de1576753.1717527933.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: 1717528043748100009 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:29:59 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=1717528318; cv=none; d=zohomail.com; s=zohoarc; b=N3VPfB7clyFlNfbS7dUSOW6bBzEmLP+yBzla4lMJlIedWmiFJncW/kYgcbu04gTEt4sjJT6RKseZDp/7k9mS+gRwn6xuZ/wdS6tveNoVk/CEM8zearQXPlQQKSaA57bL5sStPiWZ7uuyHNBerUFmJ94hHBZG/sOrX6Ua59zbSPE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528318; 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=JWrDIKjTZnxhwKpW8i1JS6L7MYf0FYF9GDdppXByRMpiL1TM88lnkayLqe10dI2wEbb7sK/EHJvMLvElhJyybV0UZEABx9FJxZwgYele3dgCcb+8Yxu00m3Sb8TldGgxkaO4WiBZtUP0ajxUw6VPMXJrAZVLjLza255CH68mc9o= 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 1717528318208698.2845291292117; Tue, 4 Jun 2024 12:11:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUh-0006HG-Bl; Tue, 04 Jun 2024 15:06: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 1sEZUf-0006Dr-93 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:49 -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 1sEZUd-0000p7-HK for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:49 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-451-nrqKrTdsMeCBJZoDVB2wrg-1; Tue, 04 Jun 2024 15:06:45 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4212e3418b1so28889845e9.0 for ; Tue, 04 Jun 2024 12:06:45 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42156176a06sm6881265e9.3.2024.06.04.12.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528006; h=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=DxqnpCEAEevLaf/7ZC7vn17oMrWrpvCeqQEjdNk5ce4qUUtbo7dEEibyMTm08vdmeZvITJ ogbkkQuv6SVrDx/H9EwaAtaLrTjf8x2FqyODUj6jd/743UUqq/HczmNsibSWAYcbaehIQo 1pwZYvHbRHr4KvEhINEvdG8mNfMOmx4= X-MC-Unique: nrqKrTdsMeCBJZoDVB2wrg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528004; x=1718132804; 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=MgyOBsiaO1zRY1bJrr3VDHMUNUEsQ5DsxgJ4jFWkGInbKjO2AShLUujhUzTB7rX6lq LuqYh9KKNZfYCDsubwooHgjt0nllDeNiVnTRlzZqqrtbmsLJ0PGtqz1aiHskS0GiuEPO E8S8UdwI6eadIVgCLHp9wGWgAK7W8gJRG5th2pkIw99nMqZM7qJcaJsiLg9ladiPIwX+ Usutn4aspzvgdxes+mvQqndoFlud1dqecbVy636qBNNL5Gzb5/SucjR94oQXaczkLTO5 rwX3ojq9DbP6f0/4wpVEjDrb2fE2SIa6fazmIhqGBEczCd3reW8vtVrJNQ6Zj4dnrj5r Hibg== X-Gm-Message-State: AOJu0YwKiIy2HIvm/6UNnr58GxUhDNc0PhI1KVJsyu+wOO7bucTAkYR9 8gtAfS79+/D3FPZPupAdxgFaMMNChx6T1oX0hXR1z1Q+A/3tSOK9RqiCXMTXiFMUS69zHgJo1de e03YZjedsJFa8qbf75Qx8HfePPjk2ifoa1gvR8yB5sTlGekG6Tjv2MhBhukKqh1whp5FXu8JGtv X2wZBS3LF9is/bKfJklP1YtdIZTpdhmA== X-Received: by 2002:a05:600c:1c19:b0:41f:d662:65f6 with SMTP id 5b1f17b1804b1-421562c7dbfmr3541075e9.3.1717528003714; Tue, 04 Jun 2024 12:06:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZ9jZmy9OLGmUYGznVib+WruK8PBTrf1O0BMMFqznZ0E/BV8ifX9qRFLVgzLQDelOh0lPmhg== X-Received: by 2002:a05:600c:1c19:b0:41f:d662:65f6 with SMTP id 5b1f17b1804b1-421562c7dbfmr3540955e9.3.1717528003261; Tue, 04 Jun 2024 12:06:43 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:40 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Wafer , Jason Wang , Eugenio =?utf-8?B?UMOpcmV6?= Subject: [PULL 12/46] hw/virtio: Fix obtain the buffer id from the last descriptor Message-ID: <3fc9184844ddb9af89f6916a204df888d37565c1.1717527933.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: 1717528319079100005 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:29:59 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=1717528039; cv=none; d=zohomail.com; s=zohoarc; b=f0tXoyN3EYcI2sXVoWUCYIvrE8QeV9LauX7WF8rL5Z4LPDaRm13BUMzRrEue5siy+mpYU7HEtMJ87HlO0bGHZveHYu8v/mMi6wMx4UWEWsMLsuCb0YYXsPen1QW8JirDMjZdTNd1cVm6AU+cCWKu1tqvuT0hECvoKNxGQeLTVIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528039; 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=3zfn4VTIDgsQPaDvqyKjQZ05mAdVtKBkByPV13wMR/U=; b=Ki/5h19+BC25dNAtLnV/w3Kufkv5EEngBTomP9WebuthrK79/49Lj5WFI9wpeFchoF//XmALSreHwFXvdXKaqeZwZAht6aHzNiCadCoeHaA5ds+mu72IjKsjwkSzI+gCIPrYv8ZEom/5lFKB6viPLozZf0n6JJIHbX/B+nCKjP4= 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 1717528039835664.495601263728; Tue, 4 Jun 2024 12:07:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUk-0006Qs-IH; Tue, 04 Jun 2024 15:06:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZUi-0006II-5U for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06: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 1sEZUg-0000po-Be for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:51 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-588-fKVyAzdJMdaeZAIGEenNbw-1; Tue, 04 Jun 2024 15:06:48 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4212b505781so736115e9.0 for ; Tue, 04 Jun 2024 12:06:48 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-421381c650csm122214995e9.27.2024.06.04.12.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528009; h=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=3zfn4VTIDgsQPaDvqyKjQZ05mAdVtKBkByPV13wMR/U=; b=f1DGPsbXxGxqe9X0e4/zY1RwBFBKhQA647yMbhZDzdiTaqPtReHvXiJ/DbLMBrbxkCdY+S 5/NhMeD+k+Or29VGIubkcRkJivrbqlELuRan3nu0wXGV/Lnjyf78abyCqbof6JGPoHsBuZ usnv9OF9a8p0dOOFG3jQiKNs+tq40As= X-MC-Unique: fKVyAzdJMdaeZAIGEenNbw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528006; x=1718132806; 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=3zfn4VTIDgsQPaDvqyKjQZ05mAdVtKBkByPV13wMR/U=; b=UXN5ypeuKZ7/SYizAiyTNDe6HAKVbRARWie0AM+5hDKbiZBQKFkTcFk3JbZHZgbtJp 816ZwRw+015IUIojOayKpVbdRSjvjWYNM+PT/9UMI4Uccq65pzpQVIk06bfUWPjavAyL IeDqS9mk5gFbIEabwGsmqaymnfq53VIQRLhcN2a0hRzkdtpE7bR1XY9u89aeouQH8Spo K/0uPGJTDfqCZagQR7aYfe9/UcKQ5BfTgQV2eSP6l3CCzxgR3lYzKzFkpfcZ3cgp2fBD BNcDVojqM0hThHTVJ2IXwa3O/Dyh9HX+ExmJ6AgTYETypUo2ETkMDulHUy3PcXqT0HTm MenQ== X-Gm-Message-State: AOJu0YyBHrFbAC2W8XEQghrBEImQ7+WlXCSVFAZBUksx5BYAWBs55E/8 2PRey5xMZtpC/f4+9bQ0nNPo7cZs7jjEEccQXIzeLpXkRRy7ueEzsdf4WoUCEOSvLfKWJqXlawm +Xdf28EZP+ncvoTvn4XKRkwjeR2DVxCVwkZX2KGXgr7LU7PgoazftdZm2Cq2i8Oh7ZMKblxSZjK pgtm10vDxQ1/WTXcUTVHaIPJvE7I4L4w== X-Received: by 2002:a05:600c:3589:b0:41f:dc27:a7c1 with SMTP id 5b1f17b1804b1-421562da803mr4711065e9.5.1717528006474; Tue, 04 Jun 2024 12:06:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGChT8wJEL0oJPEJPXgKNHKA5dfs1OeutnYx8rHSVaYpYP7psNMEDgfuC0sKJxUrGUDTfcuEg== X-Received: by 2002:a05:600c:3589:b0:41f:dc27:a7c1 with SMTP id 5b1f17b1804b1-421562da803mr4710885e9.5.1717528005929; Tue, 04 Jun 2024 12:06:45 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jiqian Chen Subject: [PULL 13/46] virtio-pci: only reset pm state during resetting Message-ID: <272efd85b86b2c37ebb89a517d5ed30ee7695dbe.1717527933.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: 1717528041751100001 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 ad0035952f..b6757ffce2 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -2309,10 +2309,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:29:59 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=1717528144; cv=none; d=zohomail.com; s=zohoarc; b=LdZ4dvJYhz5ejMT1K+n/tVJlipIiBpZ8kAnJpZ6/nMbjWth8pcdFoXHqv6UsfNLtkLnrVO5aajXdMRtVg9R+tLLMyYegHMtEqGm57E55pfzFqqyio3wNaKDuE3WogQ1vVvMRz2+w+xYxTHq3AQMXu88YEvijniIjbVByEZ+HZP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528144; 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=kcyZhdFryvopdQ3UPG9SjUivOXkvDH/7IlfvB8FbfFnNSsx8ycy6BbTI/FS0oMhlwkjqxqP0+qMbpi6APNDbEfeWAZJDIqONPzv15Ytf+J4RngcTR01i2qmceRyFHnOcXfr4wbhum/KjslykR8jBoVlsecBUgXiinH/QqxZyfDU= 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 1717528144698269.82040187806354; Tue, 4 Jun 2024 12:09:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUn-0006av-E6; Tue, 04 Jun 2024 15:06:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZUl-0006U8-EM for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06: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 1sEZUj-0000q6-7P for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:06:55 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-652-29FyxhtWOf2qHUudYCMSiQ-1; Tue, 04 Jun 2024 15:06:51 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4212e3418b1so28890145e9.0 for ; Tue, 04 Jun 2024 12:06:50 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd062fe96sm12348566f8f.67.2024.06.04.12.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528012; h=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=TsXVfhysq+J67o2n0dgYnsoSdSErj170YsCPpC6D2v7HppSGGYkae4c4iGu+7tsJ5kqQ4G MMlgYqA5w8Zu7FzBHxyaxsVLnpBozadGuzetPr5wJ6Gn2nTl6ST+VHYnZVAb6Tig5gcY9w PU4AVBZNMIgAZ90ReSdea/A06B6P1pc= X-MC-Unique: 29FyxhtWOf2qHUudYCMSiQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528009; x=1718132809; 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=gYfd7HIiL5OvulClhJCIDPR5O1Q/bUrUJkbm9IuUYdgRqE069EYb1R49gQZz3aJUN1 Ok684aohqtmKLyunstJIhpaFkaqIt3YzkvorfNTuVvc7zSiM8MgPj95qDgssP9NzG/Fv AhvMk2KK3AdS+cY+nqBAvdsr302dpgbGh35fVLb4HNus+ouHAQc4w44boPHl+wCv1mpE C/WCxIe7Rx3RQqkUvi4/2i1vnbsaHNR0GsS8WkoYT1AVGePgL+bXRMjh8NuS1wMPju3q nthoZAuYg+6J/1RNSdNAKH7aaqGVMjXhpDG5sxz3WQFDmUk4eaePnDgPq0peamuNOhld GKMg== X-Gm-Message-State: AOJu0Yxva+R3r1lD56P8ppGD+vddzrdmu5/1T2fUJspVhOt5KNqjniHb 5qJCvkz4goyJwXb8YSPR1yK+ckdxrMs6qimuP+TPQrG3eepjf18JQEOp0rwNsLxp0M9mpds2NIL iXnrv+4X3C6i3Aga9l7o66I1uZwfDGbF+XeFVvxuoyTyuoWVeoRARkApqGekcaE3HyTTF/ZaYpj Msh1mCZjhmlyrhV8TZm2qy/coFEXR65Q== X-Received: by 2002:a05:600c:468a:b0:420:2cbe:7efc with SMTP id 5b1f17b1804b1-42156338119mr3821995e9.30.1717528009489; Tue, 04 Jun 2024 12:06:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFF8nIjvxzqDzX68xtPyayDg2GMCvXfhLLLwu7DRDdP2kNBvtKw7BjaOhA681ygADbLyAXhDA== X-Received: by 2002:a05:600c:468a:b0:420:2cbe:7efc with SMTP id 5b1f17b1804b1-42156338119mr3821795e9.30.1717528009043; Tue, 04 Jun 2024 12:06:49 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:46 -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 14/46] vhost-user-gpu: fix import of DMABUF 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: 1717528146242100001 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:29:59 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=1717528052; cv=none; d=zohomail.com; s=zohoarc; b=kKFRCTn3CfpgqlsTIAATVMpflTngsgOp9b9kZWf5RoTyUKSi6EXuh/qDTjSZRRj/rQPFuwPocacZnMxV8klsOLq3/7p2y3b4LxlW2HRn0Se1V/cgyDuwA7Ntm1YMXN3oxlW7TyzMBteOLIXBWQF/X5OZNWyX37QGqWarKGiKes8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528052; 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=UZ02QZORnOSnRbi4SinoS1atXiRcoQ4qOh1xUd+y+9exN4m67EBNAKc9LpM/0YOMK0dM/SpCrfMNFIPM+yHPX/lWvBBLruPgwYW4Fc+AbaJAs+rGSTSjK/762x9kIMXB3F4o+qDxpZmtX6MA4j7KiRKNx2lAQmvJrf1jl2SQvIc= 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 1717528052923910.5101214055181; Tue, 4 Jun 2024 12:07:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUs-0006dc-JV; Tue, 04 Jun 2024 15:07: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 1sEZUr-0006cx-5w for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:01 -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 1sEZUo-0000qa-V0 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:00 -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-621-3gBYGC6wP7CBdfHRIPsNWA-1; Tue, 04 Jun 2024 15:06:55 -0400 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2ea93c06e3cso40114581fa.2 for ; Tue, 04 Jun 2024 12:06:55 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-421526593cfsm27227825e9.42.2024.06.04.12.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528017; h=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=HKtcIwc8QGhh54QXzUPQkZlzE/SEE90lrovueAk4ILWZHb5EnscaROR9spX27k+d1/ofpi ycdkgDk7ugh00KmugqGcrMN2BVeFIJKaJHTClh8qsfcStsbGucQBcZ3MgiaWHKR89ZswA3 jTWwOC7oy8eI+NdRfY7H/1oQ4SBApio= X-MC-Unique: 3gBYGC6wP7CBdfHRIPsNWA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528013; x=1718132813; 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=WGTmWLvlUllFFDlfpUt53YWdaJC+WjKZnFiRu0TCNW9SXOaWg6343ltpFe0Xv7jUDc a9U6EM8VNbtj3sulkCRTiwAW76n8ObcYK/tI0M7FTTIaY2eu3RVD/AgQgpSIpMX9S3wS BoezeHq6EWjnrcOL/Q8QALlusHI+aWCBRVBzXwerBQxMToQV5/QSxDE5myy+3JzjsYHr FpvvBcYWl0rwVoCqGvumfC48Vt7/asL+xibRmZ0E6V+zVdPIMLhB9Kmmzct37cyNkLmQ R7TUn1kaQpxZepb3k1GIiFzRp1MCg9xXTDknqQXMOlqhE1aWbysYcpXTbMgKcbPAQgfU Z/Ng== X-Gm-Message-State: AOJu0YxYH6dJY4HvO7wzSWMIhtepjMR0+DeUsFSHciRMh1Ttng1SA0iA Doze8c5QUMW1oALWtKRw3WuEV/DdM/C9qNUl/Io6mTSCS5T2gNyfQassmWMVe+99vZrX8ZuE6Lg wmrrQ64OvdcuH8Wj1Ym0eC0r1DrrX6f6eRmRKVKLX17kWuhzmw/5S1o1Ksh6ymwEvdy3ft7sn9z Nckd3r9ggcwY5XuGBmMhbsednZKq2JXg== X-Received: by 2002:a05:651c:b2a:b0:2e9:5b89:dc6a with SMTP id 38308e7fff4ca-2eac7a52b27mr1366381fa.39.1717528013256; Tue, 04 Jun 2024 12:06:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7Ru2hPSpUe0cE9lir+g1PguAn9zQdV1nKll5J/tP04HjprCj9F6vnCPvONBdGL11xbxK21w== X-Received: by 2002:a05:651c:b2a:b0:2e9:5b89:dc6a with SMTP id 38308e7fff4ca-2eac7a52b27mr1366031fa.39.1717528012630; Tue, 04 Jun 2024 12:06:52 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:49 -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 15/46] Revert "vhost-user: fix lost reconnect" 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: 1717528053961100003 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:29:59 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=1717528062; cv=none; d=zohomail.com; s=zohoarc; b=FnutWZW1hGHl0WYlVQbOqfLQ1lu84o/VPrcSDcGzSNAcoNUiImkrPZLrzQ9FNgD2kBp0rXuLVRIgkxSJV8/0KhjGq8sMA87LEA3umCcjA7I/5D24hEApKddMImtgnrpUnrryc1YVYNeoC9O/S+gp0rAJ7/5bXjN+MBvx0piNk6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528062; 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=Oy34s9ZjU0wpxXw7GtSMQqMpN+0PbSpRyYa3uvw7xdDlW0RZeAhfheCGX8+M65H6Bl/wwxZ0cGa9QriAXRX809mn0JuSpMOGhpPb3y6Uy7+WEUuIdaygmIVx+nKbdHwnnTatP1G9zOjdLR9mj84krkVx1LItkNtn1EXCtW1hOA0= 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 1717528062240928.6075311812496; Tue, 4 Jun 2024 12:07:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZUw-0006ie-OO; Tue, 04 Jun 2024 15:07: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 1sEZUu-0006gH-JV for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:04 -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 1sEZUs-0000qu-2x for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:04 -0400 Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-671-ETG8bHgAOHu3DZmgY4mUEA-1; Tue, 04 Jun 2024 15:06:58 -0400 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2eaa6f40ef2so11445761fa.3 for ; Tue, 04 Jun 2024 12:06:58 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4214beb7fa9sm31272735e9.48.2024.06.04.12.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528020; h=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=ZWgMEApyId333KyUi6WnAo/zsGBW7n11hly1nn7slNVNgO64pa1AjelCFlP6KlXe/7WNSO /yVADKsIa7LbH9jMbz4bnUSD6yDIlAmrdftFYjicXd4tDQDm80tzhfZy6DLiMbxY7traxF Z0LgysXu++/bltMeDo1DkuhIjug+aT0= X-MC-Unique: ETG8bHgAOHu3DZmgY4mUEA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528017; x=1718132817; 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=GDfjLC1JuXN0DfCr8MpPzBGKlPPrCvgn/owH+GGfBAAt5zIq0z4mzb6K238nJcsI4L JUZmfQEZKcebDPSOlpKTZFMLM60YpzellkNyVcV3GO8r7JwTsOXN5wmgIguS+fktHnGk RErRHS4+0dC7y6FQdFsFPmWggjP+BDCOVtUgBRtdJatIaPBCzrr096iW103eJokufeAe Jd35/5xRyDpv67GUD2lPPFJbmGN7lYq5AhjEpHF5QHIylUAJoSeDyA7+pIvOZ92iIQ3q hGN5N6FP7YMX+V2QC8smThEiN8G7eQ5ncLGmg9P0AyJ7IOFtgf+wbSecBGL7tRiaSTBD Fsww== X-Gm-Message-State: AOJu0YzU2EqWjYS2ZgUdqUkZGHAYxlRoIxGoowt30hiEPcAX20lNV0nZ 1z4E6/PdRH2JVGmrtv7OQkIbkDAPkTa4YdEyRM+fjbk6j11ip2czNjYlro45LhSLPVEZg58Pclm 6Qg0sGL0I4hIb+CRwHwrEcOjJ+YRNpXwmcz/BZ8n6vUy2RqgT7yZDjR0zc4yRpdzHGVZjoJmKxr jyDvLnmM8mhgZnlZRSBxmD2AI9lPNx+w== X-Received: by 2002:a2e:9396:0:b0:2e6:f1d3:9e7a with SMTP id 38308e7fff4ca-2eac7a131c6mr990031fa.19.1717528016771; Tue, 04 Jun 2024 12:06:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7X+ydK2JI/ueRP2L5ShEFmzr2PsFgtPRpJAYhQYmmhY00gcgpD+KGsx8Ap3TTKFGG+xhqZQ== X-Received: by 2002:a2e:9396:0:b0:2e6:f1d3:9e7a with SMTP id 38308e7fff4ca-2eac7a131c6mr989811fa.19.1717528016280; Tue, 04 Jun 2024 12:06:56 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:52 -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 16/46] vhost-user: fix lost reconnect again Message-ID: <250aa64c6416a74f18666ec067ec853a3a5e9b35.1717527933.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: 1717528063904100001 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:29:59 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=1717528168; cv=none; d=zohomail.com; s=zohoarc; b=nx7Ardv44JvTbORccBUZLC7K68+udWsQGhRKvoL8Oa4KzDbkDL0o5G5ZzAalmP8yydbR1vM8lSHARRHj8kytCMMef4Nk/0N/dCqSrDwELLA7YQckXw5AK2L90wkUo+tRY9dulkrrAz2VRDcKMJLiFjmshAlr59vV5usWV8JmfDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528168; 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=GQo7oq0dDQpy9JcdWKkthiQ8nlPb+v+TbT5k1BCgEG6mpZMFzRt2Ot6cvoYtju3In+ZyLSroNRqvCTENvlKkDhGJDBwLViS4xROk7PnDhp2DdU4N7xVsRIY6yq69eumlzYk1+CiBz8FJA04O9W6Ns2EPEK3Ey0Jnc9fOghsh5Ks= 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 1717528168825517.6377924599518; Tue, 4 Jun 2024 12:09:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZV0-00070R-IZ; Tue, 04 Jun 2024 15:07: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 1sEZUy-0006lZ-7y for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZUu-0000rF-OZ for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:06 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-527-N969WC7VOGyjXVsTfZPDoA-1; Tue, 04 Jun 2024 15:07:01 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4212aeac0e2so670555e9.1 for ; Tue, 04 Jun 2024 12:07:01 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4213709a0d2sm125137665e9.26.2024.06.04.12.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:06:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528023; h=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=d2McZaScrJE+3/kB6scOlG/HEIZ/guTD4BxnNFupXCV5axzWC1NWtH1zRT8g0chY8H6CZL OB6UhdTH69HawqXxrxP+fHX2jYW8SOAuG0xQtD9As0iTbxkLlHW6//xzacOKLNK0AOIj/3 fdJUEhJav4EJXhFwPaMWc6aBsR5Arjo= X-MC-Unique: N969WC7VOGyjXVsTfZPDoA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528020; x=1718132820; 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=rrj69GU8/JNvGovU+Yx1edrJOijN6V1ZnAGM95diWfgwnlRJDNDRWukTa4f+oi3SbQ zsiQY8QyZqvgXfy5I5I2EkLWCIPLWeVdrUO7hBjcmoAGuktp3TUGveJoSm5g8eZufwV3 g2BmZYHAwpvo+yv8mSMfhkDtOvv/De7y5JQmG8OfjVglIEgVIGxGYN5dU29TLwhQux/K nzCwVLnymJq/S7Cfj11KgyUVxYV3sR26XEMUUiMRfF41jUoO4kSVOu1QK7LmGzFQIAKi 9KUSOYO9rE91M90XUD7oGiAHaW3gYwdvg9f3hkKmRNwdHLnubPIL6seW6V+6Cye7ZwS+ hgHA== X-Gm-Message-State: AOJu0YwjCxYbKqf0Uly9gizaAiCRbWb9CvuKQiwTVQ7mvjTHn9jfgy/Y SGGtGJ7jUcaMYZZte+cPVdHGiFryEOZNcPgRchpBIIFyfb9OW0SAaWIHas3AaLQIB8jzjBd2/TP AYh3yxjKt1reme7VQOxThML9g8fIl7SWF5+LQFF+QO+Fj4C/sm+uluIYC8DGyRHQmbJOCL4rXIL NZ/yqLMFCd6FTulL4CKA8LoP+zqff2Zg== X-Received: by 2002:a05:600c:3589:b0:41f:dc27:a7c1 with SMTP id 5b1f17b1804b1-421562da803mr4715045e9.5.1717528019822; Tue, 04 Jun 2024 12:06:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+VLGrrKlFVj2OzhlD8Ew6iFdVY76qPENPt7iFHIz7OSYBtzYjKhRNYJ37i2LY30o+4ENsHA== X-Received: by 2002:a05:600c:3589:b0:41f:dc27:a7c1 with SMTP id 5b1f17b1804b1-421562da803mr4714885e9.5.1717528019397; Tue, 04 Jun 2024 12:06:59 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Gregory Price , Gregory Price , Jonathan Cameron , Fan Ni Subject: [PULL 17/46] hw/cxl/mailbox: change CCI cmd set structure to be a member, not a reference Message-ID: <69a99663c31fbc854e45b124406987347a87bd41.1717527933.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: 1717528170361100001 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:29:59 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=1717528303; cv=none; d=zohomail.com; s=zohoarc; b=j/7XBi9oJ0xswJTKGZYbxYKIkwxdaAkhA6gWtrcpJbrVaf1gs0YI5ItV6pZmU14Z7QvQz8ajeyEP5iitKJliL6A2rhizBWJLNjEmTfwucy7vuIR2HVHDFzN1pa74339ORfretCZHshVKv437ELBjEMcMfe9r5tM9OyUaDbRL2Dg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528303; 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=HEAhNBn46NUha95OUKD1flhe48bLk1E4t+Ksle11OqWfFXKq1DMsBIck/WPljjtqe045vK/1KJRztuhnUVIWidDFXCF4J0vYOFPTdBRTnB92cAeZ2tm3fElQBJy1uahvNSWCYtzgVet/PW/v7Mm10IlxFM8eBmW2T0fm2IiJo8M= 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 1717528302578647.9689539071223; Tue, 4 Jun 2024 12:11:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZV2-0007FR-Uz; Tue, 04 Jun 2024 15:07:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZV0-00072k-OT for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZUy-0000ru-Cg for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:10 -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-400-rHcltf5COm2oKxeyvbtN6Q-1; Tue, 04 Jun 2024 15:07:05 -0400 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2ea892f8441so43935501fa.1 for ; Tue, 04 Jun 2024 12:07:04 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42138260c5asm122254205e9.41.2024.06.04.12.07.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528026; h=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=H4Fo7o4HJ8CdaTzhpvb8OG7THpgxeESoeyK+e1nYqkO07SktYxarrF2+9MwRVBJ2QrDlE2 ZCPR7ygab3UQ3BK3534t0lPslHEqATkPbAXB6yvxaYGgSklp+MAWoTgO14nUYNgq7xyWpR 8xF5tNBAFaj+y+m8e08l8ZkfdBUQbZY= X-MC-Unique: rHcltf5COm2oKxeyvbtN6Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528023; x=1718132823; 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=JgiL03ZsLT4ZaPI/qhCrg3VaWioiBaBXn/THDAP77VhqeG/wgknNGb7WNa4ZaWTzdA +rU3TZIBwO/+SB7dYf7G+gUwn9EvIt9DryJivETWn3YbG9R7cfcYDIHGs07aEVVV0CEA q7EogL5NjohhWaKPNhAjIaUcsfhAGYdRDFnjA+QlzbSefiOhV4iV+ufbDa+8cPnPe6bJ bFerMbhKey0RHM+wG/FaTe57lS6F7k+yYnes37oAOm+FLAprTftguji822Nseo511ijX LNA1Dt9lACpfSjYq+WIJerRtpqOWXI7k0Aus7b3Ryinh/j0v5nMY2hU/xXhlxLip+Ndq 7rWA== X-Gm-Message-State: AOJu0YzAE9pb2eq2fxLs1ylCcE0ftVjNPjKOQ8ZZSLChkFbMNo8iSd7S J7HMAYfcGqzLt60jovS5Y+2pK76eYkwO5YwxtmyXEwhDPAvyxjHjuPMa7TzO2UkTZ0eJSSLpn5X veC/S7YwpFPEFd2RtW88LZnNcodap//0/sdzeIX60BsZC2Tbo2YSxRW+T/EwTali4B/mwC7xcCT HX8uLKcc7npgZ06ZSZBGfAQXz0bNSuiA== X-Received: by 2002:a05:651c:3c2:b0:2e9:8c28:3358 with SMTP id 38308e7fff4ca-2eac79f18bcmr881041fa.20.1717528023220; Tue, 04 Jun 2024 12:07:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLmjgCiUF8C0mi2kPyB9h0Xdw4I3njHCZaSoymo5J+K0aMRM/YWUg+8SZYXg74Ux/MPdtiUA== X-Received: by 2002:a05:651c:3c2:b0:2e9:8c28:3358 with SMTP id 38308e7fff4ca-2eac79f18bcmr880841fa.20.1717528022551; Tue, 04 Jun 2024 12:07:02 -0700 (PDT) Date: Tue, 4 Jun 2024 15:06:59 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Gregory Price , Gregory Price , Jonathan Cameron , Fan Ni Subject: [PULL 18/46] hw/cxl/mailbox: interface to add CCI commands to an existing CCI Message-ID: <5b02e8711374f760215075524ee413a1cbaead6b.1717527933.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: 1717528305146100007 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:29:59 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=1717528108; cv=none; d=zohomail.com; s=zohoarc; b=J8i4rWuPNQsD2UqIlJNzKFwCLxtGipey3/VYOe7V6PyseBV19FBeSFdvlmg0U/JBpaiTDrN9fjxUt7m6N7iJChgUFD4Zh5wT2HCmaBLmuZh7rFz7RKlOjcekvrUA0zwmGue+g0eiIojR/ukfnm0a64bTiAGrdr3bts6seMhAXFw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528108; 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=ix16aEDAo/z1IQFy200m/Up16kE3IOqW2cNhyQku6QTtSFRndWJB1YF7pNf7WifhGry1TAUjy0dTHKHJMiP8tYRFEmq94UFPl3mtbjaz/PQqpkblYY9nx4shniCg7ZYzqcnbjAui7oA6XKFXeyssqbGRUKfSHWRz6lgLkdHNoJs= 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 1717528108098592.0184073211499; Tue, 4 Jun 2024 12:08:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZV4-0007Pv-8d; Tue, 04 Jun 2024 15:07: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 1sEZV3-0007HG-6S for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07: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 1sEZV0-0000sB-UJ for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:12 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-316-RK54PfahOryfk7mbDNq1sA-1; Tue, 04 Jun 2024 15:07:08 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4215604d4a2so1746245e9.1 for ; Tue, 04 Jun 2024 12:07:07 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42129de0cf9sm181448665e9.13.2024.06.04.12.07.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528029; h=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=QoFfV9FrM3w9Ykd5AjfWHtpqnS6XpdmpC7HCDYvv47Ec+xI6myuton9MvStKJaC14dmUgl LZEt+Yf7za8h7UifFaWWuZoROS+JZBbgWdFO7IuQy0b2gtxWa0pqOdenr1poZ04+ipGti+ 1QgK/Xn4pEnN1+uulz1/YalBrc5boZE= X-MC-Unique: RK54PfahOryfk7mbDNq1sA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528026; x=1718132826; 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=o1P0AYshxy4Vg7CV2jrO0akWT8lDNtB4nBUcxf32Hts0caJ18Bgwrvs5Yn8jtRuzIL HwhQN29FxTlMM5ZRW5nyVcFZiKluXKmjTvkqVdjFO9stLrY7JptPH2VUf8rzjFkcsaIr UiZOx7iRklWk/QXK0wVkfDep2QdB/8udKsUJWYdKD2gH0QEKZhuDsSmxdPFWyESEiENd HyIxzmpL2BIczuWN0/z4JaYrG9Q4nWt1KrTn6UnxH+poOF0lp+hTeUpXmuygXJNLXtX5 8Tu1vq8W0vpo1jJE+tPhl0qZ8EBcItLe8Xbpo4PndGvzCB2XPoquetKHp5cZqVkn3dip l1TQ== X-Gm-Message-State: AOJu0Yym6sWvnbdU/3+GOmdWm1X8ginOl8MPS+9xSwRM5GxPkDGaiPW1 UiM+BTDDLErgA9101w3JlHYsbVeHISO8HSzVP1zLzzDId1ZV562CXCtJP7mWtUeSbo6YSuF3gDF 98d620XEN228QkUt9F190oXYCEzT/1Zz3ahfWc5of/ThluJ2cr0PsFI/whhcQTVFjY0bnEXXk8I zxQYnf8urD97YiyG24N5obcFhb6yVpsA== X-Received: by 2002:a05:600c:3155:b0:41f:fca0:8c09 with SMTP id 5b1f17b1804b1-421563393d0mr3267595e9.40.1717528026381; Tue, 04 Jun 2024 12:07:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGiv50TYIbSEk0CYNaTOAwM6d///BS30WglIOV4ybTJnZgzqoePnakqaMFWz6uEcARDTjHKXA== X-Received: by 2002:a05:600c:3155:b0:41f:fca0:8c09 with SMTP id 5b1f17b1804b1-421563393d0mr3267355e9.40.1717528025778; Tue, 04 Jun 2024 12:07:05 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:02 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL 19/46] hw/cxl/cxl-mailbox-utils: Add dc_event_log_size field to output payload of identify memory device command 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: 1717528110099100007 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:29:59 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=1717528062; cv=none; d=zohomail.com; s=zohoarc; b=MreGkYlYjhrQMifwXkK92NCdPgCQeQkwffgYWZ13Tl6CKqd+tAD/X6Do+MIxhQ8WQ4AVMZ6GsA59bKe7I1bTv3ialJxnXN1wBrq9Ux3/mwWSXVtTT1UuF7aJ8/9s8lVXfclAiXEU2rm/4uVYSU6yXZtiLYns5Bw4dCzce/Wu9kQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528062; 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=hQJQdgYkrlnrxIoFjbAhUVKm2qqEqUrp9ErZAY33UH0WpKYfy5IUpMXxxH1djOkpf0YMR1+cb8b9aFkIp4E1t1kS4j3hAJ1dDl2XGKiHPINoMNx96Z7/Mp4fBpV45Wzvq4B2EZ7h+WVgDMrLJ+kDN+rYuOi1x9+goZrir63OBdY= 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 1717528062310116.58850171965173; Tue, 4 Jun 2024 12:07:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZV9-000893-UZ; Tue, 04 Jun 2024 15:07:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZV8-0007wt-5p for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07: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 1sEZV5-0000tr-Gb for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:17 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-153-xSYYhw4HODu80bls8pQeFg-1; Tue, 04 Jun 2024 15:07:12 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-35e808b1db8so64687f8f.1 for ; Tue, 04 Jun 2024 12:07:11 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd0659bbbsm12328804f8f.110.2024.06.04.12.07.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528033; h=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=DOTCwhYlPxYUpy6T25uv0+b7SktpfDViLVIRzbCjzseQAxG+mcB6HLoH7LU/GZEX4bk7lr UWTYEXmW3Cj2lSzB57cFjMCyyegjTgCQf/W09UtdyhM6wRHo8wgCpMfDfBLFtS/kPVKPUx iQv8v0Rmuiz/WrUXfCKnsewFrmGnI7w= X-MC-Unique: xSYYhw4HODu80bls8pQeFg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528030; x=1718132830; 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=ojm2o0PVmjDbOy9PRIXS8TRSmAEMpV12MN7NOSP8KdLDvskg2P5T5/47XK+jVIh6pY RWvvm6tmV7A43vA+ZZKRVOWlx887S5RL3jkniWnf998/A2OsrP8lgTgcDs56N8oRivMr ClFWuYIONTMC2UUkW5gDVJ8+hT8w8KhbpL7zlC4V9JS8YaSeMmuKA7RdNkpZmkHi+PMY FSvOthiQ32HdjMQFkK9VnTSDoJnkkjZrFVgyFuRwFFjqDaCQ0FRNtk4U4BcxBJRArFVW CpJK9eR/Yz5NcQjuJJvign9gXKLQ3x45USdmuRp/qiy9wtjhIaNVsb3qqjB4YfhjjySV j3Tg== X-Gm-Message-State: AOJu0YyWI7m+V4jax9uMQFaVo8ieIycAGXnXBMsU3GAHdF22Q4xiBRKe evMZCTRgX7z9DQTUAUVT9/em0TE70B2pkV/4NFWEaDyBjA9uxrPdhV7XtknFlitTMVdDoKEEUyG ovesY3hwuJvAW81mbKa5PSENjHBrY0THtGdw5Po3QIX/G27IB4SEzf/KU98jv3I7CTUICjyD/Nc pMbZBdZ3pQfFNsMYuiMLuSTZmk3NPKPw== X-Received: by 2002:adf:f801:0:b0:354:c81e:b7ba with SMTP id ffacd0b85a97d-35e7c51a081mr3326163f8f.3.1717528029851; Tue, 04 Jun 2024 12:07:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGd0dgTsWT4ZP6HonGzlMLVd/dR36O1NQatxXDuPWYw51BUpRb6w/iZ5Sjhi4GnWm9Ej/8qMA== X-Received: by 2002:adf:f801:0:b0:354:c81e:b7ba with SMTP id ffacd0b85a97d-35e7c51a081mr3326123f8f.3.1717528029031; Tue, 04 Jun 2024 12:07:09 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL 20/46] 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.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: 1717528063928100002 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:29:59 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=1717528191; cv=none; d=zohomail.com; s=zohoarc; b=m5Rvy3iOCxNeZ2i3UrR0BHt84u7qIRQsX0wAn6GgGo+ijs/h79PYrmZOd9kcjf8cdoVJyZ2AFAMQD1nKTXa5eFZSqXNx7VbR8v4IE29+l1tbGBzjvaszLq1tHzEcj4Mw9SLLht9DUcYAVji+lcmNBAcdsUV76Uhh8/WMePCWJy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528191; 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=UyVCw4z0MUEYCPWNPUzcD+CuvwH2OVabPIGfmpVNr6rf7jfoeqs+vNb6ci+a9jCqodFZn7xIzNDmMAcEGs0pyfv8BzBwgnZMZVH+pJgSUpoZ+4r5SqwRwu0f2dXEhruEPklKGiLWuXDENEmrdAizV9pBSwm8aZGGnieHR6AuOA8= 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 1717528191080724.6957748276976; Tue, 4 Jun 2024 12:09:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVD-00008c-8L; Tue, 04 Jun 2024 15:07:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVA-0008GS-Kw for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07: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 1sEZV8-0000u1-1d for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:20 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-528-1vIcTpz5O1SP2rNDg5wq-Q-1; Tue, 04 Jun 2024 15:07:15 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-35e7d4f4243so938465f8f.1 for ; Tue, 04 Jun 2024 12:07:15 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd064aa6csm12364718f8f.93.2024.06.04.12.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528036; h=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=P31I74B2igfBHPWo1hGZn/BT0rGP8cCipJ7HPzs42rgWjkKFmlvaOV1+BtXglTdWqhEfH+ 7dUrbdg8m/eGKh5pgPJerZPkYOJUZRtbE3MmaJ421vTh+WKxozoXeLiDbhKpYO9KBbEd+Z bRARjBx+EVOTIJfjFfqjUSIUStxVpeo= X-MC-Unique: 1vIcTpz5O1SP2rNDg5wq-Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528033; x=1718132833; 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=usdo3tG9K+wnReeUw0DGRONYYEGdRtK3gLqOx6vC1kqGgE7JcbvRY+cBPZ7pSQMhYo 9thKLNOhZFdIB+i3Ll8Lx1SeCx4XbfN4D3vwnETF8y7Rn64YoD2VFY1rjuWrb2XStqLk QNfPcBFEayI17QJFWxzfZx2YHXOtpAuWZj/7vD8AkFQsxf3LcZOkwssgXzB45OypQBDa 3Z9iSdZj7AVwBTfeSfQ6P4cZiuFIfujF5wxcsHBwq3i9ccBc0GsjbfFoCGqSj4jZZPMA FdIVVgptJZyxHRrtrUlTbZkIQNyjpDJxuxfE07WlvJAleSDx0iBJzo4u4CYhTTnaLNaS TxAw== X-Gm-Message-State: AOJu0Yx9mUorRqH5tIuRQxBdSnFDOyofO5Wsn5WLMiV5weTHT/iVWJt0 EBLEGA6AazlxkMZIMP53CijGJ/qVDwr8+ZXTsQiMZ1Git8+S6yKl03sw7AHwG4oxrP/0l+VreM5 XFlJmCt466IC2ap7xsDwGIAWRTOCDpPUQ+4QcFhAI4koWLHSZMqTG6YC0YXFZq7rKvVTdxRcapY aYhPEf6Pd1vK0eBOP22qBVomZpA9AWUg== X-Received: by 2002:a5d:534f:0:b0:357:3e5a:6c90 with SMTP id ffacd0b85a97d-35e8ef937e8mr212466f8f.57.1717528033425; Tue, 04 Jun 2024 12:07:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE50QDKE/gRangmWH8LkkYrAFSCb9KqjPg9SXl0IFeQxipVCfhEEfcHr+IXEmuqoRplgQqHwQ== X-Received: by 2002:a5d:534f:0:b0:357:3e5a:6c90 with SMTP id ffacd0b85a97d-35e8ef937e8mr212450f8f.57.1717528032951; Tue, 04 Jun 2024 12:07:12 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:09 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL 21/46] include/hw/cxl/cxl_device: Rename mem_size as static_mem_size for type3 memory devices 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: 1717528192444100005 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:29:59 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=1717528286; cv=none; d=zohomail.com; s=zohoarc; b=cet/+ukJInu+c155P7F0ym27vdpTR3OHMb+sTT830hdKU9L203WRrdbKMp9escfmuo20kQ2a+87coOjkeGsHxbXlkGKhPCEo1DMGbDtAybBg2andDss0uXgz6elesqZqizP4Sm1fbEO5khpkdX1/MUbuxZ/qMgF1Yudd3fsJM3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528286; 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=j0bKRRoKcyULguzHnVY2CiCnlOpahjk2BA3WrRwszP8EXgRX5Jj1h8Y+eig9Czl9azk7Kxx9p8qLqrCcyuLnRPO1DCKWdGJgnoai988JtqIwCQZGbjBrd3y1V8kTYhIC6bSeW8M+3YtZaVQuAkvvmfEoncpyHbb6WzKE1rFFqOg= 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 1717528286460265.0238451752059; Tue, 4 Jun 2024 12:11:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVI-0000nT-0t; Tue, 04 Jun 2024 15:07:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVF-0000YX-Rx for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07: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 1sEZVD-0000ui-Cy for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:25 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-119-tYgUC-slOaS70RMKhRQKdw-1; Tue, 04 Jun 2024 15:07:20 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-35dc5934390so3106313f8f.0 for ; Tue, 04 Jun 2024 12:07:19 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35e5047f75esm9465264f8f.35.2024.06.04.12.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528042; h=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=JNUGcnrSdMV1gyApcINwGNmEDZ/ZsF/mvj23YDKbYonMwpPRcHlwsJcb6SGg7TuH4FuVOU l6F5x5f2Q0tmg7e2+zXa+2ME2ye3K96lVE9zKBcr/qa9wEH/EHixbKtMLbA32nfwN3tInz /8eTdI5rgZGCRxHf6xm7Ld8UZtNlJbA= X-MC-Unique: tYgUC-slOaS70RMKhRQKdw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528038; x=1718132838; 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=iC1bkkQg6RWCqjwatiYeh/fgIsN7qvW2UOHHKmJeisTt5+WLRzZ51d7M1x/YyzjEsg gQeSIB4bg8Mq25ZxnvEvcFGyXONuNOXg1BVLGe7kgLfh//osJySLdyeqO1wOK3eXaLqq IhBk3IqmjyQsNEa72lPFf43Tw99FwAkWBpSifKhcFMPkv+GVVZOVK4Cbzy2EjvV2h9BB 3ukCXjXt+Jf1T7pVIy4Hz6A0U+wlkNgENx2/Vfgtse2mMHWitQVkDg2lnLNPOOwn6+9L 9YxydKX1XkL22RfDD27kAKiiNXApNFCHJu+YOA8elNVK16FFz+HrWuGf21LiG3c6CELT p74Q== X-Gm-Message-State: AOJu0YzWXEkTUVOkzEUHISN8C9UuoKCCItaGQp/sdMtGaOpF1l2g3gvm aG4VRpQp1SDEMbKb85hGYX7CmvoZDIdbJQbcs5ufZOTTpu2V1t6aMEi+ATf3AuGPEeWRqg98O91 gZgk/dabZMcPjLcoiZo4J+h6XAHAQJSP41RfKfd6rq0zmoud8j0FtrekkZsCl5ig7YFOpabAStP l84CCYjfkeW/qctdZbgMDNjOWv/nED9Q== X-Received: by 2002:adf:f552:0:b0:35e:5b3f:3954 with SMTP id ffacd0b85a97d-35e8d07a1famr255227f8f.21.1717528037998; Tue, 04 Jun 2024 12:07:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETKaLoMDbKOvc029PhA7jBf1mQtFNjqHI7mm3boCu216JE12cqj2Q0GOIno40kmm0IttyT/g== X-Received: by 2002:adf:f552:0:b0:35e:5b3f:3954 with SMTP id ffacd0b85a97d-35e8d07a1famr255201f8f.21.1717528037536; Tue, 04 Jun 2024 12:07:17 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron , Li Zhijian Subject: [PULL 22/46] hw/mem/cxl_type3: Add support to create DC regions to type3 memory devices 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: 1717528286941100002 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:29:59 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=1717528097; cv=none; d=zohomail.com; s=zohoarc; b=n93xUs0I6Rzxr5HQESZzByUzsDSVF61w9+R8PGA9bV5Bwfc7MhZvtdzBPS+AmvuZlqzEMrx7jwvAJ7F/Bk+l5oaSI8nAEvoQjZAnXMfoAhq+WlBd6Tu8EfO3+vcXwlGwrcwmQ6OHuYK3sa+2bnM3fWO9fj52eZiKhwI/VK1P4mo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528097; 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=g8y+cTmQU7DFErk7HmIn6eARHoFsk3VX2MwFWQbKyOoGyJW48YAcf6wEzlSTloaHYWieO+WA95A5jMHjVsYmgRFXBjV8astk6lAMBF2oB2hxE7hRQoA4bbYvMHipKRuQp4rb9C5qIywHn1W6/lexmpNM/LrW7IT3hoyjoDlmUT0= 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 1717528097123896.118020906538; Tue, 4 Jun 2024 12:08:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVJ-0000xE-WA; Tue, 04 Jun 2024 15:07:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVH-0000nh-Va for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVF-0000uo-OJ for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:27 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-NmFtPm_WM2Kk9jSYLDxKmw-1; Tue, 04 Jun 2024 15:07:23 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4212adbe3b6so35385255e9.2 for ; Tue, 04 Jun 2024 12:07:22 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42157359000sm402945e9.2.2024.06.04.12.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528044; h=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=NZkVzhxfRkp4k+BeuwhUOaRrLrLw/4d1Zncg4ON4PXmgsFp8UDOEHSSz+9DKKONL58j/8H c9BASptCFaQhWgFrbdwLy8LBA4g0PzNMU90shU7OHm0O+/G+DWqjOArMglknUP+WdZ36dj CaetRWf1VFDgj3JUk/repCDq5R6lWTs= X-MC-Unique: NmFtPm_WM2Kk9jSYLDxKmw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528041; x=1718132841; 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=csJG6x3Zs4aog1+H+qi+a9ba6mJyxicgpoKZKhjwTfNgL6e+NEfTYMLq87lqOW1a4f xBtraI+IILTolYgQUIpIx9vuwnmp+6vc5D6IdPsbohTBJVsiS5DIoFk40a8/1DULC8JB bwW9RH4sJqnQee1so/NUQykASU/BGVdK6x9IP9bGYiio1FXFBu22L9SZOq7irMGmHnJj WoQFwsdOGX9A/75pJUdhgxodZxEPOPnZlGil0PZJmOtPNGREaSHfIZ5ktc6IgHXhIucT HA3kvcbdqk987zLWOllDsof9NJKl/62cUNSnOlWypZaJG4PEPgXUME1iQEJSi3vtMGdF 0SKg== X-Gm-Message-State: AOJu0YwsvHOFWHIpbST9vzS80pzDl4UqDT43WoqDR8hTRwspmocuWTyn WN0xBXr6XLIc7kvdsm5PEZUTb603kmMeK2Ro/r1f/uHRwtFitrtjMtMXvib/WzA3nYU0nIz7Drf EAF3bQFJuJfX0SG8zJzsnhlRnAcoqQh7Mf28DTOAPZBGHlQcHFMN1GzqjHKjg/DICHa+o+2EClo +jkG9WbjUP32WPljNdZM2p1YllbBoABA== X-Received: by 2002:a05:600c:3418:b0:41a:a4b1:c098 with SMTP id 5b1f17b1804b1-421562e99bbmr3904545e9.19.1717528040948; Tue, 04 Jun 2024 12:07:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGY/q9Ps1vqEepWXdlG/yVAMGQqTRVhUI+7Fz2LlD/F5IE4D4xmz/Z+B3DtVmFvCZYwjoXlGg== X-Received: by 2002:a05:600c:3418:b0:41a:a4b1:c098 with SMTP id 5b1f17b1804b1-421562e99bbmr3904365e9.19.1717528040374; Tue, 04 Jun 2024 12:07:20 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL 23/46] hw/mem/cxl-type3: Refactor ct3_build_cdat_entries_for_mr to take mr size instead of mr as argument Message-ID: <038ad26b2d5341fda3962617eb38932108e1703f.1717527933.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: 1717528098064100001 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:29:59 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=1717528115; cv=none; d=zohomail.com; s=zohoarc; b=nq7B27+czvKJWaI/Kxy27QVgN+c/Gr09CRVV3qS+eZu2IJOOFCWN/SrLjp0ugZbVeGbnV5nXNmpH2IDL4LMKmHpm2E1JSnIPSkYGwvYQfJKncnUNvqJFCcOxhonNWkk0uXwCxmswxs7dUyIg2CwIegXWYimcJIliOEGnmRRtkoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528115; 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=NfeSUU/NB+iLf4RWJNX8BDyDYeBuK2bbiWoxaLAlFhoSECMZH3RH/gAxxgRQ9oaFMOF5fNMA5+tTH8KiwXCISwVMK4TmBgspSridBxS7km0tlUaFSqRBnKMQ1TCwD0xRHFS9j0g122vFxRLXVEU6Xpln3VOSK5rvYlEF2RTexbg= 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 1717528115385256.0448271930917; Tue, 4 Jun 2024 12:08:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVT-0001Wp-0L; Tue, 04 Jun 2024 15:07:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVR-0001RM-5Q for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:37 -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 1sEZVO-0000vq-5P for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:36 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-329-k_2CqyaGPDyBShGg9izhIw-1; Tue, 04 Jun 2024 15:07:27 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-35dcde1be6cso976449f8f.1 for ; Tue, 04 Jun 2024 12:07:27 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd04d9c73sm12433333f8f.58.2024.06.04.12.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528053; h=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=ONukbO8XCdJSoQ7sJ9MsSfTwz/YOTtZFuiSDQwCa+cFpbOFddnbLjcceRfGmC1H3854S/i QbfBuPXtN5O8iTLgzpv9Mxr8nV79Dp+yCuV9//WYt4vQkMcZ15TjQpbTXl+rzllQTUHyX3 nPBOSdUeZtYhFhUgDqt5johlWDvHXyo= X-MC-Unique: k_2CqyaGPDyBShGg9izhIw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528046; x=1718132846; 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=naExqLFYjontHyTOKg+mcr5ZkAusKnUwjtv5zyNjuYWTahaQg4ASqXpcr+UiHUJ9kE s8oEUOFPUaDqC4/+UwDb8/wEiMTxZzOiOwq48/g7VhpxFLCED3UI0pI1DDf4j55iwGPN plvHs0quVVzCSxxRSYeOHlAUpZztfKwc+Pfk+JHK28a10fmn7Uk6uR3mS3VTfTeO3VQb UX/uac2+eKw0hd35/OwwO8qQOH+wubvO64ysLEazSnUPkrWmp0yztzRomjlb87CvJB2/ +5GEiZmnPWwcNpI5XCyKlpc+RLv7hDowxCpOrieLbC/8kABvOR520R3SkZQBpXaSq8/Q gAmg== X-Gm-Message-State: AOJu0YyJ+xJ6YHVWmr2FiXqnFggXty4dFtOv63MZTHxHXqAhKKTqxkgg 42l+ZkgNXghN9nL4ZzN3J77Wfz9usKO8y8CEFbQNbq4J1UbBvEFCFaMbj8eKeuKCeYGK8hypEGe 9js5ilH77pSXJjtv2RbW5E+80FfEWFpVFy5QJ3PkKzWff/j8VELDydjmnL3NlZsNSdvXp3FcBtC g2XS9vkx0XOQhieZgqYfUmH/sbo46Utw== X-Received: by 2002:a05:6000:cc6:b0:35d:cb8b:bd2e with SMTP id ffacd0b85a97d-35e8ef98e8emr208057f8f.67.1717528045852; Tue, 04 Jun 2024 12:07:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+kd0i+MknlLG+42tY0MjHiMxJM2M1SoMQQy7T8OSRwmbNdS3rDI8pX3tdDPZ+DjrYACFgMQ== X-Received: by 2002:a05:6000:cc6:b0:35d:cb8b:bd2e with SMTP id ffacd0b85a97d-35e8ef98e8emr208034f8f.67.1717528045295; Tue, 04 Jun 2024 12:07:25 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:20 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL 24/46] hw/mem/cxl_type3: Add host backend and address space handling for DC regions Message-ID: <4778704028d57318eea45289561ed1e611439d9f.1717527933.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: 1717528116311100005 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:29:59 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=1717528203; cv=none; d=zohomail.com; s=zohoarc; b=muxewS4jX6tDpplMSazzAFf5CtHmIBm4s86ic+MrHQnwyvf2GXjzLYhJlA8kcsHyyP7lmy89QB1/URrBCbfyyFreTGKs7G/pIRB2jl2zrjjoTchtb5R248yMv1HLW1LAWFXV8j0O3aaeWnsSuSdYnf3vtFFfCxRvzLcMSNOOIHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528203; 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=QSZM4zNkoMn3+sd35txVS4lebj1flDamecc5a/KQOkLD6bPBOzm5HxmYiPdrvLKRdc1BpL764WXSxBoItXBdV2Z0MB5ZxHDTLdp530D9A7n4TQmSIaS8L4PwSOETYKvqxASsekp/GEulVzW4B+OZ56GsnmNSSnzFN9LDCiLf9M8= 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 1717528203527388.5378200759242; Tue, 4 Jun 2024 12:10:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVa-0002JI-P3; Tue, 04 Jun 2024 15:07:46 -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 1sEZVX-0001zC-AX for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07: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 1sEZVR-0000vw-3E for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:42 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-326-z2Z7ZwCKMXqboMxbhBoUAQ-1; Tue, 04 Jun 2024 15:07:32 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-35e0f445846so3151002f8f.0 for ; Tue, 04 Jun 2024 12:07:32 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd04d9c89sm12353243f8f.60.2024.06.04.12.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528055; h=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=XayJ8H10dUdraALq4v6QNiDIbGknU9/GGPWXR8Uf1getD9Eagxs//hudFuD6/N3VNSl/VJ 16CtVkyRTDY+04JthIaSvS+oMumj0Mcpslw3u+5V2X3+S/oPD6BxvpLQtDKulykxMxOF7/ 6U4OJ6gl95mI7MPLoD0YKXrQSOiUHZc= X-MC-Unique: z2Z7ZwCKMXqboMxbhBoUAQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528051; x=1718132851; 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=lwpDIyGxG+PRaBMtDfwVnMwVAqK1YqMKftsZVZBZ5uUnr/ZgdObzck+JFIFdrj9Uv2 P695LoKkpXBK+MJh0ETZ6fpHRRT+l52qFFVLH9jmFziUQkrk2Dv8jWaAe/ex/qqmsYMb Yeh3NsgBrNn0+2AIG6n2LuGs+AogINatUltrasS82A0g46yJHYvyawxmHQh6chOwcJPR Sx40XWk8c3hz/pTY+uscQnFLn+o3YBua/dcs51oRbLCQ+O9hqfRrmnr+pzRW8MUJp+KK 8CbGkZvQM+VBubHAWa/O5VKsdYLhjaR8j/mtIX0vaxWzmqx3tjauG3Z8VDDzCYrEzMkj bNRw== X-Gm-Message-State: AOJu0YzzaPOeYk7fnQMhYVYvDe4usfPd3Bl1vdsmd3LGfWizRO2y8AZa hTHsw1P1DcpHeAiW2G4mQnYCL2enhIF3J0tj8bDt7Wodtjkt1VpXJCEo920lHGHalzL3EcasOFd uDSPWMuKsBLMqauN4O9VjfAPFCA0+JczUGsaJunKbwJg9kWzDr460XUnnyj3c3r856PzUqyF6hp nNWQQca8NkNjg8oaO6bQ34qYOV45TCWQ== X-Received: by 2002:a5d:64e4:0:b0:35e:8099:67f with SMTP id ffacd0b85a97d-35e840677edmr343292f8f.16.1717528050625; Tue, 04 Jun 2024 12:07:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHk7GOlvD4VyYtyvjKwZMfAFHn+w/Xh395gtGN1TymCNT1yEv/KWkah2W4lFzP4i/oFM7EWuQ== X-Received: by 2002:a5d:64e4:0:b0:35e:8099:67f with SMTP id ffacd0b85a97d-35e840677edmr343260f8f.16.1717528050142; Tue, 04 Jun 2024 12:07:30 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:25 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Jonathan Cameron Subject: [PULL 25/46] 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.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: 1717528204512100001 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:29:59 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=1717528073; cv=none; d=zohomail.com; s=zohoarc; b=TBh4/j/pvnvfBHUOTJDDN5wlOZDllnweLvHWCGqa0bkSS52rzk6R5YRA49V+4TJLss0SFvUBJnzBDoWE6LHZKlA952+UTAwGKIK8NJPeL+sWcwpNXX7eXzUq2sJhlSdRQltMtJgtaOJJza0akBz9dm2mlfokOu9tED+7jWjRftw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528073; 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=gLqd5nbSH6QVSptai6cNHkPYcXEXSmlwAAiK7lXniElHKCeJ7zlLvasJHPRC5h4dk8VIEvs4yaF36yFdxGnxLXWIJ9pnVlH4R5aIvmOX3Je0GCayybaEQqHgzBIsYFVVVrXvh6i93/V+b4m6X2hJRhefQLoCP733pHWjpmH9NgY= 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 1717528073878430.6013002736404; Tue, 4 Jun 2024 12:07:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVY-000265-FG; Tue, 04 Jun 2024 15:07:44 -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 1sEZVV-0001pN-WC for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVT-0000wE-4y for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:41 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-8XuesODzOGOlamgSxrTJjw-1; Tue, 04 Jun 2024 15:07:36 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-421388f1deaso11581215e9.3 for ; Tue, 04 Jun 2024 12:07:36 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4214beb5c9asm32032775e9.7.2024.06.04.12.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528057; h=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=AjqwTJcx0Ww78ifXZxJcguBmBR1lC7XW6xYNqFWAlJo3crsHKganR5bdZOyCtINz/9tzaw JsvpSe4r/zsywziuoaj/mEuc2vumBAgD4Yhxg8M0uhfYM47vo+P8wOre2AJ4T6vpOqU4BR DxyC6OCERpS+JgaFZ1hA8FsoW96hTq0= X-MC-Unique: 8XuesODzOGOlamgSxrTJjw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528054; x=1718132854; 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=mM594J6skuU+INy7JRXSdmqf6gaEaWAtvOLtSKPciRjg6T3n2OSskOgLWRiA1p7lAM fOQoskSOvjpWJ5quYEMMeTjkF8u+WujA9oVpGnl5NOwvUpY7EJtQwOmQMvKJGRLv0tOl DTqtD3ao/abB4IasR2HzFv4SQDTNKMePDr8xbzU9U3CngNeGMWDm6H4NcyMSKv5aAhDO Dshgd4x6O93+1Y0eUL7X//UsOQpprIWKNtiLibh+xkGjWturqxKCYk9hn/g6TcxQEMha VT+kAy+rv7VCTC2G1vhrjbkPJWpZGyLsda7TEOmp9dfq2OzRbCWDM0t5RzV8B+4OtwgV ZHDA== X-Gm-Message-State: AOJu0Yzx/z6mF+2W+yzMbb3A+TzUC8sx71GEgBnMvtTPPtn4WwJrqXHG NDn0pLothFPmwK6e+LfY79d06mZops6acVyg72li5Ohxod0ar9jVmuZ+yCTQ1O8a5V8ICQNPEoG pjpFAyfiUopylkTrxkkdpNYYn7IBHpoj8tOozBoX+qyLlKKEjdnVGtzLlNuorCbLVLJzuTXiy7O 5NAh//u7xMngJgEvj87t1rQx5JRgz8qg== X-Received: by 2002:a05:600c:46c4:b0:41f:b0e7:f299 with SMTP id 5b1f17b1804b1-421562cc205mr3347825e9.9.1717528054231; Tue, 04 Jun 2024 12:07:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGluwx6D0nJ1rclKdR6q+u7zzozDBebaOpVS1R3DJuP8FLkiZsyDQEJfMO4XPI+RbmZ63U+8Q== X-Received: by 2002:a05:600c:46c4:b0:41f:b0e7:f299 with SMTP id 5b1f17b1804b1-421562cc205mr3347545e9.9.1717528053519; Tue, 04 Jun 2024 12:07:33 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron Subject: [PULL 26/46] 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.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: 1717528076384100001 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:29:59 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=1717528135; cv=none; d=zohomail.com; s=zohoarc; b=Yyk6/t7w8UAjoW1MoLoVVIQnXF9o4alyMTc1iZ9Tf8GE70D3/iumr0m4VBVW/aqdr7IKl4/5JIfziynthPY8NFsxxKE12sAup00bq6r7SfVsDOm7AUPokCWSEeEeQmeXZWGjwo+8V4QnLiZzfQ2D9SSqj1hRb3BKMkkIAsqrUd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528135; 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=Ljb/N8l2KZrmNP5rJmNe7RlSTtH/xj60BON25t4Z45LF9+dGbIDzy0NaZKowSd6Ok4E45CPTmYI5zh75/SSldHlJunxoBHLof+bSU7qob4zdvlI83VWXmkMppMsFpxxyFpPDHtFG0HB67lESI1m4Mc0T/7cPbF/yPlo1bFZFOlA= 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 1717528135479373.87727338254217; Tue, 4 Jun 2024 12:08:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVb-0002iP-VB; Tue, 04 Jun 2024 15:07: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 1sEZVa-0002KV-Iv for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07: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 1sEZVV-0000wP-Vp for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:45 -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-680-1keN8mSHNVeSwhc_DDSFEA-1; Tue, 04 Jun 2024 15:07:39 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-35e0f8bcc3cso2518520f8f.2 for ; Tue, 04 Jun 2024 12:07:39 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd063012asm12496180f8f.75.2024.06.04.12.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528061; h=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=Pgrg0MzU8JaqjWKCU8xgCo1afcA/0s3FEUBxZqyuNO0yoP43NGqRdyzOkfQqwdl5mAJ6kd WAfeWd0B/+F/WHJ5i3gCmU/3UkP9h0XQMiT3xmb1HkpbW5oiFhxPdkqq0HCckQyIr0ltn9 lusy9TAssSwnUfFv56GA73iMQb1IJr8= X-MC-Unique: 1keN8mSHNVeSwhc_DDSFEA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528058; x=1718132858; 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=QAnf+WKzUs24ZvLQR5zCDZV3J0HfB2IyiT2vKUJjqJ60RpMpNp7IXjNfdMZkdRLbDY qcpPaeN55gYEGFJnVTA3M0ZbjV8R5rVOFk+o8ZCgsGLe4+tOFgX0HHFChoV28ZIAxpld bGp8KrynNtOikHX39yjpkWkcwuWm/KIst0qTxDZl65/5A9dTFl6rcRvWTKKIjtsTTNoN XJZ6OWRQYJhEOFYKFrHU0Z24UC26ZlEX+DjztdIMLFsA/H09+Pa5ASkzXOSYBjmrGY50 FfT9GqOwmYI/LW6j3+FXcWjlWXm6i7OUqb0kjCMEEESSl3Omw1KJqswcb7/8kFb1DLVH g1qA== X-Gm-Message-State: AOJu0Yzo+OcqZijxDq3EqK0UwpSUbajjJQv92rj7MlNiZ3pU9uS5WReX xVfmWz4zrNjTlpOJx+b+EgkfxnPl7Cq3nqnpTmjuXxxbeuSakt/DG1XGKu/gremnsd99uzuYkWn jkay4SaSJIUZg2BXZ0rRiR3NIg7LMqdV3ImklfQvNxNqAK7ZfhQR43HxPDZ1Srd5dnX7dVoa5fn IXEb6BcoiMwLgQ8AXsKasmY27bnsFErw== X-Received: by 2002:adf:f552:0:b0:35e:5b3f:3954 with SMTP id ffacd0b85a97d-35e8d07a1famr255842f8f.21.1717528057925; Tue, 04 Jun 2024 12:07:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrat6AkjWqbj5PaGfEogMCIL8xXII+mzGsMxNlgV+hZGwsxfrdni48Tx1AuekOiybv6LAQCw== X-Received: by 2002:adf:f552:0:b0:35e:5b3f:3954 with SMTP id ffacd0b85a97d-35e8d07a1famr255812f8f.21.1717528057270; Tue, 04 Jun 2024 12:07:37 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:33 -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 27/46] hw/cxl/events: Add qmp interfaces to add/release dynamic capacity extents Message-ID: <207ca2e3b7b9796fbfba8d33eee1bee7f0882141.1717527933.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: 1717528136332100002 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:29:59 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=1717528135; cv=none; d=zohomail.com; s=zohoarc; b=Us12StsqMQyO2IPXESOFWP+6DVgNPNQnRHS1un/cHEtoS9UuPP/mhmudwhypzfL+v2py9g2XdEp6/PMU5Tf1szaxyxtokC0YVMJjLUd3DPyjJJJVhxQM8v7qyMYr8/oA+T9gJ1u140ouFi8FPjGrgKG4/h6jE2BrVe/Ir6nqriA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528135; 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=MiHaAb4c5BdvbLCFr6qEB2a0j8879OnosCKI302vQ0VlCxh/ycDhXTl3Pg8g99qpM793WcacgUp4h/yTSGpD/jmOrcwbZEfcNNPqHz+zUQRoVXcNO8+pFR7K4n9V01UnV+TrahjOxvc6He5wKEZRON/+O5TxDdHPW3/QaWvH/a8= 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 17175281352731018.5767803444623; Tue, 4 Jun 2024 12:08:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVd-0002vd-LP; Tue, 04 Jun 2024 15:07: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 1sEZVb-0002dn-Hp for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVZ-0000wj-4E for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:47 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-190-EAO8d4diPcGt8ESQJq9v5g-1; Tue, 04 Jun 2024 15:07:43 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4215604d4a2so1748845e9.1 for ; Tue, 04 Jun 2024 12:07:42 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4212b8a4f98sm167172705e9.32.2024.06.04.12.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528064; h=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=fNTW3a6tYoQQZL51ICDhenu26svU1fMXTO2Vl4vPjN78LL5hu0clhZlwVrdHWsrSM654Sq gdtUG9FoJrs65HJlIkHibGgGLH8ZdpYd/8u1Dp2Z0TWcaCMR6JPjtGOLSUsQRVFF+R0rZQ Aonz7+aguCE30x3v0/RQx/BZL+WJ42A= X-MC-Unique: EAO8d4diPcGt8ESQJq9v5g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528061; x=1718132861; 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=naGff3m7i3YQn0wOm46dGuOvbk/5aJ/Fhn0bWN2vCG4F/Ktqi1MFco9VwLWlRyqvd1 JRfrqiop4ZdUBd0HtewuPylF/Re7BSH6KpnHaSeLPUDtFjCjyZxt+/do+PeGjVskDIS+ REu0Qvt4S9QqFdv4rEBDMqVO1wv2z80FeIJQcqHSUUk/mCb+JmDIIIpjiix0pIeZcyRS 1Ya7SjQ4hh/kEsEo3rLrbBetES/bjA5Q3hiR8ZLl0dMRl3O/QfdhFEjCBHJXYM8qtbf0 j12xTc3DsEip8HOBiPdeS+IVF6619hlYLztKEvBQ2F0Zl4nKl1Cv9v9GWF8wShlwoEDQ b7UA== X-Gm-Message-State: AOJu0Yyye+CjC/1whlo4ocSrIc8BrUbPqJgtBKN4fvhGSdbr4l5bpkXS XXiKUL8A+S327MN/dU4txm6EsNQBBK0gePzkebgqQ1Kk8we+br34SAug6lxfxR424Aa0P1Hh+Ym BrQeNmXVUsTuuMFG0P/wt+/Je29qozzYjM+86zR155jpsf/h978eK8hzUlQoZDgdRm50oAlu4ue BPnlXtXAX3CPp0CCqu1IFBG62Xt3jo9w== X-Received: by 2002:a05:600c:44d4:b0:41f:ed4b:93f9 with SMTP id 5b1f17b1804b1-421562dc3abmr3687255e9.19.1717528060824; Tue, 04 Jun 2024 12:07:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdReZCBXDXyZtoiS7EXWnfAw84sZEG3Z2ceLy8PRYCEJo3xhYUUd1HK0Zdl7PCksGgZJcaTA== X-Received: by 2002:a05:600c:44d4:b0:41f:ed4b:93f9 with SMTP id 5b1f17b1804b1-421562dc3abmr3687115e9.19.1717528060318; Tue, 04 Jun 2024 12:07:40 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron Subject: [PULL 28/46] hw/mem/cxl_type3: Add DPA range validation for accesses to DC regions Message-ID: <7d324ec4556b188c58ab9578a512e0367692d6bd.1717527933.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: 1717528136306100001 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:29:59 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=1717528304; cv=none; d=zohomail.com; s=zohoarc; b=DazhknWP1EAlK5uaAranE4L2RToVrj04VKhQr+tF3hItuVw1Tv2T8hhXOI0vrNNFtjEuYOPfugWUYiAN5lSrwl+wtTXjp8tZ6A7G3DD73ZmOfEcy/NgxDAfpM0kfgltOMCC1MR5qWwIDggPx2KgZHjsd3ln8hckvrtriqiyl8w8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528304; 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=THXWiEHd8rC/FhC5il2+ldaTKolcdffQ1eHiASCzGvB4Q8NKnTgusQW6F+c5mR+kKXCuMgpsPhy8pcKF/5BmvGeSNexV2eh5AdJIBU9rp3k7RG1lK/aZVkEo5xFI8NCXNnMnyEQ1I6m4OXZg8M+8f9f0rQ+aKVBe9uVZWsGuyvU= 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 171752830418850.53645458484948; Tue, 4 Jun 2024 12:11:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVh-0003JU-Mt; Tue, 04 Jun 2024 15:07: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 1sEZVf-00038A-J6 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVc-0000xN-RM for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:51 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-655-Nk49qZM-PT6Y9Oc_tM6-Hw-1; Tue, 04 Jun 2024 15:07:46 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-35e83bf3294so109121f8f.1 for ; Tue, 04 Jun 2024 12:07:46 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd064dfd1sm12517936f8f.108.2024.06.04.12.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528067; h=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=iUXB58ddxQrLbPfIsxzZ1RFuR8gLgm/iBBfe/QeTwjeAnVCopH6pN36dEqrneG6lfr/q9+ tsHbPzyqb1pWYmmLZdVj1fM6xT08lzNig5LZQPRaNud0U5o0YP1L2SnRF6jA0d9Z/OYGoq g/vns8ElI0MvLs4H6PEE1SKiqVx/YqA= X-MC-Unique: Nk49qZM-PT6Y9Oc_tM6-Hw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528064; x=1718132864; 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=lJFy6l4lXr/Id8b1wQIHw60ODcTU2AgdibpVaX9qevJ0SgdNNfi6vbGGVDV8fDc4x/ gSiR3KXJi6xCamZfrms9peQp1u7ighKgo3Tsa7BFC3R70lbeAIzpmUY+JE5TwWKYfJ03 hZ+oFFCkklSPdRg02nHEH2T9vc3DcLSgqxGD3LXaL5D3Eobm2goeKfdVBHEfGJRnWeLF if9oz8O2yg4DgYm/AK4o+YFNtZifd1TlOEQj4etakOJpaJvIAyA8CWLhkr8r2WA77kCP EvPpOECzyIZilo7zAhETzA1B5vRXgtk13lKUtacrXunMJyKeMtL1hco/GgRJ0X3l0fP8 yAHA== X-Gm-Message-State: AOJu0Yw9chj85trDM31bEb3rNRgky89IvPltUMMCUf5zY0W2RBtGnE7d ZXT5abIWkCU0Autij3MAG5Pjl+V3Qph+cmZhCk+JbNKZxTNJcTySe8DVEtNRAiB1fu2K5YPu+FS tkRXuMn0kQ8w0qcWCB9sFtECcuppbXaAJ0U81ll6ljaOOnTQwK5S8A4CkC8USYfxTBroyNKs9u1 AYuSmWJ2+cdlwJfrKfHVj1UNf/iSSWvw== X-Received: by 2002:a5d:5402:0:b0:358:ffe5:dce3 with SMTP id ffacd0b85a97d-35e8ef8fea6mr213463f8f.49.1717528064435; Tue, 04 Jun 2024 12:07:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGATLlSHlwkWNmGeRAzWO9VcJJgOUCRml/Ahfdmheos3UF4mb5mBUCEiwLLJ9rG91wT/RnEIQ== X-Received: by 2002:a5d:5402:0:b0:358:ffe5:dce3 with SMTP id ffacd0b85a97d-35e8ef8fea6mr213446f8f.49.1717528063974; Tue, 04 Jun 2024 12:07:43 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:40 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron Subject: [PULL 29/46] hw/cxl/cxl-mailbox-utils: Add superset extent release mailbox support Message-ID: <1fd233748ea9aeff3b88478cf106ad3bd32a1df2.1717527933.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: 1717528305140100006 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:29:59 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=1717528307; cv=none; d=zohomail.com; s=zohoarc; b=Ek7sPqbkqWM0SXo6q8cU37WGOmH3MYtVRc4j70Nhg2O4HrCHqzK7Q5ns5d7u5TeS2/C75nKFmMCKaDAC1MHamXwCUUBDGrpHwxU8AgVCKjGiQnPoT78fOw+JGNIa8apjHejTFbnAgN2RU1tZsDeWA0ltb3VMLeBN/ygOsHsLArI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528307; 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=MK6fGy36qaAZLTx/XaUnKqYYonTtkFyJdFf5u2rbOCW3YL2WF58rEO8WanJQL4XHHFnhaIwt9Qo+oRRqBYnzfBYYMBTfPCgXMP7cUCtYYtYOc04SV4+uTV+uwEjhOfjrUBFKeBAdPQmxBOB328Nz+UsSAOSiHpxAwySfef6icOo= 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 1717528307098797.5489677149898; Tue, 4 Jun 2024 12:11:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVj-0003Wo-1x; Tue, 04 Jun 2024 15:07:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVh-0003KO-Lq for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVg-0000xr-09 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:53 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-473-_Zk0_7QuPFuD8eiOzYJShA-1; Tue, 04 Jun 2024 15:07:50 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-35e7cce4c32so1055328f8f.3 for ; Tue, 04 Jun 2024 12:07:49 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd04caf05sm12262706f8f.42.2024.06.04.12.07.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528071; h=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=W0Gt58qV/FEigNP+5udIrmtxE5r/NgRxVTUdqRm6V+Vo6lYFfa2Y3Md3TdX/oKa6ApBijh jDJRxPH4eIcm4WqiohQC5mzTiadlvEp7518B1XWrlO8wNlMHs+67UcYzTERJ8ALNOGY1cS /AL4dweFaGEOimX32ylBwtT/YyGncn8= X-MC-Unique: _Zk0_7QuPFuD8eiOzYJShA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528068; x=1718132868; 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=s4sV7GQAz6FRvhM5r9O+xaE6/WohwmC76c1/sanu8c7zbv9QyWKEROMrg+y/lk6BxK qJ+3nJxq3ezQciG0pnAfKRy7BpoiRdorfQvHMeRjuo6cweL4lhXz6c7Xzdebx8J9zxVn JlaiCEKv4ZMFrgOvuuJvY2roA1cNJ6UeIgzbodx1gfEBn1ELXXDQ7z5lrxI65E4oukHz vste7Os2JwXoiw3cowDY+sd6KcjPclLjDiTEywiF3ARImJMXgTbK+P3ZF/1MZ9Aw0GGn S1nYLUgsp2O9eRKSrKONT+AKlDxakXr+cunAm3cW6BydxXYsNd30Czv4KKg0UubaEQyt /BJw== X-Gm-Message-State: AOJu0YyBVyoTuS+DiEAHTok02P0FnLl/yVpeLJg7bZ1Mu8Jkk5h/D6ux w7OQIKs2m7o4m9C97yGSSIhmI9BIWNNSvWOeFrsUiYEaaGwKK5kel01r+L41wKlBCQ0AhJaGN/q 1dn3DBJcAo5GZMsSypj5HOwCaxKyQ1j3OWZQegrN68GiMkOJPNL1jBdTrUv+/kzBNfDmxq9/LXo CGYl5nvMGeMZEpAS98H7EOcK9PvbC/lQ== X-Received: by 2002:a05:6000:d0e:b0:35e:83c3:48cb with SMTP id ffacd0b85a97d-35e8ef93fedmr235716f8f.67.1717528068288; Tue, 04 Jun 2024 12:07:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQp0e7dBdyt71188NymBMa3QkPpuGkRfzjcqcU5FZ0eBtRJjlLpDwgNGnYcCtOA4LwbSOC1A== X-Received: by 2002:a05:6000:d0e:b0:35e:83c3:48cb with SMTP id ffacd0b85a97d-35e8ef93fedmr235694f8f.67.1717528067837; Tue, 04 Jun 2024 12:07:47 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:44 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron Subject: [PULL 30/46] hw/mem/cxl_type3: Allow to release extent superset in QMP interface 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: 1717528309020100003 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:29:59 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=1717528239; cv=none; d=zohomail.com; s=zohoarc; b=VLqZP/wj+PjlpVh1i/qEoJJ/HqqWvR37Xir6+ggPcLVY6lNF3+eADPKjzOj7R62PJSue/KBublj/FXin7Zn/SPoh9VNHm74mi/jaC31tYgPLHFYZKyXtdlSPElxhoSSCLZq662W+ONbxKvnkUHzxAcNA2hsgLYUdZTTdW8JJcCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528239; 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=Ew1qA29MUq80JOYQ9x2J86UUI6gD0a7X1fPGmyWv7RW8JdeM/wPz1a1zj+Gdrdebc+4HEg3bIokWRk3tpKx0uRT3n/sGCFZzfR/TFhUHBrKux1gj5TjCdjhUtqRE4wA+IngvKxQg/2R77CSG1s0vTeO5bP549bQM+/NLEYFulik= 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 1717528239120582.1176062172444; Tue, 4 Jun 2024 12:10:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVn-00046b-GC; Tue, 04 Jun 2024 15:07: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 1sEZVl-0003t1-PQ for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVk-0000yM-1k for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:57 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-527-pV7sq-qvPgi-46Mjr1hTQA-1; Tue, 04 Jun 2024 15:07:53 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42156093037so1611705e9.1 for ; Tue, 04 Jun 2024 12:07:53 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35ed8b574e3sm52528f8f.79.2024.06.04.12.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528075; h=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=XfXwZ100Apolfa/+2FbEmJDAseq2wxX/d4QQLPhj/NycyKA9MNcGDHIZzqdCdSg0fVLGf+ jIR77U38amHlXNSgVS56PYpzJONeQfmhNx6RrB7JKu97VQOegSs9xV3Fh3Py2o2xFe9Mbq xR4mG0XYBxoURJhXtGFNNOryFkPWSYg= X-MC-Unique: pV7sq-qvPgi-46Mjr1hTQA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528072; x=1718132872; 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=MVpXi/2o8KlFgpXkxOi4elKTEIPpsS2eyDL6b0rw2ST9SAlSsl7ythI3LekDy7plJj 9c5fQ+g7v8tBAvFl9i8ulFcRqZWY8N3pSCcuSXKgM0EKHZkylDBG/PSSIad2ffWdVD5h e/ST9jerx2bxE6eKaD1MkBilg/bIRnLD3HvlQeQ51gYTL7MsjEnx/cZ1Fi9nLeDueuqH YCLqk/FwTt+sa5aOl1WWFmWQwSgkdx3RR3gml2SL0L/PkTB2/1jIS7Nf/G1ILg1K/g2k chq8nnIKuuYc1ouVGdG1PjYH2IjRT4i5JagkeXUhpM/IEAXUCe9PvI4afOljft/aYZig cYrg== X-Gm-Message-State: AOJu0Yz+ePJVhTm7ZurVYe6bMJ94puVA/NKdVJ9nTx80gVE9iIdkQRhk 2eOXSVX3He/12iqHeklTbLE0Q9kJ/cQ/A+kpjMXZ08jD8qLJS4+rlULMCT6aNk9MueNj0G3FutU HmJXDIHGthj4eghfNiYQYqaQaZNa0AxeB4nIazfc/0g1AaRUOUzjpd/c9AaaZ1Rz0UcELc3q0Jy 9S775KJETvz2Qw7Kg8tNNXOurDaHCRDQ== X-Received: by 2002:a05:600c:1da3:b0:419:f9ae:e50 with SMTP id 5b1f17b1804b1-4215634dba3mr3428745e9.37.1717528072159; Tue, 04 Jun 2024 12:07:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtmf1otv2cfBpSc0kN/2tPZPOjIDE3hj4mgg2t9VZw5P52wHDeIYV7CndRteKV44ug4AObAg== X-Received: by 2002:a05:600c:1da3:b0:419:f9ae:e50 with SMTP id 5b1f17b1804b1-4215634dba3mr3428565e9.37.1717528071749; Tue, 04 Jun 2024 12:07:51 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:48 -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 31/46] hw/acpi/GI: Fix trivial parameter alignment issue. Message-ID: <481a30a72769a5086a0596fb6ebe19d16d2bac77.1717527933.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: 1717528240680100001 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:29:59 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=1717528280; cv=none; d=zohomail.com; s=zohoarc; b=ASoMhovzLSSHVRqtwV8qqj0aHmC8oZnsQwJxCeRYlzWMSsmJscgW7kbNBqEZqksf8cV4meub8maIgxP/TGBGyS09ZZ210bOYRmGve2dbPzCvea2Cng/m9md1ykwT1gtd3+ftWZLDD7w6RISxBpf5vbt7wfrFZumj1YpxdtnWbhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528280; 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=FwuyVVfPjFWeuIbVTwt/RtX7dML/Cxb6ow+65f96FM3oWRqKmGojAOru6w+xAWcfOtQrrXkJhIoaI2bKjVIsel7ziQuqFSQ0ELITZiAw9M4cDZ+FEL5f1n1RdXwODBGg4WIZfpUH4XbVcGjmBuEQP9/Auiko9tleNFSlXUvOMmI= 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 1717528280253501.50234924617973; Tue, 4 Jun 2024 12:11:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVr-0004eU-3f; Tue, 04 Jun 2024 15:08:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVp-0004U6-MM for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVn-0000yd-9S for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:01 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-202-17VZsbEUMYO1oAQ7B5Pvkg-1; Tue, 04 Jun 2024 15:07:57 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42133ebdf24so30286115e9.1 for ; Tue, 04 Jun 2024 12:07:57 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4213837673csm119049435e9.31.2024.06.04.12.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528078; h=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=UHqJL4RY6avWa7rRnEOMMzFzpbK6Q3eNPnW22DDk79fCgD+py6EXhbrj/jyE9yumJttu9t FIC4T8ogkDJrremBqo2aWIKgs9hvW9RNXwY/MmFJwXpQ15LQAib6JN2eyMIfO9rM5C4xLx 7hOcEJCKD1sTBf4dDlGypCGV3pghFN0= X-MC-Unique: 17VZsbEUMYO1oAQ7B5Pvkg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528075; x=1718132875; 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=UWV4WuLz4I3ezLn3XEYf+I7m0fFzd1BKB8+Rib/+96Y5pt/2wyN2XvoO4GuPLf4lLd HkBOox0E7lFM+Oj3qPQ5S+4v6+wwcOlIrOrps3Q61LwTqIfnmHNQlhFU0g3KbdD0LMhk VLE6VFuWQnC1ekW1uC4lm/uDXuPe4NFM+taIpUToHnb9FY9lxcI+seIoWtp4g43NfCPj ml0hVbWYa57T/YYq/oaJExXuiArNIoI43r2/EjstENrv7aLH5ltcDDH69mkbH8UNu+D6 Bd2MubjbXHT342/2yMMtrnI1Nza7C3mprsSc8l2fJvyRFI4X+JqyCgZSkKuNpDLJH0Il Y82w== X-Gm-Message-State: AOJu0YxHD0apQ+Va6hDnAJY2XW4h20/Cx/d6okXAOh+f/Gab3cL946Q2 aQDz5/wPFyZTRe952kdhEeXpFjamxMnohihMWcaIbUNWkwOrhJQvDddLpvG/VuJnCo6ylVd484+ q++mttFNz9Q4bZi/4bCUoyXmybIYtGbB3PyqI1S30MLCE2FC5B+AJdBApcmZFsRSTprX2LvGeiN AWBXJGUoL9yrjXSr7Bi2yxKVBh5PSP7w== X-Received: by 2002:a05:600c:2046:b0:421:5329:235 with SMTP id 5b1f17b1804b1-421562ef808mr3990145e9.24.1717528075180; Tue, 04 Jun 2024 12:07:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGuCmM5mGleOgdSRGd5SU56p9w4IVBX6xPBJuDgSdN42IOxS7twoLXmUvSU2nj+Ti6ZdFHhxA== X-Received: by 2002:a05:600c:2046:b0:421:5329:235 with SMTP id 5b1f17b1804b1-421562ef808mr3989995e9.24.1717528074695; Tue, 04 Jun 2024 12:07:54 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , Ani Sinha Subject: [PULL 32/46] hw/acpi: Insert an acpi-generic-node base under acpi-generic-initiator Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (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: 1717528280897100002 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:29:59 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=1717528112; cv=none; d=zohomail.com; s=zohoarc; b=RPjrPeFN4vPDjPWOpHYbb3Qu5but1QihlGkw29I/lxkwZnlWQeKmAn+Mb/CTG9n1M37UOg9clgonaMKsobIZJR0YOsF+rWmgQU67aRy/lUKtrqn3JLZiJvhvwa2m/Qne3QMKfb/wtsmBjf085dGqnYVYy2A+mSVHwYwSkD5lXOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528112; 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=FToX8nMommt2bWG5vJjpEFOZKUdMNE6ay6dx9s5p/pc=; b=UND8MdnCGcFCWn2QUpmAozulQkwhVi3V8CZ8N8Rr9RcsenKHu3CRwXzMJzPxKIIATPtBa4+5d6ByUfYsq2fVzmQN/xnm9IkDshWtE3YagNxDfP4VXe33PlzZNTwcP6H0xi6ag4vldOqiUvGYNVgGmFA7bhpAGQIydujbfAxyjuM= 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 1717528112886685.9490942560353; Tue, 4 Jun 2024 12:08:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVz-0005Dw-Av; Tue, 04 Jun 2024 15:08: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 1sEZVx-00052h-Ac for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08: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 1sEZVu-0000z7-Q5 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:09 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-Sl8Vm8k6O8-Kw6J4rF8UTQ-1; Tue, 04 Jun 2024 15:08:04 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42155e1f0aaso2906695e9.2 for ; Tue, 04 Jun 2024 12:08:03 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd064b030sm12422694f8f.105.2024.06.04.12.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528085; h=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=FToX8nMommt2bWG5vJjpEFOZKUdMNE6ay6dx9s5p/pc=; b=LYrj1OfyOPibPTBit0wtVJbRIrqJibYl/E9j0xDx9tSRzuf6m2KjyJ7AbkEgUEZs3+x2Jp NH6KgjiKPEXoYLqKJ2Vv05c/uj7N/XVaEzXIQQR8mtkr8v3qrgxgLsLo4v9PUU+mNbl4Pp 9kTjVk7cjwlgrhGwTf2JRLbnm0AZCh8= X-MC-Unique: Sl8Vm8k6O8-Kw6J4rF8UTQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528082; x=1718132882; 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=FToX8nMommt2bWG5vJjpEFOZKUdMNE6ay6dx9s5p/pc=; b=M7YYTVpYJAW4FZOyegrKbWdQlnGPPOL50bKhfn33eJ1YagWVdPi3dIthZfY8vuj5Rl 4WCU0KwkrV1Ht1aOosEbFxsfnUM0eL9ea+kkNpJXkzg6ibG9diqgN14DX4aKKGsBwasf M6LetaTGcLx7/KszlwceqkQFMy05TSkj4DaX9+OcvbjIlCq41Pd1ZLFT71ip0hjwAAEW /WW2XLg/YgyGPP4LUwqzBsMDT8DcUhTQDKcdj0NfTw+k6a7LbPDsaUlpl4IVx08W4RgG 3nMeohVlr4KgphB87HUhAabkFyVUnzXba7BBmm3HqRzf/DPsgyKrC1VRLy/nOEvKM8mx c8+g== X-Gm-Message-State: AOJu0YxKYg2UK6/BcKR4X7Crlj0M2l2uKEri59JgyOXfzwB6aUDCgLGx uEpTvCjElh2ainbt+tvc1LmNMiN7wP5Q2fPgjg4m0hgXCeWPRr3o4Ew9n34Eb145C+Z4dNz1IVd q/T5Sc7C+aBc0eioYmQMSBFTaT1izw6TiUhNXb4fsoQUd8++x2xNQlXiSgNYKkBHcxwQRbmnql0 PGrhVP9vilLWasU8CvL9rqhieePWoBkQ== X-Received: by 2002:a05:600c:444b:b0:41b:e244:164a with SMTP id 5b1f17b1804b1-421562c3371mr4845065e9.6.1717528082218; Tue, 04 Jun 2024 12:08:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJaOL/+OkRJVs75/qdfBNOPf62huFZURwenKy52bPDuJru+73jhPReJeXni0XtkFQNi188QA== X-Received: by 2002:a05:600c:444b:b0:41b:e244:164a with SMTP id 5b1f17b1804b1-421562c3371mr4844795e9.6.1717528081610; Tue, 04 Jun 2024 12:08:01 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Eduardo Habkost , Eric Blake , Markus Armbruster Subject: [PULL 33/46] hw/acpi: Generic Port Affinity Structure support 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: 1717528114182100001 From: Jonathan Cameron These are very similar to the recently added Generic Initiators but instead of representing an initiator of memory traffic they represent an edge point beyond which may lie either targets or initiators. Here we add these ports such that they may be targets of hmat_lb records to describe the latency and bandwidth from host side initiators to the port. A descoverable mechanism such as UEFI CDAT read from CXL devices and switches is used to discover the remainder fo the path and the OS can build up full latency and bandwidth numbers as need for work and data placement decisions. Signed-off-by: Jonathan Cameron Message-Id: <20240524100507.32106-4-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/qom.json | 35 ++++++ include/hw/acpi/acpi_generic_initiator.h | 18 ++- include/hw/pci/pci_bridge.h | 1 + hw/acpi/acpi_generic_initiator.c | 145 +++++++++++++++++------ hw/pci-bridge/pci_expander_bridge.c | 1 - 5 files changed, 160 insertions(+), 40 deletions(-) diff --git a/qapi/qom.json b/qapi/qom.json index 38dde6d785..9d1d86bdad 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -826,6 +826,39 @@ 'data': { 'pci-dev': 'str', 'node': 'uint32' } } =20 + +## +# @AcpiGenericPortProperties: +# +# Properties for acpi-generic-port objects. +# +# @pci-bus: QOM path of the PCI bus of the hostbridge associated with +# this SRAT Generic Port Affinity Structure. This is the same as +# the bus parameter for the root ports attached to this host bridge. +# The resulting SRAT Generic Port Affinity Structure will refer to +# the ACPI object in DSDT that represents the host bridge (e.g. +# ACPI0016 for CXL host bridges.) See ACPI 6.5 Section 5.2.16.7 for +# more information. +# +# @node: Similar to a NUMA node ID, but instead of providing a reference +# point used for defining NUMA distances and access characteristics +# to memory or from an initiator (e.g. CPU), this node defines the +# boundary point between non-discoverable system buses which must be +# described by firmware, and a discoverable bus. NUMA distances +# and access characteristics are defined to and from that point. +# For system software to establish full initiator to target +# characteristics this information must be combined with information +# retrieved from the discoverable part of the path. An example would +# use CDAT (see UEFI.org) information read from devices and switches +# in conjunction with link characteristics read from PCIe +# Configuration space. +# +# Since: 9.1 +## +{ 'struct': 'AcpiGenericPortProperties', + 'data': { 'pci-bus': 'str', + 'node': 'uint32' } } + ## # @RngProperties: # @@ -953,6 +986,7 @@ { 'enum': 'ObjectType', 'data': [ 'acpi-generic-initiator', + 'acpi-generic-port', 'authz-list', 'authz-listfile', 'authz-pam', @@ -1025,6 +1059,7 @@ 'discriminator': 'qom-type', 'data': { 'acpi-generic-initiator': 'AcpiGenericInitiatorProperties', + 'acpi-generic-port': 'AcpiGenericPortProperties', 'authz-list': 'AuthZListProperties', 'authz-listfile': 'AuthZListFileProperties', 'authz-pam': 'AuthZPAMProperties', diff --git a/include/hw/acpi/acpi_generic_initiator.h b/include/hw/acpi/acp= i_generic_initiator.h index dd4be19c8f..1a899af30f 100644 --- a/include/hw/acpi/acpi_generic_initiator.h +++ b/include/hw/acpi/acpi_generic_initiator.h @@ -30,6 +30,12 @@ typedef struct AcpiGenericInitiator { AcpiGenericNode parent; } AcpiGenericInitiator; =20 +#define TYPE_ACPI_GENERIC_PORT "acpi-generic-port" + +typedef struct AcpiGenericPort { + AcpiGenericInitiator parent; +} AcpiGenericPort; + /* * ACPI 6.3: * Table 5-81 Flags =E2=80=93 Generic Initiator Affinity Structure @@ -49,8 +55,16 @@ typedef enum { * Table 5-80 Device Handle - PCI */ typedef struct PCIDeviceHandle { - uint16_t segment; - uint16_t bdf; + union { + struct { + uint16_t segment; + uint16_t bdf; + }; + struct { + uint64_t hid; + uint32_t uid; + }; + }; } PCIDeviceHandle; =20 void build_srat_generic_pci_initiator(GArray *table_data); diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h index 5cd452115a..5456e24883 100644 --- a/include/hw/pci/pci_bridge.h +++ b/include/hw/pci/pci_bridge.h @@ -102,6 +102,7 @@ typedef struct PXBPCIEDev { PXBDev parent_obj; } PXBPCIEDev; =20 +#define TYPE_PXB_CXL_BUS "pxb-cxl-bus" #define TYPE_PXB_DEV "pxb" OBJECT_DECLARE_SIMPLE_TYPE(PXBDev, PXB_DEV) =20 diff --git a/hw/acpi/acpi_generic_initiator.c b/hw/acpi/acpi_generic_initia= tor.c index c054e0e27d..78b80dcf08 100644 --- a/hw/acpi/acpi_generic_initiator.c +++ b/hw/acpi/acpi_generic_initiator.c @@ -7,6 +7,7 @@ #include "hw/acpi/acpi_generic_initiator.h" #include "hw/acpi/aml-build.h" #include "hw/boards.h" +#include "hw/pci/pci_bridge.h" #include "hw/pci/pci_device.h" #include "qemu/error-report.h" =20 @@ -18,6 +19,10 @@ typedef struct AcpiGenericInitiatorClass { AcpiGenericNodeClass parent_class; } AcpiGenericInitiatorClass; =20 +typedef struct AcpiGenericPortClass { + AcpiGenericInitiatorClass parent; +} AcpiGenericPortClass; + OBJECT_DEFINE_ABSTRACT_TYPE(AcpiGenericNode, acpi_generic_node, ACPI_GENERIC_NODE, OBJECT) =20 @@ -30,6 +35,13 @@ OBJECT_DEFINE_TYPE_WITH_INTERFACES(AcpiGenericInitiator,= acpi_generic_initiator, =20 OBJECT_DECLARE_SIMPLE_TYPE(AcpiGenericInitiator, ACPI_GENERIC_INITIATOR) =20 +OBJECT_DEFINE_TYPE_WITH_INTERFACES(AcpiGenericPort, acpi_generic_port, + ACPI_GENERIC_PORT, ACPI_GENERIC_NODE, + { TYPE_USER_CREATABLE }, + { NULL }) + +OBJECT_DECLARE_SIMPLE_TYPE(AcpiGenericPort, ACPI_GENERIC_PORT) + static void acpi_generic_node_init(Object *obj) { AcpiGenericNode *gn =3D ACPI_GENERIC_NODE(obj); @@ -53,6 +65,14 @@ static void acpi_generic_initiator_finalize(Object *obj) { } =20 +static void acpi_generic_port_init(Object *obj) +{ +} + +static void acpi_generic_port_finalize(Object *obj) +{ +} + static void acpi_generic_node_set_pci_device(Object *obj, const char *val, Error **errp) { @@ -79,42 +99,61 @@ static void acpi_generic_node_set_node(Object *obj, Vis= itor *v, } =20 gn->node =3D value; - ms->numa_state->nodes[gn->node].has_gi =3D true; + if (object_dynamic_cast(obj, TYPE_ACPI_GENERIC_INITIATOR)) { + ms->numa_state->nodes[gn->node].has_gi =3D true; + } } =20 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_node_set_pci_device); +} + +static void acpi_generic_port_class_init(ObjectClass *oc, void *data) +{ + /* + * Despite the ID representing a root bridge bus, same storage + * can be used. + */ + object_class_property_add_str(oc, "pci-bus", NULL, + acpi_generic_node_set_pci_device); } =20 /* * ACPI 6.3: * Table 5-78 Generic Initiator Affinity Structure + * ACPI 6.5: + * Table 5-67 Generic Port Affinity Structure */ static void -build_srat_generic_pci_initiator_affinity(GArray *table_data, int node, - PCIDeviceHandle *handle) +build_srat_generic_node_affinity(GArray *table_data, int node, + PCIDeviceHandle *handle, bool gp, bool pc= i) { - uint8_t index; - - build_append_int_noprefix(table_data, 5, 1); /* Type */ + build_append_int_noprefix(table_data, gp ? 6 : 5, 1); /* Type */ build_append_int_noprefix(table_data, 32, 1); /* Length */ build_append_int_noprefix(table_data, 0, 1); /* Reserved */ - build_append_int_noprefix(table_data, 1, 1); /* Device Handle Type: P= CI */ + /* Device Handle Type: PCI / ACPI */ + build_append_int_noprefix(table_data, pci ? 1 : 0, 1); build_append_int_noprefix(table_data, node, 4); /* Proximity Domain */ =20 /* Device Handle - PCI */ - build_append_int_noprefix(table_data, handle->segment, 2); - build_append_int_noprefix(table_data, handle->bdf, 2); - for (index =3D 0; index < 12; index++) { - build_append_int_noprefix(table_data, 0, 1); + if (pci) { + /* Device Handle - PCI */ + build_append_int_noprefix(table_data, handle->segment, 2); + build_append_int_noprefix(table_data, handle->bdf, 2); + build_append_int_noprefix(table_data, 0, 12); + } else { + /* Device Handle - ACPI */ + build_append_int_noprefix(table_data, handle->hid, 8); + build_append_int_noprefix(table_data, handle->uid, 4); + build_append_int_noprefix(table_data, 0, 4); } =20 build_append_int_noprefix(table_data, GEN_AFFINITY_ENABLED, 4); /* Fla= gs */ @@ -127,37 +166,69 @@ static int build_all_acpi_generic_initiators(Object *= obj, void *opaque) GArray *table_data =3D opaque; PCIDeviceHandle dev_handle; AcpiGenericNode *gn; - PCIDevice *pci_dev; Object *o; =20 - if (!object_dynamic_cast(obj, TYPE_ACPI_GENERIC_INITIATOR)) { + if (!object_dynamic_cast(obj, TYPE_ACPI_GENERIC_NODE)) { return 0; } =20 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, gn->node); - exit(1); + + if (object_dynamic_cast(OBJECT(gn), TYPE_ACPI_GENERIC_INITIATOR)) { + PCIDevice *pci_dev; + + if (gn->node >=3D ms->numa_state->num_nodes) { + error_printf("%s: node %d is invalid.\n", + TYPE_ACPI_GENERIC_INITIATOR, gn->node); + exit(1); + } + + o =3D object_resolve_path_type(gn->pci_dev, TYPE_PCI_DEVICE, NULL); + if (!o) { + error_printf("%s: device must be a PCI device.\n", + TYPE_ACPI_GENERIC_INITIATOR); + exit(1); + } + pci_dev =3D PCI_DEVICE(o); + + dev_handle.segment =3D 0; + dev_handle.bdf =3D PCI_BUILD_BDF(pci_bus_num(pci_get_bus(pci_dev)), + pci_dev->devfn); + build_srat_generic_node_affinity(table_data, + gn->node, &dev_handle, false, tru= e); + + return 0; + } else { /* TYPE_ACPI_GENERIC_PORT */ + PCIBus *bus; + const char *hid =3D "ACPI0016"; + + if (gn->node >=3D ms->numa_state->num_nodes) { + error_printf("%s: node %d is invalid.\n", + TYPE_ACPI_GENERIC_PORT, gn->node); + exit(1); + } + + o =3D object_resolve_path_type(gn->pci_dev, TYPE_PCI_BUS, NULL); + if (!o) { + error_printf("%s: device must be a PCI host bridge.\n", + TYPE_ACPI_GENERIC_PORT); + exit(1); + } + bus =3D PCI_BUS(o); + /* Need to know if this is a PXB Bus so below an expander bridge */ + if (!object_dynamic_cast(OBJECT(bus), TYPE_PXB_CXL_BUS)) { + error_printf("%s: device is not a bus below a host bridge.\n", + TYPE_ACPI_GENERIC_PORT); + exit(1); + } + /* Copy without trailing NULL */ + memcpy(&dev_handle.hid, hid, sizeof(dev_handle.hid)); + dev_handle.uid =3D pci_bus_num(bus); + build_srat_generic_node_affinity(table_data, + gn->node, &dev_handle, true, fals= e); + + return 0; } - - 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); - exit(1); - } - - pci_dev =3D PCI_DEVICE(o); - - dev_handle.segment =3D 0; - dev_handle.bdf =3D PCI_BUILD_BDF(pci_bus_num(pci_get_bus(pci_dev)), - pci_dev->devfn); - - build_srat_generic_pci_initiator_affinity(table_data, - gn->node, &dev_handle); - - return 0; } =20 void build_srat_generic_pci_initiator(GArray *table_data) diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expand= er_bridge.c index 0411ad31ea..f5431443b9 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -38,7 +38,6 @@ DECLARE_INSTANCE_CHECKER(PXBBus, PXB_BUS, DECLARE_INSTANCE_CHECKER(PXBBus, PXB_PCIE_BUS, TYPE_PXB_PCIE_BUS) =20 -#define TYPE_PXB_CXL_BUS "pxb-cxl-bus" DECLARE_INSTANCE_CHECKER(PXBBus, PXB_CXL_BUS, TYPE_PXB_CXL_BUS) =20 --=20 MST From nobody Mon Nov 25 02:29:59 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=1717528230; cv=none; d=zohomail.com; s=zohoarc; b=QJ8reboGB64xo4BeujK3efHg+n/dHiP3rPvJ3qtNsz3zKvAUqAiZHKifSFSx7g/iR1++XEaDvObFmAobNTvstAHeVGLCE1rVGDVUX8wyVAb3kTITTD7qUb39AiOKd9/2FyXdsc8NlIEWfJQiuDS2y5PIjT24bjABcf9jWTB3CPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528230; 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=381VnGSReclgz5bDfsJYpCqnbDXNXRPUyOf3bkjFhOs=; b=UaV0RlsDdtb8Sc5cca3OgOeqmXO9XlmcrlAMw2syyuhVFQ0uP1mm+kw4+DTKG71Zsv7MdGK+CE/+xAmazgCEQWCPkFzEX3bBHcn0E3CQsOR2Cs3Hq7qsUq42x/XFnD0K0m5Lt7A1GJ1w00IuULVVHEKEWRc4U57UMQm3zH6vvg0= 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 1717528230444495.6809442893315; Tue, 4 Jun 2024 12:10:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZW3-0005la-5L; Tue, 04 Jun 2024 15:08:15 -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 1sEZW0-0005PR-5Y for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08: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 1sEZVy-0000zP-41 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:11 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-372-6OhfSn7SOoSAGcYG-quBMw-1; Tue, 04 Jun 2024 15:08:06 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4212adbe3b6so35388455e9.2 for ; Tue, 04 Jun 2024 12:08:06 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4214beb5c9asm32041825e9.7.2024.06.04.12.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528089; h=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=381VnGSReclgz5bDfsJYpCqnbDXNXRPUyOf3bkjFhOs=; b=L54ahSSOR1n8YGwvGy0l1eUEfI5vqCEZpetrg0ezIEfwfZWaj13xUc6t2shzWQO6x35HgY e+WVgRF1/CSUbUNVsYpsBBFzotvSHQQBiaVCUmwOeioHu/tY4km8ogh9bFC3VSzRXFg42l NPwMRxsZs/ZW754rxlI7v9Puc24BGZE= X-MC-Unique: 6OhfSn7SOoSAGcYG-quBMw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528085; x=1718132885; 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=381VnGSReclgz5bDfsJYpCqnbDXNXRPUyOf3bkjFhOs=; b=kvEl5AlenFaUHytHGPFa2n35ovy0W7Aig0l8+4fhUpwwDJP0/OpwdBeqpMoKofgspQ 1aEsRLUgyaCylwxS5ISB2399wCUCpz7mcrVoVeNJlvvCspmivaugoDMsM2ppRP3MmjoA JYSaS4ggwiyeHzdp+nFgURf9gyjBzkldiQilD/V6UL+OXGh+wKBPbREbEwTz0WnkbB4c QHQlRfnZsCBqaNNSuY8RQayCdUVvJLGWwqKuYAgjjw4OhUjwt+aqPeWRpZiR+rvUQX6h iZEnxtALXVmTQFWGondaLMN7vF5EPDf7i8LsXkRk9EOu/gkJdTL/ol895N9f0qgRxcAU gJzg== X-Gm-Message-State: AOJu0YzOJmgj+BFJ8dnyECGSsA5UOK7GvuGgr+L29xUiwycs7WMGdg3p 90I/A8fesiI9ey+tYXuJnflUtIdz3299/zl3OH1Dl667PIo17Cv8/mFT7/o59uemXlaxDOQW+Wt CWV2M3XA1rAU3GzTbGGTnekLOWk7rcxwuqRnL+oM1p0g7qEdOzw/377PRozPoJ6zjuboNrPtIb+ HCf+nSNuU+4bc0BtIDC91KishD+iNsLw== X-Received: by 2002:a05:600c:524d:b0:421:20aa:6045 with SMTP id 5b1f17b1804b1-421562f21f3mr4042085e9.24.1717528085130; Tue, 04 Jun 2024 12:08:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzV7pUpU6/XIevsL2Do1McPWw8dJNepxEqsayE4n7jiFfSkJ3RtWWQs8e2PVjBYnmRaUE5sA== X-Received: by 2002:a05:600c:524d:b0:421:20aa:6045 with SMTP id 5b1f17b1804b1-421562f21f3mr4041855e9.24.1717528084606; Tue, 04 Jun 2024 12:08:04 -0700 (PDT) Date: Tue, 4 Jun 2024 15:08:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , Ani Sinha Subject: [PULL 34/46] bios-tables-test: Allow for new acpihmat-generic-x test data. Message-ID: <4680fb4a69d137870c421a4da697f4b39b002dc9.1717527933.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: 1717528230659100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron The test to be added exercises many corners of the SRAT and HMAT table generation. Signed-off-by: Jonathan Cameron Message-Id: <20240524100507.32106-5-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 5 +++++ tests/data/acpi/q35/APIC.acpihmat-generic-x | 0 tests/data/acpi/q35/CEDT.acpihmat-generic-x | 0 tests/data/acpi/q35/DSDT.acpihmat-generic-x | 0 tests/data/acpi/q35/HMAT.acpihmat-generic-x | 0 tests/data/acpi/q35/SRAT.acpihmat-generic-x | 0 6 files changed, 5 insertions(+) create mode 100644 tests/data/acpi/q35/APIC.acpihmat-generic-x create mode 100644 tests/data/acpi/q35/CEDT.acpihmat-generic-x create mode 100644 tests/data/acpi/q35/DSDT.acpihmat-generic-x create mode 100644 tests/data/acpi/q35/HMAT.acpihmat-generic-x create mode 100644 tests/data/acpi/q35/SRAT.acpihmat-generic-x diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..a5aa801c99 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,6 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/APIC.acpihmat-generic-x", +"tests/data/acpi/q35/CEDT.acpihmat-generic-x", +"tests/data/acpi/q35/DSDT.acpihmat-generic-x", +"tests/data/acpi/q35/HMAT.acpihmat-generic-x", +"tests/data/acpi/q35/SRAT.acpihmat-generic-x", diff --git a/tests/data/acpi/q35/APIC.acpihmat-generic-x b/tests/data/acpi/= q35/APIC.acpihmat-generic-x new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/CEDT.acpihmat-generic-x b/tests/data/acpi/= q35/CEDT.acpihmat-generic-x new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/DSDT.acpihmat-generic-x b/tests/data/acpi/= q35/DSDT.acpihmat-generic-x new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/HMAT.acpihmat-generic-x b/tests/data/acpi/= q35/HMAT.acpihmat-generic-x new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/SRAT.acpihmat-generic-x b/tests/data/acpi/= q35/SRAT.acpihmat-generic-x new file mode 100644 index 0000000000..e69de29bb2 --=20 MST From nobody Mon Nov 25 02:29:59 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=1717528173; cv=none; d=zohomail.com; s=zohoarc; b=QCRZsnLnOen+M77SIreOMPLHGlxh0ZsDplGwHlAu5HfoYNrYdvP4DSxQw5jTcZMAjLCLposKWBSzipk59JUmvzH3vShuPCPikaic8uLh2DzCtzWr+lR9C5VGzKY3odAmAzvDkexjvy6pc5fFugf+cTwMmDJqnfg63FPWZ4hULiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528173; 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=C/pPfQru8bTuS9+eYSG9NAw/m9gJaYYAeXPgdlqxVn4=; b=OQ4ToOv5jQxMKrNrkph2h2waJT0eHlt8V5S2nyuXO/TffFPROR0K8oOxfWbfWgoeWxEFJoO45+AZEWPppgUoHW9a7S8kMnHxzKMaIvR/DWinB+WZ4AyfEifZw+ocuIrMbZbJQKVUEh2EdE80Tzju1Klr4Ea7xb2sLyNx6zwNlHY= 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 1717528173577531.460250206577; Tue, 4 Jun 2024 12:09:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZW5-00066U-Ck; Tue, 04 Jun 2024 15:08: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 1sEZW3-0005sS-P8 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08: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 1sEZW0-0000zV-Nt for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:15 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-IfsphAAnPzq42slk_WmnLQ-1; Tue, 04 Jun 2024 15:08:10 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-35e50fe93a5so2484664f8f.3 for ; Tue, 04 Jun 2024 12:08:09 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd064afd8sm12314270f8f.95.2024.06.04.12.08.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528091; h=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=C/pPfQru8bTuS9+eYSG9NAw/m9gJaYYAeXPgdlqxVn4=; b=TRxQhf70lArVHDdYlrrFd7cwllV0Ln34mLK5g0mkGghC/wL9cEbmhjrhoQN08LBxHI3b+j m8WhYx74s0KlnG18nZSPgJ+jHGUYi0tPvi7zekL1rFkidU+Qsy0LGVnFXSJZT+vJLc2W/X a8QRLfjOPbfrzU210IKLA8E4RSX3UJ8= X-MC-Unique: IfsphAAnPzq42slk_WmnLQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528088; x=1718132888; 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=C/pPfQru8bTuS9+eYSG9NAw/m9gJaYYAeXPgdlqxVn4=; b=kcOUFv28vpOAuoQ20CrFYks7Z0YSygvdATokcyHc2hEb/JkaBXwoaDszTspw1R05+N XTtqf8jK4LVO5kNrXBDwGRKlVeQh4pejIRcNF86ZhqE2LuESKXXEIkl463OteM4KQ85+ 3hgwu1SJFHtfwpaeZOwNpkRh4N22SKCeLLsAZQibxQN87pmLG38UUZYDaUPr1iG3nGDc 8XoQ+EYs9DFj7KXpeSIwu5BLZwBxKK3FU2lAQWv2pKa5Bny8HexqZBzC/lcyMBsTYyrZ 4iM04YKcoGqKKYlwTg9liw2jJ+jSZ6En+HA5rwHm2kycU8GUoQU7orWJ2/WzJWotIkId AfvQ== X-Gm-Message-State: AOJu0Yzocatc57Q29omP0UvWR9AkSi7c+NvcobDWgPXRmPZJ+9cjR8w6 8XvtXZBL9uAgyiPAeQWKmdV1K1yU9gKsVxIhBAb9wU68vFTlOGwDnV3SKV/OMfG/DFT4aMmDyiL 3zyTnSpNDCbiiZLicw/0ct0Trp/ujnvuhCkrEsSmHB7WFMM8dJlvZbrBB6IvGyACu6B0kdJjaFm 2Z+laCa3h8ggPmTjJEivroAP9g+gxKOg== X-Received: by 2002:adf:face:0:b0:35a:e90b:5474 with SMTP id ffacd0b85a97d-35e840494e7mr235583f8f.2.1717528088331; Tue, 04 Jun 2024 12:08:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFd05LZFHilV3739r92v+dC/xUoybqIfk45A3yOXGdMdDtBbowCxsSsuww+Qx0LEl5JSLGUTA== X-Received: by 2002:adf:face:0:b0:35a:e90b:5474 with SMTP id ffacd0b85a97d-35e840494e7mr235562f8f.2.1717528087832; Tue, 04 Jun 2024 12:08:07 -0700 (PDT) Date: Tue, 4 Jun 2024 15:08:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , Ani Sinha Subject: [PULL 35/46] bios-tables-test: Add complex SRAT / HMAT test for GI GP Message-ID: <4c4979cc62f7db9a137c21d64e01766535272fbe.1717527933.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: 1717528174425100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Add a test with 6 nodes to exercise most interesting corner cases of SRAT and HMAT generation including the new Generic Initiator and Generic Port Affinity structures. More details of the set up in the following patch adding the table data. Signed-off-by: Jonathan Cameron Message-Id: <20240524100507.32106-6-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 92 ++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index d1ff4db7a2..1651d06b7b 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -1862,6 +1862,96 @@ static void test_acpi_q35_tcg_acpi_hmat_noinitiator(= void) free_test_data(&data); } =20 +/* Test intended to hit corner cases of SRAT and HMAT */ +static void test_acpi_q35_tcg_acpi_hmat_generic_x(void) +{ + test_data data =3D {}; + + data.machine =3D MACHINE_Q35; + data.variant =3D ".acpihmat-generic-x"; + test_acpi_one(" -machine hmat=3Don,cxl=3Don" + " -smp 3,sockets=3D3" + " -m 128M,maxmem=3D384M,slots=3D2" + " -device virtio-rng-pci,id=3Dgidev" + " -device pxb-cxl,bus_nr=3D64,bus=3Dpcie.0,id=3Dcxl.1" + " -object memory-backend-ram,size=3D64M,id=3Dram0" + " -object memory-backend-ram,size=3D64M,id=3Dram1" + " -numa node,nodeid=3D0,cpus=3D0,memdev=3Dram0" + " -numa node,nodeid=3D1" + " -object acpi-generic-initiator,id=3Dgi0,pci-dev=3Dgide= v,node=3D1" + " -numa node,nodeid=3D2" + " -object acpi-generic-port,id=3Dgp0,pci-bus=3Dcxl.1,nod= e=3D2" + " -numa node,nodeid=3D3,cpus=3D1" + " -numa node,nodeid=3D4,memdev=3Dram1" + " -numa node,nodeid=3D5,cpus=3D2" + " -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D10" + " -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D800M" + " -numa hmat-lb,initiator=3D0,target=3D2,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D100" + " -numa hmat-lb,initiator=3D0,target=3D2,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D200M" + " -numa hmat-lb,initiator=3D0,target=3D4,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D100" + " -numa hmat-lb,initiator=3D0,target=3D4,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D200M" + " -numa hmat-lb,initiator=3D0,target=3D5,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D200" + " -numa hmat-lb,initiator=3D0,target=3D5,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D400M" + " -numa hmat-lb,initiator=3D1,target=3D0,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D500" + " -numa hmat-lb,initiator=3D1,target=3D0,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D100M" + " -numa hmat-lb,initiator=3D1,target=3D2,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D50" + " -numa hmat-lb,initiator=3D1,target=3D2,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D400M" + " -numa hmat-lb,initiator=3D1,target=3D4,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D50" + " -numa hmat-lb,initiator=3D1,target=3D4,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D800M" + " -numa hmat-lb,initiator=3D1,target=3D5,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D500" + " -numa hmat-lb,initiator=3D1,target=3D5,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D100M" + " -numa hmat-lb,initiator=3D3,target=3D0,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D20" + " -numa hmat-lb,initiator=3D3,target=3D0,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D400M" + " -numa hmat-lb,initiator=3D3,target=3D2,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D80" + " -numa hmat-lb,initiator=3D3,target=3D2,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D200M" + " -numa hmat-lb,initiator=3D3,target=3D4,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D80" + " -numa hmat-lb,initiator=3D3,target=3D4,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D200M" + " -numa hmat-lb,initiator=3D3,target=3D5,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D20" + " -numa hmat-lb,initiator=3D3,target=3D5,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D400M" + " -numa hmat-lb,initiator=3D5,target=3D0,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D20" + " -numa hmat-lb,initiator=3D5,target=3D0,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D400M" + " -numa hmat-lb,initiator=3D5,target=3D2,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D80" + " -numa hmat-lb,initiator=3D5,target=3D4,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D200M" + " -numa hmat-lb,initiator=3D5,target=3D4,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D80" + " -numa hmat-lb,initiator=3D5,target=3D2,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D200M" + " -numa hmat-lb,initiator=3D5,target=3D5,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D10" + " -numa hmat-lb,initiator=3D5,target=3D5,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D800M", + &data); + free_test_data(&data); +} + #ifdef CONFIG_POSIX static void test_acpi_erst(const char *machine) { @@ -2304,6 +2394,8 @@ int main(int argc, char *argv[]) qtest_add_func("acpi/q35/nohpet", test_acpi_q35_tcg_nohpet); qtest_add_func("acpi/q35/acpihmat-noinitiator", test_acpi_q35_tcg_acpi_hmat_noinitiator); + qtest_add_func("acpi/q35/acpihmat-genericx", + test_acpi_q35_tcg_acpi_hmat_generic_x); =20 /* i386 does not support memory hotplug */ if (strcmp(arch, "i386")) { --=20 MST From nobody Mon Nov 25 02:29:59 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=1717528378; cv=none; d=zohomail.com; s=zohoarc; b=nSka3mabbUpdvZYtlTMTGsEgLR/DYIxC4OjAwNfdntuV5ZNDg13+VN80JAfL962Xf6rOFurBUfXSEPKscx9YkyKMK929/YQ6wcGnAgBAZBassrNwvz9P9BmHkgE05Ew2BiXgC3PFkce7GcKMOX+1jELIoZniLYqCIatRdGVaVsI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528378; 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=7UJLPmNVvDv5Deu6MVO7hyMXSZqetvvQChosK81S0Ks=; b=M+cBUjec2C/9bPpM0cpRbKqJ1h72BgYWUXkMQMZ8MMtzgwCqgMFcJCXoISApVRhQOOgq4UrUmUfHMZ3tgq/Z/39gKYiT4kZqFxk4YBcVVFYS8lfKxWZZS14Fj+XusimPn6s3Wtm52Ah1gjU3dwLHRXWYudv2Js8/3CR27kigg1s= 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 1717528378765412.19429249952327; Tue, 4 Jun 2024 12:12:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZW9-0006eL-I6; Tue, 04 Jun 2024 15:08: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 1sEZW7-0006Qa-8d for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZW4-000116-5r for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:18 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-70-MYlgkjtXNCec6_B53rx8xw-1; Tue, 04 Jun 2024 15:08:14 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-35dced40d17so1015634f8f.2 for ; Tue, 04 Jun 2024 12:08:13 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd04d6e5asm12344537f8f.45.2024.06.04.12.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:08:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528095; h=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=7UJLPmNVvDv5Deu6MVO7hyMXSZqetvvQChosK81S0Ks=; b=YZcho69rzTkFXo4zlzTcDZykHYXN7v+glsKslzBu2xYzCGMgcQJ7e+PqJRmMolja/NzmC4 XGYQ4PONq8SkBptvaNDlFBAlNhf59VbQaF/L5CYw6L0wabNbYMY8BJbdC7+8VqbmmLgsi7 11Tkf3LcWZP0p5kDut2xGEFJAwdvZnU= X-MC-Unique: MYlgkjtXNCec6_B53rx8xw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528092; x=1718132892; 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=7UJLPmNVvDv5Deu6MVO7hyMXSZqetvvQChosK81S0Ks=; b=i43LXkVPw1jG5hQ5KkqHCeE/PWTRVzUnZz4BdjDxS8BSGFKlVcqyydPYENfHreqA6k 6Tb40Vb7ciQYBO5U0Cps77pf54rVtNX0XPkwYzlfY5ubeZ3CQqLY3O/0Ljv/1FOfeMSz AjORe7f9VmYmjQegXLse0A/b5xO862HNbTs/SmsJjwXcUcd4/3dWQmGCrZt52ZW76KKy ICrj5p1yP3zlMrcDRF3C6gunHCNA2mxIE1HsXFtQFBPeUx5EPTWLdpgkApMATyHVxP0i 3SL4Om0+0F0ixq2uxdPyEP01AZ3v1VNyvO00FN88fU2AZ20wExutexP4nSu8i7/ZRVBL dddw== X-Gm-Message-State: AOJu0YwkfKsB8JIKBwn85klNA2Sya9yGutfmzinHk8X8ywMqG0k0/iLn VsTjsIzHubfkX3Wgg6GbGIeIcOe4G86LqKSYgNgdn0+AWFJ/fZIYaS4VDrPYyUUqtjBsuzDgUDh we06BUuYEn2cKhTX8xkvtWowi1Xe+fp9NTvwMtXLycJth1VFCXqdxVzmF2Zu70uCX6EYVM/ozHW fXkx5JsOVH768wtrZQDhwKnS8F7+iZpA== X-Received: by 2002:a05:6000:112:b0:357:5051:2a5c with SMTP id ffacd0b85a97d-35e8ef9a3b2mr221105f8f.67.1717528091878; Tue, 04 Jun 2024 12:08:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEFcrWoaUTM54nNtkE/cgltR7QF0A6VrrLMMQeOi9P9klc7UpEGTwPbOeERT4sZwWsKuMa+g== X-Received: by 2002:a05:6000:112:b0:357:5051:2a5c with SMTP id ffacd0b85a97d-35e8ef9a3b2mr221083f8f.67.1717528091210; Tue, 04 Jun 2024 12:08:11 -0700 (PDT) Date: Tue, 4 Jun 2024 15:08:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , Ani Sinha Subject: [PULL 36/46] bios-tables-test: Add data for complex numa test (GI, GP etc) Message-ID: <61cbf56ef1c5dd9dbe6bd6625f6c8d2a82c5697f.1717527933.git.mst@redhat.com> References: MIME-Version: 1.0 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: 1717528379395100001 Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Given this is a new configuration, there are affects on APIC, CEDT and DSDT, but the key elements are in SRAT (plus related data in HMAT). The configuration has node to exercise many different combinations. 0) CPUs + Memory 1) GI only 2) GP only 3) CPUS only 4) Memory only 5) CPUs + HP memory GI node, GP Node, Memory only node, hotplug memory only node, latency and bandwidth such that in Linux Access0 (any initiator) and Access1 (CPU initiators only) given different answers. Following cropped to remove details of each entry. [000h 0000 004h] Signature : "SRAT" [System Resource A= ffinity Table] [030h 0048 001h] Subtable Type : 00 [Processor Local APIC/SAP= IC Affinity] [032h 0050 001h] Proximity Domain Low(8) : 00 [033h 0051 001h] Apic ID : 00 [040h 0064 001h] Subtable Type : 00 [Processor Local APIC/SAP= IC Affinity] [042h 0066 001h] Proximity Domain Low(8) : 03 = = = [043h 0067 001h] = Apic ID : 01 [050h 0080 001h] Subtable Type : 00 [Processor Local APIC/SAP= IC Affinity] [052h 0082 001h] Proximity Domain Low(8) : 05 [053h 0083 001h] Apic ID : 02 [060h 0096 001h] Subtable Type : 01 [Memory Affinity] [062h 0098 004h] Proximity Domain : 00000000 [068h 0104 008h] Base Address : 0000000000000000 [070h 0112 008h] Address Length : 00000000000A0000 [088h 0136 001h] Subtable Type : 01 [Memory Affinity] [08Ah 0138 004h] Proximity Domain : 00000000 [090h 0144 008h] Base Address : 0000000000100000 [098h 0152 008h] Address Length : 0000000003F00000 [0A8h 0168 008h] Reserved3 : 0000000000000000 [0B0h 0176 001h] Subtable Type : 01 [Memory Affinity] [0B2h 0178 004h] Proximity Domain : 00000004 [0B8h 0184 008h] Base Address : 0000000004000000 [0C0h 0192 008h] Address Length : 0000000004000000 //Comment in hw/i386/aml-build.c on why these exist - not part of //ACPI requirements. [0D8h 0216 001h] Subtable Type : 01 [Memory Affinity] [0DAh 0218 004h] Proximity Domain : 00000000 [0E0h 0224 008h] Base Address : 0000000000000000 [0E8h 0232 008h] Address Length : 0000000000000000 [100h 0256 001h] Subtable Type : 01 [Memory Affinity] [102h 0258 004h] Proximity Domain : 00000000 [108h 0264 008h] Base Address : 0000000000000000 [110h 0272 008h] Address Length : 0000000000000000 [128h 0296 001h] Subtable Type : 01 [Memory Affinity] [12Ah 0298 004h] Proximity Domain : 00000000 [130h 0304 008h] Base Address : 0000000000000000 [138h 0312 008h] Address Length : 0000000000000000 [150h 0336 001h] Subtable Type : 01 [Memory Affinity] [152h 0338 004h] Proximity Domain : 00000000 [158h 0344 008h] Base Address : 0000000000000000 [160h 0352 008h] Address Length : 0000000000000000 [178h 0376 001h] Subtable Type : 01 [Memory Affinity] [17Ah 0378 004h] Proximity Domain : 00000000 [180h 0384 008h] Base Address : 0000000000000000 [188h 0392 008h] Address Length : 0000000000000000 // End of strange empty Memory Affinity structures. [1A0h 0416 001h] Subtable Type : 05 [Generic Initiator Affini= ty] [1A3h 0419 001h] Device Handle Type : 01 [1A4h 0420 004h] Proximity Domain : 00000001 [1A8h 0424 010h] Device Handle : 00 00 10 00 00 00 00 00 00 0= 0 00 00 00 00 00 00 [1C0h 0448 001h] Subtable Type : 06 [Generic Port Affinity] [1C3h 0451 001h] Device Handle Type : 00 [1C4h 0452 004h] Proximity Domain : 00000002 [1C8h 0456 010h] Device Handle : 41 43 50 49 30 30 31 36 40 0= 0 00 00 00 00 00 00 [1E0h 0480 001h] Subtable Type : 01 [Memory Affinity] [1E2h 0482 004h] Proximity Domain : 00000005 [1E8h 0488 008h] Base Address : 0000000100000000 [1F0h 0496 008h] Address Length : 0000000090000000 [1FCh 0508 004h] Flags (decoded below) : 00000003 Enabled : 1 Hot Pluggable : 1 Non-Volatile : 0 Example block from HMAT: [0F0h 0240 002h] Structure Type : 0001 [System Locality Latenc= y and Bandwidth Information] = = [0F2h 0242 002h] = Reserved : 0000 = = = [0F4h 0244 004h] Le= ngth : 00000078 = = = [0F8h 0248 001h] Flags (decoded below) : 00 = = = = Memory Hierarchy : 0 = = = Use Mi= nimum Transfer Size : 0 = = = Non-sequential Transfers = : 0 [0F9h 0249 001h] Data Type : 03 [0FAh 0250 001h] Minimum Transfer Size : 00 [0FBh 0251 001h] Reserved1 : 00 [0FCh 0252 004h] Initiator Proximity Domains # : 00000004 [100h 0256 004h] Target Proximity Domains # : 00000006 [104h 0260 004h] Reserved2 : 00000000 [108h 0264 008h] Entry Base Unit : 0000000000000004 [110h 0272 004h] Initiator Proximity Domain List : 00000000 [114h 0276 004h] Initiator Proximity Domain List : 00000001 [118h 0280 004h] Initiator Proximity Domain List : 00000003 [11Ch 0284 004h] Initiator Proximity Domain List : 00000005 [120h 0288 004h] Target Proximity Domain List : 00000000 [124h 0292 004h] Target Proximity Domain List : 00000001 [128h 0296 004h] Target Proximity Domain List : 00000002 [12Ch 0300 004h] Target Proximity Domain List : 00000003 [130h 0304 004h] Target Proximity Domain List : 00000004 [134h 0308 004h] Target Proximity Domain List : 00000005 [138h 0312 002h] Entry : 00C8 [13Ah 0314 002h] Entry : 0000 [13Ch 0316 002h] Entry : 0032 [13Eh 0318 002h] Entry : 0000 [140h 0320 002h] Entry : 0032 [142h 0322 002h] Entry : 0064 [144h 0324 002h] Entry : 0019 [146h 0326 002h] Entry : 0000 [148h 0328 002h] Entry : 0064 [14Ah 0330 002h] Entry : 0000 [14Ch 0332 002h] Entry : 00C8 [14Eh 0334 002h] Entry : 0019 [150h 0336 002h] Entry : 0064 [152h 0338 002h] Entry : 0000 [154h 0340 002h] Entry : 0032 [156h 0342 002h] Entry : 0000 [158h 0344 002h] Entry : 0032 [15Ah 0346 002h] Entry : 0064 [15Ch 0348 002h] Entry : 0064 [15Eh 0350 002h] Entry : 0000 [160h 0352 002h] Entry : 0032 [162h 0354 002h] Entry : 0000 [164h 0356 002h] Entry : 0032 [166h 0358 002h] Entry : 00C8 Note the zeros represent entries where the target node has no memory. These could be surpressed but it isn't 'wrong' to provide them and it is (probably) permissible under ACPI to hotplug memory into these nodes later. Signed-off-by: Jonathan Cameron Message-Id: <20240524100507.32106-7-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 5 ----- tests/data/acpi/q35/APIC.acpihmat-generic-x | Bin 0 -> 136 bytes tests/data/acpi/q35/CEDT.acpihmat-generic-x | Bin 0 -> 68 bytes tests/data/acpi/q35/DSDT.acpihmat-generic-x | Bin 0 -> 10400 bytes tests/data/acpi/q35/HMAT.acpihmat-generic-x | Bin 0 -> 360 bytes tests/data/acpi/q35/SRAT.acpihmat-generic-x | Bin 0 -> 520 bytes 6 files changed, 5 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index a5aa801c99..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,6 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/APIC.acpihmat-generic-x", -"tests/data/acpi/q35/CEDT.acpihmat-generic-x", -"tests/data/acpi/q35/DSDT.acpihmat-generic-x", -"tests/data/acpi/q35/HMAT.acpihmat-generic-x", -"tests/data/acpi/q35/SRAT.acpihmat-generic-x", diff --git a/tests/data/acpi/q35/APIC.acpihmat-generic-x b/tests/data/acpi/= q35/APIC.acpihmat-generic-x index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..317ddb3fbed94e4f49a87976fdc= 7f23b1a6c3fdc 100644 GIT binary patch literal 136 zcmXxb%Mn0O3`XITcnlXkq!sRl6*D%L%2Ae5RD#JhHu=3DutPrpp@0J43UEbqR4{U|?Xhb@F%i2v%^42yj+VP*7lGU|;~TK{Nw{0)qoc4VVoE6CiAe2mn)- B2LS*8 literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/DSDT.acpihmat-generic-x b/tests/data/acpi/= q35/DSDT.acpihmat-generic-x index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a04451374d1b95764d34fbda1ec= 791a89ffdcc46 100644 GIT binary patch literal 10400 zcmcJVO>7%UcE?}wLuwXVQj=3DyI)Wv)OqEfYpm@M#ae$H*6!9%jFmVU>W~w)x=3D$J z56oh@#nQ0^a}U#^Y!=3DH!MgNXjTraaf-}Qd%d7u8kW1Bu~eWg9y+Vr0uds~2=3D9&P!Y zV?kS;Y&pf2dsLmUjcQ(LRjQ_1c*zx|WdxsoaXR%XHws$j=3D zTyw2|yZWnz`I|q!^J(G5_x|du*FU$u znE8cu;qMKr>vcw-?eSRG^ZDVi2hjC8^X>b5)XyekFb1Cg^!OuyO@A|JbdSDkHVTFy zAG7Or-pDV4(lQ!OW`WQDUh*em7nZes&}#a-IC(g6?tyJMO_qM4a>YH=3D zuwvLobvqOaG(F6YgOeD@HM2TFJQw#k$pC>6d{FD@L)tZsqK%xsh{O zv1Y7-{+4Z&R$}fOSnKutUF_lSvpql`?%QbYg8uD7)!Z1?3w`Y50Y(clw-GK!KUoJqo&q@2k>8ATZ(oFjyD zgmR8h&QZcSN;pR;=3DP2b=3D2&Y0g70Rhl&J^KH5zZ9lOi@lwI62|ul#^4=3DG~rAW&NSsr zQ%;p|s)SReoGRrUBb;M|bBuD1QOIAx9uD52` zcaA9Mh;oi9=3DYp7#@*+`QB+83ad66pTiE^GO=3Dc#g@DlZY`C8E4Um6xdUvQS2=3D?`5Hk z*7(bTGFsy=3D2g+!TUm!6TNX!Kqb0La}3A7+3(6UqQC(yD}Jx!oxr+S(|%T6^4$^bP{ zYGZ(^XnYJf>Y}X3fTJ=3D(iwR|v+G0W(b;Sf4bQPHx6Q~p=3DE|k#-;zB7W(4ebOVge0D zB+`9CD5DW1gfg03OrX->F@Z{)Ny3>VoR~l*PE4Q@=3DLq2(A)J^%B~DDB66Yx493`BX zKqXF0pc1D-I2FQ)2~^_51S)Z+2xp3LVgi*oF@Z{)oN#i&i3wEV!~`mFrU_@7aAE?L zI5B}roGRf|2`45{i4zm3#5qPd#|S4TP>B;0sKhx=3DIL8SmCQykJ6R5;FK{zJ}Cnivd z6BDS!sS!?%aAE?LI5B}roEgHIA)J^%B~DDB5@(ihW(g-IP>B;0sKhx*I421wCQykJ z6R5w(MTzFqmj>y^Yjl#ASGTU?86D#c+ze(s{Z3$J^@(jqR~C7jn?X`h3HL;IuX2o zQCfDx$xQRfAC5yRo&*360BHc&2YsUDGz-whA=3Dr&u1wGR;s}4NDGCvTO34Eb}J&cB^ z&$OI|!%lX?F<^MKhtZ1z(b;Q6FG|siB6@Kkdhwj-Mfb=3D;_TXKNT8P+r>@~t0Qg}mz zHwMBR=3DY%)H@a6zKz5)BS=3DiZdUntELUzWm`MfmbS`0_d7%VGG+VEED32w#!H zS48;AK=3D{fz;VbTul_)#a!KP{cxF0c)Ccjh{nqVA@KxC?AU z-JLnFr>VQ?A?^a(PwPdlP=3DNsltE! zcd`pzJ`tS389x5~6uwS>`3)p6k7;_VYzN12tYFyHd_I2zwAxBA#0tOrUOal=3DZZ}F! zG+JCE)~n{2VXx;ZAAjn9^ym+A5AS{Q@uP>^_dWra8Fp$LLV%PhFMzhcyIy(31@8P)~d_>b#Ts@R7p5CCe ztU@!B<_ahPc$=3D(`x7M6y8ew2}@4nKqH!N_U))IJy1fS$&2TXFnm~fD8g%@w0NzPd0 zjK|%lYv^q$CdQ+Woel@@Is4;@#e_Sx?~cdxiT>bttnV_1i(wQtT0V{w zo5CZ6vVQT#HT_M?-muu<0r2tcj1H=3D&zhkXA&BU2bdwA0M_wlR?T(n>ydrlUB0 zgD&ooHDcNMd~kK5Fg^UH(kd3~_^(p!-}T_iW>n3r8WTH9@F%V~>$VMw(QMQJ%Z4Z$px1EKm$sRx zUku-85?Is!@?X1q|8Qdc?e~5(r+x6x|9kH4lZ9V%_X%!Y!J&z5D>%AfKT5|;oEuOz z%sbak9*FHL*HL#3d9ZNZXf_Po$a0geYVLD{LeRe z47U8o4>z}f$6>ppwYR~~rh+X2ChVYr^$i8s>15j5Jl3}qLrc7GF<{4kvcJVOz^xO< zI{^OUO&*8i9R~i+v4=3DM`T`x#6Q#^Y-1~C-?Zo*B#Y`hQJS~57?<)pDuv&aE{AM})1 z!ttfo`z_P4)J{H_ub=3D+Uytka1`K8#m6D~>| zdidEv{KbIm=3DuvvT-p|9PpOKaqyAcO76Ll+z8Y5!97|@*cH1GOf~LII!)!aQ62KAbJo`j^@Yl2_d)y3 zyV!cQl^sdoy^+##uC=3DmCg2#AF)UIO-a%jJEdKlcJcbD%N!ISXVt&+8#&*zthMA4F3 z5+A6v@+Gk*XlwIgPt;M`$>&>2t6(<3J^GfD|87uG@s!e)ma}L=3DR}_|_!c{D|M-$Fs zC{zJrf#Fmf$GOp+DDKg<)uP#omfmOiW@d0Cl4*>uG literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/SRAT.acpihmat-generic-x b/tests/data/acpi/= q35/SRAT.acpihmat-generic-x index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..cbf45a31ba6d2c06f2bb0e203d4= b40100522ac08 100644 GIT binary patch literal 520 zcmWFzatz^MVqjoQbMklg2v%^42yj+VP*7lGU|;~TK{N=3D%fdD$6nGsc8r~%gr z1za!&in$1N0#Nx6%rJ$h=3DCQzpVGJ0JrVgeIKS0=3Dv9}JW_Rs{xV_`<>k0$^dnroh0! i#K6Gd=3Dp5i_U|?wGfF{qV!3y^nRL=3DyM06c&h7#IL5atr|g literal 0 HcmV?d00001 --=20 MST From nobody Mon Nov 25 02:29:59 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=1717528280; cv=none; d=zohomail.com; s=zohoarc; b=HVn7R+xnO3t2KOo7AW0dOEdShrXwNEm4wdHltKAfkhJZkDhbkTeO27En6VTjWYUGwY4AT4o4S04RQCGPgwmPZUR6JoignBgsRfW/0PkawjDOav98Ql88RceV+EzGHOouZa0Qn0vLrFa+Iq1Yq7AFepaS43lofHTc2PRMz4dZhXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528280; 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=k0ucDaYVdJqdsLfR8NU5fCGlszW3UuHcu5X6+Pt/UWE3iDxPYBrHXFJkk4oZb16lC25/TsTZKnkrkOz2OrYTUQc/RRarqWq45uEaaTn1X2KccskAi072FmFSXmmVp5Y+h4/9s373iyE9dtdxMfQZ+WRqq09FIG4yifgEWLatk20= 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 171752828018661.50540623146378; Tue, 4 Jun 2024 12:11:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZWA-0006pO-Pw; Tue, 04 Jun 2024 15:08: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 1sEZW8-0006cc-T9 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZW6-00011I-Iv for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:20 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-487-lKnRZneCMcStunbC-ykrtw-1; Tue, 04 Jun 2024 15:08:16 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42135f6012fso26202145e9.3 for ; Tue, 04 Jun 2024 12:08:16 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4214fdf4953sm28590425e9.25.2024.06.04.12.08.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:08:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528097; h=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=SCZdwDRmiP//YruEeaWCSdEPOTnzlhiJVcC1ikYDzBlNXZka7NcxeLcP7T6twVRp8m5W6b n2Bvp3b+CJiqFUV3MR6nKZuM3fYRy+3E3ABIfq6+S3gQBTdt2IkFkwPsWjHmrf8hAFb4iI VOiOiqO3exqw8/YB9KmVGffd0kIkRdE= X-MC-Unique: lKnRZneCMcStunbC-ykrtw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528095; x=1718132895; 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=sCbFwdaNmnn/fcFHoRai4+gsoIiq64fespRFiFfxH4Ja6brsk5DFBKYy77QI/FA6Nf d3iG6HOu6SFDn+J4KNSq55NxBakutyNnU6a1bAS6sOUezWu1gQa+IexAYOv0tGXk2trY 1xty/SjVOCurX65Jetm2d5aadfqvcS7ki1q2T8BHo10CeF+JDIIerqwBPrYMyU+5SSL/ imTVFG4e8+FCaqjfMrMDvIenR0RI+dwu5h6+aUKseb2ZhKWzrFngRg0ppvhCbZVcyldl /hS9h5Z6F9rkpNxcq4KkimAHV5+7wcaV81BBlSAdYyO293buNz+XHSMmBEdYY3UMAb/n WuNg== X-Gm-Message-State: AOJu0YzImURuKv/ehyu0i4qyubz0fAIoxILFgNBlB2zmycG2SfzDvJPt wuZT3W74sNksVz7/wOYh9o7Wh64mnKuFTTOiusqTw3TDPh7hTMRuuzrZ0Hp+8YO/DfiHaWWRZ3K DqJKUBo2qNSSDfaq+vrgtmb6EYC9jtElA9pN5CqrFYs42THtG5WaREuJuQdZ/WhDf0jeSNoQeam U9PvgJMgnMQSI4WTW3wYKoT+xBhrq0pw== X-Received: by 2002:a05:600c:1c84:b0:41b:143b:5c2d with SMTP id 5b1f17b1804b1-4215633fce8mr3827145e9.28.1717528095131; Tue, 04 Jun 2024 12:08:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF86PhfnorCgaXF/D9s837vi0vghkpz3sMKsESXndwSCJgd76lasaNc3bMVXgTVALQJ9A9cZw== X-Received: by 2002:a05:600c:1c84:b0:41b:143b:5c2d with SMTP id 5b1f17b1804b1-4215633fce8mr3826985e9.28.1717528094558; Tue, 04 Jun 2024 12:08:14 -0700 (PDT) Date: Tue, 4 Jun 2024 15:08:11 -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 37/46] scripts/update-linux-headers: Copy setup_data.h to correct directory Message-ID: <86373538cd568ad0d678d4f2f0bbb4843233a652.1717527933.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: 1717528280893100001 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:29:59 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=1717528158; cv=none; d=zohomail.com; s=zohoarc; b=edu1RtwYDUprgp5ugcLxvJbYFDBLk8vCwZ5R/lszFuHhhbaCFu5PcP10a6ENLJrBmmT2S7Xs7pXpEaGTi7TuLw5RxQD1c2eiaUKZz9F1bPByXsnrJ1hcpBenPedeIbYfq3zdQCfK8RbsMV8L0FjMg4tv0qE6aU2fqQmq8cQROmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528158; 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=fJ1aXj2wczytz7h3EPXum0uvPceEdtUp92GJUnu91fgqXm6Fbb77B3Fb1mdsfDiMBRat8leOAKVR3BnLF0+Q/FL/4QO+dGMXBYiOjkTpFd8RKMCzJhFffHF42TnWsiVWXnID400Oj7j0rE+VnrMYcogZn6Ju+mml1fkI4HZhJQE= 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 1717528158329588.2013003043523; Tue, 4 Jun 2024 12:09:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZWG-0007iu-JO; Tue, 04 Jun 2024 15:08:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZWE-0007SQ-8c for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08: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 1sEZWB-00011t-5a for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:25 -0400 Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-39-2xrSgJ55Oyq23Cd2AIPEwQ-1; Tue, 04 Jun 2024 15:08:21 -0400 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2ea93c06e3cso40124191fa.2 for ; Tue, 04 Jun 2024 12:08:20 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4214a9ff986sm35948495e9.42.2024.06.04.12.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528102; h=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=FJ6yOiYgsirFsp5zxw5jrFuApMgX1ZDbmdFclyDFJUPaBgFJyaQXfU0d6JHNesd2cklvrd Vah5ZuyUGF1HqM+IgdKs4zC1ieKY6pikV2G0KDCC3kN0FvdLMHMe9kdOLkr9wrL5FyVD6f X9Nb0+oFUQvIZsYsruFNTPuahpP309w= X-MC-Unique: 2xrSgJ55Oyq23Cd2AIPEwQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528099; x=1718132899; 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=NC/hR2zjn7zKq9zsNofCjZJHrQDECkXSfP9dUYMrmNiczpJOyLOOHmcZ8b5Sz1jQGO 1KlB0SQVXtoELCDpzVcWJusJ8mJ5V0Bba52I+1HXvyK0h1ivvRqWCPbWpm9aRRiaEemD 1M9R8tUeC1IzKrWnIvo22W0owor9qpsHVCpHzjG/9cKDaGmr9U0b1Po5SCEIaxagXAfG BQ2nhcVcSx51loFzQyzwY7FWHs9L8Tf/2LxiWBiiTXq+l6kz5cDmSJWiCMpxJ1Xwok+H 3tq8mtD/c59ApjPlooSK+5VSOBsOLY+eETO4uXa6u1mGtvaiSNeEJpOKQBBsJ3Jj729d NDhg== X-Gm-Message-State: AOJu0YxlyRySKnJgLesWtL4+zMl2z7tLBEh0R6D03THr4AjyKuZlND3/ P9TYumUPQ4E8ABRG7hE7Py61hSTq2r33E1E8GBEk8SO96h69YUytMuXtWoc26sSUVs1Vl7Xkfmx 16nxvJSZ3QzOhWFv9IVZkp4dSOvISDHOkaBt8uk0eCU3hG0QmIXslf5OXZWdhqHov2PV/IhBOva J+y42dMa90EptJyiSsvO1ryMt1lkFweA== X-Received: by 2002:a2e:b4a4:0:b0:2e1:a0d1:2c0 with SMTP id 38308e7fff4ca-2eac79ecf02mr1012431fa.28.1717528098938; Tue, 04 Jun 2024 12:08:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUpmFDzYmU9Z5YiJQA8iCo1sXkzXLnMjcMoMU4vs/baONswJ+lB1vRmV+/HRl9oGDi6VIlCw== X-Received: by 2002:a2e:b4a4:0:b0:2e1:a0d1:2c0 with SMTP id 38308e7fff4ca-2eac79ecf02mr1012101fa.28.1717528098158; Tue, 04 Jun 2024 12:08:18 -0700 (PDT) Date: Tue, 4 Jun 2024 15:08:14 -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 38/46] linux-headers: update to 6.10-rc1 Message-ID: <8d5fb2def4dfb0f4921262acf5be494059a04464.1717527933.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: 1717528160378100001 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:29:59 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=1717528286; cv=none; d=zohomail.com; s=zohoarc; b=noDGXVEFbhb0jKT4L8AlBO3mdXbaUpvtfAVJEwJSKoZ7A+wpRjXJoALkaamEjpVUd9ZvlKZvQANDWcMYDCh8yQMTWTgOGH/RAWSpmwZPqpaIE3pP4Rt9U3iiwqsyeAVm1gdaO7jvPlcNHGokczLv8mtKHFbL6eW6pvEQ++NluEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528286; 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=e9UYWw3BjUSJdrf/LfrUEDboJqc3FRfdgKi9KH1ZRv2R/TXIYe50R5fZaWuusiB+olnCAKn1kwZ/JoQXJME0VULeH5kIu+vZOd8BGhZwmqU/Y30SkSYORRoKKoqn6/xSDt22XWK1P4V/hWSFhRx+DWAPnszabBW/6T9nwYkonoE= 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 171752828630036.93914019110173; Tue, 4 Jun 2024 12:11:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZWM-0000D1-NY; Tue, 04 Jun 2024 15:08:34 -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 1sEZWK-0008MJ-Hr for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:32 -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 1sEZWH-00012L-PQ for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:32 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-19-BgAx0JxTMPupAthj-nPiuQ-1; Tue, 04 Jun 2024 15:08:26 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-35dca0dc826so1051044f8f.1 for ; Tue, 04 Jun 2024 12:08:26 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4212b838b55sm165368105e9.5.2024.06.04.12.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528108; h=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=a1cxQwEUNtw9PBHNgmejJKe8SIBM+kNdhbwajR8Uwzc+nxmIhhY+LTtFfLLzmn90S/jtk6 XGp+uj+2q/w6gg77Obxcy6wa2RjOhWrsK160rqHBUKOhmr0oXvrR2vYXzrO8g6got2922U 4n40pLLP36iV+5kYoYnbP4ANsj49zqU= X-MC-Unique: BgAx0JxTMPupAthj-nPiuQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528104; x=1718132904; 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=LHsFFsitDDUvKBxDZQiMCcVUrhw1cWVOtTY+KKzSV0cQB9t4tOz+8JOP1Be75OThqN WacN+dtXKOaqzivg9PDXvzpqs3j5Lrv4PN1oVNdbaV2XKeBV7Y+HzYCN5OHUWB89pnJE /LDB+UzYi/caYD3NwwjdihQx7JnEgJU0Compgt5ib0cgKDx5eMccRaUtl6lxFogs7qGY SeCi/P4hPXFv/68wFg9el5c8Ur7nSrj6ODBezOOC8zr8DM8ndJlgXzxO2byEFsCgvj3l KHvdV9/xlU9BWhxAwG7chaRq8fVP/XBq4WfI0mOMIs2v8DZ8FSDV2rYuqJReHig4AaWH IqxA== X-Gm-Message-State: AOJu0Ywa5Rjn5YBtrNbzw3IVtUaac7rCeQhJcyxEuEHohRDIwZcWY2op egu2XJIQdO9L1bvYLlwhI6cHNqpiFMFDBz4/Hcx2ZfGMCnN5eXdAWUu54DH2VWgh1obbRTi9tuq n6AMB55C96uEiUFyaV0Z6fdJ+fLQg6DDfWG+1jovLJ4tdxN7OnhdNCzkyT8umx/sEZpLAWRMG/i 5OB3vhQm46RYIyrJCLqxbM3077gv2FLA== X-Received: by 2002:a5d:50cb:0:b0:354:fc85:7416 with SMTP id ffacd0b85a97d-35e9809b6f2mr223593f8f.71.1717528104501; Tue, 04 Jun 2024 12:08:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVT6MRHx0PGbdhRtQj3KX/KlbO/4iNjQ1oxQIcew9988BENFNyh/aleYEt6Y/rv9VszHafNA== X-Received: by 2002:a5d:50cb:0:b0:354:fc85:7416 with SMTP id ffacd0b85a97d-35e9809b6f2mr223573f8f.71.1717528103979; Tue, 04 Jun 2024 12:08:23 -0700 (PDT) Date: Tue, 4 Jun 2024 15:08:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Thomas Huth , Cornelia Huck , Richard Henderson , Zhao Liu Subject: [PULL 39/46] hw/misc/pvpanic: centralize definition of supported events 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: 1717528286924100001 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:29:59 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=1717528314; cv=none; d=zohomail.com; s=zohoarc; b=YNTfJTjVFHwRRto6YW9mp/NpcJvkzBNdodWEeVXK5QMKASLCLyC6sHubuOzF41Rh7M9Ugi369RO1mDuZu+6N//b+Ij5YVoAvlv5h1tN8zYvm/RQz/x/MF0dFTPUUUGGTz6XTJcktfQ3h3Ohs1Ra/TziQy195r/zCq8T2/3LGY0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528314; 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=mwtNGWeJoGKQ1YPFYwiH7T9u518nKQ21gBff4f7NCEMWK+Sgp0o3PNyC+9TsdZAZIvlkipWAIRZIM4v6kgMVwHrF+deBI/g2lwFA6Le0DBRTfxPB6ZoUU/wokxqtlhN4jHXiZXTuW7oDXQ7FspNlatPj5a7kblIznDgEIOhSrq4= 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 1717528314916667.2048757988127; Tue, 4 Jun 2024 12:11:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZWP-0000HW-AP; Tue, 04 Jun 2024 15:08: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 1sEZWN-0000GN-P7 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZWL-00012W-CG for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:35 -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-227-eDL5N9lwM2SPxOLWo2F4LA-1; Tue, 04 Jun 2024 15:08:31 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-35dcde1be6cso976951f8f.1 for ; Tue, 04 Jun 2024 12:08:30 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd04c0839sm12555123f8f.23.2024.06.04.12.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:08:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528112; h=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=MiHoAFO9q8dmmTLbaKxsiOLKa8I1dW8UsoS90scwHexc1lHtDucGX0eVYjWQEI1mWwwUNY Wj9wcDnCwhMZhzgA7K555EGoKRYBRekJeU92IF8ofbl+cdNdof/L+cDMPTIKvRBsPvqeUc jX4qFOtYNFC31oE/mB8haaG6UhI47w0= X-MC-Unique: eDL5N9lwM2SPxOLWo2F4LA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528109; x=1718132909; 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=a9onz1gilw/lU31auYl3KmEhaws0FzF2iZja5EiKOpj6CfrZ9k9LBYC2Ff40ZGbtv9 +bxEv3CRRxysz972EMoL/BWeg816aLs90ay7pLF35Dx0B2gQSlAtYQHOQs1g78tlRtcu SgVR0sJsfmkrPjqRs1KgC6/21zL32uthTTc3yco1RIVENxVN92WsjOrT/xvk1jy3V+dV KQS5ttFimy9syg5GRZaVn9e2UxX+0gwUW+G+deMQlBCz+KrY/ASQpmS0WiK6B0S5dVOl yVgBmC3KgfWSF92V9qXtXwUWGhr8xqX6AGjwtStO/Q+OjQtdr0rmIm9OHfIb/kSuPc+Y 0PWw== X-Gm-Message-State: AOJu0YwmE2ALAXFcieTF2r2h44yBXBNiq2+OcFofKs1vBooWo4lvKv6L 7TKQ+FipWefaCTHf1t+DqLhWwfnqyqXKtJ5geob47nWgTQg9kQOd1wlvalu4q8lItXkDvJVFyp8 KRBi4la9iLAvOeO0ZutPMYVcS3Pghpk+no7DYkFyj9g74F1LpkFQ7BQrw0uM5TLUj7kws/F/tx4 O5czWOxhVI83958Z8tPBwtNLI6IQCsIQ== X-Received: by 2002:a5d:53c6:0:b0:35e:7cc6:98fc with SMTP id ffacd0b85a97d-35e8405e26cmr237367f8f.12.1717528109235; Tue, 04 Jun 2024 12:08:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEUIeARRzKTHarzT/FGFZAeOxYIOmwxbj+3up7gEDVjYLaPPTyMlSsBt+FuZgR75g0OwIOZpw== X-Received: by 2002:a5d:53c6:0:b0:35e:7cc6:98fc with SMTP id ffacd0b85a97d-35e8405e26cmr237341f8f.12.1717528108516; Tue, 04 Jun 2024 12:08:28 -0700 (PDT) Date: Tue, 4 Jun 2024 15:08:24 -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 40/46] tests/qtest/pvpanic: use centralized definition of supported events 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: 1717528317096100003 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:29:59 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=1717528213; cv=none; d=zohomail.com; s=zohoarc; b=Qliyr5ztVnsWvMCZENaWMJGgzuMQVtlI045pJksdiZQxbV8nVyt4lX6VG41iZTJUAktOU8/8eDYe9iMjRIBe9jQKaZNMINcdyQYHDZ7vJAAas2cWjGFPlkJdQvoaykro1PbQ5uKXI6DTMlIf7tSMMlNHrFIiMzMR9vQ8kg+Yq/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528213; 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=jfa2rWSIokpkffBtIQ1CQb3nSFWOkf+WwsgsPWAhfLSJ9Nfb6y7T5AP7EVlAH0tL3MBRcbmvkc7Ryq+l+gy04XDT6Y15MLehs7T63SMAvbd+X5oxn+08BieTy6yKWruv8CoIl1eQdeYUki0iyCMPzkB6/nM5YOkX6Zo/LixddxE= 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 1717528213220596.0242079369887; Tue, 4 Jun 2024 12:10:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZWW-0000nP-6Y; Tue, 04 Jun 2024 15:08:44 -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 1sEZWU-0000dH-GN for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:42 -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 1sEZWR-00013B-Mz for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:42 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-34O-fepoMBWPEade60oh2A-1; Tue, 04 Jun 2024 15:08:34 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-35dbf83bb20so3576732f8f.2 for ; Tue, 04 Jun 2024 12:08:34 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd04cb1e7sm12358946f8f.43.2024.06.04.12.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528118; h=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=JlB9tuRJFtezEzdfjtbpVKR16tWexPMRo/ljLhIWpjs3NPZhGLQ2LJ8fajtlbFRTKIOzaU pKEHS82vuI8QnHwmZuPHuPKh+JGpyK9/buXEBIPgZbZjr3HAxy35vvCln6xIguCV8Mdd8J Xg+AIHF6vaM5qoeXk86DUIflwWnlzWo= X-MC-Unique: 34O-fepoMBWPEade60oh2A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528112; x=1718132912; 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=nohW4MMxMK36HG5geskkfg2VPVzGt9qR6QdTzl6P6/2q+eN9w3u3LhXkD8Ae42zA2g 5eBQTSlC/pVqwLSR5Hhg2oRm8MvQ4rik6xo5YLjp8+GOowuJsSrjDjOOX/3DeowtdC58 0G+cgsDF2q6R0ZwbNkySYygdmf3IX+/FzR6pttIBPT53920/7ZuSUo9YFPrcshclSLsb 314cAwIP0QEXnX6aVvSKRuHswhIDLGtL1DH6t/lPOGDk3Qreh28xSf54ZXVOOh6iRm6v NPKIGdEibm30iF2vrIOxW+tUwcksddvUTvY5bIcXIOTZoVZCoG3Jt38g6T1RkYX4M3cY 3dAQ== X-Gm-Message-State: AOJu0YxH9yWhjw0MFfvBftGKlupJGAd2OdtNKIca989dnFlQbT5mgaTC +ik1U9hVpFf6epr/vExi3k1pNa1NGTI4yZV3W4nDydGnzDZT81epIk9igZsb5dT3xGCvZ+tATtP bHlyOlwm5WOyG8bNLkazqdJDVEvf6rgvrsHYmosQ+2ykxreoM39Ux1KzyI55jpssJgMqhveyvrx ompwLh6n3lQgh5oGRxwnC8jblmpDblNw== X-Received: by 2002:a5d:5547:0:b0:351:c2c1:3682 with SMTP id ffacd0b85a97d-35e8ef88819mr219858f8f.62.1717528112574; Tue, 04 Jun 2024 12:08:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExUe/05riaI93Tr7ecHCnVKR9zamdf7wFxYfyvAJQv2XgwMbtYFffNwBaY+vF+715VTnaboQ== X-Received: by 2002:a5d:5547:0:b0:351:c2c1:3682 with SMTP id ffacd0b85a97d-35e8ef88819mr219835f8f.62.1717528112070; Tue, 04 Jun 2024 12:08:32 -0700 (PDT) Date: Tue, 4 Jun 2024 15:08:28 -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 41/46] hw/misc/pvpanic: add support for normal shutdowns 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: 1717528214944100003 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:29:59 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=1717528304; cv=none; d=zohomail.com; s=zohoarc; b=JSsDIonkQA6OCTpzjbS/ptptPPmce4G1uG3WitSr+2ZSdyapDFkyEsFnLAMIOiRScJR3UxriveWBRJ1UrlwTO9XEUcHi8XokvK94s6lrZqcB7A8xqv2X1dxbAF+oOJYuLu+0TxWRDXVFac2f/0FX55y6I7PGJgB/kKsTbwbCAJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528304; 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=SBS5O4ZvHwB2SIYEro1ar+MJYDc6bLJeC7HwlXxRc+R8Oi8eSz0Vqt7bFX6ddvijrZRAItecHLrhN+50PWMqdpttmix4UygFJnld2pnA4mGw1ezWCwMcfpm69vYpMJqWrcC7IVoqRwfv82iWjYDfFXspyNWMOhOGgtSUG6RqLJo= 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 1717528304118212.37303850230865; Tue, 4 Jun 2024 12:11:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZWZ-0000ys-0Q; Tue, 04 Jun 2024 15:08:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZWX-0000tO-Do for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZWU-00013H-TM for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:45 -0400 Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-ZtwBgnGhN6GU57Z4FZky6w-1; Tue, 04 Jun 2024 15:08:39 -0400 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2eaaae3e600so26692211fa.0 for ; Tue, 04 Jun 2024 12:08:37 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4212b838a41sm165672925e9.1.2024.06.04.12.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528121; h=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=EnJkXZZPclbYdRsqvaeCeVLP48/YcMbeV5loyYOyLoV0zN7byl1hBUYmUlna2tFFmiH6CA w0vaBIfFrfAaPOu4knsQGnRr4VznkOnTTgVrX/XJfQyR9rJJ5U9VHmllTOIrgBCYYsa9A/ G11+Rq8fWNZuC+3+sBIBXIHIjtAsEx4= X-MC-Unique: ZtwBgnGhN6GU57Z4FZky6w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528116; x=1718132916; 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=YAexYWbnQklFubyFmHZjXLiIxM0m8qQ7IwSixQm2Vw2/ZTrbj6v5+cxiR2wxFyccJJ 7WBXxEkUx8L5tjwHbrUyldi5GXIRAWGuynA3mnHtIZfvxnDyaoa1gIHfT8mgacybBbBF INeL+RozeMLsvw4RSH8z9WxQtCDh5eAEP7ocVVhunR4tyytLUdxgRfDeOH82q2mPIwHF K9kaKYrb/8LLRuKAcZZ+b79G5iFSAvuGU+Aou9uRLnSU3ZuZJ0QGDgVvEA4WadOjsf3V K8PIQeHwpm/qGRBLA8hiXz4uA+ZHfnrkQryoiBHvdM0wcyeKtoUW/gsAf8A3McUkvRQl 040w== X-Gm-Message-State: AOJu0YyPZo4geEp8oylucwDQNRdgO6gDK/CVr+vIbYmVDRiUSIb+2nj+ 3uc9AuuQFiJiHAHHpf0PnKgwYdllITnwlcq6GKCdWPCr1/tORlGUfyNEGbJB7fQ+nwsUIO8/S+x YIXBShfFHyDCTe1zSD9ctoW2p+zp/dj+AX307FHchMI1OM/wVHD7hx5BPoyVLMBMqj3z/6kV8fk BbZ+7TwFywBj0jqTVE5ljnS8xMeHIgBQ== X-Received: by 2002:a05:651c:551:b0:2ea:89f6:258f with SMTP id 38308e7fff4ca-2eac77a26a9mr1667241fa.0.1717528116148; Tue, 04 Jun 2024 12:08:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHM7rQ/o1HEVzNpueFxB0aE3Ec2r1CJndkFhkB0tYUJe3mvY4lCzbPz7MSZytDrzy+H1EVuCw== X-Received: by 2002:a05:651c:551:b0:2ea:89f6:258f with SMTP id 38308e7fff4ca-2eac77a26a9mr1666951fa.0.1717528115620; Tue, 04 Jun 2024 12:08:35 -0700 (PDT) Date: Tue, 4 Jun 2024 15:08:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Eric Blake , Markus Armbruster , Paolo Bonzini Subject: [PULL 42/46] pvpanic: Emit GUEST_PVSHUTDOWN QMP event on pvpanic shutdown signal 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: 1717528305033100001 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:29:59 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=1717528190; cv=none; d=zohomail.com; s=zohoarc; b=VbMQprmr25Ai2+BGP/24YxvCQFBfUfyM4ErZcBisU99Z+pCd2eaSovxLKiJJtt3NtCy86lFy7AbkjdNlF+wJ0bT3XOENlJvUC5ENN+wMMN8XHhUrnyNJb+34F9/3Uk/LEah0pl/0bZUcTruTQYu7RNUMvjaQOJ9jF4R+lU64s/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528190; 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=ZfSBOo/jcDGtIRYtgpdyqAx1n4h77XYXWdTXkQ1cay6TwiuHzGadTVfpar6XbbIK8IIAy3ewe9K5MWaPjtnfYVaz0EleQqQpxsxXqxPSpJJbnWls8ijoOtrSYdxNG5eOVMz+lTB/AYkTtxjjhzuyVmz2RiHZP+bDTgFRnzjCWUs= 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 1717528190082326.82911378785343; Tue, 4 Jun 2024 12:09:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZWa-00012I-3g; Tue, 04 Jun 2024 15:08: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 1sEZWX-0000uV-O5 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZWV-00013T-DW for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:45 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-152-XPZrGImMOpS4tPe_hapZlA-1; Tue, 04 Jun 2024 15:08:41 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-35e7cce4c32so1055719f8f.3 for ; Tue, 04 Jun 2024 12:08:41 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd066b47asm12322567f8f.112.2024.06.04.12.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:08:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528122; h=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=GlKo5WE5eKkUHJRvWBvZVtjatfq8dsg6nc4jDJMXtpAwjnHaS4PiQvgRJVa3+ZBOt/j1gY ZcDKWkoZ2bC0U/5ufc85Gx64g/lvgvIUVKkQRiKsOsfV41K+/jM7TewgvHYQp9KbHLvJon ux5185U4apNi+ubOyxJeKf+aufxrKAc= X-MC-Unique: XPZrGImMOpS4tPe_hapZlA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528120; x=1718132920; 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=pYTP+ThjSUhHk2gJ16Ksf1b0DPUbmRed3ppHA3oFHmJqx4C53mGk9jr4LlhnRd0Tom s/XxONXDRgNPMCu6ujsfq8hO3BJfteQWka3nGCuNMEg3UqGMUORFGCe13LVYrlQmHEOZ 10lKy2lDhiU+xmSURNd7KGKPdbKlN5uhRi2hMMm7jZOmszveNLqsXe2wx6TxACLEcnhC qVmLHlKm9uWcMpf4HQNW3w7sMX6IEPNkrR40tWGLeoATdHWT5PvAOsN2MEdP2oQ4LG8t Y4lbGA9zOpDrMcXrcizZZNdeMznPvklqmKFu1gSsmFGuhiAIg4tR8X24xQpb6iXaFNmz j4vA== X-Gm-Message-State: AOJu0Yy/rCXTKriE12qMvvOe6L4v94DDEXjUGXBX8yKWDXnVw/J34LGq os8vrle/UQRepCC7mBixQdc4L3PKxWPA2fBtFN1/MTcdoCH4z0b39HGeczbOBo+WasLd7UDH4Ej puY5mAXVwLK+YZzMTmX91/UgqjpRwf/Hpb61OXxDfpaR4FMiOuj4c84v5zFWf/B94PLAG/VZvVJ FGJ/2CdWkniAzOVhA5qa4auGttdNs57w== X-Received: by 2002:a5d:4b02:0:b0:355:6e4:60e5 with SMTP id ffacd0b85a97d-35e8ef0879emr224310f8f.35.1717528119728; Tue, 04 Jun 2024 12:08:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENQYangbr476tDOUC1skzJUTv+DIBKAUfSQr/E+j3xZpGWb86F92aNTG71pnGt8Ja5Cjqb/A== X-Received: by 2002:a5d:4b02:0:b0:355:6e4:60e5 with SMTP id ffacd0b85a97d-35e8ef0879emr224289f8f.35.1717528119230; Tue, 04 Jun 2024 12:08:39 -0700 (PDT) Date: Tue, 4 Jun 2024 15:08:35 -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 43/46] tests/qtest/pvpanic: add tests for pvshutdown event Message-ID: <982077b6957eab867d48feff46be615f217ebb9d.1717527933.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: 1717528190422100001 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:29:59 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=1717528307; cv=none; d=zohomail.com; s=zohoarc; b=e4UELph0f/fdccNuIvGKxeM4zTrJ2X31SooBC/YTJNzwqKynqHlVeqa8hP/VgfTCUhTLYN+lL7+MkhQe9ZDcARjwQLqbnljcdNxF2hdl6JCypUx0FcKMECSK+IS/tF9L73u13sgDWIJZI+mqdwNAEDLe5mhVqYyqBk7W9l8+Zko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528307; 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=Aa3GB7BRjR9o5fDmY5u99/gSTh3jz0hID5VewPIYMvPlyVQp7Aa2T8i/+XeWWlYIrrPc3asKDNgZ2S0dPsDtCtGw83NZF20/iRK50NE1/GqwlElbXuXCftM/DUAVT4hS9Q6UjEcfwr2I/l9eKABgIVT+3D570c4ueMZbMKF9zzM= 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 1717528307103921.813156155031; Tue, 4 Jun 2024 12:11:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZWn-00029Y-Vd; Tue, 04 Jun 2024 15:09: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 1sEZWn-00029I-8H for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:09:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZWl-00015L-8Q for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:09:00 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-88-YLtQwagRO9q-2sDi-AvEdg-1; Tue, 04 Jun 2024 15:08:45 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4213530af1aso22860405e9.2 for ; Tue, 04 Jun 2024 12:08:44 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd062ea66sm12351817f8f.78.2024.06.04.12.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528137; h=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=Zkp6lUwexdh/zL47G/Dphjyvfe7W13PzgMi1LSLCm1QD1khs0Z8Loju0boRQQ8+1NsCMmi LOq28RxrDFKuoiKsbU/0Zk/u9oNxxlxI8Se+vZ1Zp5Xe1UyCoYRZUeF6/fntVCV/z5k8im upuRabA637xYfd3nKqN5ocEosU9t8o4= X-MC-Unique: YLtQwagRO9q-2sDi-AvEdg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528123; x=1718132923; 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=crRV9TY5klh7SBSSZdJwG1riMxFcJ6mx1tb/99Cn6iGo+OtlsFjIVH3VWZLPgm4xC1 dtYtUDwPwrsH9XJMXGqS1KdkLnh3DwN+uHB/vea1jWUopyrtDVKZWb4lznXGKainwzib IHiCF0rcLdyqhyxrzPnnCqGj+LxHpe5qIWuDObpLG1uat2dvJWoLXlmqpEm4jG9oBrqx Do2qj/e/ndkGIAlks3oWJ4l7ek/Q3dtCw0dJO5xHt8P2Km6yIoU3kHwoiGI6Jymz6G/C buVeOrP/gQNvCe1yYEwSvjvb8f7RZMsbpVvEqcCJu7mJE4om5l6sXxTMOUgNZDBm29SH vX2A== X-Gm-Message-State: AOJu0YyTqQOzSwmDkyjFn/tf9y9pEc0t4MPDhS3XLjmc7nHEtzfV3g8/ sp7ceU7NNOy5MKSraZjrN2JWLtmkoece5SaIbCRUh7pZ+Twgznuw+lwLVvAeWpM2TBq4eDRo0L7 4GVTUoRTtvZn3Conjq/S/KNv1z/TsBqvvNfeQyE7NTU7aw+vCdwr7QJLEKg/+Rwet+Nh25525YG WHeSqVDK57DBtOGm2a2F6pq8WdaM77dw== X-Received: by 2002:adf:fa82:0:b0:357:dbf1:1d3b with SMTP id ffacd0b85a97d-35e8ef7f4e0mr225252f8f.59.1717528122875; Tue, 04 Jun 2024 12:08:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYNR5RVnoHDGc938FIDM//2FpFPkzV15IrTHFrTnMshg5cBYV9Re5c/6Tw/adkM96928uL+g== X-Received: by 2002:adf:fa82:0:b0:357:dbf1:1d3b with SMTP id ffacd0b85a97d-35e8ef7f4e0mr225233f8f.59.1717528122408; Tue, 04 Jun 2024 12:08:42 -0700 (PDT) Date: Tue, 4 Jun 2024 15:08:39 -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 44/46] Revert "docs/specs/pvpanic: mark shutdown event as not implemented" Message-ID: <53804a67c6c4431962a7da6302cea44d55181760.1717527933.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: 1717528309022100004 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:29:59 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=1717528220; cv=none; d=zohomail.com; s=zohoarc; b=KKmRIS/SWydxT4lMKtWzY0AMmOAi6WAG00WGoS+rg6mm7kPq7p1mSgtulMDywy/UqNtkDoeNBsXQOOFkFnuuRQAKhwpSvCqPinxpkAl6K8KbFlGkMk9WYqJUGn+vnzyR8dhTCi5BJJk8dly9/PMNOePK3GIhxuWLc/mTBME/qBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528220; 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=X5ZK85DrY7E/kWQuvTt0uyTur3Js4Sbrs2c23IwHRBA=; b=L+Fw/OUWciAnoHPZlDZ9uRRGUT5tuKnaJ5MQqsF7LOiwMjVmFPzxf/CLl5qeEeRcLbz2wXh5ovN10fZQo9OOYItKUEx2jwPe+pjNo+k4C+1q8gZF9XNt1gIAg8WLjk8zCHdyhh13Zxi5e6+gkI366CMz5j9CDhmrzhmsCvZDc4I= 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 1717528220759989.2526367123639; Tue, 4 Jun 2024 12:10:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZWg-0001qT-W9; Tue, 04 Jun 2024 15:08:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZWf-0001de-3L for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:53 -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 1sEZWc-00014K-8O for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:52 -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-604-LU11aHEcPCKS8s3NJdhBRw-1; Tue, 04 Jun 2024 15:08:47 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-35e83bf3294so109550f8f.1 for ; Tue, 04 Jun 2024 12:08:47 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd066ff17sm12305649f8f.116.2024.06.04.12.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528129; h=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=X5ZK85DrY7E/kWQuvTt0uyTur3Js4Sbrs2c23IwHRBA=; b=iCzcqWCelyrR5AZdECSQK06SnfXiUD3hC32Vz0jJE+PbwtrL7T+ci8v64ggQOUoNJijZNj U3pdTWX0l8aRQmvAk3Wqhcyc0Za/HMU5yezBhTzYD3C9yfZkXgLCzHLDJIeVM7STBsDcjD c8nkd8CEf6CWHcUiW7wwozhhc0q8Gyw= X-MC-Unique: LU11aHEcPCKS8s3NJdhBRw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528126; x=1718132926; 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=X5ZK85DrY7E/kWQuvTt0uyTur3Js4Sbrs2c23IwHRBA=; b=EG+vIWrT+dukY6JnAi7BpksXfCmtLqoAYNsFieuOg/TcoY0O2UPz3aZWhC38dAHRII E/yRbIYJNqKIK3sLjAA2fzOjY0v9Bjxic988zYMlKHI0sNd+vIA2f90IvCxW5CxVc3Pr rQ7R+PoZtvtB7zsXyDl5kWZMs+w9g5h97AAX9LsqEg6BQ2nGbHt4iTUs7MxDCnOPTMEl PKWcJpN/yBJjvaykQupAl34D7l9nocrhpF3zTlHoF8CxuccxfMO0xnbyt0xGCZALOHoR anRMweHbiGyX12e4Yp08swBIO0/zL167hWv2ZqA26EYKwExDHkXeucvmEE5YUuUlhQU6 nkKw== X-Gm-Message-State: AOJu0YzMUKMZD7ddZOD9oxlBy0gJ7v7BXq82gMtrzYW4JOnXR6uwfVR5 x/T2R0gkWrhOiuk6Py3BFQzpeAvlRF29eFH9MChNGoaYXFG3Z2HkZ2LxyrNm9pYpLnDxeVLbpzo cSN94n2wgrpKbYDol7+cqqThp0w4i7WN2esXhHs7jJv/NY7ldaJS/cLAJIXrln6gqtnexAZnwXs ZHOTfsML61LGWKrYOzTV5LAcQ4lPnAVA== X-Received: by 2002:a05:6000:ac1:b0:357:ac48:9676 with SMTP id ffacd0b85a97d-35e8ef8fe7bmr215576f8f.51.1717528125703; Tue, 04 Jun 2024 12:08:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZ2Bws9bhvSZVUDSxK2VewV7oWsb2mOYqXEIHq30jnoguOWmRVGsHetSQ/kV8PCk8v1uUogA== X-Received: by 2002:a05:6000:ac1:b0:357:ac48:9676 with SMTP id ffacd0b85a97d-35e8ef8fe7bmr215557f8f.51.1717528125261; Tue, 04 Jun 2024 12:08:45 -0700 (PDT) Date: Tue, 4 Jun 2024 15:08:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Cindy Lu , qemu-stable@nongnu.org Subject: [PULL 45/46] virtio-pci: Fix the failure process in kvm_virtio_pci_vector_use_one() 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: 1717528222641100001 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 b6757ffce2..349619f57a 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:29:59 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=1717528216; cv=none; d=zohomail.com; s=zohoarc; b=MC31t+3ZuJwyyefNNgOk7VIuHkhPBq+ztx/mpF+t0p50eMuLQRHUI2qVqrwNrDLVZTnIkkEUFcG8cMWr2WstJA2LAHcbLCOavk1t8ixpM3vSxHRO5jtLDP9VYCvd3hPNHhrTxHklZmJJs7nbfWjgNg0JA9Uri/OLdfVWWNeSzNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528216; 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=AE8FrzdRjaBc0d8mpYPsEcOS4v/aPdaq5V9e/CSmlgGS+/BbxJH8SsrKyDXJ/odvkPuVzJpideNkC4zIMxVm8KYZWt8gqMrIRBlBUC7/36mNNbhTbQv6mklmQBBl0hRrlrw7YNrjAY42xkJ5aYjz9P/s3zbg8iLIeeTlo5LUQCI= 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 1717528216114134.63527428925; Tue, 4 Jun 2024 12:10:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZWi-00024Q-Ua; Tue, 04 Jun 2024 15:08:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZWh-0001se-5K for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08: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 1sEZWf-00014l-0w for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:08:54 -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-5-8ZsILDqVOxOF1ZGJsRxwiQ-1; Tue, 04 Jun 2024 15:08:50 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3580f213373so4020055f8f.3 for ; Tue, 04 Jun 2024 12:08:50 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd04ca9b0sm12300744f8f.26.2024.06.04.12.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528131; h=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=KlM8mKhtk2yxH+cb2goqT0wuEYQb/5APSw9WkiYTDi86oWkVvZ+DBngPIZJLfSTkjBHoeZ zACCVXmRasgYonlUVh+KWiV5YJGoLhDtETkbUSbyG0fpKIsNY4zbv3eWqWYSXf62iYazII uOE3cbxsHrfofvl+/1XnO/ZDT80cnRw= X-MC-Unique: 8ZsILDqVOxOF1ZGJsRxwiQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528129; x=1718132929; 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=tNWa6xbazBJjKej1U5VrJzBBOmb3zTjZ3h9uHOGiZpBMk/uyMH4YEupFhzqVO4Jqel 3ihO9qVsDCsKq9eHebDFbSxj3lo13dqYFlBg2AX+YFvo3bcvlmhKT7QixB0b2ORMpcc5 BQSQqX4ByOHNx6cU5oB+uq0NoaJqwyfGFbeS/o2CYaPzMT6Fa21NivxnJ8O3tnEn17V1 IXGI+1DmBL2jWkNhNDb5Q1w1W98cQUSkjjd8PThbT2X965F88pyeVNS+owxODxqDjRd8 JCGIQF4H2HRb9sF0mDaHE6/4IfoWU6cQKVNC+ap7SIOoOJsvWRg9iPqQuY2/hlBf7ikn DEHw== X-Gm-Message-State: AOJu0YwLn/8Y9ZQtJ7wIAj22DZcjzXmhcwvw0Gmes4R0R6B/Vu8QM7Ou 0Wr8LFLW8ReK1C86YSBKNmcMCZm0PBWkc45N7Pfa7151GKqKLez2YxsyvnjkTUFRBjKlGr0r0M0 UoxU2JBmOr2FakJ4dgvNRWHrsEO2tQDBIPE/OQy3qWk1bQwjiuHQ6zTn6jG+VP4MqbAV/U0S7CR a3uyl8tyQzK1Cz2sOEU7g4Xu0KGsxFEQ== X-Received: by 2002:adf:ffc6:0:b0:35e:5b3c:b11f with SMTP id ffacd0b85a97d-35e8ef88604mr237889f8f.58.1717528128900; Tue, 04 Jun 2024 12:08:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqaFhfQbrUrDlddkkqAJv2o2eqhwf4J8xkhEdAtGa1xSDl36wXfJBVOrnEHaJgDB5dM6S1iA== X-Received: by 2002:adf:ffc6:0:b0:35e:5b3c:b11f with SMTP id ffacd0b85a97d-35e8ef88604mr237867f8f.58.1717528128446; Tue, 04 Jun 2024 12:08:48 -0700 (PDT) Date: Tue, 4 Jun 2024 15:08:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ira Weiny , Jonathan Cameron , Fan Ni Subject: [PULL 46/46] 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: 1717528216659100006 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