From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; 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=1576762284; cv=none; d=zohomail.com; s=zohoarc; b=MB+6UMsImoQl8xAgpz3G1hlLmobUF0FvJz1rA/dzG+irV+XZNIGOwqihOjMGsMOTdFo5rihLpu6G4DfvYNzdBHtql+tr41sk+eTYjn2Dovc9nNpoe+3IsSOVEz+BX4HskdEJAPSwUdX3mk/Sri7qWeFiTJptYQyxuvRo9QfTAOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762284; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ky3AoPDK1Dl90THjFQNp/2P2m3Le5A8fcjpKsYSUby0=; b=i7x3xZngFQ6+nFari8ycTjcvgKnFd4//zi5XqG0GCcHBDipSRtuuuChrsFrv3QWvvoWkwMvodLUy86LN0nZijK1ewBkeL0bBFOCz2KHYx8Rq2IaE0s1xaOt5DBEHjxd/p7wPBprSAZxiSu72wCvIQaSUH0wNdFcrRSwH1beGabo= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762284022710.9122333873064; Thu, 19 Dec 2019 05:31:24 -0800 (PST) Received: from localhost ([::1]:41540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvti-0005RF-P2 for importer@patchew.org; Thu, 19 Dec 2019 08:31:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48354) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvpb-0000RH-RB for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvpa-0001C9-NW for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:07 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:27655 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvpa-00017u-IQ for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:06 -0500 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-73-mxoiEXsIPfCC_AdFbdEjJg-1; Thu, 19 Dec 2019 08:27:02 -0500 Received: by mail-qt1-f198.google.com with SMTP id d9so3653605qtq.13 for ; Thu, 19 Dec 2019 05:27:02 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id u15sm1699900qku.67.2019.12.19.05.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:27:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762025; h=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=Ky3AoPDK1Dl90THjFQNp/2P2m3Le5A8fcjpKsYSUby0=; b=Kzb45lGVVn+8JEIOR0qj5WbLgl/AYQ9fk9v9bfiMhe8PMyIO4wJH4Fb2tid+AxafWqeTI/ wSqE15eSKFTx8hHw+hS0weSMNhfde9niJKU9LAJ/b5D4Te8b2TESkQoVS90YYG3cfPbRk5 4NsX3bGoP9G7OB6PDuzwhtrKi5vZl2w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=S797ekb1koe77yVikHhjJoQQO+mcOVBkg02x1T+LNQw=; b=GVo8bFEjjWacauG18Md/4SmIXtSctaKyt9FftWt7owK/QqCKvuJ/HhgiTSNQxE0mmc G3ehvH34EaJj55nGwFoVxr0Ipqqh8tTYHGY/rFxngStNiUWmv3fa5AHDOgiyjOL7OtW4 fnHvi7V8wUk6u26DU0rTwY5bp8vQeApPN6p2f6NXpSEXgqGztBEO2Qs7q1W1w1rjsQAk iN4iCVI/XS7jEXibq0SPA0/XHfAmMOmT/qeTBK9SyZfCj2YDtVs10tSyWQyRQmsfCBfa kjxJcQm9i/CgjH9ieXzB/e5hhzD4q95qlKAJnOk2qFJz1XZeOSei9WRJiMJYaWhK3VOF KUfg== X-Gm-Message-State: APjAAAWpPC83iI0XCxsQhBT7d1UKEULOd2Db7hBxdJ/6VX7D5CPxDRXs kyQhyx6kcQQ8/rrIvUFPt5Wlm0CgBIuCBeHVjcTNoboc1gASF3ztsHHvPSJlIu7DjoOBdJcf5yy EQt3Kn6rUAJvpXDI= X-Received: by 2002:a05:620a:13e3:: with SMTP id h3mr7884033qkl.319.1576762022013; Thu, 19 Dec 2019 05:27:02 -0800 (PST) X-Google-Smtp-Source: APXvYqxP5nXIgzLiDhJp7TyIiAZd7j377ox4jE3fyAsWjIbW1+ja4EK4UWWXxAYOaiTuxN96v7RURA== X-Received: by 2002:a05:620a:13e3:: with SMTP id h3mr7884017qkl.319.1576762021793; Thu, 19 Dec 2019 05:27:01 -0800 (PST) Date: Thu, 19 Dec 2019 08:26:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 01/24] virtio: add ability to delete vq through a pointer Message-ID: <20191219132621.16595-2-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: mxoiEXsIPfCC_AdFbdEjJg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Devices tend to maintain vq pointers, allow deleting them trough a vq point= er. Signed-off-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand Reviewed-by: David Hildenbrand --- include/hw/virtio/virtio.h | 2 ++ hw/virtio/virtio.c | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index c32a815303..e18756d50d 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -183,6 +183,8 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int que= ue_size, =20 void virtio_del_queue(VirtIODevice *vdev, int n); =20 +void virtio_delete_queue(VirtQueue *vq); + void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len); void virtqueue_flush(VirtQueue *vq, unsigned int count); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 04716b5f6c..31dd140990 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2330,17 +2330,22 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int= queue_size, return &vdev->vq[i]; } =20 +void virtio_delete_queue(VirtQueue *vq) +{ + vq->vring.num =3D 0; + vq->vring.num_default =3D 0; + vq->handle_output =3D NULL; + vq->handle_aio_output =3D NULL; + g_free(vq->used_elems); +} + void virtio_del_queue(VirtIODevice *vdev, int n) { if (n < 0 || n >=3D VIRTIO_QUEUE_MAX) { abort(); } =20 - vdev->vq[n].vring.num =3D 0; - vdev->vq[n].vring.num_default =3D 0; - vdev->vq[n].handle_output =3D NULL; - vdev->vq[n].handle_aio_output =3D NULL; - g_free(vdev->vq[n].used_elems); + virtio_delete_queue(&vdev->vq[n]); } =20 static void virtio_set_isr(VirtIODevice *vdev, int value) --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; 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=1576762173; cv=none; d=zohomail.com; s=zohoarc; b=IzPq8MjX2vBZUQ/HVEVmTIH6x2dUoupBq+d4vufRUWUaacMBFOD285Yozdgz6WZ6KtAZTD7yaY1dm+88Vsgim5f2Dy9sGz9Y7DfuQ/LI9/45qWZCqF1/utxHpizSlpH1TdAvCRziAQ9qp0ZFugbfnsH1Ut3Ui398elGU37yuR48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762173; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KTcB6zAIaRzY9EwvftE6Rtrz5u5tIha89kZ+phnxUYk=; b=QJZzGiwNwfJE+scqu9Dratim5Tf+tApxWH5keuP8SkVGxFAB4THEBtIH0KPaVUxZv8lXIpKKLhVU3GZLc//ZBcP6F1/D2n4GWNwjIovPKqoeF7djse9lZAdERccFjDexoYpmZI7qsPStosTW1hdHp+LGGs6k/sptcObQ3vNlqZU= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762173446425.99247004089216; Thu, 19 Dec 2019 05:29:33 -0800 (PST) Received: from localhost ([::1]:41492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvrw-0003Gv-1H for importer@patchew.org; Thu, 19 Dec 2019 08:29:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48757) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvpe-0000Uc-Ro for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvpd-0001R5-NE for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:10 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:50816 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvpd-0001NP-Ip for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:09 -0500 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-285-_kvgLlE2Mma9C4kIPoNYzw-1; Thu, 19 Dec 2019 08:27:07 -0500 Received: by mail-qv1-f69.google.com with SMTP id e14so3632588qvr.6 for ; Thu, 19 Dec 2019 05:27:07 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id z28sm1899665qtz.69.2019.12.19.05.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:27:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762028; h=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=KTcB6zAIaRzY9EwvftE6Rtrz5u5tIha89kZ+phnxUYk=; b=jN3rrAgDdy1gVu4rXtRM4mBDIsZijRB5f6+rYHC9BkQzGs0CMn6XnU7MN2lPdkGZFCPu65 CV0YPfUBovhdUnx/EXp+PTcpFy+g9gWffmUxGsvrbXuD9IC7q1yb1tI5/vz7ozHIYZlnNI +Y8eeY7Z88Sw+bGVrcIy5oaA03UhFLQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RMQMUHnYVnq2AcC/aQn0pR+4gejts1KmX+FDMoG77/0=; b=naylXn3nwdLQPUAGMiHbw43sucnO67X09f7JbblIfVKCDr2Djsvb9ySaXjVKxJHLTN czFna/+3pFGFtnKAFMTlglplZ12MjqqEucIgp1j77XXrtm3AJ5ZtrKVjvxent4bqhO6J AkSBqe2HZx806j2HIyY2k08VP66VlFFB5xeUqMLS8V2hilfFxEFG4Ab/9+yoDjBa2y3B dxM5ChM8j+CeG99jT+Pjth8t4mNbHhvjYhq0ZpBGnRmLNpbih1dZXQgfgapTkgZgkdG6 fjms0qzJ00FHsw02MpQdV3nf6R3UYthvf5MJb1fuM1k5yhwlOFvsMEUaDIkYakzu6PlG dq9A== X-Gm-Message-State: APjAAAXzwaTLtR/CuK9DTFFuPHAq8ZZ8jaJzmqQXwsHPGhRO3xnFtQDP 3R2yhihWHNklIE31paLvW/HQJu6dzwrKILegxo9iYHzGClbQ/tIgEC6w8XR4ZKlopI4J41YH2TW 7c8RbyJYykJI1vig= X-Received: by 2002:a05:620a:899:: with SMTP id b25mr8050054qka.197.1576762026907; Thu, 19 Dec 2019 05:27:06 -0800 (PST) X-Google-Smtp-Source: APXvYqxNnCz1H3lCM9IiZzqfI/CJF05c6S6ZN3gu+TwOOtIJkdZLM/fbz/OdgwJmPhoA4DXA0T8Ecw== X-Received: by 2002:a05:620a:899:: with SMTP id b25mr8050038qka.197.1576762026665; Thu, 19 Dec 2019 05:27:06 -0800 (PST) Date: Thu, 19 Dec 2019 08:27:02 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 02/24] virtio: make virtio_delete_queue idempotent Message-ID: <20191219132621.16595-3-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: _kvgLlE2Mma9C4kIPoNYzw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Pan Nengyuan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Let's make sure calling this twice is harmless - no known instances, but seems safer. Suggested-by: Pan Nengyuan Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 31dd140990..6de3cfdc2c 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2337,6 +2337,7 @@ void virtio_delete_queue(VirtQueue *vq) vq->handle_output =3D NULL; vq->handle_aio_output =3D NULL; g_free(vq->used_elems); + vq->used_elems =3D NULL; } =20 void virtio_del_queue(VirtIODevice *vdev, int n) --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762367; cv=none; d=zohomail.com; s=zohoarc; b=JZ8s++myXf4Kol+kDKDC16ZvlvRqP0sQe0ycsVqXJrdHF8bEfFXGdwlF3lUKv5A1Y8ptK4wNmPuHlKMvJiuMBsS9FUiuJIsb/FeqKarQPgpxaeB+RcEJ85DNACxTFziyt+fJNOvDWjjYRM7okLCwq4XpAD5sSvg7K7GfPHX7NK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762367; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y+1AiFYA4jwJXgwLDoVnwKQ62HQ9au7D6spvhTUBGU8=; b=Jo4NgL/l6avAH/R4+6CnuY6b2hQ7fKVYG6qKOkcu8xraHu7c7GZ9h1hOYfcL64ofPoWxQlwQtYY1T93LbrP2N3i/1AMjsvD/egY+DNIhrfu0wNOrYSqf6EjPjlRseiV+C2bsOoZN7y0El7HT+l77UO6snBifvZRJVnzk5mqizlY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762367063740.3735710712691; Thu, 19 Dec 2019 05:32:47 -0800 (PST) Received: from localhost ([::1]:41556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvv3-0006uL-Hx for importer@patchew.org; Thu, 19 Dec 2019 08:32:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49478) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvpk-0000eR-ME for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvpj-0001up-Ee for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:16 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:48564 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvpj-0001r1-4m for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:15 -0500 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-57-UZnKyHyhOcmSOJUkA3J-4Q-1; Thu, 19 Dec 2019 08:27:13 -0500 Received: by mail-qk1-f199.google.com with SMTP id a73so3627615qkg.5 for ; Thu, 19 Dec 2019 05:27:13 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id 17sm1890693qtz.85.2019.12.19.05.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:27:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762034; h=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=Y+1AiFYA4jwJXgwLDoVnwKQ62HQ9au7D6spvhTUBGU8=; b=W36k18w4cNTM4/Ix1yhMtoMCcG3f9Jpp5xs2tWH6UE5y6f5yn7V00hlZF7ye6JUTH4XHCU 53VIOMD7yueEUe81U1IWX4VoRfpKuy9lzRUsZUA+5uNoqk8nWRHTkdBuzZChVblwAoZvAi 6a6R1Wtq52Ok8n+SP+ZwImYfSwPwtdg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1upHWGgN+kA2iqb9NZ9XxvQ8bHfo9CqfdVL2Jr4HnRY=; b=HLwUApcnY7oYFfVWWOQgPcM0WwNp4LWl4jUYcWwqevuEXcw0BJfrPMg6kiNfgHe8AG OE0Z9nqBFTSZ518LcBOjodxodR8i9uoa8fp+tgFgLDxTBJQ9yyJK5ygqN+6xZZOW/U3T IlsS7ce3pYoCMtvk87k2s95nyTcpb4aoy/J1BrMV1GNMiz8YiIiR5t06CQiBVUqZC//c uc/7VdA5ovIeqrYFdM2Rk2XPYevusRAmuw0TxImw2Grlg9vSN9rEAK0Ho6GXd5eSW4Ch n+Ggy9mr6HChoCV4i3V6AsCl9Baq8QmtCHuYElZHrumSAPRZ8X+6ZGwizNVV295r/ey8 6csg== X-Gm-Message-State: APjAAAVH6Nn1sFCMRlBjKfu301iU7g1FUGjxi/+UwU92ctNyYb8jGH2g t2lOsE7MOORDtPX+jMWEfUTKswXrUuzItaBthT3C4VBMMBidJZedVYEddlOj8pg8+HKA0IYoGmj uGRi6FfxqLqUlAP0= X-Received: by 2002:a0c:89c6:: with SMTP id 6mr7621618qvs.72.1576762032116; Thu, 19 Dec 2019 05:27:12 -0800 (PST) X-Google-Smtp-Source: APXvYqyQEb3lI6AU4HnJrLsZKO681JM41kuyGZ6+zJjKvXF459ds4mqo/YduOMfDbOKs6SCVNyaFBQ== X-Received: by 2002:a0c:89c6:: with SMTP id 6mr7621584qvs.72.1576762031850; Thu, 19 Dec 2019 05:27:11 -0800 (PST) Date: Thu, 19 Dec 2019 08:27:07 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 03/24] virtio-balloon: fix memory leak while attach virtio-balloon device Message-ID: <20191219132621.16595-4-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: UZnKyHyhOcmSOJUkA3J-4Q-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Hildenbrand , Pan Nengyuan , Euler Robot Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Pan Nengyuan ivq/dvq/svq/free_page_vq is forgot to cleanup in virtio_balloon_device_unrealize, the memory leak stack is as follow: Direct leak of 14336 byte(s) in 2 object(s) allocated from: #0 0x7f99fd9d8560 in calloc (/usr/lib64/libasan.so.3+0xc7560) #1 0x7f99fcb20015 in g_malloc0 (/usr/lib64/libglib-2.0.so.0+0x50015) #2 0x557d90638437 in virtio_add_queue hw/virtio/virtio.c:2327 #3 0x557d9064401d in virtio_balloon_device_realize hw/virtio/virtio-bal= loon.c:793 #4 0x557d906356f7 in virtio_device_realize hw/virtio/virtio.c:3504 #5 0x557d9073f081 in device_set_realized hw/core/qdev.c:876 #6 0x557d908b1f4d in property_set_bool qom/object.c:2080 #7 0x557d908b655e in object_property_set_qobject qom/qom-qobject.c:26 Reported-by: Euler Robot Signed-off-by: Pan Nengyuan Message-Id: <1575444716-17632-2-git-send-email-pannengyuan@huawei.com> Signed-off-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand Reviewed-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand --- hw/virtio/virtio-balloon.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 40b04f5180..57f3b9f22d 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -831,6 +831,13 @@ static void virtio_balloon_device_unrealize(DeviceStat= e *dev, Error **errp) } balloon_stats_destroy_timer(s); qemu_remove_balloon_handler(s); + + virtio_delete_queue(s->ivq); + virtio_delete_queue(s->dvq); + virtio_delete_queue(s->svq); + if (s->free_page_vq) { + virtio_delete_queue(s->free_page_vq); + } virtio_cleanup(vdev); } =20 --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762135; cv=none; d=zohomail.com; s=zohoarc; b=IO8ILUimPwfZ6hpguhPk/QMsLx9AC+XIsNu1WwuVVESfqLqSvhuPezVv1qQ9Ylu/oaUUTr3hjjsUzv8TBJIFZLg4X1l6kgXsc92wuZbslvjwBVE6nbW4BEE91voxNf+DUfMKzTXfoL3YwqPZQeWX3ZPOpkW2Dt80KngU2d17EKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762135; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Nm5rBDcoCplmlWRAfpJUTX03Lt2BWA14BTGdBKMUPBs=; b=BZYMgeWFga1S6CzTaprTkkMIbdPKRxsKBpPvdcTOPnbzi0WkS2lqsn0Vq5HZRHGqXyFTch8FnJECQQjBvpF0FIJ3bPSUNuWT5AEoMa38hmBrCKZJvyJcWcwNk5UqLB0eN2ZXT3khVzK+DpPZ9UcBd8hftN0cSD5wRJop0P0EIpk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762135358493.6302271778468; Thu, 19 Dec 2019 05:28:55 -0800 (PST) Received: from localhost ([::1]:41476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvrJ-0002Lw-92 for importer@patchew.org; Thu, 19 Dec 2019 08:28:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50054) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvpp-0000mO-Kl for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvpo-0002LJ-EZ for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:21 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:31362 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvpo-0002Iy-59 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:20 -0500 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-189-s-q-aSmsPi2TXiA8F8touQ-1; Thu, 19 Dec 2019 08:27:18 -0500 Received: by mail-qv1-f72.google.com with SMTP id n11so3605223qvp.15 for ; Thu, 19 Dec 2019 05:27:18 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id b7sm1861870qtj.15.2019.12.19.05.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:27:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762039; h=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=Nm5rBDcoCplmlWRAfpJUTX03Lt2BWA14BTGdBKMUPBs=; b=eFW9v1VNs6/sRMytbtkj+9mUNVMnc2X0Ofn3ZM074HhEvO1aolv8TVdQC17OmnjPvBaLgO dX7JcnGi6tsobHVfMimF/UEWlnQLGyIsa+okYMPZRYkjsa32z7aFABop70kvP2oCRzxa1H gK0OQNivMHTc2RtsKXD/gr5uG34hc7E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=SV/3gkt55AkXiObd4ttRVZfM0Ouiap0tkA8DR2mthfg=; b=cidFTFL8lSNGKNEL2rgq3mQi2v8bQTwrLYb9a8cMw0EHGTP0Jwlui3dFektVE2j4DT F3kMW4zpaBgfc+HFmvMOaRPHjs1IM4Dhel1aiquUW787JH0tLefqYWGXLHnS9vLPTq5U 0adRGAKaGhfUG5ZZbLeS/3mb2MW/K8PK0MnOorZWY7rGdRCEkQhSPdLFoSATr7i42jje vMF76qEvaV6RN8pTLcGOwHHTFYDThxjN77Y5Ki9JaPgbg6hEyhCp/9mRMj8u8zUaGBlj VRUnSCXu42HZZkrAXFJPxV5v9VBAp6ugFHfjgi7TDbCMgC6YwWwVZFmuVw4qh5i+V3vL DiGg== X-Gm-Message-State: APjAAAUyjLRUFyZw/0y113daO9TcVIFEbeD0M8tZgVbacPdiumfYCrZm O0uS39BUnY/WkSnI9xL/eJQCZQUw/fqSbJZp3B2gxEvIqzX0Mwj64GJD7jzOXrBe448i1/7PHD7 J6DnT5YS+Z+BXxLE= X-Received: by 2002:aed:2b04:: with SMTP id p4mr6747250qtd.270.1576762037869; Thu, 19 Dec 2019 05:27:17 -0800 (PST) X-Google-Smtp-Source: APXvYqzxJSPYH0s/GOrWKXPHoKaapoOlZ68ZAq0Wt+zq6meHdeQTCK3Hqf5x6HDhG78xE123I89yUg== X-Received: by 2002:aed:2b04:: with SMTP id p4mr6747232qtd.270.1576762037692; Thu, 19 Dec 2019 05:27:17 -0800 (PST) Date: Thu, 19 Dec 2019 08:27:12 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 04/24] virtio-serial-bus: fix memory leak while attach virtio-serial-bus Message-ID: <20191219132621.16595-5-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: s-q-aSmsPi2TXiA8F8touQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Amit Shah , Pan Nengyuan , Paolo Bonzini , Euler Robot , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Pan Nengyuan ivqs/ovqs/c_ivq/c_ovq is forgot to cleanup in virtio_serial_device_unrealize, the memory leak stack is as bellow: Direct leak of 1290240 byte(s) in 180 object(s) allocated from: #0 0x7fc9bfc27560 in calloc (/usr/lib64/libasan.so.3+0xc7560) #1 0x7fc9bed6f015 in g_malloc0 (/usr/lib64/libglib-2.0.so.0+0x50015) #2 0x5650e02b83e7 in virtio_add_queue hw/virtio/virtio.c:2327 #3 0x5650e02847b5 in virtio_serial_device_realize hw/char/virtio-serial= -bus.c:1089 #4 0x5650e02b56a7 in virtio_device_realize hw/virtio/virtio.c:3504 #5 0x5650e03bf031 in device_set_realized hw/core/qdev.c:876 #6 0x5650e0531efd in property_set_bool qom/object.c:2080 #7 0x5650e053650e in object_property_set_qobject qom/qom-qobject.c:26 #8 0x5650e0533e14 in object_property_set_bool qom/object.c:1338 #9 0x5650e04c0e37 in virtio_pci_realize hw/virtio/virtio-pci.c:1801 Reported-by: Euler Robot Signed-off-by: Pan Nengyuan Cc: Laurent Vivier Cc: Amit Shah Cc: "Marc-Andr=C3=A9 Lureau" Cc: Paolo Bonzini Message-Id: <1575444716-17632-3-git-send-email-pannengyuan@huawei.com> Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- hw/char/virtio-serial-bus.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 33259042a9..e1cbce3ba3 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -1126,9 +1126,17 @@ static void virtio_serial_device_unrealize(DeviceSta= te *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOSerial *vser =3D VIRTIO_SERIAL(dev); + int i; =20 QLIST_REMOVE(vser, next); =20 + virtio_delete_queue(vser->c_ivq); + virtio_delete_queue(vser->c_ovq); + for (i =3D 0; i < vser->bus.max_nr_ports; i++) { + virtio_delete_queue(vser->ivqs[i]); + virtio_delete_queue(vser->ovqs[i]); + } + g_free(vser->ivqs); g_free(vser->ovqs); g_free(vser->ports_map); --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; 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=1576762325; cv=none; d=zohomail.com; s=zohoarc; b=MXMu2ySARu8KfFiqZ4fuX+GE+I1hwd/Hh0Souhx42QyX9DbdYI98A5F6PU29LiXEU746lESHFUzbh4VFt2waQSPRFdkUoAW6rrrfSGgGRxgAo8AfkxjS6UsGzmdPZzXeNOWrH/0Gus8fi/MXDZleXG7lEBsy6snA3+sgSLfBGgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762325; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=K9epneyHKkAEq5gGDVE/gbeFue8BzwP7OkBM6QzY9Yk=; b=lc7sXNnrKp6HyBMw6uD2Hgsa+irf02xnYpuyQIdSf97BeTKD/C5f80Imw+zdl3iLkQ8ajzt6xDp9zH0n8iSkhKCNfJ+iJnfCptmKt+6Fg5VQxGBlzfJwkklma1AF/b6aAlTJbDn4nORVmlbZEBlqvJvuURJKx/qHKbftUBsrr7s= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762325917694.6034979774305; Thu, 19 Dec 2019 05:32:05 -0800 (PST) Received: from localhost ([::1]:41548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvuO-00065p-05 for importer@patchew.org; Thu, 19 Dec 2019 08:32:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50992) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvpx-0000y4-D2 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvpw-00033Q-5t for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:29 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:46574 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvpv-0002zo-UC for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:28 -0500 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-270-Evpot7u6NaCjp8aT6n3wnw-1; Thu, 19 Dec 2019 08:27:23 -0500 Received: by mail-qv1-f71.google.com with SMTP id l1so3607705qvu.13 for ; Thu, 19 Dec 2019 05:27:23 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id o33sm1897762qta.27.2019.12.19.05.27.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:27:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762047; h=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=K9epneyHKkAEq5gGDVE/gbeFue8BzwP7OkBM6QzY9Yk=; b=bPvoIaMU5QATgf+yXgsF1nIXWpi9E4STfdLNJ+Oz6E7DU+I0T1R/t+FBVWQvJVZYTnaQ8x 1/yCti0v5AAW4K6oQ+19pXIXwfFXY2Le1pXC+JtY/6x3BJFA5Wo9sPL1qeg11Lre6vrqzT LfbS8tkShq7hUNtgLEX+DrId1O/W1kY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=iiaP0RxMw50Y4u2HruPOoUKc+xP0ZRMmYrMUAAr8Wgg=; b=hg0tGMT3xb6lHAjYqRLGFr3Gr4AiipMqYjRLGyiAmYBoU1n50aW4VzjszjPU1JHqFt OK4lp79aH31UUMBpF4JTq0q9zb4GWjQCNWAZ+NomsmldadZKOFpR5UobqxN6srKz6kfE g8IvzEGT2jYgHGm9SB+HFNMfaVWB2hKXqoLrCzcO/1miDRlt0lk1Axs1g03km5q0FfXn 3OR/PCRq5nePrNkBfxIthG4gjg26EDP313Gy1smwwbkVza9dc6ZnoCoFuuV5Mdm/z3rn wy59eWgzNYQR1z9xl2TYum15m1DoXZMHGyjlBWlwqkubJJs3S23d+pgE37uYfkjQHSAB WS6A== X-Gm-Message-State: APjAAAUhT3m7S6uGkr7mua7jcHR71XnHMUsaeSzqL384HAxXhGggYP2Q 9TX5Jbb0vbdCD7KO6luDapl+IoLEnbr0SOaxN6n++EGv8c37qiKehnFsTivlaeFwOt/cvooeNk9 yRgpN54UWtL607Ng= X-Received: by 2002:ac8:43ce:: with SMTP id w14mr6840876qtn.256.1576762042565; Thu, 19 Dec 2019 05:27:22 -0800 (PST) X-Google-Smtp-Source: APXvYqwfZ/tO72wFxLEI4JPFGcBIyC19eV+6gmBShoKgxCk8r0R2N5885i8e+ggVHP+x7XMqa8Qsrw== X-Received: by 2002:ac8:43ce:: with SMTP id w14mr6840863qtn.256.1576762042403; Thu, 19 Dec 2019 05:27:22 -0800 (PST) Date: Thu, 19 Dec 2019 08:27:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 05/24] virtio-input: convert to new virtio_delete_queue Message-ID: <20191219132621.16595-6-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: Evpot7u6NaCjp8aT6n3wnw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Seems cleaner than using VQ index values. Signed-off-by: Michael S. Tsirkin --- hw/input/virtio-input.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c index ec54e46ad6..9c013afddb 100644 --- a/hw/input/virtio-input.c +++ b/hw/input/virtio-input.c @@ -280,6 +280,7 @@ static void virtio_input_device_unrealize(DeviceState *= dev, Error **errp) { VirtIOInputClass *vic =3D VIRTIO_INPUT_GET_CLASS(dev); VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); + VirtIOInput *vinput =3D VIRTIO_INPUT(dev); Error *local_err =3D NULL; =20 if (vic->unrealize) { @@ -289,8 +290,8 @@ static void virtio_input_device_unrealize(DeviceState *= dev, Error **errp) return; } } - virtio_del_queue(vdev, 0); - virtio_del_queue(vdev, 1); + virtio_delete_queue(vinput->evt); + virtio_delete_queue(vinput->sts); virtio_cleanup(vdev); } =20 --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762152; cv=none; d=zohomail.com; s=zohoarc; b=E2ZNEiUFr8bD55rqD2UWX10aISeZCyDLIfwUDQCUcDHKggVOSwluNY0wWEQXTKU599T2hO+XEJUMbi2KsvxglZ+min4+aioYOCS9ueGUJVVPINLg1HWuDURs5NX2BE8RyoI/3HvQOpSGJc0F64rGflOD6rDEedbYaezXMrh7k6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762152; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8li2Tk9kJtAQIFMop0/eFLC5J5NJiOvfkc+z767fYRk=; b=MUzWrZbcci4dVVMEcj3Yhf+x7xTIrh7zbgkAbxomWRWFrZwLlmTTYnVXMX3cYAhCg4NmZJDh3zoSjqhnTR4d9vJ8qaOYoAoBQ4WBHykIFRSzgKZyC2v3dFetQMiQH3UqO0Lmf8FpUeVcF2rbEtnbKzSsnQ7gFdkL9Skl/8wS/MU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15767621524021015.4975803368308; Thu, 19 Dec 2019 05:29:12 -0800 (PST) Received: from localhost ([::1]:41482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvra-0002mK-Ip for importer@patchew.org; Thu, 19 Dec 2019 08:29:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51458) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvq1-00014K-9v for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvq0-0003Ql-70 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:33 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:25559 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvq0-0003OA-0m for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:32 -0500 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-207-EdhtTpk2PRen4Wjf8miTww-1; Thu, 19 Dec 2019 08:27:30 -0500 Received: by mail-qk1-f200.google.com with SMTP id g28so3594405qkl.6 for ; Thu, 19 Dec 2019 05:27:30 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id m27sm1879294qta.21.2019.12.19.05.27.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:27:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762051; h=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=8li2Tk9kJtAQIFMop0/eFLC5J5NJiOvfkc+z767fYRk=; b=X5Wb8uBZjwivh4h7GGrxb2SyOlUxqQiWeXvQPwY8efpPPtb14jimgTYdYVLZcBaiqp+X4c SwkLsTC6xAicOnr1bKSGUDDFOtl0p/PY4wcpuzmN1XKqjvmnrFN0kxVUuyo8JcaIZJZ223 qGxRFgsl95DcA321LLROT6cbCwNbkoM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8e5zVSr3EGK6wfLcmhM6md/VpcFIAiAuGM2x/CJ8sg4=; b=GnCNplev8y1iOJtboiaqXKxjBgX1/0RMOrRRkSF+hIZ4lgP3dtfW8Gm4o5qMQ9Vhbq tmj2ZHjX1d5t65S4binR4+6KeJxU5m2sr1f1jAsajL1RLqqFWlFG2FBIwBkNRVHG8fc8 5T0YoMdLjupBGqk4HPt7TqIGeyda1S/jRGQe0f3K7/tu6+WC4kmx1ZIIrPYVGaRkIshP FzQnJinnbQyMxPp8Sp8UHziaRNL32mfwrAWfgtYn5Gh2snMWk4JhRnAYbGqN9ygWSSYV iEhsNzYVQf8/SlS/pzVT36FVmiLJhM45KNn+AZJEze/FPMtlB4Lz1jFFHBCm4Wf6vQKF jjSQ== X-Gm-Message-State: APjAAAUGWh7iGkXojHjwhr4dxV9OtazgJlvzuStgXZNuhDFmCJRQMBII bXyfao2zJsrYCDa8/jjWSxNqExpyfYUWo52oB3dfVylmoM1O+F0u4kDiQNSO7u0lwuYofKODISE wUq6fSVrryJBOYcY= X-Received: by 2002:a37:644:: with SMTP id 65mr8220441qkg.309.1576762048196; Thu, 19 Dec 2019 05:27:28 -0800 (PST) X-Google-Smtp-Source: APXvYqwxTFTstNlGaO4audt9RA8wrjhpPEXetF06giI138x7OWlyriFVhBuUmIPpiFETxDTxKaimRw== X-Received: by 2002:a37:644:: with SMTP id 65mr8220410qkg.309.1576762047917; Thu, 19 Dec 2019 05:27:27 -0800 (PST) Date: Thu, 19 Dec 2019 08:27:22 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 06/24] intel_iommu: fix bug to read DMAR_RTADDR_REG Message-ID: <20191219132621.16595-7-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: EdhtTpk2PRen4Wjf8miTww-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Yi Sun , Eduardo Habkost , Peter Xu , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Yi Sun Should directly read DMAR_RTADDR_REG but not using 's->root'. Because 's->root' is modified in 'vtd_root_table_setup()' so that the first 12 bits are omitted. This causes the guest iommu debugfs cannot show pasid tables. Signed-off-by: Yi Sun Message-Id: <20191205095439.29114-1-yi.y.sun@linux.intel.com> Signed-off-by: Michael S. Tsirkin Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 43c94b993b..ee06993675 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2610,16 +2610,15 @@ static uint64_t vtd_mem_read(void *opaque, hwaddr a= ddr, unsigned size) switch (addr) { /* Root Table Address Register, 64-bit */ case DMAR_RTADDR_REG: + val =3D vtd_get_quad_raw(s, DMAR_RTADDR_REG); if (size =3D=3D 4) { - val =3D s->root & ((1ULL << 32) - 1); - } else { - val =3D s->root; + val =3D val & ((1ULL << 32) - 1); } break; =20 case DMAR_RTADDR_REG_HI: assert(size =3D=3D 4); - val =3D s->root >> 32; + val =3D vtd_get_quad_raw(s, DMAR_RTADDR_REG) >> 32; break; =20 /* Invalidation Queue Address Register, 64-bit */ --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; 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=1576762498; cv=none; d=zohomail.com; s=zohoarc; b=OpZ2Vt9BJHSyT68hI9ry4a05DN/Ef79CWiwhDNZ7rCoCP65tNcw76G6KSOPWRC6VXiDTkngx6DFrfJkhxwUioOdLj2nfFj4VtHfAKKgDJrU8yfWcWJJTrzmv8IPNbbT6kZRfh3mMwyMj69gF/4XpNXduI3YRJp8543LzpLovdeo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762498; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zj2wVrIh8KQNhFA65bESMfJP7roYgy+mFo3n5QglPhQ=; b=TxuEJivjmFvNuidnY28HVAJvy+btJEBsNLzeQI3u81zfCNHVm9RWP7ThvO8hqnVZtLkgT5CKbBsiRgeyZHtqRbLA1i1sXyDrdftdfN/zGX9qtJejqwiO1tWYnIpptGHG8VEpd5BBxCnN9wLndVFZantOjjA7dB3IlRD+vALS1og= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762498793466.5868714758665; Thu, 19 Dec 2019 05:34:58 -0800 (PST) Received: from localhost ([::1]:41590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvxB-0001mE-4V for importer@patchew.org; Thu, 19 Dec 2019 08:34:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51735) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvq3-000185-Uy for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvq2-0003f9-T7 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:35 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:31228 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvq2-0003cQ-Mn for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:34 -0500 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-268-4BquQgKdOXqGIWJJ4J27Fg-1; Thu, 19 Dec 2019 08:27:33 -0500 Received: by mail-qk1-f199.google.com with SMTP id 12so3575745qkf.20 for ; Thu, 19 Dec 2019 05:27:33 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id g53sm443675qtk.76.2019.12.19.05.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:27:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762054; h=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=zj2wVrIh8KQNhFA65bESMfJP7roYgy+mFo3n5QglPhQ=; b=HwhU+lhSzy2xJNfzn8StHrNOmV2fplVMQYJCl7Xi9Dt09g0/TVW1ofpoUIDfT3QMqjy0uT tFOOGWs7WJlgHQyNg9QL9o3H59yyPTwhmMYD21mcTF0ROAg4n4WzTHuqAFSt+qI6oOKjT9 Rf8y3lk+USaAVmkUjVPVlw84wcINkjY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=sanExUpcAf7TPhNumiJmyXjhA8u9u6QpSUASPDnjn/0=; b=jTCSfoNiPHPfVs68xEs9ttEAyVA9pM8uWmvIaPbL7YYT+FDiCd2EJHQUlkuEwvWLNM yUPFS7W2dX5XfN1a9eoHqTkxszEzp1Mct1AdB2mSxL4DhlsHNcsjt0YeU04VVOPpfcy6 enq4hzqlSU4FJuMpCEzyrwxbVFOl/lYE0v9Gr3rMrlfGiVm9kP1PEURC0bRmLXnjVRAx r0RT8YoutQyF+fVX2HyQvvx0Fs9mZCZ/Z6s7WkagF/VNPDea2ejHquQyWMFKkjuZW8Qp KHlVSd0IjASY++ccfAiqQiWcbQxd+jTzH0qDFJHNTquPY3qE7in9G89oCI+Cqq9jnezW 0KEQ== X-Gm-Message-State: APjAAAUDSo5tXs9uQXaBPfrng+o8LAK/1sqQZ8TNyNHwB9X+UtU/zkRS g+NjjgnavbkV8yAyxml+jroXAcqvDgzJmPydViuatWaVq2SvGSB9XbrXGvxeQ3TImUdftmHTQxB wAioaDh1yg4nTDJY= X-Received: by 2002:ac8:709a:: with SMTP id y26mr7000067qto.304.1576762052420; Thu, 19 Dec 2019 05:27:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzkA5yqJEFgrmZxI0g2Lrazb3uSDg2jMPT3Sp/NwzeIe2D+Z8sQlqs1fSN/YO0FvJGnFVn9MQ== X-Received: by 2002:ac8:709a:: with SMTP id y26mr7000056qto.304.1576762052277; Thu, 19 Dec 2019 05:27:32 -0800 (PST) Date: Thu, 19 Dec 2019 08:27:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 07/24] virtio: update queue size on guest write Message-ID: <20191219132621.16595-8-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 4BquQgKdOXqGIWJJ4J27Fg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Some guests read back queue size after writing it. Update the size immediatly upon write otherwise they get confused. Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index c6b47a9c73..e5c759e19e 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1256,6 +1256,8 @@ static void virtio_pci_common_write(void *opaque, hwa= ddr addr, break; case VIRTIO_PCI_COMMON_Q_SIZE: proxy->vqs[vdev->queue_sel].num =3D val; + virtio_queue_set_num(vdev, vdev->queue_sel, + proxy->vqs[vdev->queue_sel].num); break; case VIRTIO_PCI_COMMON_Q_MSIX: msix_vector_unuse(&proxy->pci_dev, --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576763342; cv=none; d=zohomail.com; s=zohoarc; b=fZkEDvPNEOJhdtFyJfE30P/stU9f81phlwHKh9wMaUkANoGqbU0GtNHeH6zksEr/E8vNHKKOzGvAtuGGaeOCX4K7NxN41/clroEe9AMMzpCnF9JzqIOP/q6HNcWbvWUqgl8tUCKnklKQhjKYKY8zmKs58Dmvl1pt1d/bMpQwTD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576763342; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qRixv/P79kxY74uYbLq18UmxPGC6mi06pOMRV9g5ikg=; b=Gm+wltJcyO3ylrK94NfdH78LE9fvu3nUzd2CtaN+zRKVr2BhfuG7p5C7U4YGBIiW1KUJd6lGJdaUwJYcvnl0EQniKYDrL3HXWlQLGdZ8tULH4hpxwosc9GUiTg0D+8GDxQ8Ps8EZlZgUI5cRu2r31CvaxUYylGlLT7LOEPy4BDM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576763342823535.2163048090417; Thu, 19 Dec 2019 05:49:02 -0800 (PST) Received: from localhost ([::1]:41816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwAn-0004Tk-C0 for importer@patchew.org; Thu, 19 Dec 2019 08:49:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39186) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvsf-00053M-Hw for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:30:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvsc-0007Qp-R0 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:30:17 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:58050 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvsc-0007Nn-Gw for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:30:14 -0500 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-413-UguUD9rlMJGKiCxiN1H_QQ-1; Thu, 19 Dec 2019 08:27:39 -0500 Received: by mail-qk1-f199.google.com with SMTP id 65so3587049qkl.23 for ; Thu, 19 Dec 2019 05:27:39 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id g16sm1715392qkk.61.2019.12.19.05.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:27:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762213; h=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=qRixv/P79kxY74uYbLq18UmxPGC6mi06pOMRV9g5ikg=; b=JKgwFfWqAtdZh2Y5AtH7rWiLIRS+hkdiuscP8nYOgD8XM2uwcZA2xU9OIMUH2WeLzUoyls RXj0Psie3o8gJhA8hYh388yvPjQ8lC+2IpEzr3x4g2hNRn1dFV8c2e2mibIZGXGFBFgLpp 5EGA+SSlTN3t/dDHWrW9DjWOn5Epmqg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=OAefkcAtOZgXGyKa55BHKeK0Ha6uDf6rtRTKOYAg8DI=; b=Qcz3ZMXDcO1Ftx69VUBh/m1OGaFEWZKu60RvKTf4KBK6ZNFVHKqIQW0HRTvQS4eTsW /6Rf7e9qeONUoMg2En0a2hK9YKWoHsWROyapjV/nJn+UpksA2uoIdMeoMj6jE67eA696 68dPvXiB88K7nuD80MWeNujfTlEB4DIIy2DufkZ5QvE93OSEhGf0WQ+jhn8sp6TnsQKy nmILf2z96c6kTYlCLi5CCIjr8mAyYy4OdwPSDIL0XWVBtp049VqZ04JaiQwHZ6Of1tAs HzGD9DwkVSmoddHIHSrCsy+1AYhG/MufnOdJaTsks8RpvlI98V9kHQxNjjs9ejGg6qFM vhmQ== X-Gm-Message-State: APjAAAWg81FBBTZ2fOl7RxzWIZhC0Xeb1wMGHNrjYrq5APUWpW4qliCl vZqUbEDjl4EGxA9GxdcUMY+fhg0UnFcFZ24T0gja3bggvCcMfEC0GMINv/GUitFt8/br+JA6rlo JHdT4twFeetHhG0Y= X-Received: by 2002:a0c:9e6d:: with SMTP id z45mr7575475qve.65.1576762058154; Thu, 19 Dec 2019 05:27:38 -0800 (PST) X-Google-Smtp-Source: APXvYqwuRLaL+bf0/Vh60qsaI6YPdMNz5CAt2HinJ03tsRTmkEVvGnY6O4FQSijWmfvMK46d5mWUPQ== X-Received: by 2002:a0c:9e6d:: with SMTP id z45mr7575421qve.65.1576762057717; Thu, 19 Dec 2019 05:27:37 -0800 (PST) Date: Thu, 19 Dec 2019 08:27:32 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 08/24] virtio-pci: disable vring processing when bus-mastering is disabled Message-ID: <20191219132621.16595-9-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: UguUD9rlMJGKiCxiN1H_QQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Alexey Kardashevskiy , Michael Roth , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Michael Roth Currently the SLOF firmware for pseries guests will disable/re-enable a PCI device multiple times via IO/MEM/MASTER bits of PCI_COMMAND register after the initial probe/feature negotiation, as it tends to work with a single device at a time at various stages like probing and running block/network bootloaders without doing a full reset in-between. In QEMU, when PCI_COMMAND_MASTER is disabled we disable the corresponding IOMMU memory region, so DMA accesses (including to vring fields like idx/flags) will no longer undergo the necessary translation. Normally we wouldn't expect this to happen since it would be misbehavior on the driver side to continue driving DMA requests. However, in the case of pseries, with iommu_platform=3Don, we trigger the following sequence when tearing down the virtio-blk dataplane ioeventfd in response to the guest unsetting PCI_COMMAND_MASTER: #2 0x0000555555922651 in virtqueue_map_desc (vdev=3Dvdev@entry=3D0x55555= 6dbcfb0, p_num_sg=3Dp_num_sg@entry=3D0x7fffe657e1a8, addr=3Daddr@entry=3D0x= 7fffe657e240, iov=3Diov@entry=3D0x7fffe6580240, max_num_sg=3Dmax_num_sg@ent= ry=3D1024, is_write=3Dis_write@entry=3Dfalse, pa=3D0, sz=3D0) at /home/mdroth/w/qemu.git/hw/virtio/virtio.c:757 #3 0x0000555555922a89 in virtqueue_pop (vq=3Dvq@entry=3D0x555556dc8660, = sz=3Dsz@entry=3D184) at /home/mdroth/w/qemu.git/hw/virtio/virtio.c:950 #4 0x00005555558d3eca in virtio_blk_get_request (vq=3D0x555556dc8660, s= =3D0x555556dbcfb0) at /home/mdroth/w/qemu.git/hw/block/virtio-blk.c:255 #5 0x00005555558d3eca in virtio_blk_handle_vq (s=3D0x555556dbcfb0, vq=3D= 0x555556dc8660) at /home/mdroth/w/qemu.git/hw/block/virtio-blk.c:776 #6 0x000055555591dd66 in virtio_queue_notify_aio_vq (vq=3Dvq@entry=3D0x5= 55556dc8660) at /home/mdroth/w/qemu.git/hw/virtio/virtio.c:1550 #7 0x000055555591ecef in virtio_queue_notify_aio_vq (vq=3D0x555556dc8660) at /home/mdroth/w/qemu.git/hw/virtio/virtio.c:1546 #8 0x000055555591ecef in virtio_queue_host_notifier_aio_poll (opaque=3D0= x555556dc86c8) at /home/mdroth/w/qemu.git/hw/virtio/virtio.c:2527 #9 0x0000555555d02164 in run_poll_handlers_once (ctx=3Dctx@entry=3D0x555= 55688bfc0, timeout=3Dtimeout@entry=3D0x7fffe65844a8) at /home/mdroth/w/qemu.git/util/aio-posix.c:520 #10 0x0000555555d02d1b in try_poll_mode (timeout=3D0x7fffe65844a8, ctx=3D= 0x55555688bfc0) at /home/mdroth/w/qemu.git/util/aio-posix.c:607 #11 0x0000555555d02d1b in aio_poll (ctx=3Dctx@entry=3D0x55555688bfc0, blo= cking=3Dblocking@entry=3Dtrue) at /home/mdroth/w/qemu.git/util/aio-posix.c:639 #12 0x0000555555d0004d in aio_wait_bh_oneshot (ctx=3D0x55555688bfc0, cb= =3Dcb@entry=3D0x5555558d5130 , opaque=3Dopaq= ue@entry=3D0x555556de86f0) at /home/mdroth/w/qemu.git/util/aio-wait.c:71 #13 0x00005555558d59bf in virtio_blk_data_plane_stop (vdev=3D) at /home/mdroth/w/qemu.git/hw/block/dataplane/virtio-blk.c:288 #14 0x0000555555b906a1 in virtio_bus_stop_ioeventfd (bus=3Dbus@entry=3D0x= 555556dbcf38) at /home/mdroth/w/qemu.git/hw/virtio/virtio-bus.c:245 #15 0x0000555555b90dbb in virtio_bus_stop_ioeventfd (bus=3Dbus@entry=3D0x= 555556dbcf38) at /home/mdroth/w/qemu.git/hw/virtio/virtio-bus.c:237 #16 0x0000555555b92a8e in virtio_pci_stop_ioeventfd (proxy=3D0x555556db4e= 40) at /home/mdroth/w/qemu.git/hw/virtio/virtio-pci.c:292 #17 0x0000555555b92a8e in virtio_write_config (pci_dev=3D0x555556db4e40, = address=3D, val=3D1048832, len=3D) at /home/mdroth/w/qemu.git/hw/virtio/virtio-pci.c:613 I.e. the calling code is only scheduling a one-shot BH for virtio_blk_data_plane_stop_bh, but somehow we end up trying to process an additional virtqueue entry before we get there. This is likely due to the following check in virtio_queue_host_notifier_aio_poll: static bool virtio_queue_host_notifier_aio_poll(void *opaque) { EventNotifier *n =3D opaque; VirtQueue *vq =3D container_of(n, VirtQueue, host_notifier); bool progress; if (!vq->vring.desc || virtio_queue_empty(vq)) { return false; } progress =3D virtio_queue_notify_aio_vq(vq); namely the call to virtio_queue_empty(). In this case, since no new requests have actually been issued, shadow_avail_idx =3D=3D last_avail_idx, so we actually try to access the vring via vring_avail_idx() to get the latest non-shadowed idx: int virtio_queue_empty(VirtQueue *vq) { bool empty; ... if (vq->shadow_avail_idx !=3D vq->last_avail_idx) { return 0; } rcu_read_lock(); empty =3D vring_avail_idx(vq) =3D=3D vq->last_avail_idx; rcu_read_unlock(); return empty; but since the IOMMU region has been disabled we get a bogus value (0 usually), which causes virtio_queue_empty() to falsely report that there are entries to be processed, which causes errors such as: "virtio: zero sized buffers are not allowed" or "virtio-blk missing headers" and puts the device in an error state. This patch works around the issue by introducing virtio_set_disabled(), which sets a 'disabled' flag to bypass checks like virtio_queue_empty() when bus-mastering is disabled. Since we'd check this flag at all the same sites as vdev->broken, we replace those checks with an inline function which checks for either vdev->broken or vdev->disabled. The 'disabled' flag is only migrated when set, which should be fairly rare, but to maintain migration compatibility we disable it's use for older machine types. Users requiring the use of the flag in conjunction with older machine types can set it explicitly as a virtio-device option. NOTES: - This leaves some other oddities in play, like the fact that DRIVER_OK also gets unset in response to bus-mastering being disabled, but not restored (however the device seems to continue working) - Similarly, we disable the host notifier via virtio_bus_stop_ioeventfd(), which seems to move the handling out of virtio-blk dataplane and back into the main IO thread, and it ends up staying there till a reset (but otherwise continues working normally) Cc: David Gibson , Cc: Alexey Kardashevskiy Cc: "Michael S. Tsirkin" Signed-off-by: Michael Roth Message-Id: <20191120005003.27035-1-mdroth@linux.vnet.ibm.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 15 +++++++++++++++ hw/core/machine.c | 1 + hw/virtio/virtio-pci.c | 12 ++++++++---- hw/virtio/virtio.c | 35 ++++++++++++++++++++++++++++------- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index e18756d50d..777772475c 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -100,6 +100,8 @@ struct VirtIODevice uint16_t device_id; bool vm_running; bool broken; /* device in invalid state, needs reset */ + bool use_disabled_flag; /* allow use of 'disable' flag when needed */ + bool disabled; /* device in temporarily disabled state */ bool use_started; bool started; bool start_on_kick; /* when virtio 1.0 feature has not been negotiated= */ @@ -380,4 +382,17 @@ static inline void virtio_set_started(VirtIODevice *vd= ev, bool started) vdev->started =3D started; } } + +static inline void virtio_set_disabled(VirtIODevice *vdev, bool disable) +{ + if (vdev->use_disabled_flag) { + vdev->disabled =3D disable; + } +} + +static inline bool virtio_device_disabled(VirtIODevice *vdev) +{ + return unlikely(vdev->disabled || vdev->broken); +} + #endif diff --git a/hw/core/machine.c b/hw/core/machine.c index 1689ad3bf8..9f3073b23b 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -29,6 +29,7 @@ =20 GlobalProperty hw_compat_4_1[] =3D { { "virtio-pci", "x-pcie-flr-init", "off" }, + { "virtio-device", "use-disabled-flag", "false" }, }; const size_t hw_compat_4_1_len =3D G_N_ELEMENTS(hw_compat_4_1); =20 diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index e5c759e19e..f723b9f631 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -608,10 +608,14 @@ static void virtio_write_config(PCIDevice *pci_dev, u= int32_t address, pcie_cap_flr_write_config(pci_dev, address, val, len); } =20 - if (range_covers_byte(address, len, PCI_COMMAND) && - !(pci_dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { - virtio_pci_stop_ioeventfd(proxy); - virtio_set_status(vdev, vdev->status & ~VIRTIO_CONFIG_S_DRIVER_OK); + if (range_covers_byte(address, len, PCI_COMMAND)) { + if (!(pci_dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { + virtio_set_disabled(vdev, true); + virtio_pci_stop_ioeventfd(proxy); + virtio_set_status(vdev, vdev->status & ~VIRTIO_CONFIG_S_DRIVER= _OK); + } else { + virtio_set_disabled(vdev, false); + } } =20 if (proxy->config_cap && diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 6de3cfdc2c..7bc6a9455e 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -546,7 +546,7 @@ static inline bool is_desc_avail(uint16_t flags, bool w= rap_counter) * Called within rcu_read_lock(). */ static int virtio_queue_empty_rcu(VirtQueue *vq) { - if (unlikely(vq->vdev->broken)) { + if (virtio_device_disabled(vq->vdev)) { return 1; } =20 @@ -565,7 +565,7 @@ static int virtio_queue_split_empty(VirtQueue *vq) { bool empty; =20 - if (unlikely(vq->vdev->broken)) { + if (virtio_device_disabled(vq->vdev)) { return 1; } =20 @@ -783,7 +783,7 @@ void virtqueue_fill(VirtQueue *vq, const VirtQueueEleme= nt *elem, =20 virtqueue_unmap_sg(vq, elem, len); =20 - if (unlikely(vq->vdev->broken)) { + if (virtio_device_disabled(vq->vdev)) { return; } =20 @@ -839,7 +839,7 @@ static void virtqueue_packed_flush(VirtQueue *vq, unsig= ned int count) =20 void virtqueue_flush(VirtQueue *vq, unsigned int count) { - if (unlikely(vq->vdev->broken)) { + if (virtio_device_disabled(vq->vdev)) { vq->inuse -=3D count; return; } @@ -1602,7 +1602,7 @@ err_undo_map: =20 void *virtqueue_pop(VirtQueue *vq, size_t sz) { - if (unlikely(vq->vdev->broken)) { + if (virtio_device_disabled(vq->vdev)) { return NULL; } =20 @@ -1698,7 +1698,7 @@ unsigned int virtqueue_drop_all(VirtQueue *vq) { struct VirtIODevice *vdev =3D vq->vdev; =20 - if (unlikely(vdev->broken)) { + if (virtio_device_disabled(vq->vdev)) { return 0; } =20 @@ -1816,7 +1816,7 @@ static void virtio_notify_vector(VirtIODevice *vdev, = uint16_t vector) BusState *qbus =3D qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); =20 - if (unlikely(vdev->broken)) { + if (virtio_device_disabled(vdev)) { return; } =20 @@ -1920,6 +1920,7 @@ void virtio_reset(void *opaque) vdev->guest_features =3D 0; vdev->queue_sel =3D 0; vdev->status =3D 0; + vdev->disabled =3D false; atomic_set(&vdev->isr, 0); vdev->config_vector =3D VIRTIO_NO_VECTOR; virtio_notify_vector(vdev, vdev->config_vector); @@ -2559,6 +2560,13 @@ static bool virtio_started_needed(void *opaque) return vdev->started; } =20 +static bool virtio_disabled_needed(void *opaque) +{ + VirtIODevice *vdev =3D opaque; + + return vdev->disabled; +} + static const VMStateDescription vmstate_virtqueue =3D { .name =3D "virtqueue_state", .version_id =3D 1, @@ -2724,6 +2732,17 @@ static const VMStateDescription vmstate_virtio_start= ed =3D { } }; =20 +static const VMStateDescription vmstate_virtio_disabled =3D { + .name =3D "virtio/disabled", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D &virtio_disabled_needed, + .fields =3D (VMStateField[]) { + VMSTATE_BOOL(disabled, VirtIODevice), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_virtio =3D { .name =3D "virtio", .version_id =3D 1, @@ -2741,6 +2760,7 @@ static const VMStateDescription vmstate_virtio =3D { &vmstate_virtio_extra_state, &vmstate_virtio_started, &vmstate_virtio_packed_virtqueues, + &vmstate_virtio_disabled, NULL } }; @@ -3575,6 +3595,7 @@ static void virtio_device_instance_finalize(Object *o= bj) static Property virtio_properties[] =3D { DEFINE_VIRTIO_COMMON_FEATURES(VirtIODevice, host_features), DEFINE_PROP_BOOL("use-started", VirtIODevice, use_started, true), + DEFINE_PROP_BOOL("use-disabled-flag", VirtIODevice, use_disabled_flag,= true), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; 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=1576762351; cv=none; d=zohomail.com; s=zohoarc; b=dhyMXOXAfXKUUKdhxN/0VF4an+F3oGsfzVR+B2/RihhYMi+r4k9u1wOaakkMqLyoLKDsZxECVbrtVnjOgop9VhFsomgf8iUrTNAaV0RopwOIRP+C2Kr3/pIrjXFxx2NbjrwE6vdekGZAUhgO1XSe0CZU4bMzAK6fVMMG/sHMMoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762351; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2mjtemMUgB27JpLi8+N3bxzl1+0IVjBnBvvjPKdiAjc=; b=NQUpukZMrhcSHr9KbFQUiLMh529JPUnC5ku0zqfD+cKUQawZdHmYf659EdZPDc+XBwNDbxzKMRUr9lOfZQpK8OlyBaXKuZc/9TrezhHPpXn/033SR0SAxjk8XkWW9GQGo7JWnCT7/kqpuWqkMBrBHdrmSpSeEGT7PD7vVzpGYGo= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762351309407.44758794306733; Thu, 19 Dec 2019 05:32:31 -0800 (PST) Received: from localhost ([::1]:41550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvun-0006a2-Dp for importer@patchew.org; Thu, 19 Dec 2019 08:32:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52602) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvqG-0001QN-Oi for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvqF-0004Gm-4M for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:48 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:43031 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvqE-0004DT-Rb for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:46 -0500 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-14-lHAdNdruMTibRYx5tV3_jw-1; Thu, 19 Dec 2019 08:27:43 -0500 Received: by mail-qt1-f197.google.com with SMTP id l1so3631714qtp.21 for ; Thu, 19 Dec 2019 05:27:43 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id c184sm1730787qke.118.2019.12.19.05.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:27:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762066; h=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=2mjtemMUgB27JpLi8+N3bxzl1+0IVjBnBvvjPKdiAjc=; b=J18V1ZbhElYfnFo0KE+hsDrLmHvqtW+oVX6irCHw27Bf0CLz47KsC0qVhpoM/TAGjM67pJ 4bcTs/uxV47sKY8gUNIDBq+HoqGnrNRFJWc9/EUVJPx/vTYcJ2EdhiVWXHL1Vzqm3jChOC 0yyGuenpATRncurGraYjl3Z2yj7diC4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=P6B2QZEV+S1MRINFAeh/u30RoNzW+dHtR0xLU33u1wE=; b=OZMCx81c1I5iAefoiybaBa61bhEDG9XnPU5zWUkzegAte4viWrHazukH4bXKRWineV /MuovJZNpR8FsrQw47x/c6hTuVyV9y+7XPC+a/E6oMnI42tA86ls/wdlJxqbKsn+Jg78 gherBdRfnySz9ZAgCPnRtjsRHDy9lA5u7JMu3Sl546YIsrcX+zmmnzLnpsHwALzUXntS JurU+AcDkQXRQGgyV4NwsfIR76J3/AHTRVMwrrSvBO515RfYBj0DrzuHtWJSbTwMm6ku rS8jwK+2cc+au1S7E6XJIozHeYm0XcaPrfYA9rnR8tNySni/XWqwym36GFo5d/um0zuu lh4w== X-Gm-Message-State: APjAAAUcmw1Cyj/dLg+Mc6nhFf05d9DO/O+qE/N+yG6TI4rJjPkmIdf6 F3IcOXDbZV0RgnsVi4rbPygShAwIvQQS3AMZ1513t2OutpFazIppX7BYw76b8a2Pjr4Y5PkjlIO o89UgBvr+HaiOnHM= X-Received: by 2002:ac8:100d:: with SMTP id z13mr6785316qti.1.1576762062743; Thu, 19 Dec 2019 05:27:42 -0800 (PST) X-Google-Smtp-Source: APXvYqx6cSSJRmwk8DVhMu2bf4hetXa7O5LI0cZZgZDioCSzStNsdMG5Yy7UKVs6VFHTMtFJM4NA/g== X-Received: by 2002:ac8:100d:: with SMTP id z13mr6785290qti.1.1576762062438; Thu, 19 Dec 2019 05:27:42 -0800 (PST) Date: Thu, 19 Dec 2019 08:27:38 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 09/24] Implement backend program convention command for vhost-user-blk Message-ID: <20191219132621.16595-10-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: lHAdNdruMTibRYx5tV3_jw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Micky Yun Chan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Micky Yun Chan This patch is to add standard commands defined in docs/interop/vhost-user.r= st For vhost-user-* program Signed-off-by: Micky Yun Chan (michiboo) Message-Id: <20191209015331.5455-1-chanmickyyun@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/interop/vhost-user.json | 31 +++++++ contrib/vhost-user-blk/vhost-user-blk.c | 108 ++++++++++++++---------- docs/interop/vhost-user.rst | 17 ++++ 3 files changed, 112 insertions(+), 44 deletions(-) diff --git a/docs/interop/vhost-user.json b/docs/interop/vhost-user.json index da6aaf51c8..ce0ef74db5 100644 --- a/docs/interop/vhost-user.json +++ b/docs/interop/vhost-user.json @@ -54,6 +54,37 @@ ] } =20 +## +# @VHostUserBackendBlockFeature: +# +# List of vhost user "block" features. +# +# @read-only: The --read-only command line option is supported. +# @blk-file: The --blk-file command line option is supported. +# +# Since: 5.0 +## +{ + 'enum': 'VHostUserBackendBlockFeature', + 'data': [ 'read-only', 'blk-file' ] +} + +## +# @VHostUserBackendCapabilitiesBlock: +# +# Capabilities reported by vhost user "block" backends +# +# @features: list of supported features. +# +# Since: 5.0 +## +{ + 'struct': 'VHostUserBackendCapabilitiesBlock', + 'data': { + 'features': [ 'VHostUserBackendBlockFeature' ] + } +} + ## # @VHostUserBackendInputFeature: # diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-b= lk/vhost-user-blk.c index ae61034656..6fd91c7e99 100644 --- a/contrib/vhost-user-blk/vhost-user-blk.c +++ b/contrib/vhost-user-blk/vhost-user-blk.c @@ -576,70 +576,90 @@ vub_new(char *blk_file) return vdev_blk; } =20 +static int opt_fdnum =3D -1; +static char *opt_socket_path; +static char *opt_blk_file; +static gboolean opt_print_caps; +static gboolean opt_read_only; + +static GOptionEntry entries[] =3D { + { "print-capabilities", 'c', 0, G_OPTION_ARG_NONE, &opt_print_caps, + "Print capabilities", NULL }, + { "fd", 'f', 0, G_OPTION_ARG_INT, &opt_fdnum, + "Use inherited fd socket", "FDNUM" }, + { "socket-path", 's', 0, G_OPTION_ARG_FILENAME, &opt_socket_path, + "Use UNIX socket path", "PATH" }, + {"blk-file", 'b', 0, G_OPTION_ARG_FILENAME, &opt_blk_file, + "block device or file path", "PATH"}, + { "read-only", 'r', 0, G_OPTION_ARG_NONE, &opt_read_only, + "Enable read-only", NULL } +}; + int main(int argc, char **argv) { - int opt; - char *unix_socket =3D NULL; - char *blk_file =3D NULL; - bool enable_ro =3D false; int lsock =3D -1, csock =3D -1; VubDev *vdev_blk =3D NULL; + GError *error =3D NULL; + GOptionContext *context; =20 - while ((opt =3D getopt(argc, argv, "b:rs:h")) !=3D -1) { - switch (opt) { - case 'b': - blk_file =3D g_strdup(optarg); - break; - case 's': - unix_socket =3D g_strdup(optarg); - break; - case 'r': - enable_ro =3D true; - break; - case 'h': - default: - printf("Usage: %s [ -b block device or file, -s UNIX domain so= cket" - " | -r Enable read-only ] | [ -h ]\n", argv[0]); - return 0; + context =3D g_option_context_new(NULL); + g_option_context_add_main_entries(context, entries, NULL); + if (!g_option_context_parse(context, &argc, &argv, &error)) { + g_printerr("Option parsing failed: %s\n", error->message); + exit(EXIT_FAILURE); + } + if (opt_print_caps) { + g_print("{\n"); + g_print(" \"type\": \"block\",\n"); + g_print(" \"features\": [\n"); + g_print(" \"read-only\",\n"); + g_print(" \"blk-file\"\n"); + g_print(" ]\n"); + g_print("}\n"); + exit(EXIT_SUCCESS); + } + + if (!opt_blk_file) { + g_print("%s\n", g_option_context_get_help(context, true, NULL)); + exit(EXIT_FAILURE); + } + + if (opt_socket_path) { + lsock =3D unix_sock_new(opt_socket_path); + if (lsock < 0) { + exit(EXIT_FAILURE); } + } else if (opt_fdnum < 0) { + g_print("%s\n", g_option_context_get_help(context, true, NULL)); + exit(EXIT_FAILURE); + } else { + lsock =3D opt_fdnum; } =20 - if (!unix_socket || !blk_file) { - printf("Usage: %s [ -b block device or file, -s UNIX domain socket" - " | -r Enable read-only ] | [ -h ]\n", argv[0]); - return -1; - } - - lsock =3D unix_sock_new(unix_socket); - if (lsock < 0) { - goto err; - } - - csock =3D accept(lsock, (void *)0, (void *)0); + csock =3D accept(lsock, NULL, NULL); if (csock < 0) { - fprintf(stderr, "Accept error %s\n", strerror(errno)); - goto err; + g_printerr("Accept error %s\n", strerror(errno)); + exit(EXIT_FAILURE); } =20 - vdev_blk =3D vub_new(blk_file); + vdev_blk =3D vub_new(opt_blk_file); if (!vdev_blk) { - goto err; + exit(EXIT_FAILURE); } - if (enable_ro) { + if (opt_read_only) { vdev_blk->enable_ro =3D true; } =20 if (!vug_init(&vdev_blk->parent, VHOST_USER_BLK_MAX_QUEUES, csock, vub_panic_cb, &vub_iface)) { - fprintf(stderr, "Failed to initialized libvhost-user-glib\n"); - goto err; + g_printerr("Failed to initialize libvhost-user-glib\n"); + exit(EXIT_FAILURE); } =20 g_main_loop_run(vdev_blk->loop); - + g_main_loop_unref(vdev_blk->loop); + g_option_context_free(context); vug_deinit(&vdev_blk->parent); - -err: vub_free(vdev_blk); if (csock >=3D 0) { close(csock); @@ -647,8 +667,8 @@ err: if (lsock >=3D 0) { close(lsock); } - g_free(unix_socket); - g_free(blk_file); + g_free(opt_socket_path); + g_free(opt_blk_file); =20 return 0; } diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 7827b710aa..015ac08177 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -1376,3 +1376,20 @@ Command line options: Enable virgl rendering support. =20 (optional) + +vhost-user-blk +-------------- + +Command line options: + +--blk-file=3DPATH + + Specify block device or file path. + + (optional) + +--read-only + + Enable read-only. + + (optional) --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762535; cv=none; d=zohomail.com; s=zohoarc; b=HZ5rzxTXUAGUIvSlHIuftAD+ipeywT8FUeZj8s0NjVbtLTUZ70hWuHPrxw3k5xh89XE1DjuDd+UF0vrWk5L9BRX4AunodnwMlQSN63bt1abGftTKmekjMZv4btWtpOF9l9KAcd46O3vn6SbbL17NrkfvAA+4EvyNOrd1UkPnQuY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762535; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lKKnmIlMXAiHs2ciw2UuZ4upMkVLi7gPIVS0NfnoTbA=; b=gFTlLR7mRX1vgGBgDQK9iFaY7cjh29z1b/rjjzixzGK/ObHHQ/t/Vto6E29RvvQnArWdBwVj+q2KBtSJ/j++X/zA+oW6zQWHAQW8akpYfLMhs8pSCvDiloaupfccxADm1BeK9Gotb6WFvrZxLek8LEvZlkHShxBtyrw4zyo2sqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762535888203.53186453664182; Thu, 19 Dec 2019 05:35:35 -0800 (PST) Received: from localhost ([::1]:41598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvxm-0002rA-8t for importer@patchew.org; Thu, 19 Dec 2019 08:35:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53128) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvqL-0001XQ-2c for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvqJ-0004gB-GF for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:52 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44020 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvqJ-0004da-Bj for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:27:51 -0500 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-277-UCoA-7y-NvmSnfIY6KMszA-1; Thu, 19 Dec 2019 08:27:49 -0500 Received: by mail-qk1-f200.google.com with SMTP id 11so1358671qkk.11 for ; Thu, 19 Dec 2019 05:27:49 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id 200sm1732921qkn.79.2019.12.19.05.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:27:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762070; h=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=lKKnmIlMXAiHs2ciw2UuZ4upMkVLi7gPIVS0NfnoTbA=; b=F6IkgA4uE/kKQcmbFa+71bgDiQWAyANR5VamGwP9yygaL1FS7gme3N+IrnQndwKna6WPpW Cqgf5L+5puxkhEiOgHwInWiUPLhRK8wklqnu6lMslt0mU69Rrpxs6Ofc+cONQ3tVCTluev mQkBiFKU1eiHKMaKURMsaKBMrn97rso= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=5GbppUzD6Fm8YJOtPEK4xw/kFiMIjjx9zvi6lU+LCW4=; b=QyMJCEaaX3E/7FIK9JF1aCCuoXRkyUk/0cpAx7NEYsp7NwQkmSPvsKV1uXSmGjRDTJ Zh8iFUR9aYIjt5kv0cScJCfBjM7zRRLSiU5DpZPGsjEYeyjMPbwVCBEyo7tdsM+UTHUU 3UppOBEOT7Ti/dM8BWgKvsSbHnxPWsdgzh2r/DG5rEdhI+N4lMX/tSV8DDxVV647x71F O0YcHoQ68fMJwwkoz9QzwQbuilVCYaZncnZyuxO6IK/m/i4ttfH9nWQH4bejWpGHm5Os SpuXzo/c6uAeZ7o04VhjpOemhBnTTZF6DRGINpd1JRiuuWVHN8PIRREsH9HucPi3Gs3C J2eA== X-Gm-Message-State: APjAAAVpU0Sv5lWnaUZCqTtWh7nXOqdQf5dJ3AteIiNty5nN1NmliWam vDYm8PMtI1qHx9li41V+A7x8mPlU3EftyL6sv/fTNUchuG7visBo8DjkinAPHOsYIWMZKmMAsTs tMEeAb9+EveDo64I= X-Received: by 2002:a37:7cc7:: with SMTP id x190mr8061380qkc.10.1576762068728; Thu, 19 Dec 2019 05:27:48 -0800 (PST) X-Google-Smtp-Source: APXvYqyl+ePPzdRdfeYDPONNpTljMD15lgAxbD+kaz3E0DXkyaEzvJAVkye7+vT1khgdrcYRT8/2/g== X-Received: by 2002:a37:7cc7:: with SMTP id x190mr8061349qkc.10.1576762068465; Thu, 19 Dec 2019 05:27:48 -0800 (PST) Date: Thu, 19 Dec 2019 08:27:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 10/24] virtio: don't enable notifications during polling Message-ID: <20191219132621.16595-11-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: UCoA-7y-NvmSnfIY6KMszA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , Paolo Bonzini , Fam Zheng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Virtqueue notifications are not necessary during polling, so we disable them. This allows the guest driver to avoid MMIO vmexits. Unfortunately the virtio-blk and virtio-scsi handler functions re-enable notifications, defeating this optimization. Fix virtio-blk and virtio-scsi emulation so they leave notifications disabled. The key thing to remember for correctness is that polling always checks one last time after ending its loop, therefore it's safe to lose the race when re-enabling notifications at the end of polling. There is a measurable performance improvement of 5-10% with the null-co block driver. Real-life storage configurations will see a smaller improvement because the MMIO vmexit overhead contributes less to latency. Signed-off-by: Stefan Hajnoczi Message-Id: <20191209210957.65087-1-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 1 + hw/block/virtio-blk.c | 9 +++++++-- hw/scsi/virtio-scsi.c | 9 +++++++-- hw/virtio/virtio.c | 12 ++++++------ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 777772475c..b69d517496 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -228,6 +228,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int ve= rsion_id); =20 void virtio_notify_config(VirtIODevice *vdev); =20 +bool virtio_queue_get_notification(VirtQueue *vq); void virtio_queue_set_notification(VirtQueue *vq, int enable); =20 int virtio_queue_ready(VirtQueue *vq); diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 4c357d2928..c4e55fb3de 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -764,13 +764,16 @@ bool virtio_blk_handle_vq(VirtIOBlock *s, VirtQueue *= vq) { VirtIOBlockReq *req; MultiReqBuffer mrb =3D {}; + bool suppress_notifications =3D virtio_queue_get_notification(vq); bool progress =3D false; =20 aio_context_acquire(blk_get_aio_context(s->blk)); blk_io_plug(s->blk); =20 do { - virtio_queue_set_notification(vq, 0); + if (suppress_notifications) { + virtio_queue_set_notification(vq, 0); + } =20 while ((req =3D virtio_blk_get_request(s, vq))) { progress =3D true; @@ -781,7 +784,9 @@ bool virtio_blk_handle_vq(VirtIOBlock *s, VirtQueue *vq) } } =20 - virtio_queue_set_notification(vq, 1); + if (suppress_notifications) { + virtio_queue_set_notification(vq, 1); + } } while (!virtio_queue_empty(vq)); =20 if (mrb.num_reqs) { diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index e8b2b64d09..f080545f48 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -597,12 +597,15 @@ bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQue= ue *vq) { VirtIOSCSIReq *req, *next; int ret =3D 0; + bool suppress_notifications =3D virtio_queue_get_notification(vq); bool progress =3D false; =20 QTAILQ_HEAD(, VirtIOSCSIReq) reqs =3D QTAILQ_HEAD_INITIALIZER(reqs); =20 do { - virtio_queue_set_notification(vq, 0); + if (suppress_notifications) { + virtio_queue_set_notification(vq, 0); + } =20 while ((req =3D virtio_scsi_pop_req(s, vq))) { progress =3D true; @@ -622,7 +625,9 @@ bool virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue= *vq) } } =20 - virtio_queue_set_notification(vq, 1); + if (suppress_notifications) { + virtio_queue_set_notification(vq, 1); + } } while (ret !=3D -EINVAL && !virtio_queue_empty(vq)); =20 QTAILQ_FOREACH_SAFE(req, &reqs, next, next) { diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 7bc6a9455e..95d8ff8508 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -432,6 +432,11 @@ static void virtio_queue_packed_set_notification(VirtQ= ueue *vq, int enable) } } =20 +bool virtio_queue_get_notification(VirtQueue *vq) +{ + return vq->notification; +} + void virtio_queue_set_notification(VirtQueue *vq, int enable) { vq->notification =3D enable; @@ -3410,17 +3415,12 @@ static bool virtio_queue_host_notifier_aio_poll(voi= d *opaque) { EventNotifier *n =3D opaque; VirtQueue *vq =3D container_of(n, VirtQueue, host_notifier); - bool progress; =20 if (!vq->vring.desc || virtio_queue_empty(vq)) { return false; } =20 - progress =3D virtio_queue_notify_aio_vq(vq); - - /* In case the handler function re-enabled notifications */ - virtio_queue_set_notification(vq, 0); - return progress; + return virtio_queue_notify_aio_vq(vq); } =20 static void virtio_queue_host_notifier_aio_poll_end(EventNotifier *n) --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576763162; cv=none; d=zohomail.com; s=zohoarc; b=AwDY8vkhfRS9DTlNebEaG7N26PMdUUUB2VEZT9RG1g8/lwq8BVzjhsKnmKa2OniuNPJAgB7XuL0LPE9o7DJHGzg2CFuZ1fN7A/l94BrJCC9iCnjx3achU03gF5o4Uu2A9Ck7ds9b/VP5hF3gxPJSzJe7lG3i4Um1Mm/Qq/IjORQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576763162; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dKchKYl705eOKAdStDEG/DJxGozyOewX+87Jiu8vhOE=; b=dFIBdMD6Ge0aLL8zExl8G8JnRxdZaeyLnAPU7RsrNrPNoWN3P0/0cLRvDyrG5ZZMAi211/jj8ODEehSbhMi/1d4TpL26kVf+NaleZIo0NIy+4AcakEO8q0koqxc+y7BRh/zv0tVTjCtNm8zr5AmDmE8051t38zVGf/q43TwWR8M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576763162975353.52297688055535; Thu, 19 Dec 2019 05:46:02 -0800 (PST) Received: from localhost ([::1]:41780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihw7t-0000TB-3V for importer@patchew.org; Thu, 19 Dec 2019 08:46:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42935) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvtR-00060i-Ju for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:31:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvtP-0002CV-3U for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:31:05 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:44084 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvtO-00028f-KY for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:31:02 -0500 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-16-atjigJSnNp26IEic1Ig1wA-1; Thu, 19 Dec 2019 08:27:55 -0500 Received: by mail-qk1-f198.google.com with SMTP id n128so3601751qke.19 for ; Thu, 19 Dec 2019 05:27:55 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id d23sm1921711qte.32.2019.12.19.05.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:27:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762262; h=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=dKchKYl705eOKAdStDEG/DJxGozyOewX+87Jiu8vhOE=; b=EJUZk6VbMi/AM3cCJCiN34yESk5WLnOBuMfamFe5M5vnlkLTjwPn/PxTdVyUel6BjWGg2P W641XBO7jDqSXS+j7urggzwYGYAzp9+BE69FoHeXHS0OtRWVwRusVHM6De+yfNUevtWieD sSIafdVW0TgQCK1jGmhGDyGOmSgS0TM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=StiyRjOCa+/LSXZdI0ohjjf7ldwT+oHbzEpi5cjGfPo=; b=pRQ8Eacp4CUxD/7oYjq676w0UeUvlXdt7i+/tDnlxxcHMohZmSAb2m3l/cFOp9lsem JvyQjguY6LA61omiDe3+34SHbc6pHNrDYmZe5ZVdNugi+N7NraoQYXlz3mAviQHLQadz OSS2eHAMh7bntea0YbkJZgevgRKoAgrLzYCnf+z7W9/Ck7f7jj43bBp2tHkunV4GkFJz xu4ccM/LwlGqeHV0of35Ej1NfM6NvdgP+w+LUXhAuprdqaa6OyLCU+teAejbYwjzWbJY ABvErrH+auyr9bOspTMYh5aNkSGXpyq57vRMTDRbvu5eJqWOQympMP3DA0zNMRY0dV5k Iyrg== X-Gm-Message-State: APjAAAXsQfhjt0xee4Z/ZtzvcKAwPfRuQMbMXsYMu6K1thBQSDeGRfqH B80q9QoSDvbTSdNZUpA2h9CVdRL22cYKLTftrjKNEMtNWy9gLVFwjilZJ2t0CnCJb4NPrEWDkwi qTTFJQA+8W9vwPRw= X-Received: by 2002:ac8:7b9b:: with SMTP id p27mr7068528qtu.2.1576762074965; Thu, 19 Dec 2019 05:27:54 -0800 (PST) X-Google-Smtp-Source: APXvYqzulW7WgBBtIsFrHK9/sjoDj5/+cxL/GNNKDQOj9+tuvyQsjcPP7K3OaOwfXjOUt2hzlbXkfA== X-Received: by 2002:ac8:7b9b:: with SMTP id p27mr7068505qtu.2.1576762074572; Thu, 19 Dec 2019 05:27:54 -0800 (PST) Date: Thu, 19 Dec 2019 08:27:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 11/24] numa: Extend CLI to provide initiator information for numa nodes Message-ID: <20191219132621.16595-12-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: atjigJSnNp26IEic1Ig1wA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Jingqi Liu , Tao Xu , Markus Armbruster , Igor Mammedov , Dan Williams Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tao Xu In ACPI 6.3 chapter 5.2.27 Heterogeneous Memory Attribute Table (HMAT), The initiator represents processor which access to memory. And in 5.2.27.3 Memory Proximity Domain Attributes Structure, the attached initiator is defined as where the memory controller responsible for a memory proximity domain. With attached initiator information, the topology of heterogeneous memory can be described. Add new machine property 'hmat' to enable all HMAT specific options. Extend CLI of "-numa node" option to indicate the initiator numa node-id. In the linux kernel, the codes in drivers/acpi/hmat/hmat.c parse and report the platform's HMAT tables. Before using initiator option, enable HMAT with -machine hmat=3Don. Acked-by: Markus Armbruster Reviewed-by: Igor Mammedov Reviewed-by: Jingqi Liu Suggested-by: Dan Williams Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-2-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/machine.json | 10 ++++++- include/sysemu/numa.h | 5 ++++ hw/core/machine.c | 64 +++++++++++++++++++++++++++++++++++++++++++ hw/core/numa.c | 23 ++++++++++++++++ qemu-options.hx | 35 +++++++++++++++++++---- 5 files changed, 131 insertions(+), 6 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index ca26779f1a..27d0e37534 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -463,6 +463,13 @@ # @memdev: memory backend object. If specified for one node, # it must be specified for all nodes. # +# @initiator: defined in ACPI 6.3 Chapter 5.2.27.3 Table 5-145, +# points to the nodeid which has the memory controller +# responsible for this NUMA node. This field provides +# additional information as to the initiator node that +# is closest (as in directly attached) to this node, and +# therefore has the best performance (since 5.0) +# # Since: 2.1 ## { 'struct': 'NumaNodeOptions', @@ -470,7 +477,8 @@ '*nodeid': 'uint16', '*cpus': ['uint16'], '*mem': 'size', - '*memdev': 'str' }} + '*memdev': 'str', + '*initiator': 'uint16' }} =20 ## # @NumaDistOptions: diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index ae9c41d02b..788cbec7a2 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -18,6 +18,8 @@ struct NodeInfo { uint64_t node_mem; struct HostMemoryBackend *node_memdev; bool present; + bool has_cpu; + uint16_t initiator; uint8_t distance[MAX_NODES]; }; =20 @@ -33,6 +35,9 @@ struct NumaState { /* Allow setting NUMA distance for different NUMA nodes */ bool have_numa_distance; =20 + /* Detect if HMAT support is enabled. */ + bool hmat_enabled; + /* NUMA nodes information */ NodeInfo nodes[MAX_NODES]; }; diff --git a/hw/core/machine.c b/hw/core/machine.c index 9f3073b23b..166c8c6134 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -519,6 +519,20 @@ static void machine_set_nvdimm(Object *obj, bool value= , Error **errp) ms->nvdimms_state->is_enabled =3D value; } =20 +static bool machine_get_hmat(Object *obj, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + return ms->numa_state->hmat_enabled; +} + +static void machine_set_hmat(Object *obj, bool value, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + ms->numa_state->hmat_enabled =3D value; +} + static char *machine_get_nvdimm_persistence(Object *obj, Error **errp) { MachineState *ms =3D MACHINE(obj); @@ -646,6 +660,7 @@ void machine_set_cpu_numa_node(MachineState *machine, const CpuInstanceProperties *props, Error *= *errp) { MachineClass *mc =3D MACHINE_GET_CLASS(machine); + NodeInfo *numa_info =3D machine->numa_state->nodes; bool match =3D false; int i; =20 @@ -715,6 +730,17 @@ void machine_set_cpu_numa_node(MachineState *machine, match =3D true; slot->props.node_id =3D props->node_id; slot->props.has_node_id =3D props->has_node_id; + + if (machine->numa_state->hmat_enabled) { + if ((numa_info[props->node_id].initiator < MAX_NODES) && + (props->node_id !=3D numa_info[props->node_id].initiator))= { + error_setg(errp, "The initiator of CPU NUMA node %" PRId64 + " should be itself", props->node_id); + return; + } + numa_info[props->node_id].has_cpu =3D true; + numa_info[props->node_id].initiator =3D props->node_id; + } } =20 if (!match) { @@ -961,6 +987,13 @@ static void machine_initfn(Object *obj) =20 if (mc->numa_mem_supported) { ms->numa_state =3D g_new0(NumaState, 1); + object_property_add_bool(obj, "hmat", + machine_get_hmat, machine_set_hmat, + &error_abort); + object_property_set_description(obj, "hmat", + "Set on/off to enable/disable " + "ACPI Heterogeneous Memory Attribu= te " + "Table (HMAT)", NULL); } =20 /* Register notifier when init is done for sysbus sanity checks */ @@ -1049,6 +1082,32 @@ static char *cpu_slot_to_string(const CPUArchId *cpu) return g_string_free(s, false); } =20 +static void numa_validate_initiator(NumaState *numa_state) +{ + int i; + NodeInfo *numa_info =3D numa_state->nodes; + + for (i =3D 0; i < numa_state->num_nodes; i++) { + if (numa_info[i].initiator =3D=3D MAX_NODES) { + error_report("The initiator of NUMA node %d is missing, use " + "'-numa node,initiator' option to declare it", i); + exit(1); + } + + if (!numa_info[numa_info[i].initiator].present) { + error_report("NUMA node %" PRIu16 " is missing, use " + "'-numa node' option to declare it first", + numa_info[i].initiator); + exit(1); + } + + if (!numa_info[numa_info[i].initiator].has_cpu) { + error_report("The initiator of NUMA node %d is invalid", i); + exit(1); + } + } +} + static void machine_numa_finish_cpu_init(MachineState *machine) { int i; @@ -1089,6 +1148,11 @@ static void machine_numa_finish_cpu_init(MachineStat= e *machine) machine_set_cpu_numa_node(machine, &props, &error_fatal); } } + + if (machine->numa_state->hmat_enabled) { + numa_validate_initiator(machine->numa_state); + } + if (s->len && !qtest_enabled()) { warn_report("CPU(s) not present in any NUMA nodes: %s", s->str); diff --git a/hw/core/numa.c b/hw/core/numa.c index e3332a984f..e60da99293 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -133,6 +133,29 @@ static void parse_numa_node(MachineState *ms, NumaNode= Options *node, numa_info[nodenr].node_mem =3D object_property_get_uint(o, "size",= NULL); numa_info[nodenr].node_memdev =3D MEMORY_BACKEND(o); } + + /* + * If not set the initiator, set it to MAX_NODES. And if + * HMAT is enabled and this node has no cpus, QEMU will raise error. + */ + numa_info[nodenr].initiator =3D MAX_NODES; + if (node->has_initiator) { + if (!ms->numa_state->hmat_enabled) { + error_setg(errp, "ACPI Heterogeneous Memory Attribute Table " + "(HMAT) is disabled, enable it with -machine hmat= =3Don " + "before using any of hmat specific options"); + return; + } + + if (node->initiator >=3D MAX_NODES) { + error_report("The initiator id %" PRIu16 " expects an integer " + "between 0 and %d", node->initiator, + MAX_NODES - 1); + return; + } + + numa_info[nodenr].initiator =3D node->initiator; + } numa_info[nodenr].present =3D true; max_numa_nodeid =3D MAX(max_numa_nodeid, nodenr + 1); ms->numa_state->num_nodes++; diff --git a/qemu-options.hx b/qemu-options.hx index 65c9473b73..63f6b33322 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -43,7 +43,8 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " suppress-vmdesc=3Don|off disables self-describing mig= ration (default=3Doff)\n" " nvdimm=3Don|off controls NVDIMM support (default=3Dof= f)\n" " enforce-config-section=3Don|off enforce configuration= section migration (default=3Doff)\n" - " memory-encryption=3D@var{} memory encryption object t= o use (default=3Dnone)\n", + " memory-encryption=3D@var{} memory encryption object t= o use (default=3Dnone)\n" + " hmat=3Don|off controls ACPI HMAT support (default=3Do= ff)\n", QEMU_ARCH_ALL) STEXI @item -machine [type=3D]@var{name}[,prop=3D@var{value}[,...]] @@ -103,6 +104,9 @@ NOTE: this parameter is deprecated. Please use @option{= -global} @option{migration.send-configuration}=3D@var{on|off} instead. @item memory-encryption=3D@var{} Memory encryption object to use. The default is none. +@item hmat=3Don|off +Enables or disables ACPI Heterogeneous Memory Attribute Table (HMAT) suppo= rt. +The default is off. @end table ETEXI =20 @@ -161,14 +165,14 @@ If any on the three values is given, the total number= of CPUs @var{n} can be omi ETEXI =20 DEF("numa", HAS_ARG, QEMU_OPTION_numa, - "-numa node[,mem=3Dsize][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode]\n" - "-numa node[,memdev=3Did][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode]\= n" + "-numa node[,mem=3Dsize][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode][,= initiator=3Dnode]\n" + "-numa node[,memdev=3Did][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode][= ,initiator=3Dnode]\n" "-numa dist,src=3Dsource,dst=3Ddestination,val=3Ddistance\n" "-numa cpu,node-id=3Dnode[,socket-id=3Dx][,core-id=3Dy][,thread-id=3Dz= ]\n", QEMU_ARCH_ALL) STEXI -@item -numa node[,mem=3D@var{size}][,cpus=3D@var{firstcpu}[-@var{lastcpu}]= ][,nodeid=3D@var{node}] -@itemx -numa node[,memdev=3D@var{id}][,cpus=3D@var{firstcpu}[-@var{lastcpu= }]][,nodeid=3D@var{node}] +@item -numa node[,mem=3D@var{size}][,cpus=3D@var{firstcpu}[-@var{lastcpu}]= ][,nodeid=3D@var{node}][,initiator=3D@var{initiator}] +@itemx -numa node[,memdev=3D@var{id}][,cpus=3D@var{firstcpu}[-@var{lastcpu= }]][,nodeid=3D@var{node}][,initiator=3D@var{initiator}] @itemx -numa dist,src=3D@var{source},dst=3D@var{destination},val=3D@var{di= stance} @itemx -numa cpu,node-id=3D@var{node}[,socket-id=3D@var{x}][,core-id=3D@va= r{y}][,thread-id=3D@var{z}] @findex -numa @@ -215,6 +219,27 @@ split equally between them. @samp{mem} and @samp{memdev} are mutually exclusive. Furthermore, if one node uses @samp{memdev}, all of them have to use it. =20 +@samp{initiator} is an additional option that points to an @var{initiator} +NUMA node that has best performance (the lowest latency or largest bandwid= th) +to this NUMA @var{node}. Note that this option can be set only when +the machine property 'hmat' is set to 'on'. + +Following example creates a machine with 2 NUMA nodes, node 0 has CPU. +node 1 has only memory, and its initiator is node 0. Note that because +node 0 has CPU, by default the initiator of node 0 is itself and must be +itself. +@example +-machine hmat=3Don \ +-m 2G,slots=3D2,maxmem=3D4G \ +-object memory-backend-ram,size=3D1G,id=3Dm0 \ +-object memory-backend-ram,size=3D1G,id=3Dm1 \ +-numa node,nodeid=3D0,memdev=3Dm0 \ +-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 \ +-smp 2,sockets=3D2,maxcpus=3D2 \ +-numa cpu,node-id=3D0,socket-id=3D0 \ +-numa cpu,node-id=3D0,socket-id=3D1 +@end example + @var{source} and @var{destination} are NUMA node IDs. @var{distance} is the NUMA distance from @var{source} to @var{destination}. The distance from a node to itself is always 10. If any pair of nodes is --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762533; cv=none; d=zohomail.com; s=zohoarc; b=fbKt/YP3DMMJD7/BwetCPl3+svnnWaak3tGdjCCf+x1gr6ExnEwRdQWkD43ijLx8u2grfgTYxlSV4h3mpfAQind/m6tF4LJ6CEBW/RtPR+C8R+pUH1swiF7zg4sQtCqjjHCEchdQUi8pB9lvbpqXSixylYHPF4JOg+JHkbtwLSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762533; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NltAMrsEv5ke5pAZDfAtw5/nLxY9luxe7WgsDSBXFn4=; b=LYp1hA8C8o4ITWzTCihLvslLkzpdkQJeKzMb6PBYj9AAniEjiukS2Mcl0rG7rKNUXV7//lEIbt3xA4fzHdOuoadxPFAWYCUT6yYQIY+HhKwiJgQENuhSh81R9RZnwQEmnwIqhrST2oGaaUTq377J+enwpUIryy78iX7EahxlOBA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762533211750.8313737975843; Thu, 19 Dec 2019 05:35:33 -0800 (PST) Received: from localhost ([::1]:41596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvxj-0002nN-K6 for importer@patchew.org; Thu, 19 Dec 2019 08:35:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54730) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvqZ-0001v0-PG for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvqW-0005v4-UV for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:07 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:59105 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvqW-0005rU-LA for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:04 -0500 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-106-2_uLCg7xMLW3K-DkVn5JAQ-1; Thu, 19 Dec 2019 08:28:02 -0500 Received: by mail-qk1-f199.google.com with SMTP id u30so3613588qke.13 for ; Thu, 19 Dec 2019 05:28:02 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id i14sm1692968qkl.133.2019.12.19.05.27.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:27:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762084; h=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=NltAMrsEv5ke5pAZDfAtw5/nLxY9luxe7WgsDSBXFn4=; b=hXU9Iz6ikXzvDMRiQ2mbmJRJgcPVZR9uC/l+jXwA6H2fdW41drvzNr/lBEAyYKffHG3IpN UQKZgbrFtsQwJ93WT/KWfkA5mfc6lxtyHm+C/kkSdekTDYcVAbOq0q3GzXrH3PpUDQqfMe lqSJX2uSypwYOd0rkRXdBg6BrQzkQCE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dadO/2+4wmmhotigSKRnNx63YJGVnWQHqOLOFTkAVzg=; b=GFRa/+kjsEQmjFXX3LTUZwINbywCKsWmsxtn3qswgXvDLKznTSBpX9dQx3Tb59u02C iMecsgVSd8UeWrHUqLFiv4pUeV9qDn8jav6SYX64Y7fZRBdyF8hVXevH0Auj3w8au3m/ 2MjTCtXUqJy7/Maw5H+5TjLOOJ07btcUNeCVxqgl84LP1R7FtKja9bn6DMTl9aiuRLVB Gf7Loz2QvRhRlexIoivZPw7yf7itdLnfGRTawXze+4Z3jntgUlA94BisM6dpUj+Y4Zug 4i3qh/o+13SzegOBqasf4MGdsHA0bXSD3GFtDg+tMF/bHqoWR1oXjv219ihVNP+YxRiW 8hag== X-Gm-Message-State: APjAAAWvA8jqOTqI6928ZDhbUK0kXN0cpPQz4ot2E9bx1qEGrc0tGvVs Tflz95f5Sf6xx1ixZYtN9hSYc7OZhTBH8SXToNQVwfyMSLNiT/srDzATKty7Y3UOitwFYBGzN59 Kiej7QwSD/G2KVTA= X-Received: by 2002:a05:620a:128d:: with SMTP id w13mr7984483qki.289.1576762081150; Thu, 19 Dec 2019 05:28:01 -0800 (PST) X-Google-Smtp-Source: APXvYqzElH28fT44Zj77WgpEAyabYJlAPB9kn/j0PPZVpyINgj54DETMIgu3hiWIJDoACsQcDgTuXw== X-Received: by 2002:a05:620a:128d:: with SMTP id w13mr7984447qki.289.1576762080484; Thu, 19 Dec 2019 05:28:00 -0800 (PST) Date: Thu, 19 Dec 2019 08:27:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 12/24] numa: Extend CLI to provide memory latency and bandwidth information Message-ID: <20191219132621.16595-13-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 2_uLCg7xMLW3K-DkVn5JAQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Liu Jingqi , Tao Xu , Markus Armbruster , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Jingqi Add -numa hmat-lb option to provide System Locality Latency and Bandwidth Information. These memory attributes help to build System Locality Latency and Bandwidth Information Structure(s) in ACPI Heterogeneous Memory Attribute Table (HMAT). Before using hmat-lb option, enable HMAT with -machine hmat=3Don. Acked-by: Markus Armbruster Signed-off-by: Liu Jingqi Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-3-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- qapi/machine.json | 93 +++++++++++++++++++- include/sysemu/numa.h | 53 ++++++++++++ hw/core/numa.c | 194 ++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 47 +++++++++- 4 files changed, 384 insertions(+), 3 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 27d0e37534..cf8faf5a2a 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -426,10 +426,12 @@ # # @cpu: property based CPU(s) to node mapping (Since: 2.10) # +# @hmat-lb: memory latency and bandwidth information (Since: 5.0) +# # Since: 2.1 ## { 'enum': 'NumaOptionsType', - 'data': [ 'node', 'dist', 'cpu' ] } + 'data': [ 'node', 'dist', 'cpu', 'hmat-lb' ] } =20 ## # @NumaOptions: @@ -444,7 +446,8 @@ 'data': { 'node': 'NumaNodeOptions', 'dist': 'NumaDistOptions', - 'cpu': 'NumaCpuOptions' }} + 'cpu': 'NumaCpuOptions', + 'hmat-lb': 'NumaHmatLBOptions' }} =20 ## # @NumaNodeOptions: @@ -557,6 +560,92 @@ 'base': 'CpuInstanceProperties', 'data' : {} } =20 +## +# @HmatLBMemoryHierarchy: +# +# The memory hierarchy in the System Locality Latency and Bandwidth +# Information Structure of HMAT (Heterogeneous Memory Attribute Table) +# +# For more information about @HmatLBMemoryHierarchy, see chapter +# 5.2.27.4: Table 5-146: Field "Flags" of ACPI 6.3 spec. +# +# @memory: the structure represents the memory performance +# +# @first-level: first level of memory side cache +# +# @second-level: second level of memory side cache +# +# @third-level: third level of memory side cache +# +# Since: 5.0 +## +{ 'enum': 'HmatLBMemoryHierarchy', + 'data': [ 'memory', 'first-level', 'second-level', 'third-level' ] } + +## +# @HmatLBDataType: +# +# Data type in the System Locality Latency and Bandwidth +# Information Structure of HMAT (Heterogeneous Memory Attribute Table) +# +# For more information about @HmatLBDataType, see chapter +# 5.2.27.4: Table 5-146: Field "Data Type" of ACPI 6.3 spec. +# +# @access-latency: access latency (nanoseconds) +# +# @read-latency: read latency (nanoseconds) +# +# @write-latency: write latency (nanoseconds) +# +# @access-bandwidth: access bandwidth (Bytes per second) +# +# @read-bandwidth: read bandwidth (Bytes per second) +# +# @write-bandwidth: write bandwidth (Bytes per second) +# +# Since: 5.0 +## +{ 'enum': 'HmatLBDataType', + 'data': [ 'access-latency', 'read-latency', 'write-latency', + 'access-bandwidth', 'read-bandwidth', 'write-bandwidth' ] } + +## +# @NumaHmatLBOptions: +# +# Set the system locality latency and bandwidth information +# between Initiator and Target proximity Domains. +# +# For more information about @NumaHmatLBOptions, see chapter +# 5.2.27.4: Table 5-146 of ACPI 6.3 spec. +# +# @initiator: the Initiator Proximity Domain. +# +# @target: the Target Proximity Domain. +# +# @hierarchy: the Memory Hierarchy. Indicates the performance +# of memory or side cache. +# +# @data-type: presents the type of data, access/read/write +# latency or hit latency. +# +# @latency: the value of latency from @initiator to @target +# proximity domain, the latency unit is "ns(nanosecond)". +# +# @bandwidth: the value of bandwidth between @initiator and @target +# proximity domain, the bandwidth unit is +# "Bytes per second". +# +# Since: 5.0 +## +{ 'struct': 'NumaHmatLBOptions', + 'data': { + 'initiator': 'uint16', + 'target': 'uint16', + 'hierarchy': 'HmatLBMemoryHierarchy', + 'data-type': 'HmatLBDataType', + '*latency': 'uint64', + '*bandwidth': 'size' }} + ## # @HostMemPolicy: # diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 788cbec7a2..70f93c83d7 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -14,11 +14,34 @@ struct CPUArchId; #define NUMA_DISTANCE_MAX 254 #define NUMA_DISTANCE_UNREACHABLE 255 =20 +/* the value of AcpiHmatLBInfo flags */ +enum { + HMAT_LB_MEM_MEMORY =3D 0, + HMAT_LB_MEM_CACHE_1ST_LEVEL =3D 1, + HMAT_LB_MEM_CACHE_2ND_LEVEL =3D 2, + HMAT_LB_MEM_CACHE_3RD_LEVEL =3D 3, + HMAT_LB_LEVELS /* must be the last entry */ +}; + +/* the value of AcpiHmatLBInfo data type */ +enum { + HMAT_LB_DATA_ACCESS_LATENCY =3D 0, + HMAT_LB_DATA_READ_LATENCY =3D 1, + HMAT_LB_DATA_WRITE_LATENCY =3D 2, + HMAT_LB_DATA_ACCESS_BANDWIDTH =3D 3, + HMAT_LB_DATA_READ_BANDWIDTH =3D 4, + HMAT_LB_DATA_WRITE_BANDWIDTH =3D 5, + HMAT_LB_TYPES /* must be the last entry */ +}; + +#define UINT16_BITS 16 + struct NodeInfo { uint64_t node_mem; struct HostMemoryBackend *node_memdev; bool present; bool has_cpu; + uint8_t lb_info_provided; uint16_t initiator; uint8_t distance[MAX_NODES]; }; @@ -28,6 +51,31 @@ struct NumaNodeMem { uint64_t node_plugged_mem; }; =20 +struct HMAT_LB_Data { + uint8_t initiator; + uint8_t target; + uint64_t data; +}; +typedef struct HMAT_LB_Data HMAT_LB_Data; + +struct HMAT_LB_Info { + /* Indicates it's memory or the specified level memory side cache. */ + uint8_t hierarchy; + + /* Present the type of data, access/read/write latency or bandwidth. */ + uint8_t data_type; + + /* The range bitmap of bandwidth for calculating common base */ + uint64_t range_bitmap; + + /* The common base unit for latencies or bandwidths */ + uint64_t base; + + /* Array to store the latencies or bandwidths */ + GArray *list; +}; +typedef struct HMAT_LB_Info HMAT_LB_Info; + struct NumaState { /* Number of NUMA nodes */ int num_nodes; @@ -40,11 +88,16 @@ struct NumaState { =20 /* NUMA nodes information */ NodeInfo nodes[MAX_NODES]; + + /* NUMA nodes HMAT Locality Latency and Bandwidth Information */ + HMAT_LB_Info *hmat_lb[HMAT_LB_LEVELS][HMAT_LB_TYPES]; }; typedef struct NumaState NumaState; =20 void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp); void parse_numa_opts(MachineState *ms); +void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node, + Error **errp); void numa_complete_configuration(MachineState *ms); void query_numa_node_mem(NumaNodeMem node_mem[], MachineState *ms); extern QemuOptsList qemu_numa_opts; diff --git a/hw/core/numa.c b/hw/core/numa.c index e60da99293..34eb413f5d 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -23,6 +23,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/units.h" #include "sysemu/hostmem.h" #include "sysemu/numa.h" #include "sysemu/sysemu.h" @@ -198,6 +199,186 @@ void parse_numa_distance(MachineState *ms, NumaDistOp= tions *dist, Error **errp) ms->numa_state->have_numa_distance =3D true; } =20 +void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node, + Error **errp) +{ + int i, first_bit, last_bit; + uint64_t max_entry, temp_base, bitmap_copy; + NodeInfo *numa_info =3D numa_state->nodes; + HMAT_LB_Info *hmat_lb =3D + numa_state->hmat_lb[node->hierarchy][node->data_type]; + HMAT_LB_Data lb_data =3D {}; + HMAT_LB_Data *lb_temp; + + /* Error checking */ + if (node->initiator > numa_state->num_nodes) { + error_setg(errp, "Invalid initiator=3D%d, it should be less than %= d", + node->initiator, numa_state->num_nodes); + return; + } + if (node->target > numa_state->num_nodes) { + error_setg(errp, "Invalid target=3D%d, it should be less than %d", + node->target, numa_state->num_nodes); + return; + } + if (!numa_info[node->initiator].has_cpu) { + error_setg(errp, "Invalid initiator=3D%d, it isn't an " + "initiator proximity domain", node->initiator); + return; + } + if (!numa_info[node->target].present) { + error_setg(errp, "The target=3D%d should point to an existing node= ", + node->target); + return; + } + + if (!hmat_lb) { + hmat_lb =3D g_malloc0(sizeof(*hmat_lb)); + numa_state->hmat_lb[node->hierarchy][node->data_type] =3D hmat_lb; + hmat_lb->list =3D g_array_new(false, true, sizeof(HMAT_LB_Data)); + } + hmat_lb->hierarchy =3D node->hierarchy; + hmat_lb->data_type =3D node->data_type; + lb_data.initiator =3D node->initiator; + lb_data.target =3D node->target; + + if (node->data_type <=3D HMATLB_DATA_TYPE_WRITE_LATENCY) { + /* Input latency data */ + + if (!node->has_latency) { + error_setg(errp, "Missing 'latency' option"); + return; + } + if (node->has_bandwidth) { + error_setg(errp, "Invalid option 'bandwidth' since " + "the data type is latency"); + return; + } + + /* Detect duplicate configuration */ + for (i =3D 0; i < hmat_lb->list->len; i++) { + lb_temp =3D &g_array_index(hmat_lb->list, HMAT_LB_Data, i); + + if (node->initiator =3D=3D lb_temp->initiator && + node->target =3D=3D lb_temp->target) { + error_setg(errp, "Duplicate configuration of the latency f= or " + "initiator=3D%d and target=3D%d", node->initiator, + node->target); + return; + } + } + + hmat_lb->base =3D hmat_lb->base ? hmat_lb->base : UINT64_MAX; + + if (node->latency) { + /* Calculate the temporary base and compressed latency */ + max_entry =3D node->latency; + temp_base =3D 1; + while (QEMU_IS_ALIGNED(max_entry, 10)) { + max_entry /=3D 10; + temp_base *=3D 10; + } + + /* Calculate the max compressed latency */ + temp_base =3D MIN(hmat_lb->base, temp_base); + max_entry =3D node->latency / hmat_lb->base; + max_entry =3D MAX(hmat_lb->range_bitmap, max_entry); + + /* + * For latency hmat_lb->range_bitmap record the max compressed + * latency which should be less than 0xFFFF (UINT16_MAX) + */ + if (max_entry >=3D UINT16_MAX) { + error_setg(errp, "Latency %" PRIu64 " between initiator=3D= %d and " + "target=3D%d should not differ from previously ent= ered " + "min or max values on more than %d", node->latency, + node->initiator, node->target, UINT16_MAX - 1); + return; + } else { + hmat_lb->base =3D temp_base; + hmat_lb->range_bitmap =3D max_entry; + } + + /* + * Set lb_info_provided bit 0 as 1, + * latency information is provided + */ + numa_info[node->target].lb_info_provided |=3D BIT(0); + } + lb_data.data =3D node->latency; + } else if (node->data_type >=3D HMATLB_DATA_TYPE_ACCESS_BANDWIDTH) { + /* Input bandwidth data */ + if (!node->has_bandwidth) { + error_setg(errp, "Missing 'bandwidth' option"); + return; + } + if (node->has_latency) { + error_setg(errp, "Invalid option 'latency' since " + "the data type is bandwidth"); + return; + } + if (!QEMU_IS_ALIGNED(node->bandwidth, MiB)) { + error_setg(errp, "Bandwidth %" PRIu64 " between initiator=3D%d= and " + "target=3D%d should be 1MB aligned", node->bandwidt= h, + node->initiator, node->target); + return; + } + + /* Detect duplicate configuration */ + for (i =3D 0; i < hmat_lb->list->len; i++) { + lb_temp =3D &g_array_index(hmat_lb->list, HMAT_LB_Data, i); + + if (node->initiator =3D=3D lb_temp->initiator && + node->target =3D=3D lb_temp->target) { + error_setg(errp, "Duplicate configuration of the bandwidth= for " + "initiator=3D%d and target=3D%d", node->initiator, + node->target); + return; + } + } + + hmat_lb->base =3D hmat_lb->base ? hmat_lb->base : 1; + + if (node->bandwidth) { + /* Keep bitmap unchanged when bandwidth out of range */ + bitmap_copy =3D hmat_lb->range_bitmap; + bitmap_copy |=3D node->bandwidth; + first_bit =3D ctz64(bitmap_copy); + temp_base =3D UINT64_C(1) << first_bit; + max_entry =3D node->bandwidth / temp_base; + last_bit =3D 64 - clz64(bitmap_copy); + + /* + * For bandwidth, first_bit record the base unit of bandwidth = bits, + * last_bit record the last bit of the max bandwidth. The max + * compressed bandwidth should be less than 0xFFFF (UINT16_MAX) + */ + if ((last_bit - first_bit) > UINT16_BITS || + max_entry >=3D UINT16_MAX) { + error_setg(errp, "Bandwidth %" PRIu64 " between initiator= =3D%d " + "and target=3D%d should not differ from previously= " + "entered values on more than %d", node->bandwidth, + node->initiator, node->target, UINT16_MAX - 1); + return; + } else { + hmat_lb->base =3D temp_base; + hmat_lb->range_bitmap =3D bitmap_copy; + } + + /* + * Set lb_info_provided bit 1 as 1, + * bandwidth information is provided + */ + numa_info[node->target].lb_info_provided |=3D BIT(1); + } + lb_data.data =3D node->bandwidth; + } else { + assert(0); + } + + g_array_append_val(hmat_lb->list, lb_data); +} + void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp) { Error *err =3D NULL; @@ -236,6 +417,19 @@ void set_numa_options(MachineState *ms, NumaOptions *o= bject, Error **errp) machine_set_cpu_numa_node(ms, qapi_NumaCpuOptions_base(&object->u.= cpu), &err); break; + case NUMA_OPTIONS_TYPE_HMAT_LB: + if (!ms->numa_state->hmat_enabled) { + error_setg(errp, "ACPI Heterogeneous Memory Attribute Table " + "(HMAT) is disabled, enable it with -machine hmat= =3Don " + "before using any of hmat specific options"); + return; + } + + parse_numa_hmat_lb(ms->numa_state, &object->u.hmat_lb, &err); + if (err) { + goto end; + } + break; default: abort(); } diff --git a/qemu-options.hx b/qemu-options.hx index 63f6b33322..c45e2ae513 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -168,16 +168,19 @@ DEF("numa", HAS_ARG, QEMU_OPTION_numa, "-numa node[,mem=3Dsize][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode][,= initiator=3Dnode]\n" "-numa node[,memdev=3Did][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode][= ,initiator=3Dnode]\n" "-numa dist,src=3Dsource,dst=3Ddestination,val=3Ddistance\n" - "-numa cpu,node-id=3Dnode[,socket-id=3Dx][,core-id=3Dy][,thread-id=3Dz= ]\n", + "-numa cpu,node-id=3Dnode[,socket-id=3Dx][,core-id=3Dy][,thread-id=3Dz= ]\n" + "-numa hmat-lb,initiator=3Dnode,target=3Dnode,hierarchy=3Dmemory|first= -level|second-level|third-level,data-type=3Daccess-latency|read-latency|wri= te-latency[,latency=3Dlat][,bandwidth=3Dbw]\n", QEMU_ARCH_ALL) STEXI @item -numa node[,mem=3D@var{size}][,cpus=3D@var{firstcpu}[-@var{lastcpu}]= ][,nodeid=3D@var{node}][,initiator=3D@var{initiator}] @itemx -numa node[,memdev=3D@var{id}][,cpus=3D@var{firstcpu}[-@var{lastcpu= }]][,nodeid=3D@var{node}][,initiator=3D@var{initiator}] @itemx -numa dist,src=3D@var{source},dst=3D@var{destination},val=3D@var{di= stance} @itemx -numa cpu,node-id=3D@var{node}[,socket-id=3D@var{x}][,core-id=3D@va= r{y}][,thread-id=3D@var{z}] +@itemx -numa hmat-lb,initiator=3D@var{node},target=3D@var{node},hierarchy= =3D@var{hierarchy},data-type=3D@var{tpye}[,latency=3D@var{lat}][,bandwidth= =3D@var{bw}] @findex -numa Define a NUMA node and assign RAM and VCPUs to it. Set the NUMA distance from a source node to a destination node. +Set the ACPI Heterogeneous Memory Attributes for the given nodes. =20 Legacy VCPU assignment uses @samp{cpus} option where @var{firstcpu} and @var{lastcpu} are CPU indexes. Each @@ -256,6 +259,48 @@ specified resources, it just assigns existing resource= s to NUMA nodes. This means that one still has to use the @option{-m}, @option{-smp} options to allocate RAM and VCPUs respectively. =20 +Use @samp{hmat-lb} to set System Locality Latency and Bandwidth Information +between initiator and target NUMA nodes in ACPI Heterogeneous Attribute Me= mory Table (HMAT). +Initiator NUMA node can create memory requests, usually it has one or more= processors. +Target NUMA node contains addressable memory. + +In @samp{hmat-lb} option, @var{node} are NUMA node IDs. @var{hierarchy} is= the memory +hierarchy of the target NUMA node: if @var{hierarchy} is 'memory', the str= ucture +represents the memory performance; if @var{hierarchy} is 'first-level|seco= nd-level|third-level', +this structure represents aggregated performance of memory side caches for= each domain. +@var{type} of 'data-type' is type of data represented by this structure in= stance: +if 'hierarchy' is 'memory', 'data-type' is 'access|read|write' latency or = 'access|read|write' +bandwidth of the target memory; if 'hierarchy' is 'first-level|second-leve= l|third-level', +'data-type' is 'access|read|write' hit latency or 'access|read|write' hit = bandwidth of the +target memory side cache. + +@var{lat} is latency value in nanoseconds. @var{bw} is bandwidth value, +the possible value and units are NUM[M|G|T], mean that the bandwidth value= are +NUM byte per second (or MB/s, GB/s or TB/s depending on used suffix). +Note that if latency or bandwidth value is 0, means the corresponding late= ncy or +bandwidth information is not provided. + +For example, the following options describe 2 NUMA nodes. Node 0 has 2 cpu= s and +a ram, node 1 has only a ram. The processors in node 0 access memory in no= de +0 with access-latency 5 nanoseconds, access-bandwidth is 200 MB/s; +The processors in NUMA node 0 access memory in NUMA node 1 with access-lat= ency 10 +nanoseconds, access-bandwidth is 100 MB/s. +@example +-machine hmat=3Don \ +-m 2G \ +-object memory-backend-ram,size=3D1G,id=3Dm0 \ +-object memory-backend-ram,size=3D1G,id=3Dm1 \ +-smp 2 \ +-numa node,nodeid=3D0,memdev=3Dm0 \ +-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 \ +-numa cpu,node-id=3D0,socket-id=3D0 \ +-numa cpu,node-id=3D0,socket-id=3D1 \ +-numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmemory,data-type=3Dacce= ss-latency,latency=3D5 \ +-numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmemory,data-type=3Dacce= ss-bandwidth,bandwidth=3D200M \ +-numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmemory,data-type=3Dacce= ss-latency,latency=3D10 \ +-numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmemory,data-type=3Dacce= ss-bandwidth,bandwidth=3D100M +@end example + ETEXI =20 DEF("add-fd", HAS_ARG, QEMU_OPTION_add_fd, --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762472; cv=none; d=zohomail.com; s=zohoarc; b=IuRfPO4KX8u/EQRSl28GV/HzKh9H8jKUB0/QyZYBni79Xglq70ZLiutHS5NP5y8ParxIli1QgvgC34tsCUdWmjgirJ2/cRi5T527bRGLMwl5VXEb15egPDs7R440fDMSaRmu1bNsQUARqIttfylT3lOS12AwkO0tjERU3gn3OCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762472; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=klGZIVQc3hBJQfinJ26OVi+VOwga7x1VuUPTY5D8tzs=; b=Q7DdjfNq4Ju0ti5EKxuwcVR2S9DaDYqmGVZyjK4wz/HQBBYE3loNngNVPLeGjy3JfAf2qhUbL64T8BeKGfygndLqBP/Tx5gBA8EbpoKY6hcKHwqwQL3GvNy1M3uoSZA2BDtK9VQeY/z7uhhQIB4+aBc/dV+IWnh0d2SERSb9pxY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762472314139.92511054038482; Thu, 19 Dec 2019 05:34:32 -0800 (PST) Received: from localhost ([::1]:41588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvwk-00018L-Az for importer@patchew.org; Thu, 19 Dec 2019 08:34:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55239) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvqe-00022h-Ha for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvqc-0006MN-8r for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:12 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:27571 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvqb-0006Im-Px for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:09 -0500 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-224-ASlU2f8CMeuLYF3R39TQjw-1; Thu, 19 Dec 2019 08:28:08 -0500 Received: by mail-qk1-f199.google.com with SMTP id l7so3623334qke.8 for ; Thu, 19 Dec 2019 05:28:07 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id i90sm1855270qtd.49.2019.12.19.05.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:28:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762089; h=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=klGZIVQc3hBJQfinJ26OVi+VOwga7x1VuUPTY5D8tzs=; b=QbAQifurkRQSHB9f/ChOhqR/SmwZA5qUBUeEZHms5dXTViodSJTyRAQ5fHuW5dKq5/k5wO jhPE3ZFj6JBlI8GHnN/ndzqluDy9ljmih+U7bNuZRA8ZlO5g/QaSpJW2jEV0C6fNreQTXM 0pmgHCB7q+inkF7tXKPyme52SN1bd8M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mSMJvbjH9qZGhoCUn98j+YBZhKH+0cjp9bCrPGE112s=; b=VTWNb303T5um5DSwg6YtGGFHVfMDYte92vyzhmkliQo545odA3+26KLN+Xv5NmQbR0 Oj0a+E4TU1I+0Wg2fJV6mNkQOlxI0cxaXc9b/sQp2+Lmw58y3D3EXlj/YtdxY4eJkr9k Czfn2lWlvu5VjkrMsaUvhP1OjgGQaeCRL67ilux4nES17Z/o+1zNoi6KY6QZ2ZJlYMD5 7Lj3TJwH3EZelE72WrITJ0M03KYiLs5EZ6awvKPrvBHKHH30o8sawiwkNTbXgDMHuDhf 0Q8djmdD7DETTRM6HzXyvBbUWkbxB97JQrp8Z27da5ubIOXCxtJ8mCIPbdNEUAnS4ndg CCgg== X-Gm-Message-State: APjAAAXT3ga7Q3qQHXYahabgGaeH3s+Q+tPa0BpN7TdJ2Lk/2AoF070v 39WsYYZt5xUUmq9lUpI5y+LGRBsPeqAVmkGkqsYxJJl8/LaMurUAl87u9oU0loaO4vSSrRX4uXX NtRNKa0cB3zX0rEI= X-Received: by 2002:a37:6313:: with SMTP id x19mr7843578qkb.443.1576762087099; Thu, 19 Dec 2019 05:28:07 -0800 (PST) X-Google-Smtp-Source: APXvYqyVIanHvZomuuKuBUnT6gJDJI2vTlnoTX/YmTgBFONi3q7s0hp7K7Wy9EbpX+xWEYryLIqyyQ== X-Received: by 2002:a37:6313:: with SMTP id x19mr7843536qkb.443.1576762086646; Thu, 19 Dec 2019 05:28:06 -0800 (PST) Date: Thu, 19 Dec 2019 08:28:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 13/24] numa: Extend CLI to provide memory side cache information Message-ID: <20191219132621.16595-14-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: ASlU2f8CMeuLYF3R39TQjw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Liu Jingqi , Tao Xu , Markus Armbruster , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Jingqi Add -numa hmat-cache option to provide Memory Side Cache Information. These memory attributes help to build Memory Side Cache Information Structure(s) in ACPI Heterogeneous Memory Attribute Table (HMAT). Before using hmat-cache option, enable HMAT with -machine hmat=3Don. Acked-by: Markus Armbruster Signed-off-by: Liu Jingqi Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-4-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- qapi/machine.json | 81 +++++++++++++++++++++++++++++++++++++++++-- include/sysemu/numa.h | 5 +++ hw/core/numa.c | 80 ++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 17 +++++++-- 4 files changed, 179 insertions(+), 4 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index cf8faf5a2a..b3d30bc816 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -428,10 +428,12 @@ # # @hmat-lb: memory latency and bandwidth information (Since: 5.0) # +# @hmat-cache: memory side cache information (Since: 5.0) +# # Since: 2.1 ## { 'enum': 'NumaOptionsType', - 'data': [ 'node', 'dist', 'cpu', 'hmat-lb' ] } + 'data': [ 'node', 'dist', 'cpu', 'hmat-lb', 'hmat-cache' ] } =20 ## # @NumaOptions: @@ -447,7 +449,8 @@ 'node': 'NumaNodeOptions', 'dist': 'NumaDistOptions', 'cpu': 'NumaCpuOptions', - 'hmat-lb': 'NumaHmatLBOptions' }} + 'hmat-lb': 'NumaHmatLBOptions', + 'hmat-cache': 'NumaHmatCacheOptions' }} =20 ## # @NumaNodeOptions: @@ -646,6 +649,80 @@ '*latency': 'uint64', '*bandwidth': 'size' }} =20 +## +# @HmatCacheAssociativity: +# +# Cache associativity in the Memory Side Cache Information Structure +# of HMAT +# +# For more information of @HmatCacheAssociativity, see chapter +# 5.2.27.5: Table 5-147 of ACPI 6.3 spec. +# +# @none: None (no memory side cache in this proximity domain, +# or cache associativity unknown) +# +# @direct: Direct Mapped +# +# @complex: Complex Cache Indexing (implementation specific) +# +# Since: 5.0 +## +{ 'enum': 'HmatCacheAssociativity', + 'data': [ 'none', 'direct', 'complex' ] } + +## +# @HmatCacheWritePolicy: +# +# Cache write policy in the Memory Side Cache Information Structure +# of HMAT +# +# For more information of @HmatCacheWritePolicy, see chapter +# 5.2.27.5: Table 5-147: Field "Cache Attributes" of ACPI 6.3 spec. +# +# @none: None (no memory side cache in this proximity domain, +# or cache write policy unknown) +# +# @write-back: Write Back (WB) +# +# @write-through: Write Through (WT) +# +# Since: 5.0 +## +{ 'enum': 'HmatCacheWritePolicy', + 'data': [ 'none', 'write-back', 'write-through' ] } + +## +# @NumaHmatCacheOptions: +# +# Set the memory side cache information for a given memory domain. +# +# For more information of @NumaHmatCacheOptions, see chapter +# 5.2.27.5: Table 5-147: Field "Cache Attributes" of ACPI 6.3 spec. +# +# @node-id: the memory proximity domain to which the memory belongs. +# +# @size: the size of memory side cache in bytes. +# +# @level: the cache level described in this structure. +# +# @associativity: the cache associativity, +# none/direct-mapped/complex(complex cache indexing). +# +# @policy: the write policy, none/write-back/write-through. +# +# @line: the cache Line size in bytes. +# +# Since: 5.0 +## +{ 'struct': 'NumaHmatCacheOptions', + 'data': { + 'node-id': 'uint32', + 'size': 'size', + 'level': 'uint8', + 'associativity': 'HmatCacheAssociativity', + 'policy': 'HmatCacheWritePolicy', + 'line': 'uint16' }} + ## # @HostMemPolicy: # diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 70f93c83d7..ba693cc80b 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -91,6 +91,9 @@ struct NumaState { =20 /* NUMA nodes HMAT Locality Latency and Bandwidth Information */ HMAT_LB_Info *hmat_lb[HMAT_LB_LEVELS][HMAT_LB_TYPES]; + + /* Memory Side Cache Information Structure */ + NumaHmatCacheOptions *hmat_cache[MAX_NODES][HMAT_LB_LEVELS]; }; typedef struct NumaState NumaState; =20 @@ -98,6 +101,8 @@ void set_numa_options(MachineState *ms, NumaOptions *obj= ect, Error **errp); void parse_numa_opts(MachineState *ms); void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node, Error **errp); +void parse_numa_hmat_cache(MachineState *ms, NumaHmatCacheOptions *node, + Error **errp); void numa_complete_configuration(MachineState *ms); void query_numa_node_mem(NumaNodeMem node_mem[], MachineState *ms); extern QemuOptsList qemu_numa_opts; diff --git a/hw/core/numa.c b/hw/core/numa.c index 34eb413f5d..33fda31a4c 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -379,6 +379,73 @@ void parse_numa_hmat_lb(NumaState *numa_state, NumaHma= tLBOptions *node, g_array_append_val(hmat_lb->list, lb_data); } =20 +void parse_numa_hmat_cache(MachineState *ms, NumaHmatCacheOptions *node, + Error **errp) +{ + int nb_numa_nodes =3D ms->numa_state->num_nodes; + NodeInfo *numa_info =3D ms->numa_state->nodes; + NumaHmatCacheOptions *hmat_cache =3D NULL; + + if (node->node_id >=3D nb_numa_nodes) { + error_setg(errp, "Invalid node-id=3D%" PRIu32 ", it should be less= " + "than %d", node->node_id, nb_numa_nodes); + return; + } + + if (numa_info[node->node_id].lb_info_provided !=3D (BIT(0) | BIT(1))) { + error_setg(errp, "The latency and bandwidth information of " + "node-id=3D%" PRIu32 " should be provided before memory= side " + "cache attributes", node->node_id); + return; + } + + if (node->level < 1 || node->level >=3D HMAT_LB_LEVELS) { + error_setg(errp, "Invalid level=3D%" PRIu8 ", it should be larger = than 0 " + "and less than or equal to %d", node->level, + HMAT_LB_LEVELS - 1); + return; + } + + assert(node->associativity < HMAT_CACHE_ASSOCIATIVITY__MAX); + assert(node->policy < HMAT_CACHE_WRITE_POLICY__MAX); + if (ms->numa_state->hmat_cache[node->node_id][node->level]) { + error_setg(errp, "Duplicate configuration of the side cache for " + "node-id=3D%" PRIu32 " and level=3D%" PRIu8, + node->node_id, node->level); + return; + } + + if ((node->level > 1) && + ms->numa_state->hmat_cache[node->node_id][node->level - 1] && + (node->size >=3D + ms->numa_state->hmat_cache[node->node_id][node->level - 1]->si= ze)) { + error_setg(errp, "Invalid size=3D%" PRIu64 ", the size of level=3D= %" PRIu8 + " should be less than the size(%" PRIu64 ") of " + "level=3D%" PRIu8, node->size, node->level, + ms->numa_state->hmat_cache[node->node_id] + [node->level - 1]->size, + node->level - 1); + return; + } + + if ((node->level < HMAT_LB_LEVELS - 1) && + ms->numa_state->hmat_cache[node->node_id][node->level + 1] && + (node->size <=3D + ms->numa_state->hmat_cache[node->node_id][node->level + 1]->si= ze)) { + error_setg(errp, "Invalid size=3D%" PRIu64 ", the size of level=3D= %" PRIu8 + " should be larger than the size(%" PRIu64 ") of " + "level=3D%" PRIu8, node->size, node->level, + ms->numa_state->hmat_cache[node->node_id] + [node->level + 1]->size, + node->level + 1); + return; + } + + hmat_cache =3D g_malloc0(sizeof(*hmat_cache)); + memcpy(hmat_cache, node, sizeof(*hmat_cache)); + ms->numa_state->hmat_cache[node->node_id][node->level] =3D hmat_cache; +} + void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp) { Error *err =3D NULL; @@ -430,6 +497,19 @@ void set_numa_options(MachineState *ms, NumaOptions *o= bject, Error **errp) goto end; } break; + case NUMA_OPTIONS_TYPE_HMAT_CACHE: + if (!ms->numa_state->hmat_enabled) { + error_setg(errp, "ACPI Heterogeneous Memory Attribute Table " + "(HMAT) is disabled, enable it with -machine hmat= =3Don " + "before using any of hmat specific options"); + return; + } + + parse_numa_hmat_cache(ms, &object->u.hmat_cache, &err); + if (err) { + goto end; + } + break; default: abort(); } diff --git a/qemu-options.hx b/qemu-options.hx index c45e2ae513..16e8888fcc 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -169,7 +169,8 @@ DEF("numa", HAS_ARG, QEMU_OPTION_numa, "-numa node[,memdev=3Did][,cpus=3Dfirstcpu[-lastcpu]][,nodeid=3Dnode][= ,initiator=3Dnode]\n" "-numa dist,src=3Dsource,dst=3Ddestination,val=3Ddistance\n" "-numa cpu,node-id=3Dnode[,socket-id=3Dx][,core-id=3Dy][,thread-id=3Dz= ]\n" - "-numa hmat-lb,initiator=3Dnode,target=3Dnode,hierarchy=3Dmemory|first= -level|second-level|third-level,data-type=3Daccess-latency|read-latency|wri= te-latency[,latency=3Dlat][,bandwidth=3Dbw]\n", + "-numa hmat-lb,initiator=3Dnode,target=3Dnode,hierarchy=3Dmemory|first= -level|second-level|third-level,data-type=3Daccess-latency|read-latency|wri= te-latency[,latency=3Dlat][,bandwidth=3Dbw]\n" + "-numa hmat-cache,node-id=3Dnode,size=3Dsize,level=3Dlevel[,associativ= ity=3Dnone|direct|complex][,policy=3Dnone|write-back|write-through][,line= =3Dsize]\n", QEMU_ARCH_ALL) STEXI @item -numa node[,mem=3D@var{size}][,cpus=3D@var{firstcpu}[-@var{lastcpu}]= ][,nodeid=3D@var{node}][,initiator=3D@var{initiator}] @@ -177,6 +178,7 @@ STEXI @itemx -numa dist,src=3D@var{source},dst=3D@var{destination},val=3D@var{di= stance} @itemx -numa cpu,node-id=3D@var{node}[,socket-id=3D@var{x}][,core-id=3D@va= r{y}][,thread-id=3D@var{z}] @itemx -numa hmat-lb,initiator=3D@var{node},target=3D@var{node},hierarchy= =3D@var{hierarchy},data-type=3D@var{tpye}[,latency=3D@var{lat}][,bandwidth= =3D@var{bw}] +@itemx -numa hmat-cache,node-id=3D@var{node},size=3D@var{size},level=3D@va= r{level}[,associativity=3D@var{str}][,policy=3D@var{str}][,line=3D@var{size= }] @findex -numa Define a NUMA node and assign RAM and VCPUs to it. Set the NUMA distance from a source node to a destination node. @@ -280,11 +282,20 @@ NUM byte per second (or MB/s, GB/s or TB/s depending = on used suffix). Note that if latency or bandwidth value is 0, means the corresponding late= ncy or bandwidth information is not provided. =20 +In @samp{hmat-cache} option, @var{node-id} is the NUMA-id of the memory be= longs. +@var{size} is the size of memory side cache in bytes. @var{level} is the c= ache +level described in this structure, note that the cache level 0 should not = be used +with @samp{hmat-cache} option. @var{associativity} is the cache associativ= ity, +the possible value is 'none/direct(direct-mapped)/complex(complex cache in= dexing)'. +@var{policy} is the write policy. @var{line} is the cache Line size in byt= es. + For example, the following options describe 2 NUMA nodes. Node 0 has 2 cpu= s and a ram, node 1 has only a ram. The processors in node 0 access memory in no= de 0 with access-latency 5 nanoseconds, access-bandwidth is 200 MB/s; The processors in NUMA node 0 access memory in NUMA node 1 with access-lat= ency 10 nanoseconds, access-bandwidth is 100 MB/s. +And for memory side cache information, NUMA node 0 and 1 both have 1 level= memory +cache, size is 10KB, policy is write-back, the cache Line size is 8 bytes: @example -machine hmat=3Don \ -m 2G \ @@ -298,7 +309,9 @@ nanoseconds, access-bandwidth is 100 MB/s. -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmemory,data-type=3Dacce= ss-latency,latency=3D5 \ -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmemory,data-type=3Dacce= ss-bandwidth,bandwidth=3D200M \ -numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmemory,data-type=3Dacce= ss-latency,latency=3D10 \ --numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmemory,data-type=3Dacce= ss-bandwidth,bandwidth=3D100M +-numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmemory,data-type=3Dacce= ss-bandwidth,bandwidth=3D100M \ +-numa hmat-cache,node-id=3D0,size=3D10K,level=3D1,associativity=3Ddirect,p= olicy=3Dwrite-back,line=3D8 \ +-numa hmat-cache,node-id=3D1,size=3D10K,level=3D1,associativity=3Ddirect,p= olicy=3Dwrite-back,line=3D8 @end example =20 ETEXI --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762686; cv=none; d=zohomail.com; s=zohoarc; b=Y2b61szbvUKZRu1fxAId2qHUsA81RzAMKrUTt3lsFe/gvZCpfMjGguYBAoDrLfIZuW40anLvlgv8+ilHvFcVF9L9Pv95/67bjyq14pEqoolvBzOO3kdp6efNHB4W6ru7SJ0csJdvVHZX9zkn0AysDsmim7qhG/gnG8UHpUBD8Oo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762686; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZmE9OX4kBPKoQOj2PRfOYuZgphmH5o7Of8Fb3fSurvc=; b=W2UJZzT5RC8GLh7MGBk50IN26DA7XDdSFwaZLIKj88OfC7M6cp5OtT2rIlYs27YEu2j8WbkKvg11aEgWgCxoMq9S44uxOTISSV7ELgr8deVxWBQrxABl71xuwVt0NcPR8SRX+lrXNYyywfHHh43/sQ60FuvKV51jBc97lqtfLfM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762686301682.2945457753805; Thu, 19 Dec 2019 05:38:06 -0800 (PST) Received: from localhost ([::1]:41638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihw0C-0006ZB-Km for importer@patchew.org; Thu, 19 Dec 2019 08:38:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55917) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvqk-0002CP-Q6 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvqi-0006xq-Px for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:18 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:40497 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvqi-0006ub-IU for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:16 -0500 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-293-e1KRxH6ZNxKblReP-BRB4A-1; Thu, 19 Dec 2019 08:28:14 -0500 Received: by mail-qt1-f199.google.com with SMTP id l25so3676628qtu.0 for ; Thu, 19 Dec 2019 05:28:14 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id h1sm1686837qkc.38.2019.12.19.05.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:28:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762096; h=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=ZmE9OX4kBPKoQOj2PRfOYuZgphmH5o7Of8Fb3fSurvc=; b=SGAQ3ddx9ymHW6XFsMBb6W0oWAIcrtmPdLgWsUbNIZgz7+C3t6YN7c/Vsm3AwlrMHnmbKZ w64EtB285KvlgcCzdOoqLFePSO5biYjF8W/n0Yw/oLzSMJ5O36wi9ZZl/3quVjI0W2xUoe Ze5px9VMw5MsPtw6OgHFv8LsqA6TzJA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PFI023X+CNmWXB7LxQBp9gVsjdUDGd7UnFpJP80aHdo=; b=ty9GB7MdezYEmxg5Mhn/JceYgKP0x5sah/5OAAf3WTAP1IQAxs3OlRexDwSU/t0fvy hVLwHvrjT/GIo25+r19MUfrGa2vpQLCS/shxKlCRzoITu5qxvYFlZAK4QXVk++48bTTR IB0uxZ5WdI2eSYb6+O10tN2QPn23bUUvtDztq+YljzVcMOgo37uSK0a2lvhz2AItoNfj 92dDm8T0zjzJ8Irzq5VOBSFci53bBdyOPE3JBmyezDRaWWGU4BOjwS2ATyMw3B66vL4D TUeMJB2WSXuIJlf6YqRLsQk/x2LcjrpiX+UrM5QBePP1SSs9lpDclru9K25rOlgSds8j wt6g== X-Gm-Message-State: APjAAAVC4xxRejr4anqkadPY7QptCu4om5wS9Lv/7EVDGzVARe6aF/Y/ TVdBjQH+lfWRkbH+vCKvOtjU2W7/OVOCao+nONyOajqMLPaRzReZL6Ua4l0Gci4YaDwRc+c9LVz 6MSc7NzSAs7d0eHU= X-Received: by 2002:ac8:602:: with SMTP id d2mr7047232qth.245.1576762093545; Thu, 19 Dec 2019 05:28:13 -0800 (PST) X-Google-Smtp-Source: APXvYqyGl3w4Tfqg7weG3pPG6c7RXCbpEhi0ww3+1X+UBV1QtHF6/nPx9nVaFDJ8vz/0iL/B7/eCjg== X-Received: by 2002:ac8:602:: with SMTP id d2mr7047201qth.245.1576762093199; Thu, 19 Dec 2019 05:28:13 -0800 (PST) Date: Thu, 19 Dec 2019 08:28:07 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 14/24] hmat acpi: Build Memory Proximity Domain Attributes Structure(s) Message-ID: <20191219132621.16595-15-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: e1KRxH6ZNxKblReP-BRB4A-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Liu Jingqi , Tao Xu , Markus Armbruster , Daniel Black , Paolo Bonzini , Jonathan Cameron , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Jingqi HMAT is defined in ACPI 6.3: 5.2.27 Heterogeneous Memory Attribute Table (HMAT). The specification references below link: http://www.uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf It describes the memory attributes, such as memory side cache attributes and bandwidth and latency details, related to the Memory Proximity Domain. The software is expected to use this information as hint for optimization. This structure describes Memory Proximity Domain Attributes by memory subsystem and its associativity with processor proximity domain as well as hint for memory usage. In the linux kernel, the codes in drivers/acpi/hmat/hmat.c parse and report the platform's HMAT tables. Acked-by: Markus Armbruster Reviewed-by: Igor Mammedov Reviewed-by: Daniel Black Reviewed-by: Jonathan Cameron Signed-off-by: Liu Jingqi Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-5-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/hmat.h | 42 ++++++++++++++++++ hw/acpi/hmat.c | 99 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 5 +++ hw/acpi/Kconfig | 7 ++- hw/acpi/Makefile.objs | 1 + 5 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 hw/acpi/hmat.h create mode 100644 hw/acpi/hmat.c diff --git a/hw/acpi/hmat.h b/hw/acpi/hmat.h new file mode 100644 index 0000000000..437dbc6872 --- /dev/null +++ b/hw/acpi/hmat.h @@ -0,0 +1,42 @@ +/* + * HMAT ACPI Implementation Header + * + * Copyright(C) 2019 Intel Corporation. + * + * Author: + * Liu jingqi + * Tao Xu + * + * HMAT is defined in ACPI 6.3: 5.2.27 Heterogeneous Memory Attribute Table + * (HMAT) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#ifndef HMAT_H +#define HMAT_H + +#include "hw/acpi/aml-build.h" + +/* + * ACPI 6.3: 5.2.27.3 Memory Proximity Domain Attributes Structure, + * Table 5-145, Field "flag", Bit [0]: set to 1 to indicate that data in + * the Proximity Domain for the Attached Initiator field is valid. + * Other bits reserved. + */ +#define HMAT_PROXIMITY_INITIATOR_VALID 0x1 + +void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_st= ate); + +#endif diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c new file mode 100644 index 0000000000..9ff79308a4 --- /dev/null +++ b/hw/acpi/hmat.c @@ -0,0 +1,99 @@ +/* + * HMAT ACPI Implementation + * + * Copyright(C) 2019 Intel Corporation. + * + * Author: + * Liu jingqi + * Tao Xu + * + * HMAT is defined in ACPI 6.3: 5.2.27 Heterogeneous Memory Attribute Table + * (HMAT) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#include "qemu/osdep.h" +#include "sysemu/numa.h" +#include "hw/acpi/hmat.h" + +/* + * ACPI 6.3: + * 5.2.27.3 Memory Proximity Domain Attributes Structure: Table 5-145 + */ +static void build_hmat_mpda(GArray *table_data, uint16_t flags, + uint32_t initiator, uint32_t mem_node) +{ + + /* Memory Proximity Domain Attributes Structure */ + /* Type */ + build_append_int_noprefix(table_data, 0, 2); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); + /* Length */ + build_append_int_noprefix(table_data, 40, 4); + /* Flags */ + build_append_int_noprefix(table_data, flags, 2); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); + /* Proximity Domain for the Attached Initiator */ + build_append_int_noprefix(table_data, initiator, 4); + /* Proximity Domain for the Memory */ + build_append_int_noprefix(table_data, mem_node, 4); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); + /* + * Reserved: + * Previously defined as the Start Address of the System Physical + * Address Range. Deprecated since ACPI Spec 6.3. + */ + build_append_int_noprefix(table_data, 0, 8); + /* + * Reserved: + * Previously defined as the Range Length of the region in bytes. + * Deprecated since ACPI Spec 6.3. + */ + build_append_int_noprefix(table_data, 0, 8); +} + +/* Build HMAT sub table structures */ +static void hmat_build_table_structs(GArray *table_data, NumaState *numa_s= tate) +{ + uint16_t flags; + int i; + + for (i =3D 0; i < numa_state->num_nodes; i++) { + flags =3D 0; + + if (numa_state->nodes[i].initiator < MAX_NODES) { + flags |=3D HMAT_PROXIMITY_INITIATOR_VALID; + } + + build_hmat_mpda(table_data, flags, numa_state->nodes[i].initiator,= i); + } +} + +void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_st= ate) +{ + int hmat_start =3D table_data->len; + + /* reserve space for HMAT header */ + acpi_data_push(table_data, 40); + + hmat_build_table_structs(table_data, numa_state); + + build_header(linker, table_data, + (void *)(table_data->data + hmat_start), + "HMAT", table_data->len - hmat_start, 2, NULL, NULL); +} diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 12ff55fcfb..90a9c2ce6f 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -67,6 +67,7 @@ #include "hw/i386/intel_iommu.h" =20 #include "hw/acpi/ipmi.h" +#include "hw/acpi/hmat.h" =20 /* These are used to size the ACPI tables for -M pc-i440fx-1.7 and * -M pc-i440fx-2.0. Even if the actual amount of AML generated grows @@ -2834,6 +2835,10 @@ void acpi_build(AcpiBuildTables *tables, MachineStat= e *machine) acpi_add_table(table_offsets, tables_blob); build_slit(tables_blob, tables->linker, machine); } + if (machine->numa_state->hmat_enabled) { + acpi_add_table(table_offsets, tables_blob); + build_hmat(tables_blob, tables->linker, machine->numa_state); + } } if (acpi_get_mcfg(&mcfg)) { acpi_add_table(table_offsets, tables_blob); diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index 12e3f1e86e..54209c6f2f 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -7,6 +7,7 @@ config ACPI_X86 select ACPI_NVDIMM select ACPI_CPU_HOTPLUG select ACPI_MEMORY_HOTPLUG + select ACPI_HMAT =20 config ACPI_X86_ICH bool @@ -23,6 +24,10 @@ config ACPI_NVDIMM bool depends on ACPI =20 +config ACPI_HMAT + bool + depends on ACPI + config ACPI_PCI bool depends on ACPI && PCI @@ -33,5 +38,3 @@ config ACPI_VMGENID depends on PC =20 config ACPI_HW_REDUCED - bool - depends on ACPI diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs index 655a9c1973..517bd88704 100644 --- a/hw/acpi/Makefile.objs +++ b/hw/acpi/Makefile.objs @@ -7,6 +7,7 @@ common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) +=3D cpu.o common-obj-$(CONFIG_ACPI_NVDIMM) +=3D nvdimm.o common-obj-$(CONFIG_ACPI_VMGENID) +=3D vmgenid.o common-obj-$(CONFIG_ACPI_HW_REDUCED) +=3D generic_event_device.o +common-obj-$(CONFIG_ACPI_HMAT) +=3D hmat.o common-obj-$(call lnot,$(CONFIG_ACPI_X86)) +=3D acpi-stub.o =20 common-obj-y +=3D acpi_interface.o --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762649; cv=none; d=zohomail.com; s=zohoarc; b=e/W1nIKkUm6On0QbThhLzrV6FP9WNTgoUNI+b9JSOwy7kUGvTWfKwqIGUyG8H7NV1eVBVN0XwnzXh2vcvJJfwd+eiBd1dH81GjWczw30BQwGlYao5F45nhy1gSYccyHBitF8JcrlQXvyT+gKYMDmwSHInwgk3Sh5YhGG/AF9/UU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762649; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bLV8rQCbLBZmY0FVDGOQq3AQD9eSmdJYBYmhF7NfsUU=; b=hEeaZJi4E4FvICtVm+tUafjgDyfG9s8uoDYu0sl8lS6PYAI9NIKcbuqx0gKERsvOzQXyF/BZO6PMZuCt/MEaK0eYh4P7INAUo7vUgqLhjze7U0gDRBqgjpNwg9dx51PkxMRd3nd4j+VDYg1cggzYgGhRT79DiPWjQuQHpsYGQ0s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762649190557.9378095485953; Thu, 19 Dec 2019 05:37:29 -0800 (PST) Received: from localhost ([::1]:41634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvzb-0005df-Ku for importer@patchew.org; Thu, 19 Dec 2019 08:37:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56375) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvqo-0002Ir-Sv for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvqn-0007OC-AJ for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:22 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:60365 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvqn-0007LQ-4f for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:21 -0500 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-391-9xTDXOKWPcKlHM8J27Rygg-1; Thu, 19 Dec 2019 08:28:19 -0500 Received: by mail-qv1-f70.google.com with SMTP id z9so3602753qvo.10 for ; Thu, 19 Dec 2019 05:28:19 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id u24sm1753487qkm.40.2019.12.19.05.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:28:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762100; h=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=bLV8rQCbLBZmY0FVDGOQq3AQD9eSmdJYBYmhF7NfsUU=; b=crrUZiWVToNOedMrrhs5VAK/sYuakNs/bNYp7JfyGxZv/fOPaGTsTI51iuhtFsvkKLQC8/ PAswSrbZ1pVxK2whRphY0oXH8WsFnfkspMd/MSm5LkaguA7n6o18rCnQjvqPVXU/YGyr+b 4Ct+jo8r2b7gV8/I0msRh88AcEVzCC0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3qP/C/NttECQ066FqPp6xPe1UgZkrZPuw+r54Uke8BM=; b=AlW7mUM+Sq3i+hID082pUbK3ufKqmKSflUzvY+VeJMv6e8UBfbAjR5fdmKOuv9cCuH /THBqchPdNx7ucR9664vcOlBB9tXNB11b6D2nSARaLRNdQQhnKsIM8A1m4hG9zd2Czfm MMS3yTGziIEenPv9yksxXbhnpOUFs6BhoThFBESZ0MXfaOh60ZPwCFwjbSv5xuZQzVeY C/6EIJlERuHT14kOXBjv8yvlWSgIcZ2PZ8+vta4LG6INhEoAKRVxeaEUsxHjBgZCPK5u ovqBp4TK2eebL8TXKihc0f45C7kP+hx8m7fs8YOaNWqOjsATf2+U3cIkoHSMbogsZKOu hg/Q== X-Gm-Message-State: APjAAAUjdV7pM//jvg6GWIUbcnpHc/2HZKhl9X74g39GrOtCF7AQ0iG9 U+bt8FcDnxqxcBs/DHIEbg7rwfJxdCkIv+De5QQRQpsISDdDKqiKZ7W7tU6C3T0i5eWrOblFMBJ knBW+jFWnF+fEqV0= X-Received: by 2002:a37:c24b:: with SMTP id j11mr7774811qkm.57.1576762098431; Thu, 19 Dec 2019 05:28:18 -0800 (PST) X-Google-Smtp-Source: APXvYqyfK3nNyK8DQdtgP4JJo/Ucem5WqYsV8QZIfcoQR0J3B7YmhWNTJPZJbxiKwJN3+mvfLTVzGw== X-Received: by 2002:a37:c24b:: with SMTP id j11mr7774781qkm.57.1576762098166; Thu, 19 Dec 2019 05:28:18 -0800 (PST) Date: Thu, 19 Dec 2019 08:28:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 15/24] hmat acpi: Build System Locality Latency and Bandwidth Information Structure(s) Message-ID: <20191219132621.16595-16-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 9xTDXOKWPcKlHM8J27Rygg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Igor Mammedov , Tao Xu , Markus Armbruster , Liu Jingqi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Jingqi This structure describes the memory access latency and bandwidth information from various memory access initiator proximity domains. The latency and bandwidth numbers represented in this structure correspond to rated latency and bandwidth for the platform. The software could use this information as hint for optimization. Acked-by: Markus Armbruster Reviewed-by: Igor Mammedov Signed-off-by: Liu Jingqi Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-6-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/hmat.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c index 9ff79308a4..4635d45dee 100644 --- a/hw/acpi/hmat.c +++ b/hw/acpi/hmat.c @@ -25,6 +25,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/units.h" #include "sysemu/numa.h" #include "hw/acpi/hmat.h" =20 @@ -67,11 +68,89 @@ static void build_hmat_mpda(GArray *table_data, uint16_= t flags, build_append_int_noprefix(table_data, 0, 8); } =20 +/* + * ACPI 6.3: 5.2.27.4 System Locality Latency and Bandwidth Information + * Structure: Table 5-146 + */ +static void build_hmat_lb(GArray *table_data, HMAT_LB_Info *hmat_lb, + uint32_t num_initiator, uint32_t num_target, + uint32_t *initiator_list) +{ + int i, index; + HMAT_LB_Data *lb_data; + uint16_t *entry_list; + uint32_t base; + /* Length in bytes for entire structure */ + uint32_t lb_length + =3D 32 /* Table length upto and including Entry Base Unit */ + + 4 * num_initiator /* Initiator Proximity Domain List */ + + 4 * num_target /* Target Proximity Domain List */ + + 2 * num_initiator * num_target; /* Latency or Bandwidth Entries = */ + + /* Type */ + build_append_int_noprefix(table_data, 1, 2); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); + /* Length */ + build_append_int_noprefix(table_data, lb_length, 4); + /* Flags: Bits [3:0] Memory Hierarchy, Bits[7:4] Reserved */ + assert(!(hmat_lb->hierarchy >> 4)); + build_append_int_noprefix(table_data, hmat_lb->hierarchy, 1); + /* Data Type */ + build_append_int_noprefix(table_data, hmat_lb->data_type, 1); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); + /* Number of Initiator Proximity Domains (s) */ + build_append_int_noprefix(table_data, num_initiator, 4); + /* Number of Target Proximity Domains (t) */ + build_append_int_noprefix(table_data, num_target, 4); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); + + /* Entry Base Unit */ + if (hmat_lb->data_type <=3D HMAT_LB_DATA_WRITE_LATENCY) { + /* Convert latency base from nanoseconds to picosecond */ + base =3D hmat_lb->base * 1000; + } else { + /* Convert bandwidth base from Byte to Megabyte */ + base =3D hmat_lb->base / MiB; + } + build_append_int_noprefix(table_data, base, 8); + + /* Initiator Proximity Domain List */ + for (i =3D 0; i < num_initiator; i++) { + build_append_int_noprefix(table_data, initiator_list[i], 4); + } + + /* Target Proximity Domain List */ + for (i =3D 0; i < num_target; i++) { + build_append_int_noprefix(table_data, i, 4); + } + + /* Latency or Bandwidth Entries */ + entry_list =3D g_malloc0(num_initiator * num_target * sizeof(uint16_t)= ); + for (i =3D 0; i < hmat_lb->list->len; i++) { + lb_data =3D &g_array_index(hmat_lb->list, HMAT_LB_Data, i); + index =3D lb_data->initiator * num_target + lb_data->target; + + entry_list[index] =3D (uint16_t)(lb_data->data / hmat_lb->base); + } + + for (i =3D 0; i < num_initiator * num_target; i++) { + build_append_int_noprefix(table_data, entry_list[i], 2); + } + + g_free(entry_list); +} + /* Build HMAT sub table structures */ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_s= tate) { uint16_t flags; - int i; + uint32_t num_initiator =3D 0; + uint32_t initiator_list[MAX_NODES]; + int i, hierarchy, type; + HMAT_LB_Info *hmat_lb; =20 for (i =3D 0; i < numa_state->num_nodes; i++) { flags =3D 0; @@ -82,6 +161,29 @@ static void hmat_build_table_structs(GArray *table_data= , NumaState *numa_state) =20 build_hmat_mpda(table_data, flags, numa_state->nodes[i].initiator,= i); } + + for (i =3D 0; i < numa_state->num_nodes; i++) { + if (numa_state->nodes[i].has_cpu) { + initiator_list[num_initiator++] =3D i; + } + } + + /* + * ACPI 6.3: 5.2.27.4 System Locality Latency and Bandwidth Information + * Structure: Table 5-146 + */ + for (hierarchy =3D HMAT_LB_MEM_MEMORY; + hierarchy <=3D HMAT_LB_MEM_CACHE_3RD_LEVEL; hierarchy++) { + for (type =3D HMAT_LB_DATA_ACCESS_LATENCY; + type <=3D HMAT_LB_DATA_WRITE_BANDWIDTH; type++) { + hmat_lb =3D numa_state->hmat_lb[hierarchy][type]; + + if (hmat_lb && hmat_lb->list->len) { + build_hmat_lb(table_data, hmat_lb, num_initiator, + numa_state->num_nodes, initiator_list); + } + } + } } =20 void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_st= ate) --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762629; cv=none; d=zohomail.com; s=zohoarc; b=YiCGc+D6GrQ+pWoKEOrfzamwCG8636kpB3Ts4G/lfqRMrh1ZTXWbzpAxs089s3Wft2r2xp1dZN2h+JSa0JZ3F3pjd1R85IhY3JzX9a/GrZ3MsVvesGnDekPo53MvZ5e3qHYcvN6DRjOiztHoL07HG2/Jj7dXGtl8paIRVVL4dxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762629; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9TnHo7VvJZaLFzHYDnog4vzTE/uU8KgG0+PD95HCZAE=; b=ED3pdKNK5oPw1QpAcT7Ch7Bh/9a5CBNGR+qo9+qJrkpvJL9yD0sUCWaUJX/OK4WCvPvu6gGHCOOMq5f6USxLaEAQLP8sBHU7IP4eCcMjz4bLroVFaZaunc0SX6wbiZrXwDDheDH7r7M9n518HsduvkRuVwPdGo0MKXzwHTj4Exg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762629290176.22957563770842; Thu, 19 Dec 2019 05:37:09 -0800 (PST) Received: from localhost ([::1]:41632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvzH-00058I-VM for importer@patchew.org; Thu, 19 Dec 2019 08:37:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57560) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvqy-0002YK-N0 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvqx-0008DU-9A for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:32 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:35075 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvqx-0008BE-1n for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:31 -0500 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231-RtLigwRtM9ebhVYi5uljAA-1; Thu, 19 Dec 2019 08:28:26 -0500 Received: by mail-qv1-f72.google.com with SMTP id dw11so3590567qvb.16 for ; Thu, 19 Dec 2019 05:28:26 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id c20sm1935269qtc.13.2019.12.19.05.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:28:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762110; h=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=9TnHo7VvJZaLFzHYDnog4vzTE/uU8KgG0+PD95HCZAE=; b=IBQ2IoGZo5J6qNHexwHYPenOVO5bIIisloXzklr18MTedXVgHrlUOIJsxwwhp7iJTY3JaD BDbMBW0Ej3/thCW6OJQSY1ol3Vja1pD6OM2zvkcBSGCf/4rOZbmp9pBlkQup2htwlIu5zw fRPstW+vAs6QZ2BQcmdKL3J1ntaHgQw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=yLxJY7rN1k5OoWYN8rEjFXzk7p6lyE6U8ZaTa83HTg0=; b=bQc73j7jHrQRlgpcjBHWDlWrlqZ0cAA1DTgD5FMHOa6M24+P2aHN7uKqR1/iFKSZ9H 3ymKcwaWR8unYCerwV0tiUlJfRNN39kXk+e+pAL3FP0vFfD3IOvsY/sygRd2j7X7PWOp Mbb7RIWtYNrsCxjy//NEfcdJyk9wEmIAil0NowXo34LVAHzHarRposBriqoOy5ZYsbc6 ouHLRQT03yG3s6LpX/EefdlH/J0Ni85UB/vpZkjGFGgrwO/l5fqvgYg6LxekGxPt42yc zEL/bv+WawYS5qyLSdQ5ioO2QWEceGrKNqx8npF/NdTy6XSwvaJqIrMhVjGEq73Q7uOc Tjfg== X-Gm-Message-State: APjAAAVO73BZaz6ZSd45N+TGSvC31+1cFMCsemM1scoTDRI84H/lZWhi +f2GWN8KKg3Lqup/AdDZigh5Ov+k6ve3Xjh06ycJxqh+MT+Tr/BbfMY2wXv2p46S24iNLlVNtLj GUAaqI/TvWhiDYzY= X-Received: by 2002:a0c:c389:: with SMTP id o9mr7601388qvi.232.1576762104153; Thu, 19 Dec 2019 05:28:24 -0800 (PST) X-Google-Smtp-Source: APXvYqwM7ha9P8MMuBct7HkWloorJVvXOXiC3l+pb0wjbxcrjT+TFNJJFgaazcjfYaXTq0Nw9RFthQ== X-Received: by 2002:a0c:c389:: with SMTP id o9mr7601368qvi.232.1576762103922; Thu, 19 Dec 2019 05:28:23 -0800 (PST) Date: Thu, 19 Dec 2019 08:28:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 16/24] hmat acpi: Build Memory Side Cache Information Structure(s) Message-ID: <20191219132621.16595-17-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: RtLigwRtM9ebhVYi5uljAA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Liu Jingqi , Tao Xu , Markus Armbruster , Daniel Black , Jonathan Cameron , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Jingqi This structure describes memory side cache information for memory proximity domains if the memory side cache is present and the physical device forms the memory side cache. The software could use this information to effectively place the data in memory to maximize the performance of the system memory that use the memory side cache. Acked-by: Markus Armbruster Reviewed-by: Igor Mammedov Reviewed-by: Daniel Black Reviewed-by: Jonathan Cameron Signed-off-by: Liu Jingqi Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-7-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/hmat.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c index 4635d45dee..7c24bb5371 100644 --- a/hw/acpi/hmat.c +++ b/hw/acpi/hmat.c @@ -143,14 +143,62 @@ static void build_hmat_lb(GArray *table_data, HMAT_LB= _Info *hmat_lb, g_free(entry_list); } =20 +/* ACPI 6.3: 5.2.27.5 Memory Side Cache Information Structure: Table 5-147= */ +static void build_hmat_cache(GArray *table_data, uint8_t total_levels, + NumaHmatCacheOptions *hmat_cache) +{ + /* + * Cache Attributes: Bits [3:0] =E2=80=93 Total Cache Levels + * for this Memory Proximity Domain + */ + uint32_t cache_attr =3D total_levels; + + /* Bits [7:4] : Cache Level described in this structure */ + cache_attr |=3D (uint32_t) hmat_cache->level << 4; + + /* Bits [11:8] - Cache Associativity */ + cache_attr |=3D (uint32_t) hmat_cache->associativity << 8; + + /* Bits [15:12] - Write Policy */ + cache_attr |=3D (uint32_t) hmat_cache->policy << 12; + + /* Bits [31:16] - Cache Line size in bytes */ + cache_attr |=3D (uint32_t) hmat_cache->line << 16; + + /* Type */ + build_append_int_noprefix(table_data, 2, 2); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); + /* Length */ + build_append_int_noprefix(table_data, 32, 4); + /* Proximity Domain for the Memory */ + build_append_int_noprefix(table_data, hmat_cache->node_id, 4); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); + /* Memory Side Cache Size */ + build_append_int_noprefix(table_data, hmat_cache->size, 8); + /* Cache Attributes */ + build_append_int_noprefix(table_data, cache_attr, 4); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 2); + /* + * Number of SMBIOS handles (n) + * Linux kernel uses Memory Side Cache Information Structure + * without SMBIOS entries for now, so set Number of SMBIOS handles + * as 0. + */ + build_append_int_noprefix(table_data, 0, 2); +} + /* Build HMAT sub table structures */ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_s= tate) { uint16_t flags; uint32_t num_initiator =3D 0; uint32_t initiator_list[MAX_NODES]; - int i, hierarchy, type; + int i, hierarchy, type, cache_level, total_levels; HMAT_LB_Info *hmat_lb; + NumaHmatCacheOptions *hmat_cache; =20 for (i =3D 0; i < numa_state->num_nodes; i++) { flags =3D 0; @@ -184,6 +232,25 @@ static void hmat_build_table_structs(GArray *table_dat= a, NumaState *numa_state) } } } + + /* + * ACPI 6.3: 5.2.27.5 Memory Side Cache Information Structure: + * Table 5-147 + */ + for (i =3D 0; i < numa_state->num_nodes; i++) { + total_levels =3D 0; + for (cache_level =3D 1; cache_level < HMAT_LB_LEVELS; cache_level+= +) { + if (numa_state->hmat_cache[i][cache_level]) { + total_levels++; + } + } + for (cache_level =3D 0; cache_level <=3D total_levels; cache_level= ++) { + hmat_cache =3D numa_state->hmat_cache[i][cache_level]; + if (hmat_cache) { + build_hmat_cache(table_data, total_levels, hmat_cache); + } + } + } } =20 void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_st= ate) --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762868; cv=none; d=zohomail.com; s=zohoarc; b=i3SYwIWU61RAkHPtdYp7koPnSx/rvX6nrYsweDzjFxlev4yX0L6ILgL7TC2sCciCDCjYShwAJxGwoUqSLLo8QHJhd7fPrK1em+BQiz+kXMLZRAmrONX1ZFzinyWsUc9rVCCR+IdSaL2m2J/OlQ2mfaSYDqOTmf3NVIY/QdUpTDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762868; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Cp6Js316PIXYZH4FnO2Nl29XN8Dewk3Zb8G0nu+p7nE=; b=b4Yry5oj2oRVQqNYj7AvaZMggbpfj8FRuTM6LCTrIOJtGv+tBMkOxIL8oieG5tfPuKAwjTPFdokCBHtE7ejIfR3SbpXaIrDQ2fiH8S9rs7waziXVvWsjPM8L/LM7bFUlWANi7qAJqr88n4JqZGa1nXNhLsIK47Zq6F8uiO2JPO0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762868553543.176195304325; Thu, 19 Dec 2019 05:41:08 -0800 (PST) Received: from localhost ([::1]:41676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihw39-0001w9-1H for importer@patchew.org; Thu, 19 Dec 2019 08:41:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57972) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvr2-0002dk-5h for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvr0-0008U8-0V for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:35 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:36461 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvqz-0008Ps-Mp for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:33 -0500 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-122-NFWyS1fMNcGLWQZvXnldBg-1; Thu, 19 Dec 2019 08:28:31 -0500 Received: by mail-qk1-f200.google.com with SMTP id j16so3608932qkk.17 for ; Thu, 19 Dec 2019 05:28:31 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id h32sm1913588qth.2.2019.12.19.05.28.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:28:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762113; h=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=Cp6Js316PIXYZH4FnO2Nl29XN8Dewk3Zb8G0nu+p7nE=; b=YGktv4R6jMwmbNkCW6kQfRu+Gh53nxMwh4oXnNsXQKC36sd214mfUcOCeT50n2NZRHxfmN FWJ+SWbbLXBbg5D7Cy4GtmrSna4GqqvRAA0Bg+3hvzOsd7OD44PncMPAHgZol6vdH76e+I uDCBOnXbfHKKnN6actr+caBxZxu9hjI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=5G41uwHBTYAB+Ul1VVsmoX3H1jPszYS18zVu3nGvXFk=; b=hQ1EpsEkhZAz39XxTPsLRKJFZ2K9+/QOsiobep5LP4vNkD9wAOYq2KJuKoAGaIIQpW w2iASzP8WW+PiP1kO1lAOVZpRJuN6TtoA3cdXzU+/Qz631i9J6APyPokWmDyW5nRxS/Z b3tZ50S8fu5fSpV7SHx2cZLdYC6UssESKizQgPlH5d8RWtacWK9qJtCf65FT9U3q3P4X LFMl4nFbGgj034NQirT2/qNr1JQ6wLrw2p0ruJ+rgiATonwRLm4lfTfFVOmJZTylnpNd 7uLmnNmEUbrLP2+pMH9cyF+E50aPlffWQqPCH4amQXUwBgkR6CY8IGz4ZngibsM3UUnb rk8w== X-Gm-Message-State: APjAAAU/+zy25lyViYbpiwC01WuuwRVFSUfGYGWqEueR190bAEIW7169 WjPXfaxnKiRwocPwAYVA3Bxqssj3Avm6Udsbw2yAkRiR36ycMb4aEgnUWM44FEGNyAeVZnWtwuy nKGNoyHA6MxZyiQk= X-Received: by 2002:ac8:22fd:: with SMTP id g58mr6758384qta.125.1576762110227; Thu, 19 Dec 2019 05:28:30 -0800 (PST) X-Google-Smtp-Source: APXvYqxgoGDOrdetfJSn2abn5dUr9eE2UOH80FFP6ZIAZayD1anYYmu3ugbHrBrhszKyqhsMhSycag== X-Received: by 2002:ac8:22fd:: with SMTP id g58mr6758349qta.125.1576762109809; Thu, 19 Dec 2019 05:28:29 -0800 (PST) Date: Thu, 19 Dec 2019 08:28:24 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 17/24] tests/numa: Add case for QMP build HMAT Message-ID: <20191219132621.16595-18-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: NFWyS1fMNcGLWQZvXnldBg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Tao Xu , Markus Armbruster , Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tao Xu Check configuring HMAT usecase Acked-by: Markus Armbruster Suggested-by: Igor Mammedov Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-8-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- tests/numa-test.c | 213 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 213 insertions(+) diff --git a/tests/numa-test.c b/tests/numa-test.c index 8de8581231..17dd807d2a 100644 --- a/tests/numa-test.c +++ b/tests/numa-test.c @@ -327,6 +327,216 @@ static void pc_dynamic_cpu_cfg(const void *data) qtest_quit(qs); } =20 +static void pc_hmat_build_cfg(const void *data) +{ + QTestState *qs =3D qtest_initf("%s -nodefaults --preconfig -machine hm= at=3Don " + "-smp 2,sockets=3D2 " + "-m 128M,slots=3D2,maxmem=3D1G " + "-object memory-backend-ram,size=3D64M,id=3Dm0 " + "-object memory-backend-ram,size=3D64M,id=3Dm1 " + "-numa node,nodeid=3D0,memdev=3Dm0 " + "-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D1", + data ? (char *)data : ""); + + /* Fail: Initiator should be less than the number of nodes */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 2, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); + + /* Fail: Target should be less than the number of nodes */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 2," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); + + /* Fail: Initiator should contain cpu */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 1, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); + + /* Fail: Data-type mismatch */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"write-latency\"," + " 'bandwidth': 524288000 } }"))); + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"read-bandwidth\"," + " 'latency': 5 } }"))); + + /* Fail: Bandwidth should be 1MB (1048576) aligned */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 1048575 } }"))); + + /* Configuring HMAT bandwidth and latency details */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 1 } }"))); /* 1 ns */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 5 } }"))); /* Fail: Duplicate configuration */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 68717379584 } }"))); /* 65534 MB/s */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 65534 } }"))); /* 65534 ns */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 34358689792 } }"))); /* 32767 MB/s */ + + /* Fail: node_id should be less than the number of nodes */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 2, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* Fail: level should be less than HMAT_LB_LEVELS (4) */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 4, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* Fail: associativity option should be 'none', if level is 0 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 0, 'associativity': \"direct\", 'policy': \"none\"," + " 'line': 0 } }"))); + /* Fail: policy option should be 'none', if level is 0 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 0, 'associativity': \"none\", 'policy': \"write-back\"," + " 'line': 0 } }"))); + /* Fail: line option should be 0, if level is 0 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 0, 'associativity': \"none\", 'policy': \"none\"," + " 'line': 8 } }"))); + + /* Configuring HMAT memory side cache attributes */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); /* Fail: Duplicate configuration */ + /* Fail: The size of level 2 size should be small than level 1 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 2, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + /* Fail: The size of level 0 size should be larger than level 1 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 0, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 1, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* let machine initialization to complete and run */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, + "{ 'execute': 'x-exit-preconfig' }"))); + qtest_qmp_eventwait(qs, "RESUME"); + + qtest_quit(qs); +} + +static void pc_hmat_off_cfg(const void *data) +{ + QTestState *qs =3D qtest_initf("%s -nodefaults --preconfig " + "-smp 2,sockets=3D2 " + "-m 128M,slots=3D2,maxmem=3D1G " + "-object memory-backend-ram,size=3D64M,id=3Dm0 " + "-object memory-backend-ram,size=3D64M,id=3Dm1 " + "-numa node,nodeid=3D0,memdev=3Dm0", + data ? (char *)data : ""); + + /* + * Fail: Enable HMAT with -machine hmat=3Don + * before using any of hmat specific options + */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'node', 'nodeid': 1, 'memdev': \"m1\"," + " 'initiator': 0 } }"))); + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'node', 'nodeid': 1, 'memdev': \"m1\" } }= "))); + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 1 } }"))); + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* let machine initialization to complete and run */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, + "{ 'execute': 'x-exit-preconfig' }"))); + qtest_qmp_eventwait(qs, "RESUME"); + + qtest_quit(qs); +} + +static void pc_hmat_erange_cfg(const void *data) +{ + QTestState *qs =3D qtest_initf("%s -nodefaults --preconfig -machine hm= at=3Don " + "-smp 2,sockets=3D2 " + "-m 128M,slots=3D2,maxmem=3D1G " + "-object memory-backend-ram,size=3D64M,id=3Dm0 " + "-object memory-backend-ram,size=3D64M,id=3Dm1 " + "-numa node,nodeid=3D0,memdev=3Dm0 " + "-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D1", + data ? (char *)data : ""); + + /* Can't store the compressed latency */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 1 } }"))); /* 1 ns */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 65535 } }"))); /* 65535 ns */ + + /* Test the 0 input (bandwidth not provided) */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 0 } }"))); /* 0 MB/s */ + /* Fail: bandwidth should be provided before memory side cache attribu= tes */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* Can't store the compressed bandwidth */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 68718428160 } }"))); /* 65535 MB/s */ + + /* let machine initialization to complete and run */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, + "{ 'execute': 'x-exit-preconfig' }"))); + qtest_qmp_eventwait(qs, "RESUME"); + + qtest_quit(qs); +} + int main(int argc, char **argv) { const char *args =3D NULL; @@ -346,6 +556,9 @@ int main(int argc, char **argv) if (!strcmp(arch, "i386") || !strcmp(arch, "x86_64")) { qtest_add_data_func("/numa/pc/cpu/explicit", args, pc_numa_cpu); qtest_add_data_func("/numa/pc/dynamic/cpu", args, pc_dynamic_cpu_c= fg); + qtest_add_data_func("/numa/pc/hmat/build", args, pc_hmat_build_cfg= ); + qtest_add_data_func("/numa/pc/hmat/off", args, pc_hmat_off_cfg); + qtest_add_data_func("/numa/pc/hmat/erange", args, pc_hmat_erange_c= fg); } =20 if (!strcmp(arch, "ppc64")) { --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762748; cv=none; d=zohomail.com; s=zohoarc; b=VZ/uutvwHMjx7Y3gQtPu4VeN0Za4wRCkldJGbvrojCkEam6MYwnsSl9y/DxJI3eO6ces4zIEMlBFtHauvFhMpaXZoyqXdFhamd1fkHSvMVIk6Enuhm+W3SIGsLXWoHZLmDlfteidgUrdCMe5TY+txaQQxq2F3GYOpgwwByl/nls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762748; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r0mT2tK5RxGEzjJ+ngzjeka5vepbie8k6lkBxlC/UtY=; b=QbgxttI60RoQ/jsQd2qFTiDpUwX4jp1YBiGYb0hPVPI11resvyiZGAh0j7fH16jFYzky6HNpfIxuNCA2Ym31J8J+nn1E3sHfUFcFZe7h76R8fD8aELrZAnAtj9smqPGfFWdBoZm1wQL62cCK1kEvCjR+yCkCiKryS05OimMXsqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762748693603.7919911642002; Thu, 19 Dec 2019 05:39:08 -0800 (PST) Received: from localhost ([::1]:41648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihw1C-0007ss-St for importer@patchew.org; Thu, 19 Dec 2019 08:39:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58463) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvr9-0002og-NM for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvr7-0000aO-V7 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:43 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56788 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvr6-0000YP-4l for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:41 -0500 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-360-pEjLrW1EMDyHXkm2niicfw-1; Thu, 19 Dec 2019 08:28:38 -0500 Received: by mail-qt1-f198.google.com with SMTP id c8so3632851qte.22 for ; Thu, 19 Dec 2019 05:28:38 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id k29sm1850888qtu.54.2019.12.19.05.28.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:28:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762119; h=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=r0mT2tK5RxGEzjJ+ngzjeka5vepbie8k6lkBxlC/UtY=; b=E6dsUfRNvuiYdk8MZk8/HV4Fw25umQEzUcr1yAIAf81HS52QXCf7S7WjEOxgL+uRsumQAQ OVezsJwIsOo9Jok5DuQSfEuWH0ZZqBBjG8beKpwOM+GY4q0LGQ28us3TmQqRpsE0CS2Alg UCcQ58M3wbKYmLUOgz37wH1lINx3CqQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kqRad/Uza3VmDCeEjm17UGUfOA6jrRJCCY76mhTVGsg=; b=qXrT4+G8VcaOWGBl2jK3SeRx/qklqbTr8wb5kEGt38mhWj70yx9haaWInyuzLNL2M2 +OjsiX6rHQ8onM08a0+e2vqVkNiYfyuJH7BGJ403JXAZW5o/0bJAato5CDmX6vPQqxEZ KqE4bV/OhCDkKhVFvw+iJKDz/P4tnmplPG97yHPyehiEfluH0WkadoDeOpygSdxs50gc HDOSocun9DoFdnUgKTZJhLFjxEAoVtygREetN9F/qxjofX5sDaSGlIUi49y//+4dvfbZ brTPeLLr+/EiAgFbMTec/kYuOZIfsFfC4ezo05WMnFGVxMzvLHN3ryWWPLzFYuneCJb9 BLmQ== X-Gm-Message-State: APjAAAVyRHKlDl1ZuhweHGWMpjrcmHI4xAJaFjHdXxTU0F0xRYI1Ecnt 6HtdO7/MaSZgs4khFMrKYPWfp52HlhNcj12TRNKc3IP69nRfRe6yERNAkUWWUrvB8fz4CV/2grY i48toiyYcbYhta4o= X-Received: by 2002:a0c:aacb:: with SMTP id g11mr6965116qvb.108.1576762116200; Thu, 19 Dec 2019 05:28:36 -0800 (PST) X-Google-Smtp-Source: APXvYqwAlgrKjMuQlAI2TIpLXu6O0vFUs6YjB4OjkGmfrytnPJbZYdGoJ4UnJCTOjAq3yL/4tWXNaA== X-Received: by 2002:a0c:aacb:: with SMTP id g11mr6965088qvb.108.1576762115931; Thu, 19 Dec 2019 05:28:35 -0800 (PST) Date: Thu, 19 Dec 2019 08:28:30 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 18/24] tests/bios-tables-test: add test cases for ACPI HMAT Message-ID: <20191219132621.16595-19-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: pEjLrW1EMDyHXkm2niicfw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Jingqi Liu , Tao Xu , Markus Armbruster , Daniel Black , Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tao Xu ACPI table HMAT has been introduced, QEMU now builds HMAT tables for Heterogeneous Memory with boot option '-numa node'. Add test cases on PC and Q35 machines with 2 numa nodes. Because HMAT is generated when system enable numa, the following tables need to be added for this test: tests/data/acpi/pc/APIC.acpihmat tests/data/acpi/pc/SRAT.acpihmat tests/data/acpi/pc/HMAT.acpihmat tests/data/acpi/pc/DSDT.acpihmat tests/data/acpi/q35/APIC.acpihmat tests/data/acpi/q35/SRAT.acpihmat tests/data/acpi/q35/HMAT.acpihmat tests/data/acpi/q35/DSDT.acpihmat Acked-by: Markus Armbruster Reviewed-by: Igor Mammedov Reviewed-by: Daniel Black Reviewed-by: Jingqi Liu Suggested-by: Igor Mammedov Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-9-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/bios-tables-test-allowed-diff.h | 8 +++++ tests/bios-tables-test.c | 44 +++++++++++++++++++++++++++ tests/data/acpi/pc/APIC.acpihmat | 0 tests/data/acpi/pc/DSDT.acpihmat | 0 tests/data/acpi/pc/HMAT.acpihmat | 0 tests/data/acpi/pc/SRAT.acpihmat | 0 tests/data/acpi/q35/APIC.acpihmat | 0 tests/data/acpi/q35/DSDT.acpihmat | 0 tests/data/acpi/q35/HMAT.acpihmat | 0 tests/data/acpi/q35/SRAT.acpihmat | 0 10 files changed, 52 insertions(+) create mode 100644 tests/data/acpi/pc/APIC.acpihmat create mode 100644 tests/data/acpi/pc/DSDT.acpihmat create mode 100644 tests/data/acpi/pc/HMAT.acpihmat create mode 100644 tests/data/acpi/pc/SRAT.acpihmat create mode 100644 tests/data/acpi/q35/APIC.acpihmat create mode 100644 tests/data/acpi/q35/DSDT.acpihmat create mode 100644 tests/data/acpi/q35/HMAT.acpihmat create mode 100644 tests/data/acpi/q35/SRAT.acpihmat diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test= -allowed-diff.h index dfb8523c8b..3c9e0c979b 100644 --- a/tests/bios-tables-test-allowed-diff.h +++ b/tests/bios-tables-test-allowed-diff.h @@ -1 +1,9 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/APIC.acpihmat", +"tests/data/acpi/pc/SRAT.acpihmat", +"tests/data/acpi/pc/HMAT.acpihmat", +"tests/data/acpi/pc/DSDT.acpihmat", +"tests/data/acpi/q35/APIC.acpihmat", +"tests/data/acpi/q35/SRAT.acpihmat", +"tests/data/acpi/q35/HMAT.acpihmat", +"tests/data/acpi/q35/DSDT.acpihmat", diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 79f5da092f..9823820043 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -947,6 +947,48 @@ static void test_acpi_virt_tcg_numamem(void) =20 } =20 +static void test_acpi_tcg_acpi_hmat(const char *machine) +{ + test_data data; + + memset(&data, 0, sizeof(data)); + data.machine =3D machine; + data.variant =3D ".acpihmat"; + test_acpi_one(" -machine hmat=3Don" + " -smp 2,sockets=3D2" + " -m 128M,slots=3D2,maxmem=3D1G" + " -object memory-backend-ram,size=3D64M,id=3Dm0" + " -object memory-backend-ram,size=3D64M,id=3Dm1" + " -numa node,nodeid=3D0,memdev=3Dm0" + " -numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0" + " -numa cpu,node-id=3D0,socket-id=3D0" + " -numa cpu,node-id=3D0,socket-id=3D1" + " -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D1" + " -numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D65534M" + " -numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmem= ory," + "data-type=3Daccess-latency,latency=3D65534" + " -numa hmat-lb,initiator=3D0,target=3D1,hierarchy=3Dmem= ory," + "data-type=3Daccess-bandwidth,bandwidth=3D32767M" + " -numa hmat-cache,node-id=3D0,size=3D10K,level=3D1," + "associativity=3Ddirect,policy=3Dwrite-back,line=3D8" + " -numa hmat-cache,node-id=3D1,size=3D10K,level=3D1," + "associativity=3Ddirect,policy=3Dwrite-back,line=3D8", + &data); + free_test_data(&data); +} + +static void test_acpi_q35_tcg_acpi_hmat(void) +{ + test_acpi_tcg_acpi_hmat(MACHINE_Q35); +} + +static void test_acpi_piix4_tcg_acpi_hmat(void) +{ + test_acpi_tcg_acpi_hmat(MACHINE_PC); +} + static void test_acpi_virt_tcg(void) { test_data data =3D { @@ -991,6 +1033,8 @@ int main(int argc, char *argv[]) qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem); qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm); qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm); + qtest_add_func("acpi/piix4/acpihmat", test_acpi_piix4_tcg_acpi_hma= t); + qtest_add_func("acpi/q35/acpihmat", test_acpi_q35_tcg_acpi_hmat); } else if (strcmp(arch, "aarch64") =3D=3D 0) { qtest_add_func("acpi/virt", test_acpi_virt_tcg); qtest_add_func("acpi/virt/numamem", test_acpi_virt_tcg_numamem); diff --git a/tests/data/acpi/pc/APIC.acpihmat b/tests/data/acpi/pc/APIC.acp= ihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/pc/DSDT.acpihmat b/tests/data/acpi/pc/DSDT.acp= ihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/pc/HMAT.acpihmat b/tests/data/acpi/pc/HMAT.acp= ihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/pc/SRAT.acpihmat b/tests/data/acpi/pc/SRAT.acp= ihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/APIC.acpihmat b/tests/data/acpi/q35/APIC.a= cpihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/DSDT.acpihmat b/tests/data/acpi/q35/DSDT.a= cpihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/HMAT.acpihmat b/tests/data/acpi/q35/HMAT.a= cpihmat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/SRAT.acpihmat b/tests/data/acpi/q35/SRAT.a= cpihmat new file mode 100644 index 0000000000..e69de29bb2 --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762927; cv=none; d=zohomail.com; s=zohoarc; b=ACNUIU+N3Z2Pu5zyAE+YMfXsIJd5YszEEfvdHnbZWUoxbsTNOfZE8Vfz89T9m4UCLrC3SMgFkuwF+O1nlkdjPtWQ/IhZCz8UNg4BK7t8N3MjM2T59J/iVPvNCZwfAluRH5g1cZkZkBa1f9Xv8sW69/vp6A1T6ALg1P/Su7a6pbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762927; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KK1l/PHjlNOm2EdO0lI4ftoCkLwZHJNbAAGaDddroN4=; b=PTBm6dhuwcjkDLGfNtFNkjer/fF+poDKAisyHs/HhzKunC2fDTpqN1+GSk/nBwbP5nJZy77MHyY4wyXJx9flHm00I7BVQ1SlHlDzndm6ikW5vocT0kPXBRyYXPyO5EyvQbT5a0XCIplQAsWpcNtRn3Ttp4qWIdJ/QAU/2Ev8N+A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762927396265.629427659464; Thu, 19 Dec 2019 05:42:07 -0800 (PST) Received: from localhost ([::1]:41696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihw43-0003FJ-Qj for importer@patchew.org; Thu, 19 Dec 2019 08:42:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58827) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvrE-00030Q-I2 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvrB-0000hO-Qj for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:48 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:41938 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvrB-0000ex-Hp for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:45 -0500 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-317-fjm1Hp85N0CIZrElBZlWBA-1; Thu, 19 Dec 2019 08:28:42 -0500 Received: by mail-qv1-f70.google.com with SMTP id f16so3639664qvr.7 for ; Thu, 19 Dec 2019 05:28:42 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id q131sm1745388qke.1.2019.12.19.05.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:28:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762123; h=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=KK1l/PHjlNOm2EdO0lI4ftoCkLwZHJNbAAGaDddroN4=; b=RRCaR+yKnB5PLab/AcgjFEVti2CsXnpmUS5/DHoC46el3bvxotNJgxV+SSsd7kgIr3sOpy 4Rtv5TEi0ew/cwdd184nzZmsfNv7xrdzJCyRP3mUbXal9IFZxn8WvDw+ngo3oI3kknhck5 STcCEbmn66ZBnpWpfM2NFgL8l74VOYA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WHf91FL9X6R/LHFT3E8dg17f/3EsgQa7B7wKa5HVzBM=; b=BxF3vaXtGqX6GY71hvkuoMJ2Z3OvWs81E/O14DBORBZ0OYDELeU0IqdK+2I/HsYODE 9Phr8d+AUoET83EhPQZAJaaV5rbeN6qVgUiOpsUhoizi0pVOOZu1+u+GRoshWK3PqLVk WA2t2RLkdaw7oyQPzlELzNZyziG0GWpW4RDy1qZN+nzxoCe3x9iqqDXUDBamRR1pki4O CyxMzvnnFb3LYuU/OnZypjQta8HhbzB3PFbP7hFLc2A/xBsIX1ZuV9stuQ+z6HnrEZ6y zjaMUbsUPr2weN4HNLxbvTDzfsvX5fl/dzLNst7HBE5u7XJWBYQrsesq0rC6F0oX+348 7uLw== X-Gm-Message-State: APjAAAXwzNxAyb05dGYbT7TQ4KVwgHSQMnTAueSiTh9AIbZPqQC1Cfbp Nt+Y/6kdta5GRTsYb38CeC7UQfJcMOkXdr6DzZYsii72LWA/cXPKsYMzPyvwQHC0ul/Wfdl763o G7l7w49aJU5vGoes= X-Received: by 2002:a37:e55:: with SMTP id 82mr8252027qko.370.1576762121502; Thu, 19 Dec 2019 05:28:41 -0800 (PST) X-Google-Smtp-Source: APXvYqyDAi7wF4+qFB3EZzCfFEBb/XB6oTBV42cxqvsmMPxvgi8x/74i1fjvvmsZQYi4iW6UAO5hQg== X-Received: by 2002:a37:e55:: with SMTP id 82mr8251971qko.370.1576762120845; Thu, 19 Dec 2019 05:28:40 -0800 (PST) Date: Thu, 19 Dec 2019 08:28:36 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 19/24] ACPI: add expected files for HMAT tests (acpihmat) Message-ID: <20191219132621.16595-20-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: fjm1Hp85N0CIZrElBZlWBA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann , Shameer Kolothum , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michael S. Tsirkin --- tests/bios-tables-test-allowed-diff.h | 8 -------- tests/data/acpi/pc/APIC.acpihmat | Bin 0 -> 128 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 0 -> 6455 bytes tests/data/acpi/pc/HMAT.acpihmat | Bin 0 -> 280 bytes tests/data/acpi/pc/SRAT.acpihmat | Bin 0 -> 280 bytes tests/data/acpi/q35/APIC.acpihmat | Bin 0 -> 128 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 0 -> 9203 bytes tests/data/acpi/q35/HMAT.acpihmat | Bin 0 -> 280 bytes tests/data/acpi/q35/SRAT.acpihmat | Bin 0 -> 280 bytes 9 files changed, 8 deletions(-) diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test= -allowed-diff.h index 3c9e0c979b..dfb8523c8b 100644 --- a/tests/bios-tables-test-allowed-diff.h +++ b/tests/bios-tables-test-allowed-diff.h @@ -1,9 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/APIC.acpihmat", -"tests/data/acpi/pc/SRAT.acpihmat", -"tests/data/acpi/pc/HMAT.acpihmat", -"tests/data/acpi/pc/DSDT.acpihmat", -"tests/data/acpi/q35/APIC.acpihmat", -"tests/data/acpi/q35/SRAT.acpihmat", -"tests/data/acpi/q35/HMAT.acpihmat", -"tests/data/acpi/q35/DSDT.acpihmat", diff --git a/tests/data/acpi/pc/APIC.acpihmat b/tests/data/acpi/pc/APIC.acp= ihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a21f164699bfccd8992ea1bdb57= 17f2dc3025496 100644 GIT binary patch literal 128 zcmZ<^@N{lqU|?Xp<>c?|5v<@85#a0y6k`O6f!H9Lf#JbFFwFr}2jX%tGJA8l)n3DUlYJT5~Da#Tw;OmQgB5 z;e`?xQH-Fp0w_-I0@g(f^nx~cZ9hWu2zi9`6;d?uRn+h7awwY80?9=3DQh?+C!o9~>N zIp@p_4clm3JxpZZtF6 zQqyh}m`6RXM_sK?U7@Go8VvOxF_0>z{4Y}*=3Dowjb~^1iRBDC2O&%H{P469?*Yd<3S)Dt4h6;IOcSyOPx- z!WD4$wLe@U78=3DP|`7%3EwMsS4-eFO_K#izg#6ML(cR4Bz6PvU5R=3DuHvG+44E7K{9y z6ECfDk9kauEHJ*xci0Y#Ozbje@9J977{a4bE#a@qaH9S|m${5%)E3*q|Ah$V>+HR5 zu5SznPS1`HR78A%sRS%2D~3MY#1jLL=3DEdA9|33PCl*Ly0kI^5oPz%fKV$A2xtyHao z-0T&jGLuo6h>LZR<>Hx$h*$A9Bj&|{_)z>HriG$3SBz5nl+Y*)M?Vn=3D&ffb~t1uE{d-UPP0&mPByb5_OVD*q(BW%2Nc(JOlG3`}LFI|f`=3DSey^@YH<&jQ>9`(iJt-z0wM57Jv?U^J)4RXZ+GHZiZuivg zZGaL;n`&*%U|YQl-P^pE?zTj1*ln||$CE>;08qMnTSSIE#X(PW*rT&8@3Y-ap)w>c zd$`4zcfSRD54Sk;wjR1IcCXcUod*{#N6A~t70Nbl)vsq2eC6nCk-qYZHe0!lRqZA2 zi%uI!pXiIEwp6*U*AoELv*{_3{BnXN{9xN>e`_EP71Ng*)#Txr%OxH~VrDldeQQa<8Ge8=3DJMn+3DE47N^G3vzH=3DWh8`3cdvXO%`;klFjC_}?-2FHc0qdkOl%cqf+NSnr(A-=3D_dWw&8kU!5Ae#H60Rg?h_=3DNlq`P6jF9mmnKqB)ShY&cQg#u0?%&`j zQ7BN5I`NVGHp^B}!6vPml`UkK;4co4N%PL1?(Xbn+DFnnxbOw}EpV#LQGS;#I_{Ye zbGVO{g3JVSP@2b>jf!bzw(k6Sn~H{F8nwEJI1et3EHwE)Jt(s(vC}! zP9%M zs8J=3D79qOhAjU~ZX)99Y|i26vsLo)X}(|#xac-TX&D(R{{<3yLb5kU3)V)~po`^Blz zDbrMGnlwd!dig~mK;Oii(44~9LGvUWYI z9!00zR9E{I0;>@_0@|ja^FE-c3n;Y(#Az1y;TN|PVS?}tAV}K@)5_wVL)n@A1f^zp z@^|E&fr5hckg4+YDW(Q8)tEl{?8|AYKvD9JMAQw8pprsv_&o!2c#{mw<^Hecw6i8M zV{lN@GzSMYnmDKrt65%FGb%2WlInVl3Z1_cgBt)!nD#CzUyjj9F?_uSPmPfdORxE* z`~`%nYeDs*OMFo3mWBA|!$}swQ=3DbBgzVKFko_e0*3i^4FXFo#yJT;Uj{qXzGXiy3S zBVEAh6Jfq4DE5pg2M7Q9DbRfL!;#$mhG2-}-_m1q$81!w)DkM~dLM1B#FK{3k23?Y@DG5!5LM7{@gieM*uS(V_37ras zN>;q117D}ZpzlalRYKKJsANq`XgUn~u4J8&(3w!EWSy1J*)V89vLf<>X=3D$NQ$@-Fn zz7z&6O4gGSdNLF$Sx-smsW7N6S?45lE)*(RPfO_OFsLC}&q(N*P^e^`m(ckzXi2i3 zmC&=3DHP|5nTguWaGU6HJ>Na!n}P|12uLeCus)ynh6jannpOWkkdA+k@kZrc}B2&iU( zkRd^8mLZ@b1)2^Cq?x?mPU01_Z=3DMiD(R;0w^3bjitO7+I4R>CfqbaPX|iu4b)+6IEy#y@m1HD=3D)MtG8P`^wv!ddD& zzI>?nXNek Qg_O1sXWa%LGz<~_AAR>eTL1t6 literal 0 HcmV?d00001 diff --git a/tests/data/acpi/pc/HMAT.acpihmat b/tests/data/acpi/pc/HMAT.acp= ihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c00f7ba6cd0acecbc4b158f430d= 29b2f32988522 100644 GIT binary patch literal 280 zcmeb9bqtYUWME*L;pFe^5v<@85#a0r6axw|fY=3D}!1~h;SWIjwBokmuNOFc;30ICth zW`eR`Fhdzga*PcB{=3D?M+<&o8c*vJ6H|M&lYJ;*!-WC@U?fIv`?15Cr@;rh|!0TAyG A0RR91 literal 0 HcmV?d00001 diff --git a/tests/data/acpi/pc/SRAT.acpihmat b/tests/data/acpi/pc/SRAT.acp= ihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1dcae90aec688e88f9d212e632f= aaaaf2e0dc7bc 100644 GIT binary patch literal 280 zcmWFzatx7RWME)C;N1+c3F q8VCj-m|+T0)xmizPc?|5v<@85#a0y6k`O6f!H9Lf#JbFFwFr}2jX%tGJl1TZsreZQ3+HD9Lq;HVsVfQY0;|Op$crfCjjB<5o&q zWT7}k(jb7O0QuoVfrNF?-snJw-g@gb{u6R*fS!8oH7Md!)c4Ko$TLd{h!53)oNxBM z@0+(fGjFv^zvFkmxxkneRIYmUPO);m<@xBd7-Q6?Z>N#D!FqdsrPjA{sf^Xz&xtlZ zDz^KqU%6JZ{<0l@9)@>53ay(FyY+>0@7B%egO9^oj6iSSia4i+v%&kFO22pD@s`&p z+5LLM&zHaAw%zw+D{c47ew*3-YYpFWo0I*k9WQhD4d(f;tPD3N2HS;s?(~9xt$n+^ zboujF?vx+=3D>Yu;4`v%Vdu!?UR-)j+lgztrXIUG8l4R);ei7t+<4Cg-^h{Lkap(9a9 zJ@@mni&Cu|zTpJ69Bb9Cx2jz=3DRtqD<*l<4Tt!}{bjD7W8j%9lL4#o2?S2z7)tL^uT z?xlXGTV@gUgb{V!{A0+SaG3ve5VAp-J32aK!XDpf7<-pFmnWa6;m~Qr>B}}c<-Ryo7{D?H(`vN0Qat4O-d+<|Fva(Hs<(fJ z+RVEel+(<@R|Q|qR@YAnR5is92z3gmD)Y+KP0Op`quIiTbNTcOX;qP`^$wnEcRdu9 z*DQx?L?d0~r)pNjBIcydGplCpvR#(SzRP+CKijDI$MAI8of7BcSfU_?EMyi~ud&zg zeLe-Hy@RKNtJjW+v-3%!%_q(?hk!3Z%P}y++(miDY5d_Zi?e*l?q`k*I()ijy_0?? zZQJMfM4@U1=3DVV1Gny}(o7pI{Ua#EUy>4#}%pLax>bxO0ENW)WVICM@=3D%#(VULLM7=3D z>{i2DXKucaZ!6lS$obQ&7F`0z`;S;It#-FHxAE5ATrPvz!?Ue?l6%tcb!MvAPktZXV3Yw8jHF$)&&Iv>3gkUP@gk-A0Bh+N>GQXlHuL&^cx5M5ycJhE8tiN=3D+lozsTSX;UXcUFVFUbH>m)W9mex>zp-o z&Kf#rO`QmJosOZ?F?2enPK3J7f}yiu=3Dq#8z5$ZbU44rd^&N)*jLS5&)p>y8QIdAGj zsOxkMovxwNHFYA?b)GVGo-%ZvGIb)7Yv;XrcQ*q&eMj@(}vE|rcQ*q&P7A# zqM>uq)QM2nc}6hH@lJR~Fe~w9cSbV3M#1vZ4{0T6amW0AdNs3g@H<(up|rjI|8U2GbN!aB&L!E1C>~1pc<46 zR6+%l3=3D|$|V8TE(C>f}P3MLsSLZuT1DzSnI1J$5ppb{#WWS|I@P8g`f z3MLFxgOY(ts9=3D(TB2+qIpb{&XFi;Ij1}dR~Nd}5g>4bqwtYE@GH7FUVgbF4ZC_<$Z z1}d?F2?N!jWS|l%m}H;`l};F_#0n-1RD+U%N~mCxfg)5oVW1K#m@rTcN(L&Sf=3DLF7 zQ0at$N~~bQKs6{CsDuh887M-f69y`=3Df(ZlFpk$yDDwt%T2$fD4sKg2;3{-=3DXfl8=3Dg zl7S*rI$@v^E0{1)4N3+op@K;Uicsl$|V8TE( zC>f}P3MLsSLZuT1DzSnI1J$5ppb{#WWS|I@P8g`f3MLFxgOY(ts9=3D(TB2+qIpolaB zMWh=3DjLft?SY6hw?VW1k53{+#1foe<`sK$hWYD_XvjY$ToF=3D3z@69%d=3D$v`zG8K}mD zfoe<`sKz7%)tF?U8WRSJNL^hRC?Z@jaWct35#lnakeKS+!axzJa|;7Sq|PlFC_;5^ z$v_eM%stzOg|cCOApTiBq<=3D{7XX&fl+yBK2Y5Fgfo)ys32&>iJD#LNND)iyehi@}H z8`-K-d!0UN^ij9n`NmeKYYnH~<9pk92r_lZbMD2)me-yFpj|4=3D@Z2X^HboDk@SpNs z>f;mmY((#E^I1kM45E!EBh5+NBb3$u;(0typ@%g#hTSPF@cB<>*i;(s#;|`g?8M0C z&dTQ!Gz5&M>=3Dycdqr=3D{(Hs2FHv-G5c9nyeAe7fIhcdWbH@ffH)^~cpKiRyT)@V%>7 zwCWX6y@K)S)hq7!>XqI>K-#@Tb)I^R@}5@S6Xm@`dGCbsUR>T!mdE3=3D@2%d~%KM_c zpD6F2P~MNrSCi#4k5Rs=3Dm9L8O)kOK~3FWJC`SoP^iN`3vu9aUG<<}GC*H0+F9+$5r z%V!^>d`&A~6Xk1(^0gDn*W&W^WckU*C|}pg*G2hyqI~^?@^zHY&{mc#@5u6M^T2Hd zJ!TV6EzLeRE0#RIXkEwYlFOJE%yhWd7)dAl#-ro;WqNIKa!Hr>d)UNF<)re-9a>>HbIWS*Wj z)8S5MB%SOt(>XuT9?75S1eN%OM%H0i_jrwwPvhCVbLB<(9>L=3D`9z9WSwW}R9Upba3 zTx!~DT`Sh#yc7NI?cWx6Z@=3D~C+q=3DKM{TAz4UaPqg&)aFvYu4BKuk%(O55VD0u+7}p zc|7*tzd%8m6+L=3D-?=3D?0%me&qmw!G?e~v(DuTyOnf%MDWA|5z5HXC-t zs1s9v<%ST2vB>dFm%Ub_R9Y#~2;@7O33tisuD_ZZ^1(Ly&?}WnJJhtOxw7NdvmORA z)w^)xg^YTEKypdO(NVOW>_**)g~PLhA@!7EV^vIFs#$o6N6D02O3R%fi$S^j) zTc7bd-llz$3@iMioEwCA^$|uanG`2`Sj&tE5*Gz$E(ynVu%eNX0UcT4{f*49KAK8g z+VQD)dNdc{$TePQFy&qCbn_<(9ece-1`EZ}&KO-0PbGT^`g*bxr(o>pdLO(*6AUX7 zf0(P7S@t2#FHFav+%4p|&G7#}-5I(wcv;xZkr=3DkU^E%e_^?>z0*vQbd6t|8>0^F7z zC$KD$AlIkGB36u+%sNiyp2Om(wW|GUX%*L8ydI;4LK6i`XF^-wLA@on=3D;_vGt5hys z!gy(o2e*I!=3DI*=3D2?U7|JeMziu+?;Z@Nb9@a3fdN)0`SG&LAfedCNfJeNo4jLK~Q|{ z_8)d=3D)35`7vrX^zp4Uz^jfpa*gLb7^#77+;O=3D>mKYF+Oad;8Ch!I#-(9#lJhE1(G+ z(9{d6SNeDl{L~n9I-uPpxLSP~A04mg&Wro&;naY}gjaI7x$jv))7xNfIUC^Au}8XXzbmHOiLrd+G+1CIuZwOgqmZ z&8ax1J?4)C(cBC1AraODHr4xB!9bslTx^nc;BEfH{KLFu zqu-J<=3DUW_pm_LrE#T@!ZpIIC;ivAs^zZ4TkFY-VnVp8>3AMz-Z` HcG>>`zx=3DOx literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/HMAT.acpihmat b/tests/data/acpi/q35/HMAT.a= cpihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c00f7ba6cd0acecbc4b158f430d= 29b2f32988522 100644 GIT binary patch literal 280 zcmeb9bqtYUWME*L;pFe^5v<@85#a0r6axw|fY=3D}!1~h;SWIjwBokmuNOFc;30ICth zW`eR`Fhdzga*PcB{=3D?M+<&o8c*vJ6H|M&lYJ;*!-WC@U?fIv`?15Cr@;rh|!0TAyG A0RR91 literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/SRAT.acpihmat b/tests/data/acpi/q35/SRAT.a= cpihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1dcae90aec688e88f9d212e632f= aaaaf2e0dc7bc 100644 GIT binary patch literal 280 zcmWFzatx7RWME)C;N1+c3F q8VCj-m|+T0)xmizP (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576763077635457.37500351353754; Thu, 19 Dec 2019 05:44:37 -0800 (PST) Received: from localhost ([::1]:41742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihw6W-0006hT-Cy for importer@patchew.org; Thu, 19 Dec 2019 08:44:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59298) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvrI-00038B-Lv for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvrH-0001At-7m for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:52 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53709 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvrH-00018S-1O for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:51 -0500 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-329-qT_j1qUPM5aF4VeMou0eBg-1; Thu, 19 Dec 2019 08:28:46 -0500 Received: by mail-qk1-f198.google.com with SMTP id n128so3603113qke.19 for ; Thu, 19 Dec 2019 05:28:46 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id i6sm1707884qkk.7.2019.12.19.05.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:28:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762130; h=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=75DSOPWG53BQMc2DQp8pZrGaf6WLAio2xZatEQc8yH4=; b=bCw93670+cKN95kV1tGrsJIdEP+XnOy1/gNZgO9cOSY/UH93ZFIYEZxcxjyUuwfjKIsBJB JoxEkQoDOYubQikQBvpz95cdtaQ0zrx2kzsxEHyjjXFhksDrvR204bBnEPqECUXdhdYhOq FCTBgCP8nXlHy+H2+nHfsUUQ3QQJbyk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ilfUa7pwbD2DsrhFhXRw/VkM07xbn4jtSmYjKOWR/YA=; b=Ef7bBZp6vnpmW+e4AlJ9Odhx5bwo5T4ep8DpiUCufhmWyxmumdBsX9zvaSTwtkAvJ8 3vQvuc2O1ZPHcKgLxsbgcvitHSShCXF5SJV/I18efDXI60Cs0FeQKfhSSPT7CWAxDA/t jezBngeGhti46yQrrH2r2JXBFJ44vGgF8kTMsrIMvrpnuF31yzaBV8L6L7LAlyxwJtEy yjTRVyDtiki+ZO/0r6a2/DP9jKhw8HGdvOpbymskcBwhQERyS1tchci7dgu7SQl0fDB4 5OYycfGwt3yOBynx3p4kBPeSLhCnb7DZIwYY526aLFT2cMYaYn8ysnR3SzbjVyau7An2 TRPw== X-Gm-Message-State: APjAAAWSz62qSNRDQM2u4aNWjGSuqYouNZiOEMvodnT1rjG7YZ9d2ABX SlSDQ80QqTm9wKcig+1l7v7Twp4f86/bagIuAz6dByK4zeNn7ZKlfQSm64Mb5LFXR8++871GCLR bMBbzO5/Y467rjow= X-Received: by 2002:ad4:59c2:: with SMTP id el2mr7209425qvb.152.1576762125891; Thu, 19 Dec 2019 05:28:45 -0800 (PST) X-Google-Smtp-Source: APXvYqyKyddGWs+xFzcbGcIZNKYRgVlVtE005Yc3m9Xih4kCiABUio0P6iSUjYdg0PBEUcsYYfgBaw== X-Received: by 2002:ad4:59c2:: with SMTP id el2mr7209407qvb.152.1576762125640; Thu, 19 Dec 2019 05:28:45 -0800 (PST) Date: Thu, 19 Dec 2019 08:28:41 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 20/24] virtio-mmio: Clear v2 transport state on soft reset Message-ID: <20191219132621.16595-21-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: qT_j1qUPM5aF4VeMou0eBg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Sergio Lopez , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker At the moment when the guest writes a status of 0, we only reset the virtio core state but not the virtio-mmio state. The virtio-mmio specification says (v1.1 cs01, 4.2.2.1 Device Requirements: MMIO Device Register Layout): Upon reset, the device MUST clear all bits in InterruptStatus and ready bits in the QueueReady register for all queues in the device. The core already takes care of InterruptStatus by clearing isr, but we still need to clear QueueReady. It would be tempting to clean all registers, but since the specification doesn't say anything more, guests could rely on the registers keeping their state across reset. Linux for example, relies on this for GuestPageSize in the legacy MMIO tranport. Fixes: 44e687a4d9ab ("virtio-mmio: implement modern (v2) personality (virti= o-1)") Signed-off-by: Jean-Philippe Brucker Message-Id: <20191213095410.1516119-1-jean-philippe@linaro.org> Reviewed-by: Sergio Lopez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mmio.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 94d934c44b..ef40b7a9b2 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -65,6 +65,19 @@ static void virtio_mmio_stop_ioeventfd(VirtIOMMIOProxy *= proxy) virtio_bus_stop_ioeventfd(&proxy->bus); } =20 +static void virtio_mmio_soft_reset(VirtIOMMIOProxy *proxy) +{ + int i; + + if (proxy->legacy) { + return; + } + + for (i =3D 0; i < VIRTIO_QUEUE_MAX; i++) { + proxy->vqs[i].enabled =3D 0; + } +} + static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned siz= e) { VirtIOMMIOProxy *proxy =3D (VirtIOMMIOProxy *)opaque; @@ -378,6 +391,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offs= et, uint64_t value, =20 if (vdev->status =3D=3D 0) { virtio_reset(vdev); + virtio_mmio_soft_reset(proxy); } break; case VIRTIO_MMIO_QUEUE_DESC_LOW: --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576763208; cv=none; d=zohomail.com; s=zohoarc; b=m1t7umX4IOEyUXqoFKJDe9+nqnMgaoQVlty6nERkWMrrs/Y6J3PPjwfEGfThHeTeWbP6ricQ5+SVE2L2vfywruEFRAYHvebXNlev2cycgZCNlJWN0pNUsSNTas6XW35tkBJiEjEZnxnRBoUpXBRvELeprmhlAT64ztPZiinPy34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576763208; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WMQapAZoKHuzNu9Pp7IYAg1kGSgMFQ0zkXvOLbEXi5E=; b=RjLlzkpfbzE/pj257SHRsmJf7t2Aih8bO/BJHqc5H0mVa9oz0UrDxYkM1dHYFUK+rZutgO5IZ6NfLMGkELBYxq4hPTsMDYaNWRMF34s4SRrl62H/gYGbmQjkMEWldGJcLZHx4JTwZYjNh42MnOOJdoZjmbVvjOO6E/rpLFp6rZI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576763208595319.96323945404095; Thu, 19 Dec 2019 05:46:48 -0800 (PST) Received: from localhost ([::1]:41786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihw8c-0001UM-VU for importer@patchew.org; Thu, 19 Dec 2019 08:46:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59632) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvrL-0003EC-Kr for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvrK-0001SS-9Y for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:55 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:31326 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvrK-0001PT-28 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:54 -0500 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-192-E8cMwEGVMSO7WscCABmPgw-1; Thu, 19 Dec 2019 08:28:52 -0500 Received: by mail-qk1-f200.google.com with SMTP id n128so3603294qke.19 for ; Thu, 19 Dec 2019 05:28:52 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id q30sm1772378qtd.5.2019.12.19.05.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762133; h=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=WMQapAZoKHuzNu9Pp7IYAg1kGSgMFQ0zkXvOLbEXi5E=; b=istLO5yqNGf1ctDmYyHKrSafItfzDPnYeHydSv8mcEk08TbwBqz2+9L4u3vyO1IgfD9wDx IhGeVNkFxErMT+teVpDPByaSQ1TO3e/kNCACXrVvhNw86Iczy4SPTf+Rf+9jMtDwt5z1qn 0l0H5GiN8PypqlAVUWrph+JyMcnmUlw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=kOPqzhUAAr1F9DHkT+R7bzvkT8C45cWHnUcu3/B6bq0=; b=KiAWiNDEa55EGgSpkWK00P57t4Pkks8a9Ojwi5JN+lCnReuz1dj2XNjQPJqhy+Q8B2 wr78tiFQty+4dXQimBysm3BmnXsQ5sO5W7hyXpvkG0OO8oZ0QvRScBqNtk1m91gGYVIM X13HSq3GAvPeWH5RQmJYQZUMBMIHK9ji4wKmPPJWX8zimB6mcNW14gzzRqyV6bBdJpXK olVK/kMMDDNewWmj7fCt8H2pTNreosTIcWwh0a94+6XxnVAdP8w8a9a8kQnXNPigwLaf il0w2DfkkvLx+YUKKSlAaAOmuLNI4k1fg+tdrUEP1jLx0djy3B4ay+h2dkRoWAmMgiaq u/CQ== X-Gm-Message-State: APjAAAUCgfDF+tiuTSXuQtS+XvTTQfzfht/m6dA+bZ/MBy/067lpM+zg lL4lG7NP6dakzdsF+hDJC21AhIHzSgdECtqUPbrIDvnwf9gbquWHEvCU6Ls43oWsuj2Z9BRJSQY LYi0qwL/EIg+jr98= X-Received: by 2002:a37:e507:: with SMTP id e7mr8296781qkg.358.1576762131229; Thu, 19 Dec 2019 05:28:51 -0800 (PST) X-Google-Smtp-Source: APXvYqz2SRzCojR7gOsMmlyRcdIwVvvWTsmsJ5uSf0jHmdPHbJZcpqT2yBvTBfYnLlWSUaR9DlwPOg== X-Received: by 2002:a37:e507:: with SMTP id e7mr8296753qkg.358.1576762130981; Thu, 19 Dec 2019 05:28:50 -0800 (PST) Date: Thu, 19 Dec 2019 08:28:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 21/24] hw/pci/pci_host: Remove redundant PCI_DPRINTF() Message-ID: <20191219132621.16595-22-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: E8cMwEGVMSO7WscCABmPgw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 In commit 3bf4dfdd111 we introduced the pci_cfg_[read/write] trace events in pci_host_config_[read/write]_common(). We have the following call trace: pci_host_data_[read/write]() - PCI_DPRINTF() - pci_data_[read/write]() - PCI_DPRINTF() - pci_host_config_[read/write]_common() trace_pci_cfg_[read/write]() Since the PCI_DPRINTF() calls are redundant with the trace events, remove them. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191216002134.18279-2-philmd@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci_host.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index c5f9244934..0958d157de 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -115,8 +115,6 @@ void pci_data_write(PCIBus *s, uint32_t addr, uint32_t = val, int len) return; } =20 - PCI_DPRINTF("%s: %s: addr=3D%02" PRIx32 " val=3D%08" PRIx32 " len=3D%d= \n", - __func__, pci_dev->name, config_addr, val, len); pci_host_config_write_common(pci_dev, config_addr, PCI_CONFIG_SPACE_SI= ZE, val, len); } @@ -125,18 +123,13 @@ uint32_t pci_data_read(PCIBus *s, uint32_t addr, int = len) { PCIDevice *pci_dev =3D pci_dev_find_by_addr(s, addr); uint32_t config_addr =3D addr & (PCI_CONFIG_SPACE_SIZE - 1); - uint32_t val; =20 if (!pci_dev) { return ~0x0; } =20 - val =3D pci_host_config_read_common(pci_dev, config_addr, - PCI_CONFIG_SPACE_SIZE, len); - PCI_DPRINTF("%s: %s: addr=3D%02"PRIx32" val=3D%08"PRIx32" len=3D%d\n", - __func__, pci_dev->name, config_addr, val, len); - - return val; + return pci_host_config_read_common(pci_dev, config_addr, + PCI_CONFIG_SPACE_SIZE, len); } =20 static void pci_host_config_write(void *opaque, hwaddr addr, @@ -167,8 +160,7 @@ static void pci_host_data_write(void *opaque, hwaddr ad= dr, uint64_t val, unsigned len) { PCIHostState *s =3D opaque; - PCI_DPRINTF("write addr " TARGET_FMT_plx " len %d val %x\n", - addr, len, (unsigned)val); + if (s->config_reg & (1u << 31)) pci_data_write(s->bus, s->config_reg | (addr & 3), val, len); } @@ -177,14 +169,11 @@ static uint64_t pci_host_data_read(void *opaque, hwaddr addr, unsigned len) { PCIHostState *s =3D opaque; - uint32_t val; + if (!(s->config_reg & (1U << 31))) { return 0xffffffff; } - val =3D pci_data_read(s->bus, s->config_reg | (addr & 3), len); - PCI_DPRINTF("read addr " TARGET_FMT_plx " len %d val %x\n", - addr, len, val); - return val; + return pci_data_read(s->bus, s->config_reg | (addr & 3), len); } =20 const MemoryRegionOps pci_host_conf_le_ops =3D { --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576763033; cv=none; d=zohomail.com; s=zohoarc; b=B7jWPMKtskgVScF9838jgU1Fv9SQTQ5ArrhvZHQXa3XdUJc0EWPu9CZBLS0wGYbzVkSrO9LtzWKrqFQb1vDrEHVBJkT/+d2ms8tKdallfoWGkW4z136yBa1uLqRkREtS9CVOBWa5nUO8czEzBFe5zi/dZ9QkEPh1MEs0uS5urt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576763033; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mD5CnKaHCqEnDtYsfaWuvKKdqaTymxgk4zlUTmpGAA8=; b=DIroCx67U5m/SrxrRNbvni5j4d+2sN4ug3in9zDXUNji54rCMtM5oNOs9LCNeey9D1J0w1AAfRazJ16ON3cOqvor5ds/xown0QY70PD1YY68oG8VOCQMzd0C7Qi6qHmhVB52tWIVJSAXO6HQZuFAr+4wLIGtvB+2hTVDjFrckMs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576763033808995.7338078860145; Thu, 19 Dec 2019 05:43:53 -0800 (PST) Received: from localhost ([::1]:41718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihw5o-0005SU-2K for importer@patchew.org; Thu, 19 Dec 2019 08:43:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60208) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvrQ-0003MP-JD for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:29:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvrP-0001vY-Ec for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:29:00 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:36056 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvrP-0001re-8q for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:59 -0500 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-260-N1FOdMFOPAaNa09OTiTAhQ-1; Thu, 19 Dec 2019 08:28:56 -0500 Received: by mail-qk1-f199.google.com with SMTP id a73so3630337qkg.5 for ; Thu, 19 Dec 2019 05:28:56 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id c37sm1884177qta.56.2019.12.19.05.28.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:28:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762138; h=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=mD5CnKaHCqEnDtYsfaWuvKKdqaTymxgk4zlUTmpGAA8=; b=iOEPxuLlV5jiPOnwL+Z0x7/uuBgyf30X+rInhZ0zV4k7itj4JDOEE6NrME1VYASerccoue G/M2gzDLMKxJdBnlDwYqwOIBjdPElAnM4jwvAd+rApfhLpLKUq+8B4VsHfi1rHkfhaB3/S q7kpzhStHVqVnnZ+gzguv+tjkJUrcMw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=zrcV6NduOW424RfDjQAFC57USpEMc62nbflawLr92Qk=; b=VSW/PB7V1GL0OfM6DYGdPKJkCl9MQKTCp5FwZZTYPf2veATwobZa741996LqVc5geI /lTyObd4N2eQMxgdiKTeU1SYMrFjGt8NUjv29bKRv9vpnG4Q+1WhWnTr5O+ypT5/ITYv 0FivkEE3bOUXUQO76VXzmcx2+XYHtJceX8su3t8xlJGN+CrvKkpjwnX1ft2cySeevaPW 1gPdjjrGKpzkMdN0XpEzq2BkR3jUtN5av0IBqSiqq0J2MjKQLnmz9DdBCy4zdoXStM1C FYlfv2R+sjUYJmIHSSxxV1NgJxpyjPF9XYkNGXMvUQrI1YJNMJPt4QBfZ6/p48rCkVAP xOZw== X-Gm-Message-State: APjAAAVJSnjVBIhFdMO8b84lD+mNTs9yAJn5bS52Ntbua1yqB+5NakEZ P2eGEd8el4pSjGuI4wrOXD+fC4nwfgjgjrEruY35l9d3H19acwh+fjHX3DuJgmSzz1VcllVbxuX wBy/Wrz9rvI7ymJw= X-Received: by 2002:ac8:3094:: with SMTP id v20mr7108658qta.306.1576762136248; Thu, 19 Dec 2019 05:28:56 -0800 (PST) X-Google-Smtp-Source: APXvYqxwvR7qD69zLue8XYugyddN465V20M+iYrINBFMFADZE1KA8X3uD1kfn5tyjSg0CqnDgzKIxg== X-Received: by 2002:ac8:3094:: with SMTP id v20mr7108641qta.306.1576762136078; Thu, 19 Dec 2019 05:28:56 -0800 (PST) Date: Thu, 19 Dec 2019 08:28:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 22/24] hw/pci/pci_host: Let pci_data_[read/write] use unsigned 'size' argument Message-ID: <20191219132621.16595-23-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: N1FOdMFOPAaNa09OTiTAhQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 Both functions are called by MemoryRegionOps.[read/write] handlers with unsigned 'size' argument. Both functions call pci_host_config_[read/write]_common() which expect a uint32_t 'len' parameter (also unsigned). Since it is pointless (and confuse) to use a signed value, use a unsigned type. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20191216002134.18279-3-philmd@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci_host.h | 4 ++-- hw/pci/pci_host.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/hw/pci/pci_host.h b/include/hw/pci/pci_host.h index ba31595fc7..9ce088bd13 100644 --- a/include/hw/pci/pci_host.h +++ b/include/hw/pci/pci_host.h @@ -62,8 +62,8 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uin= t32_t addr, uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr, uint32_t limit, uint32_t len); =20 -void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len); -uint32_t pci_data_read(PCIBus *s, uint32_t addr, int len); +void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, unsigned len); +uint32_t pci_data_read(PCIBus *s, uint32_t addr, unsigned len); =20 extern const MemoryRegionOps pci_host_conf_le_ops; extern const MemoryRegionOps pci_host_conf_be_ops; diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index 0958d157de..ce7bcdb1d5 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -106,7 +106,7 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev= , uint32_t addr, return ret; } =20 -void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len) +void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, unsigned len) { PCIDevice *pci_dev =3D pci_dev_find_by_addr(s, addr); uint32_t config_addr =3D addr & (PCI_CONFIG_SPACE_SIZE - 1); @@ -119,7 +119,7 @@ void pci_data_write(PCIBus *s, uint32_t addr, uint32_t = val, int len) val, len); } =20 -uint32_t pci_data_read(PCIBus *s, uint32_t addr, int len) +uint32_t pci_data_read(PCIBus *s, uint32_t addr, unsigned len) { PCIDevice *pci_dev =3D pci_dev_find_by_addr(s, addr); uint32_t config_addr =3D addr & (PCI_CONFIG_SPACE_SIZE - 1); --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762781; cv=none; d=zohomail.com; s=zohoarc; b=ghLcBEjhcyTgQM1ZNN7VkUwN0N53bc3Dnkg75hJbWKYpNtHChnHquhcw57B4b2R1XqBIt2M67/EUsbJw8/bPKVSUYkqBPVNEkgWngmdqNHOjndEf440fXMv5bHv+wTiBRIqsAkhHuDKD3PpfbChY3oo4qChd9YImgJMISJEPCHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762781; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=51WDbq+PBwGZb4DLRjFJvXY/baMy4xbXgzhN6b6J6AM=; b=UYFM3hWlLrqPG1fNnppMQDiWSYzzmQhXQIyURFLDPiL6aTV03YYq9fpQS6ZeBd4TajM5u5W4gU1INrNAHeuW226y7tFJYh1Gp2ex+HkWm6IGiVqDofqk/SElRsZYxyBEVX6N+QUITmPe7A38vXYp6regObF5w2CaHnagdpw082M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762781587992.7645541041156; Thu, 19 Dec 2019 05:39:41 -0800 (PST) Received: from localhost ([::1]:41661 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihw1k-0000IO-7V for importer@patchew.org; Thu, 19 Dec 2019 08:39:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:32902) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvrY-0003ZD-Hi for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:29:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvrT-0002GD-8Y for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:29:08 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47495 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvrT-0002E8-3M for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:29:03 -0500 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-89-1OYjnvGtMUmTZlmTY2eMWA-1; Thu, 19 Dec 2019 08:29:01 -0500 Received: by mail-qv1-f70.google.com with SMTP id v3so623742qvm.2 for ; Thu, 19 Dec 2019 05:29:01 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id d8sm1802324qtr.53.2019.12.19.05.28.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:28:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762142; h=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=51WDbq+PBwGZb4DLRjFJvXY/baMy4xbXgzhN6b6J6AM=; b=N5xDHfB7D+JqMHPbGTNaHLGYlmzTsg3gqzQcDzWgLcXiwohW/tjFL9wnIWJ9LZSTOUv8mO 73KC/hEO9vUlsoh/LF3Pa9l/Hh81hBl0G341H6Ui71g9jx2g+XfeSFiyG7f0yZKB5LVLVc lj9p9k9v88GVPmqs8H7j/eRC4eXkimM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=o8odu1UwTWT4bWPiNG9EYA27yURxcpg5mIlh0CMeiVA=; b=SXBaLYxVmU8K9Vj8j2+8PSNx//3Tnn+lDtTsNHjH9ulFlS2+RKVkKdJX5R89rWP29x zBM+EbxwazDiSVj9ThXyxjn1SVX1T86A6qvqXNklEili9sYr0elhfq3eXsD490FO+5NT /vQoLcQLOhg/Cw1U7/YUpSsTN3WM8BZVoEnlOMMzWPXUJECwf9J+rBTTHxe0roqY0meJ uEeBPefYpWmrQlOeDlM6C7OGr3rXQUwjqomGoQo6zQhfFW/bfNUcLJ+ce9ef8+Q5qiM+ hzmCSAjoRYUXDqfcATb70dCWarwNNx0hYXWzHs774hgpp3lXk66jsRJPT/4cN4cUZaCm il2Q== X-Gm-Message-State: APjAAAXgcmLkueT5ZiayJB2ugSzMoUTfoz+jrrRrImrzcxnwtDGnKfBD vG2hfqzX++q86rT0ni7kiAh9N9oZS6BIRW0pmeRufdyKwu+zwjVjlG4L/+quWbCwd9rRia7VP3A ZCRFWuIDZ7nKmH+U= X-Received: by 2002:a37:98c6:: with SMTP id a189mr8136605qke.500.1576762140420; Thu, 19 Dec 2019 05:29:00 -0800 (PST) X-Google-Smtp-Source: APXvYqz9fPT3y+a9XwjOCQhYfL9erAj7ft8zFn5rKGEOB4gKChIFoyuY4Y/fIXkKRJgkdWeX4Guc8w== X-Received: by 2002:a37:98c6:: with SMTP id a189mr8136579qke.500.1576762140173; Thu, 19 Dec 2019 05:29:00 -0800 (PST) Date: Thu, 19 Dec 2019 08:28:56 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 23/24] vhost-user: add VHOST_USER_RESET_DEVICE to reset devices Message-ID: <20191219132621.16595-24-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 1OYjnvGtMUmTZlmTY2eMWA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , David Vrabel , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Raphael Norwitz Add a VHOST_USER_RESET_DEVICE message which will reset the vhost user backend. Disabling all rings, and resetting all internal state, ready for the backend to be reinitialized. A backend has to report it supports this features with the VHOST_USER_PROTOCOL_F_RESET_DEVICE protocol feature bit. If it does so, the new message is used instead of sending a RESET_OWNER which has had inconsistent implementations. Signed-off-by: David Vrabel Signed-off-by: Raphael Norwitz Message-Id: <1572385083-5254-2-git-send-email-raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user.c | 8 +++++++- docs/interop/vhost-user.rst | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 02a9b25199..d27a10fcc6 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -58,6 +58,7 @@ enum VhostUserProtocolFeature { VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD =3D 10, VHOST_USER_PROTOCOL_F_HOST_NOTIFIER =3D 11, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD =3D 12, + VHOST_USER_PROTOCOL_F_RESET_DEVICE =3D 13, VHOST_USER_PROTOCOL_F_MAX }; =20 @@ -98,6 +99,7 @@ typedef enum VhostUserRequest { VHOST_USER_GET_INFLIGHT_FD =3D 31, VHOST_USER_SET_INFLIGHT_FD =3D 32, VHOST_USER_GPU_SET_SOCKET =3D 33, + VHOST_USER_RESET_DEVICE =3D 34, VHOST_USER_MAX } VhostUserRequest; =20 @@ -890,10 +892,14 @@ static int vhost_user_set_owner(struct vhost_dev *dev) static int vhost_user_reset_device(struct vhost_dev *dev) { VhostUserMsg msg =3D { - .hdr.request =3D VHOST_USER_RESET_OWNER, .hdr.flags =3D VHOST_USER_VERSION, }; =20 + msg.hdr.request =3D virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_RESET_DEVIC= E) + ? VHOST_USER_RESET_DEVICE + : VHOST_USER_RESET_OWNER; + if (vhost_user_write(dev, &msg, NULL, 0) < 0) { return -1; } diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 015ac08177..5f8b3a456b 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -785,6 +785,7 @@ Protocol features #define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD 10 #define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER 11 #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12 + #define VHOST_USER_PROTOCOL_F_RESET_DEVICE 13 =20 Master message types -------------------- @@ -1190,6 +1191,20 @@ Master message types ancillary data. The GPU protocol is used to inform the master of rendering state and updates. See vhost-user-gpu.rst for details. =20 +``VHOST_USER_RESET_DEVICE`` + :id: 34 + :equivalent ioctl: N/A + :master payload: N/A + :slave payload: N/A + + Ask the vhost user backend to disable all rings and reset all + internal device state to the initial state, ready to be + reinitialized. The backend retains ownership of the device + throughout the reset operation. + + Only valid if the ``VHOST_USER_PROTOCOL_F_RESET_DEVICE`` protocol + feature is set by the backend. + Slave message types ------------------- =20 --=20 MST From nobody Fri May 3 23:42:35 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576762975; cv=none; d=zohomail.com; s=zohoarc; b=Ucxui5FTccqSfesdLJmNJyWxRCoiw4xzZgfPxfg6buABqd3Hs9OykPa2C796byIPYWXCRu3OeenLUOABiRHKdoQMvIj5sLkcDtVotnnOLkvnBnxlREctZPXoaVbqAq0IgPcRYvsWOx55O6PRdTZtqyWK4qRXxLqenCcNKboNM4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576762975; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5EhLJ8ESaItKzPeue3PIZ6PBy1w7sicN5shNVXQfGIo=; b=ZOO6ACxyvtkScGdA8p5Nh8ZsNK+sljbXvHmA7iR/f9GLRFxOwK8gAyaozgV2taV3RIeNxhiOrgaAfY/lZGuQGvZb0qsc8tYZ+Bcq9NPaWVquD06A1gNUH+MFtMafoGS0M+OLIq0BGe92f4B+BXrrQXtabAk3C5JGbdyXjSevXRQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576762975941178.10964358041588; Thu, 19 Dec 2019 05:42:55 -0800 (PST) Received: from localhost ([::1]:41710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihw4s-0004Le-9C for importer@patchew.org; Thu, 19 Dec 2019 08:42:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33040) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvrZ-0003bP-T1 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:29:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvrY-0002iF-2M for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:29:09 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:47983 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvrX-0002fJ-SO for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:29:07 -0500 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-gTKy-oztPteuJYrrVEe3jw-1; Thu, 19 Dec 2019 08:29:06 -0500 Received: by mail-qt1-f200.google.com with SMTP id e8so3667291qtg.9 for ; Thu, 19 Dec 2019 05:29:06 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id 124sm1755170qkn.58.2019.12.19.05.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:29:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762147; h=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=5EhLJ8ESaItKzPeue3PIZ6PBy1w7sicN5shNVXQfGIo=; b=Yhj0kd6WPbP/r7kv1gboGQcIx7FiBmsa6wL8UpeN9P0FH3jNhXDprmbKB5iqInfpPbEXo4 w/VHyXy/iBHHsEeDBVhzWpt40570XdCzF+LJeUdUHFZKZlfRJyoPGLnJLHMpMDP0Pjsohf L9ycjqaO8BaGp1k0F+G0SzLzDKnJH5Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wp7IEacTPDnbh2fT1ey9LJUjRbVmj0GN0bCAT90OXe4=; b=f8DZhq9Bi9Ujsd+FTbvLrO85Lk96iS9VcpuK/UqK7JrCKZtsfFW8E6kZS2GSWywMU3 yUYsgAL/o8FGEcW2PzZJC9eHJxG1T47CKk2dUYVdF78CfKpwwtVPb9Ak+tmcuJlKB6A/ gS0pf//GqH7iv2MsaF20o3fXRkXdBdJHYT2mu5C9k7pGq/Z4aVKHQByWj8P8etvhJukQ MqcmYQHag3MIpnNS3O57VI0SKmQP7c87sTCGMxh18BIRmP3KNC+U/MoWuDTQuOY5CRqG FX9M0i5WnIZCNAtWwozXIZES8wcQrMp7eXNrdCswzwtRmYbff3BAPCTpHZ8TloHCjcdu Jv/A== X-Gm-Message-State: APjAAAWVmulEqBxiFh57OiRvh6xzVn3d0ryb9r2p5HKWrdboKSln0dr2 GyfV/umGn3Y4CaBuC+tPF39l0ghovEYvw+BOR7KS4ck7rsKPN4hxlMUp4i+U0XpfTvfQUy984li IFXketM5BymrxYIo= X-Received: by 2002:ac8:768d:: with SMTP id g13mr6948166qtr.7.1576762145447; Thu, 19 Dec 2019 05:29:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzdL66iSvydYXqYxiJeIDCxy3TRsQOjcbzZ/o/Mu03gw2y8M2HbJDzdMk+ZcMkjzOh3QrCtIw== X-Received: by 2002:ac8:768d:: with SMTP id g13mr6948145qtr.7.1576762145270; Thu, 19 Dec 2019 05:29:05 -0800 (PST) Date: Thu, 19 Dec 2019 08:29:00 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 24/24] vhost-user-scsi: reset the device if supported Message-ID: <20191219132621.16595-25-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: gTKy-oztPteuJYrrVEe3jw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , Paolo Bonzini , David Vrabel , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Raphael Norwitz If the vhost-user-scsi backend supports the VHOST_USER_F_RESET_DEVICE protocol feature, then the device can be reset when requested. If this feature is not supported, do not try a reset as this will send a VHOST_USER_RESET_OWNER that the backend is not expecting, potentially putting into an inoperable state. Signed-off-by: David Vrabel Signed-off-by: Raphael Norwitz Message-Id: <1572385083-5254-3-git-send-email-raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/scsi/vhost-user-scsi.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 6a6c15dd32..23f972df59 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -39,6 +39,10 @@ static const int user_feature_bits[] =3D { VHOST_INVALID_FEATURE_BIT }; =20 +enum VhostUserProtocolFeature { + VHOST_USER_PROTOCOL_F_RESET_DEVICE =3D 13, +}; + static void vhost_user_scsi_set_status(VirtIODevice *vdev, uint8_t status) { VHostUserSCSI *s =3D (VHostUserSCSI *)vdev; @@ -62,6 +66,25 @@ static void vhost_user_scsi_set_status(VirtIODevice *vde= v, uint8_t status) } } =20 +static void vhost_user_scsi_reset(VirtIODevice *vdev) +{ + VHostSCSICommon *vsc =3D VHOST_SCSI_COMMON(vdev); + struct vhost_dev *dev =3D &vsc->dev; + + /* + * Historically, reset was not implemented so only reset devices + * that are expecting it. + */ + if (!virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_RESET_DEVICE)) { + return; + } + + if (dev->vhost_ops->vhost_reset_device) { + dev->vhost_ops->vhost_reset_device(dev); + } +} + static void vhost_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq) { } @@ -182,6 +205,7 @@ static void vhost_user_scsi_class_init(ObjectClass *kla= ss, void *data) vdc->get_features =3D vhost_scsi_common_get_features; vdc->set_config =3D vhost_scsi_common_set_config; vdc->set_status =3D vhost_user_scsi_set_status; + vdc->reset =3D vhost_user_scsi_reset; fwc->get_dev_path =3D vhost_scsi_common_get_fw_dev_path; } =20 --=20 MST