From nobody Thu Nov 13 04:41:28 2025 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=1578229161; cv=none; d=zohomail.com; s=zohoarc; b=TqRcIqmMFzkl58ozVZhEtgWiDbWyVIPhdlz6OaH9SmfAh7tuSZbqfJvuHuOsK+Resrxt4nUSYyQsb46bcQ1Vv1foZ9rXL73T7Y8la/s+VhA+5yasQtdHZoBkmnUOKx5ufMbbZT3i5Mxc0t22WZZ3av6C3lhPVKFDW087I/76ry4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229161; 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=GbumFfqolMfvK1vG1P2wvAVEVyvYoFp1n5egduhaNZ6weiUSkU6ep3sYFXUD6Da+NYu0oOKL/2a/+mQhf9wQlfFlP/SXCh7fkhoMNb6bW1bvdf4THvEdnKoFEMnN/dZqdQQ+dEyZsK7TqofKOwt9Vfv5WUlI1o5msApQWzPE4P8= 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 1578229161764421.22986238493047; Sun, 5 Jan 2020 04:59:21 -0800 (PST) Received: from localhost ([::1]:41786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5V2-0002Gd-4n for importer@patchew.org; Sun, 05 Jan 2020 07:59:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58023) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5TI-0000P5-04 for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5TH-0003RR-1n for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:31 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:33947 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 1io5TG-0003Qx-TL for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:31 -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-175-c6z1mY36Nay18Qe9GMr9aw-1; Sun, 05 Jan 2020 07:57:26 -0500 Received: by mail-qt1-f198.google.com with SMTP id e8so8946396qtg.9 for ; Sun, 05 Jan 2020 04:57:26 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id l19sm21531653qtq.48.2020.01.05.04.57.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:57:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229048; 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=D3VHnbYg7+IctQi4zToZMmZquMO9B03QHkxFr5piFhTpXNYl92xrds2Ol5VDlO5RbcJFZ+ KvgEcW8RZH8ymSc24GVYmyBcFJMxkk7+Jdrwx8LQiq78nsEC6RJBlJlXJfAK07WYrLUGNS jFV0ZO/0oK22EpNmOrvoJBhKV+hjEuA= 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=jn53EQV5wCQz9tMFZkDwUgQtxA3ZsRZ4naV2IQGZ0NkXfMGj2uFWHW2+uwWd7I++Pq vGdBg8v58zFz4jsdYBe/kXcQbaa3XziY1pYuhuUTKBHUBtKjAmCltaDjZHdAHuwlnUGM WxlGlLLpt76BEiFflrDB7UgsJ0EqSd3A6VDIc7qLFusnOISty3BgJf/R+XcSaBaYCvfa CtCvpNycnDs53y3ersXQasLpc5StzsrftMksBr49fSXJhbOsMYRO5Loelic4IPftCs1X WqF5n6X6yCZKJXt1/elnASpijrUSpyvDjDKJY/wSCGPqTtkEdpFh/Y56hnVkXHmJlJ4t ZxDA== X-Gm-Message-State: APjAAAVLaOZqGb4LsR9W6EThRylb5Qu/SiovTSEQOuce3HLWZuzX1jft LcFg8LM43gf6Cap9JNA1ZFkkwHKerJ92D7lJwXkfhCm9MAycBGDkHrr4N8DYfAbc8b+Nx344PCV hFrXLmgm5TBVRj6M= X-Received: by 2002:a05:6214:13ef:: with SMTP id ch15mr68673854qvb.183.1578229046153; Sun, 05 Jan 2020 04:57:26 -0800 (PST) X-Google-Smtp-Source: APXvYqwGEkOL4TCdQsqJcdin/3NQQWXkgkSx+Z3V8ACExs9c74RHybbBIX30MaW53oxyD8AVJmoUkw== X-Received: by 2002:a05:6214:13ef:: with SMTP id ch15mr68673841qvb.183.1578229045940; Sun, 05 Jan 2020 04:57:25 -0800 (PST) Date: Sun, 5 Jan 2020 07:57:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 01/32] virtio: add ability to delete vq through a pointer Message-ID: <20200105125622.27231-2-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: c6z1mY36Nay18Qe9GMr9aw-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 Thu Nov 13 04:41:28 2025 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=1578229174; cv=none; d=zohomail.com; s=zohoarc; b=OUbdOCSx0fkYr/3zGEiYkpqqupqxVqpdUtxohqtO8i+JxQjfjutAbRrZXxmtzO0L3sbuZTw4zS0Qv9tmMf9Zaw9xi5ocTq/ZITtJNSk0oiJZ0/o0i1ED519BTXClULkjOTM0prXkLpStO4yKBSX8ohIjFAKCe7UH8KfdoZsg5WQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229174; 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=WjHUyUE1A1z619jSVMhxmxUZa325VLU3STsQEmXrHQ3F6TinyUZEduk+HaN7gSkwh17LxOJkgdFxbWATmTcSSNcTD6KQcQQ4hGa/1PJyPrje2j/299QXJKa3R4ANMgiU3zWMVx/nbHkkRMEA1NR9MhjA8Gz0yxVbyt/imp6kvIs= 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 1578229174368723.7516580147959; Sun, 5 Jan 2020 04:59:34 -0800 (PST) Received: from localhost ([::1]:41790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5VF-0002O4-1H for importer@patchew.org; Sun, 05 Jan 2020 07:59:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58042) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5TJ-0000QU-Gl for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5TI-0003UR-Kd for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:33 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:22193 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 1io5TI-0003Sz-H8 for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:32 -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-147-yWCbzG0NNKufGFWsJP9ZSw-1; Sun, 05 Jan 2020 07:57:30 -0500 Received: by mail-qt1-f200.google.com with SMTP id r9so8038518qtc.4 for ; Sun, 05 Jan 2020 04:57:30 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id k88sm1558531qte.32.2020.01.05.04.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:57:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229052; 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=ISQ01HtlT38FA2S1uttdcBNWLKHkN406W+pfib+d29gX6IFFDJpQ5pre4A7DyKFCGySBWu lsyErAZWxjgC3Jz5s0j9qD8exxW7sQxnZ8jdPIAceYVEjv3x+3gdyRq3759dRqSYaui5FP 5et3gTxyQXhF9SmRRfNTvr6t3XaCtwM= 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=GNEpGqz4jDdRqb3Sk5Oi/mhATe0/SldRsVMahI7FCCr+dI5WerXdR7qqOlwUaidnL0 5G3cVgyq0Rpi13VT6oQJFL1vqF6kk2564U2L7iaC0gGWlecIepkHRFy9RyhFMJIuCAAU yt0iE6vsovC4iiByP+hgHlTEd8t1T66AfPMRSu8nZ9Lhc5Hds2Y9HlaOAuNdLe8jF0ex K9J/6L5FR1nLdwMztJ7lqNXu7wtuABuKdeyBA+JSTLHq0ffnpljAh4bXpYRlMt6YwvpO n5Cewo3bK7xW8ADJdAzhDKwR5xguSKFDSbIok3zLjihtboHmtfviYEejcmzrazGDPGab AXag== X-Gm-Message-State: APjAAAXxng/njOuiP9sspgKFfUQLMO4ocXO+Sk32wtxb75x/owDHoP7u dca+B1O7404M3vOXXpMuVdJ7QRKZzNsPdTRI6o+Xs12jLpqEth15md0AT36Hwv8nQjCueTVo+2e 4pKjdGtJWNnwSjZM= X-Received: by 2002:a05:6214:bc3:: with SMTP id ff3mr72052508qvb.155.1578229050061; Sun, 05 Jan 2020 04:57:30 -0800 (PST) X-Google-Smtp-Source: APXvYqy8oVrUoPL39KIBn1pNBGLdD/EJLWzQHz74WL16hL0dBEFOW0Gk19pzHD8MgRR14gqBxAG2QQ== X-Received: by 2002:a05:6214:bc3:: with SMTP id ff3mr72052502qvb.155.1578229049911; Sun, 05 Jan 2020 04:57:29 -0800 (PST) Date: Sun, 5 Jan 2020 07:57:26 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 02/32] virtio: make virtio_delete_queue idempotent Message-ID: <20200105125622.27231-3-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: yWCbzG0NNKufGFWsJP9ZSw-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 , 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 Thu Nov 13 04:41:28 2025 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=1578229392; cv=none; d=zohomail.com; s=zohoarc; b=HTLXKKP5z293Pw8MteC9i4PxEWxQL9xsxes9nQtVVnVUNgDJaCwOtpa8QsyvmeZ9QNOXqGyOu06e2NrulBuEsMh7mxtWkaTdkflp+TjqqexdpYKSJancOb+Np+X703wL4oIMUQC9c+L1RNa9sTrzuMdUp1Li8o/yngtn+l8r3AA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229392; 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=CVJEDMIxMA58qSeg6MmBxYP0US0NnIYS5xtSfy+uRdcXGY9e6y83w9fX4DsO5WQimq0f8vNE/WKBrgwhb6G31awmXO1I0egr0EwzeAmf1vJY5/MQc5USuL2dUXEmm9PYtsQ5A9eEO9enmWEOaR2EWfrMd7KANt1f+VNNRnO8+uk= 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 1578229392613455.65257546943667; Sun, 5 Jan 2020 05:03:12 -0800 (PST) Received: from localhost ([::1]:41872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Yk-00062F-O0 for importer@patchew.org; Sun, 05 Jan 2020 08:03:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58082) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5TQ-0000bi-V3 for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5TP-0003gw-RJ for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:40 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32276 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 1io5TP-0003gj-NO for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:39 -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-351-__2DBuQJN66emddeKSeiCw-1; Sun, 05 Jan 2020 07:57:35 -0500 Received: by mail-qt1-f200.google.com with SMTP id x8so8875175qtq.14 for ; Sun, 05 Jan 2020 04:57:35 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id g52sm19046718qta.58.2020.01.05.04.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:57:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229059; 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=QW6PXgNR4OcExaJan+jtbRrBhrZGgoc9r5slZkHMpUKVqoa26v1km+cZ0BY+Un9wfKcwTJ nS+p1zqoMtfP4rZduLNolSOqAZUmGL+2x7fGbeGDz8sPJEA0Go7DxIs2vkLLiqz6slODYM IYxuA35MZbQtp8OHmDXCqPxnxqmmr7Q= 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=YKd5N5kvVAeWXAOeMTK/yn/rqdMro0ZY9MmZO/bQlcGV0rA47pdRNZrVYasZZvQ5qF cVqZja2TpBZWI8H61yd65sWyEJIaqAQAfghUW7FmA+zwLVvjEiOkgoyLBAYolGv+VzNG NdW8tj4Sxq5EVvgH/07lzFTND9R85uebrji90lY47JiBGdm/unszEuDxiQoCF1qM0OEI w6wMHEzCJEDDAM/ezE71hJJxUeuDY4A12Hv87W70mNtfVBteWSZmIuCtUssa/G9bxWv7 hfOwTbJnBsMDZ8KStFIy0XOzK4i53tiMiVYCkd/W1SbC2jjg6JZn17SZfO5D+t+c7PLU Gx+g== X-Gm-Message-State: APjAAAXEBnD8TGdwcl8vva0YQbKx70ma1qCMH0/0+omChOQaQQwUi19x cvk7JiKoYwy6IdSQrDmaezx+8KqJbynyTqwvv038ZiVZNLo9fESR6mXOHOwNDVFORNaVnxwdtXv bK/ja+tiR6nddtuY= X-Received: by 2002:a0c:a563:: with SMTP id y90mr62740223qvy.78.1578229054854; Sun, 05 Jan 2020 04:57:34 -0800 (PST) X-Google-Smtp-Source: APXvYqybwO2O4OgIabEdTzA+/hkr4g5j7ZfdylmRWEBTa5snlbEE0KQ98qXVnFIjsp2am1CWe6RAZQ== X-Received: by 2002:a0c:a563:: with SMTP id y90mr62740212qvy.78.1578229054639; Sun, 05 Jan 2020 04:57:34 -0800 (PST) Date: Sun, 5 Jan 2020 07:57:30 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 03/32] virtio-balloon: fix memory leak while attach virtio-balloon device Message-ID: <20200105125622.27231-4-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: __2DBuQJN66emddeKSeiCw-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 , 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 Thu Nov 13 04:41:28 2025 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=1578229193; cv=none; d=zohomail.com; s=zohoarc; b=Nd09NoDpMCLL2BO80u1qNaYSq2HXqVZBEV5arU4QULQqnp4M9M0eTW68a4HDRzpb7MhXUAytR0cxzzzXsUsu9JVx+d0WeBgo3qXBQtVd1Sfk0DgjUkdTZDIfixayzK9TGZzzx/fIptWHpch35UDQNjQNGpwrqiZ2P93mua/db10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229193; 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=dWV6dzvLCgWjJVbDEDdPPhIfFFufBsbbz2gR+E/UxFY204VrtsvPSp+RQ7/Y77lg7ovkaKQniqyR3m30czyCzA64bV8hqe6lbiejoMJnLRZ1QS2U+oor84/VP7AplHjHjMOisUHVwgWknJV5J7NlM73s19ngMgxrgk1ank7YP4A= 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 1578229193666216.19573710659233; Sun, 5 Jan 2020 04:59:53 -0800 (PST) Received: from localhost ([::1]:41796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5VY-0002k2-3Q for importer@patchew.org; Sun, 05 Jan 2020 07:59:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58102) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5TY-0000k1-TP for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5TX-0003jq-Nd for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:48 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56870 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 1io5TX-0003iq-Jm for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:47 -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-392-_6WUKmuqMIS0LXNnp6OeOg-1; Sun, 05 Jan 2020 07:57:41 -0500 Received: by mail-qt1-f199.google.com with SMTP id k27so9559116qtu.12 for ; Sun, 05 Jan 2020 04:57:41 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id c13sm19270948qko.87.2020.01.05.04.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:57:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229063; 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=YNEuj8zRVrHi5NdDRArqV9Y2xTxtws2Youp94E9VWOoFBOMqT09DE/stYoyC3ZQ77AyKjM xAmoAI6RZMr4iXquwDyVDKnangw9G2U2JWHXYH1Brsz7hCx0MbOu6j63SMNQj6ZQaLKjJn mGgAVeqFK6rZrifSs6KyQ/zKifkH4TE= 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=X/LCDTBKPBQereGcSHG5eEDOusQ/93rAuzu8nFxDlyljtNaO+U9hMbCPDcicpKCrcR 6D8ndi0vnB4zJGSxD3KfvIOh5cxF3IS/WPIMxmR6y4G5vhda2maOOZi5tUQJbcYdQtUf yaDA6RK63EnxEvZ3E3/A4vmZ+kfNKSrOTFLHxo80E7WxX8epttYa1PTcLQp1Fk+sfUnk ns+WriHbalth0RYVmOxreUxxOfDFs5XYe8uODFXMW5cxn3JR/wsTlEnVA+ZtPuNxKYXb sEWJcHYKLqYtS6k9qdYDITfW8wemFwSf+j6itzDNgiqfqc13/8mUU0BFcSs1m/zG379Z aaVg== X-Gm-Message-State: APjAAAUh4IpnGg83VGA4A9PREBnVsLT4bGKTuLZQq97HxbLiE5PjE6tq gDCl1RSQE/rSa4NVrxHPzrE2r68+1yqgn3k/BrKFGqJWyKGSjYapNm8DRtbj+FE64tWq0dUiUm5 2keTwf+X4TaZMQIo= X-Received: by 2002:a05:6214:1149:: with SMTP id b9mr73798127qvt.227.1578229060512; Sun, 05 Jan 2020 04:57:40 -0800 (PST) X-Google-Smtp-Source: APXvYqzya5OPB3zk+w7cR+JmWpck3qkY5h5Xhn4etT6tQvVBuFe68IP0YNFelcXEC9SpJQmk6+DfTg== X-Received: by 2002:a05:6214:1149:: with SMTP id b9mr73798114qvt.227.1578229060297; Sun, 05 Jan 2020 04:57:40 -0800 (PST) Date: Sun, 5 Jan 2020 07:57:35 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 04/32] virtio-serial-bus: fix memory leak while attach virtio-serial-bus Message-ID: <20200105125622.27231-5-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: _6WUKmuqMIS0LXNnp6OeOg-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 , 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 Thu Nov 13 04:41:28 2025 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=1578229406; cv=none; d=zohomail.com; s=zohoarc; b=I+qixx6PDrPtXY7g45G6XLanVDbb2SCJ7Q1NH2P+asvUqsOOhaBV8vW9H0crWVe48i9h0pqZdHPleLDgxGXiE9TN0voTwbwl6iyNP0RAYdujMEkKH+RP3/SUM2pmqw6uHxuqzIb6v5ojCNshf3UbPwlA/AAuk/Rt4bDqwt1vjXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229406; 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=W7WmIgEJ4dWH+dZjMk7T9kaGsQCP+7mbaneZCjLZTuhk64NsLkWtlkdd5tfo6aLaoo6orMU7w2OYrrejUH4sZ+IzSbaYFo/R3weFEGQh67dsX3muHmCfGoesqvE0YUADejMX1R6zTNPP3i0dp7HQCXMkJh5ub6kJUr7IK6NPXQ8= 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 1578229406415907.5488814182594; Sun, 5 Jan 2020 05:03:26 -0800 (PST) Received: from localhost ([::1]:41876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Yy-0006WP-PU for importer@patchew.org; Sun, 05 Jan 2020 08:03:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58097) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5TY-0000jY-Hf for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5TX-0003ji-Hy for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:48 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:22637 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 1io5TX-0003jU-Dz for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:47 -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-54-H1kk4p0HNcmSGrbDBngf8A-1; Sun, 05 Jan 2020 07:57:45 -0500 Received: by mail-qt1-f198.google.com with SMTP id d9so28195440qtq.13 for ; Sun, 05 Jan 2020 04:57:45 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id w20sm21865250qtj.4.2020.01.05.04.57.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:57:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229067; 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=UzufamW7/NaGKuvlszzqtO/7/T4KLz14A0I503vwUWc5LDfpeH2QCWEbkXgdLdqyqE3A5p ohpN+60YL4ZcyAbUgdSS1j+JShox6NGUvI9KPBdUfnbd1MrWCbRJVn1TV1kkaXNMxufPWt 8Zcu/Dv18NSWEwhwFX+7nt0p0Nib5rM= 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=CQJhmcA4PbtgQbhoAi3b6V6mUtRWar0NeztRWY7mM8bPWeegqavF7idproqjJgVhnM 4WVceFRPbY1FwPCzL/5kpJm7L0ThQ1zd1aKsRSZJUiBgj0sR6b/l9W8icKUnAfOmP49f e9qUolsKu5VHKkV+aFGMa/7+4Vz0HW1PNF6cmSYd9ChZVAYCp9zW1Ma2D8IvKiG5cBAI 3jNBK+K895RXs95rt2Qu/YPC4BwMCfMgYymMJuUpI7zXYXMeuviNb+km1D2vnJGn0x6i b6luMYk7esOJPWRyUNwE1hC9ADGWWHQcWykYy6QP59cqxacFggiNNbvSvhUg+nV+izue Vn8w== X-Gm-Message-State: APjAAAWoIqC5ENBxpYvjT2YkKelo0W0Q9UfXMCCEUJMbFX8cOzXGk7Xw OtZvD6cdNMaGxgPLZRe4CJ5vje6daLzhA06Yl9HKxipCsU3QKoN9yG6gH1m+Gh6QjnO4cTJBXeP p5u2VFRoiQQ4ij0M= X-Received: by 2002:aed:256d:: with SMTP id w42mr70505959qtc.385.1578229064939; Sun, 05 Jan 2020 04:57:44 -0800 (PST) X-Google-Smtp-Source: APXvYqzMjtSTRO/gE7LEGLDi8SRZHAY/yO7moOX9NXEKTKs6dCNIDksAhfQVOwEKtkr4iuZX1tqXyg== X-Received: by 2002:aed:256d:: with SMTP id w42mr70505953qtc.385.1578229064794; Sun, 05 Jan 2020 04:57:44 -0800 (PST) Date: Sun, 5 Jan 2020 07:57:40 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 05/32] virtio-input: convert to new virtio_delete_queue Message-ID: <20200105125622.27231-6-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: H1kk4p0HNcmSGrbDBngf8A-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 , 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 Thu Nov 13 04:41:28 2025 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=1578229393; cv=none; d=zohomail.com; s=zohoarc; b=JoMaWXIBf/BOzMcJGSm5F4nWYGMYyOFlf4zfgZfzDp3bSG5wnIkhLLUQWDIo2r4ETIQLfKjHQDPdALtG7QeYigGZbfhylb4EViUC0EIe52TvaIn9SrYdwiu06jw6n7bA7szDYsZy7Jx/K3oAW+Pxc9VYTFkdCCOxnw+wse+GFdU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229393; 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=UfEOExkv5zaQNXlJF+KJBHOQij77+gOfT2PsMIuadnXIPqLvNw9LOau7ANAUCvuZa0c1hOxjM1jYpUTcfHlAcMMqG/w243KA7PM1+psVlRtj4x5P1W7tkVf0yQrJimiWqymWTZw3hTe+iXiQ6PWRyi8vLUUAatdwyqQDQUBUwfk= 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 1578229393182545.2522920532368; Sun, 5 Jan 2020 05:03:13 -0800 (PST) Received: from localhost ([::1]:41874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Yl-00064E-1B for importer@patchew.org; Sun, 05 Jan 2020 08:03:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58119) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Tg-0000vN-2A for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Te-0003n4-Tw for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:55 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:53606 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 1io5Te-0003mt-QN for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:54 -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-155-fvuyiLjwO3ukQdOfKlzBgw-1; Sun, 05 Jan 2020 07:57:50 -0500 Received: by mail-qv1-f69.google.com with SMTP id e10so1733926qvq.18 for ; Sun, 05 Jan 2020 04:57:50 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id r80sm19325029qke.134.2020.01.05.04.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:57:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229074; 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=Om2D03T8LZDHmmCrynVffr7ZrDYlJx7JIOeya99IZaQlVmBXBc2cxU6RM+nQ6mbrxu9N6T XN+jBS9DLzNIbBQk73FVxZRkphwJpZrab0ozWbJLVAmdAK3vCCjXrgqQ/OgL1ghlf72k+V Mh5KcJJpfg+LRhFj8/RZjwrXzsDfNjU= 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=S47lKfQ360j7i6+SUWLxhCkrvaKXhCRN9W+lcEr4rgJR/Yn5G2PzlkF0Jt0cgfyoP2 5f8ELtn/eX7ZxxLfNA6zXdoV3DCH+9Biq+W5t5vIVqd2QMdhGy0ichSt93QRADWBAxa8 uFWKSLTfM8tSBXCjsWIqYIB1p+brmkwlW3wETKjGbcWsBPHfx7OhHm3Frg9StdaMs8HL rebucqI71hf8JGrcU2S0iGAVDUdyE9r+H07EbQGH5NJaNU94KAT2TWcqCl1axj5wlId2 xmxMdbg3ZmeeHi+KnGVG3bgNvHWEA+n7Ei+5gBJwVuzI2ptygkrN71TvhuxOKY6Vpq8N NeUg== X-Gm-Message-State: APjAAAU6qFhT18jCaJML0H1mfI02GAcKGPt3rLpnC8Q/CrTWf05giWbN 34X8ScfjoFzSOCLW9j2D6Eu/MLunO+IySad3hNemU3j4/kBT10iyG94Aa/yl1LNOa7b1RZemEl6 RCrbqFFhHMsi1uOY= X-Received: by 2002:ac8:64a:: with SMTP id e10mr70464921qth.292.1578229070065; Sun, 05 Jan 2020 04:57:50 -0800 (PST) X-Google-Smtp-Source: APXvYqwMIga4L4/YEt0EtoelaucL7ilPDrNP7l7eXbJhX7lAbGrrA2Pza82yF6eidBq2Ke2DosDoww== X-Received: by 2002:ac8:64a:: with SMTP id e10mr70464911qth.292.1578229069917; Sun, 05 Jan 2020 04:57:49 -0800 (PST) Date: Sun, 5 Jan 2020 07:57:45 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 06/32] intel_iommu: fix bug to read DMAR_RTADDR_REG Message-ID: <20200105125622.27231-7-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: fvuyiLjwO3ukQdOfKlzBgw-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 , 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 Thu Nov 13 04:41:28 2025 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=1578229382; cv=none; d=zohomail.com; s=zohoarc; b=TOcQ5tiFrjDy6uBfK/caIuYBYqSRqk5LSMXGDWr2tf4SqgZxDPZ5iWypK0yo2zaF6cid2CBRq2kOiUJKP+vEqJ1wdUTO2TGu3DZMBTpSe1C4WwnnRKzzkFNPzYtSBy7K8fWDluhfGxsJRaNzxOd0FhsBRRPiL1SuQz/F0MXvA0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229382; 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=OMvJhEP2LlmkkK5OqUcX3Hea5Sokrq83L2n0JELoweI=; b=N4N3d1fjWzLjlWu0b5jK7fRq1lwXrzPP6WtgvR1dk3NFAooOBtNnCsgkK3N3arf8k+0EBYCP+lXR3J0dsXrARks/AoyC30ljfQ4T8R3InFteoyCFfVQZ3+1HH5UmzlqEZUSW+ZH++HnPs4r+y88eEIzm29AYcN75CfqcZWiln94= 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 1578229382037435.0965832241991; Sun, 5 Jan 2020 05:03:02 -0800 (PST) Received: from localhost ([::1]:41870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Ya-0005uh-C1 for importer@patchew.org; Sun, 05 Jan 2020 08:03:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58130) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Ti-0000zV-Ma for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Th-0003oI-MD for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:58 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51108 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 1io5Th-0003oA-Iy for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:57:57 -0500 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-T6W2fuNgPDC80NAjY1idnA-1; Sun, 05 Jan 2020 07:57:55 -0500 Received: by mail-qk1-f197.google.com with SMTP id 143so27747943qkg.12 for ; Sun, 05 Jan 2020 04:57:55 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id b24sm12925295qtp.82.2020.01.05.04.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:57:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229077; 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=OMvJhEP2LlmkkK5OqUcX3Hea5Sokrq83L2n0JELoweI=; b=Eq03FMvsqiHo2lOMUcELnttnxFqac1eFRkAS84ztnzKg1l8szOrfL9460sZnfLo2OpSKqB CCgNVQjgAweuKKAV+bfmP00d3gUpxgsE5LPOEK6KgT9WQaEEMPuA92TRzAeP88Xhv4EkLZ G4ZDlaEvqV/AoNRdr8uSB+x3dCDq4qQ= 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=MZOXCGQ//jaCo4R+sHDCJUpSHTnIinHqd1QfSjM9oh0=; b=HNPAqiy/6U/b29JgTjaLNDhM1a9E6KlfbIHRO8H3sCSw26OJknUSLkHxhSCKL2nHNt gKQ27HXbUxNTflZCQTkmMTg4nd1yGVmzNrkczFcC9gzFnPNQ7jW+jgh+FBTpOiYElqrT CtHcW3Tr20JgO6nVXtAR63G+88yYLd6cS5Lm75IGqdTKF3BigYtTkNYaDXbTJutLBDaK jQvHRNLHodNkcX816zej8qX4oaRFmAciog0TmdiChU12vqzxQDbsx1tH808gfi+ElUtq +E5lC3RJtvJfTtEGeVTJKeuLdmhZp7NQTufIkucggz+jvOMn6nkAC5wBp5HgI2qB1lh8 5+5g== X-Gm-Message-State: APjAAAW+/jhHn52k92Hg4prmwfiZrdK94adom6MW8GkDMlsSdh7iarr/ bYelb79b3rxF06SlnXvz9rX9O0XhmKTBfxWCXH3rEEHEvFyt2umHVffnoPBv1hY82cZbsSOw+hj /h5yqg9bDcviFf1w= X-Received: by 2002:a05:620a:782:: with SMTP id 2mr79975012qka.169.1578229075252; Sun, 05 Jan 2020 04:57:55 -0800 (PST) X-Google-Smtp-Source: APXvYqw1Qk4YhcGCoYf6m/vD0doiqUD1Z1VuqEi61vXLMweISvyLQ0KnwPSR3E1lAv4n5G6zbYeSxA== X-Received: by 2002:a05:620a:782:: with SMTP id 2mr79974995qka.169.1578229075040; Sun, 05 Jan 2020 04:57:55 -0800 (PST) Date: Sun, 5 Jan 2020 07:57:50 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 07/32] virtio: update queue size on guest write Message-ID: <20200105125622.27231-8-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: T6W2fuNgPDC80NAjY1idnA-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 , Denis Plotnikov , Roman Kagan , qemu-stable@nongnu.org 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" Some guests read back queue size after writing it. Update the size immediatly upon write otherwise they get confused. In particular this is the case for seabios. Reported-by: Roman Kagan Suggested-by: Denis Plotnikov Cc: qemu-stable@nongnu.org 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 Thu Nov 13 04:41:28 2025 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=1578229592; cv=none; d=zohomail.com; s=zohoarc; b=RAyktnymT7Y/Ko1qN8BSw3WGZvvMbd8nL2/CtC0eMldQlEBWtWxyX0SHMg5bPR3TnKRI4MK0/Bt+gt1WbUv7LT5m61bfd3qrrhAnZhWhMdDhHVVhRyAUEgBhK+W6RU0xVeBc9hbcAERygCA8m2bCt1ipY0Kh6fFDTj9clDxIiI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229592; 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=q6Os4L+WBppxRr1+PQZIGTRXnHgagS3ljQ3yg+JHbYs=; b=hHRnzQVEFXxKmudAsKysaNDNGE3sdFU4ARJaC3h+GUCtvz8ANlJsaQUOo8BCLyheWiH69ViCOm3ILuVuj5op5B+VXcXTmejTG7ldkBJAUR/CcqM5wh6Us+3oJDhHg5z/trczDGxHyoIotH+iGoKJC6HfyDu8JG5YxpRqVXQ32d4= 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 1578229592117314.1588417397393; Sun, 5 Jan 2020 05:06:32 -0800 (PST) Received: from localhost ([::1]:41924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5by-0001zk-Dx for importer@patchew.org; Sun, 05 Jan 2020 08:06:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58159) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Tq-0001Bx-0s for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Tn-0003rW-Qx for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:05 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:36866 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 1io5Tn-0003rL-LC for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:03 -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-237-5LFPXxjMPkGQI5VnuOR3Kg-1; Sun, 05 Jan 2020 07:58:02 -0500 Received: by mail-qv1-f71.google.com with SMTP id l1so10855936qvu.13 for ; Sun, 05 Jan 2020 04:58:01 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id z141sm19252755qkb.63.2020.01.05.04.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:58:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229083; 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=q6Os4L+WBppxRr1+PQZIGTRXnHgagS3ljQ3yg+JHbYs=; b=Wu5flJMu5M7XrOzRUcSOPerrJlS2XDfq/NloS1IXcHfBE1jy5Rlacr6ekGarUqi2nxn9Iw 468TX3WEPhV/sJ0ttdssICvpi0npHaGjGWGHS5C8rNFRj6D44dA7OGAnQNhalRTd3S6YWp 5Xq7tqoTfnoSNX3JaUSUduOCG0MrdBg= 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=Sh9NZFodPuDYsX7mh7EXFUKW/sqh5xR67aWfobfmobY=; b=TTKoEBxKtG3+M+e08nbXGMHnqi6/3S97egi2xk2ZjpOJoiVQAovslDUxw+5Jb3Fvk7 by45coQ+IBV3awZJE34pxcMqJfiRoXIAng/PJY1/LQiDBK0de3izpaQSI7Mo09Z1f+Wn NKLq/Hsxn4rLQUXZWPanCsaM8VN9X+V1qYQmiB6+nPbOrcuanB7QG02/3jsJ46xNC7Qn rqiBrQrMFLwSZ04edrpvLTbcuYW4QIdpkEwRC9al7/bxAc2xBJskDmVcxLONaGvk3dLi t7V8FExojjgn1XU5vMfWnifZEd3xHfdLRNpziRcSwqak3bGs7eRCUA+ubQ0jKh67+tTU cfBQ== X-Gm-Message-State: APjAAAVMNUPg+9Ah5VAcfYPtUEoK2Crv5JQYxEd5AKzRH60IbbBJ/t8+ 04h9XR77xEYqN1+61CBj0ke8vuLNixQeS3gVQn/vJw6NJszgqMbkhuXo72knJMJ4tIemVz1jKau OCNm9xk2eRkJoFsI= X-Received: by 2002:a0c:c24f:: with SMTP id w15mr75970566qvh.66.1578229081145; Sun, 05 Jan 2020 04:58:01 -0800 (PST) X-Google-Smtp-Source: APXvYqyT58Zq+8x+koemOa8m9/yNaiem+ic7Y3Th2XIUzgRCOo3TDMZQxS3EnCpYz3QlbFprhMzyqg== X-Received: by 2002:a0c:c24f:: with SMTP id w15mr75970553qvh.66.1578229080822; Sun, 05 Jan 2020 04:58:00 -0800 (PST) Date: Sun, 5 Jan 2020 07:57:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 08/32] virtio-pci: disable vring processing when bus-mastering is disabled Message-ID: <20200105125622.27231-9-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 5LFPXxjMPkGQI5VnuOR3Kg-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 56137e9bf0..0854dcebdd 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -34,6 +34,7 @@ const size_t hw_compat_4_2_len =3D G_N_ELEMENTS(hw_compat= _4_2); =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 Thu Nov 13 04:41:28 2025 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=1578229794; cv=none; d=zohomail.com; s=zohoarc; b=SOnmt9X5qwfqyuOnMn9T8sPvRSGkwo/gr2hn4X7wCJPlu4fAm73h7jVlQTw1VJn21Wh/PFdzjdX49keRmHa5okirdfqarpZlSyOGDqZNcY+9S2Tlu8Pj47XLIGyxrdJd4+Lcz9B86RkRrOvUN8viHfWE0v00Xcp5bKjZRM/3fQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229794; 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=IZT9VnInh0a/woHhhOZmwBoPFqcdNr4yBx2M1u+NiNpekIQuZn2yfhk1yglU9R9uktxpYBWqoO8shoDFxxI80zTWcOkKhjYDv2vWbnL3mUBEd0CCdDt3Xn6LnikdB5UiC1dEJQ1/k5AscBNcps+DW780zYlPUKm69bl+3Ws2nk4= 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 1578229794852989.986937342941; Sun, 5 Jan 2020 05:09:54 -0800 (PST) Received: from localhost ([::1]:41966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5fF-00073X-1r for importer@patchew.org; Sun, 05 Jan 2020 08:09:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58171) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Tu-0001IT-B5 for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Ts-0003ux-Mh for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:10 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:44341 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 1io5Ts-0003ua-HZ for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:08 -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-364-6iiKViAOMFmiMLZBz9K61Q-1; Sun, 05 Jan 2020 07:58:06 -0500 Received: by mail-qv1-f69.google.com with SMTP id p3so6444222qvt.9 for ; Sun, 05 Jan 2020 04:58:06 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id 184sm19225653qke.73.2020.01.05.04.58.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:58:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229088; 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=KmMVf0LmN/oVXH091eC4JGKwertJbv4OPghaE+QqIREIJ7IfXF04+yfOa564rEdia4X8gm 9XRPZMOfpgu84tHYLbNSxyuzPlyTQitrTvJYYHrUaen82B3taT3LSGoQKISx0vzIO/lAiQ mjfyayFMMXRBbVxfna7zbET9p98I1lo= 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=GXhhoOKeiTLSrA5nHNZEz3EUHbTqZH16XaY5zyn+sA5hN+mgJVOJF5yMSF6s/npXiH HgAZc7cH8vkbmP3NZpz0VtwuoayYOyIBOWIu5rQm75C8YBwQ53qXb6/Dth3jNTcOMfO5 opToRviTkFyunF6/Km+ITWI4vCbEYMFfCFP7bBuTZCaCeGArEeibeM77TLbgNddR2vxB 63v/kTercTbKZEkJXJ/HkS0Sx2YcUqu0+qW1rrWtWGe6Uxtf49dYh7qlY7+21ErZZb/f DfJ67HdYagMjMzKQC583vx+UcfT3P/FOC7ggc8Ik2X+m436OPXQy9Fui086lQq4KyhhO njXQ== X-Gm-Message-State: APjAAAUKKPswiTTYavOc2FODbRWLb/pp3fYzf0Ufp2pMI9odjRdfG1Mi TZ7IohgI+JeWJXjq+Dbdv+hxwWW6wKDCNx9r21qjAeEb8FSJSiekxGiC0TOrOIw4DmjKJhwsd4P vr7yIlqZReg8KUnI= X-Received: by 2002:ae9:c104:: with SMTP id z4mr77457075qki.418.1578229085625; Sun, 05 Jan 2020 04:58:05 -0800 (PST) X-Google-Smtp-Source: APXvYqwR8SP+i99dEbE241wuu8Zc6Zi34dKH+cZAjlYPGS30lKJfYoAF+jZtvmYmYah1flMaSJF2cw== X-Received: by 2002:ae9:c104:: with SMTP id z4mr77457062qki.418.1578229085267; Sun, 05 Jan 2020 04:58:05 -0800 (PST) Date: Sun, 5 Jan 2020 07:58:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 09/32] Implement backend program convention command for vhost-user-blk Message-ID: <20200105125622.27231-10-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 6iiKViAOMFmiMLZBz9K61Q-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 , 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 Thu Nov 13 04:41:28 2025 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=1578229970; cv=none; d=zohomail.com; s=zohoarc; b=euRMUW/2QJF/xzN0XZtsHFah6Woec4HGkegmH9kpO5S165JDuMbv0O16rCYUIJLG16JyXsQm8BWJm4p0YYIZwzhEUmPL8Monm8iJ/Hu+7vEXAqi7zxHX6F5IdA9cmi72T1KZHdMKclDzNIPr+A9EBfRt6Di3smo/mUEIwq0fXkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229970; 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=w1jQK9Yxd2TIknp+M77tR7Mc2wzi2h6Dp27XqCYt2e4=; b=ki1V+TcYmYuQ1JGIwe8bal8qYmSR7zJVx4w5Mkd2J4pe3q4uKObpUS5KxyY9WyqLVIBkL0Y3vKZoD8miZbRVodjAX35AJNlYY+TU6keMSqBWeGZdqtz1n8ktPEdFlIhf0wMPVwPnmj4HxuCzeKzrMdBplgkaB54WwUX40PF0rlM= 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 1578229970935711.8644361063324; Sun, 5 Jan 2020 05:12:50 -0800 (PST) Received: from localhost ([::1]:42004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5i5-0002EU-8e for importer@patchew.org; Sun, 05 Jan 2020 08:12:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58193) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Tz-0001QN-GO for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Ty-0003x7-4A for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:15 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:37666 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 1io5Tx-0003wn-Vq for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:14 -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-244-mtMJk_nkOLav80IQXd_EMQ-1; Sun, 05 Jan 2020 07:58:11 -0500 Received: by mail-qt1-f197.google.com with SMTP id c8so32580873qte.22 for ; Sun, 05 Jan 2020 04:58:11 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id b35sm21939105qtc.9.2020.01.05.04.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:58:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229093; 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=w1jQK9Yxd2TIknp+M77tR7Mc2wzi2h6Dp27XqCYt2e4=; b=U1PCZcoal3iqeNNro9FgQmGI9OnS3askj42n9C6toZC8RT0ksjoP6sNp4629eniI3mgVtd UQZZfvd+qou7qmZJ9UeXArvnPApjfFROGCHuQJv1HllIm/WqTR20ioaEbG8st9qKFpVt17 AXyHY3IzsoQE8y2JwkGh0pNVo59tWxQ= 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=Ks6shax4mMonha1r8yzWlFliM2SkYmnLxhP6HsmGeGE=; b=ANzYli9BlMd5QEo6lWgZGIZtb0b7r6I6yJA6fW+pcQuhZS0qPltqsHbJd4YTuTR0zl zQYO74luwwvODM2ZQRuQfp9A0jVlzUXLadfbOl/DzrYTRcG9uU6YN3dYYROw07R9iK3N c5i157paYB4OQhPMs98oEEB0Nl41e7tk8S0dLUxuLe56IZ6UvtbkOMbaxucBzZiKps+F 06MtBjcNJPrm+1mkHpy+8ZM8wkpuWh62IzTsui33OtSgBUN7kLyE8h+fPuggAjkPaowc TW8w7pfcte+7ND2KYF/u4dcKjgU1BlpI6X1FJHHUYihd/lwGRlwPQFJg8+XBTyZeuc6A xvIg== X-Gm-Message-State: APjAAAV/2ar8holACi0/02PF1gDdSKU1+h20BrrtLsnPZIxW/Z0HUpI7 u7aOuqGjmBuaPDXb+SZFQQ51GIYJ4dZli0NEYua8KkrlTjg3IEm3vF/upGMYPwZ8trDX4Yu31La jL8DRhzhMD+Z0G+c= X-Received: by 2002:ac8:534b:: with SMTP id d11mr71529186qto.170.1578229091021; Sun, 05 Jan 2020 04:58:11 -0800 (PST) X-Google-Smtp-Source: APXvYqzlFNzqS0gmB/zolFhggrnVT1qp+cOLY6pKTITBMeu03UUBZV4+fx0/wzPXGJjDed0mv+07Fg== X-Received: by 2002:ac8:534b:: with SMTP id d11mr71529179qto.170.1578229090812; Sun, 05 Jan 2020 04:58:10 -0800 (PST) Date: Sun, 5 Jan 2020 07:58:06 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 10/32] virtio: don't enable notifications during polling Message-ID: <20200105125622.27231-11-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: mtMJk_nkOLav80IQXd_EMQ-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: 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 d62e6377c2..b12157b5eb 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 Thu Nov 13 04:41:28 2025 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=1578230208; cv=none; d=zohomail.com; s=zohoarc; b=lXZj/OTpxOqhSzOfvFjIB0/B3K0mt3UENhoDgn0rlT993+EtIbnO5wbM+X8UN/Bp44u14fcS/3zej6vnMdRFAhLhHOequNBUFAADrm1LgDEj9g7d8VdcEQvorq2fXmSqoBq7aqcPmOZlh516KgLHp2uJsHrxgO2brK7sslAYU+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578230208; 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=pXEsl8xj2B6C4J6CzOpzs7IZM8KuBGBRcno+vmHdxQg=; b=VhzNfpvm1T7bROwyxn91BvrCfMMVvTXSEa9zPoGfmGgqEe7RVcCi7b4gCqouLQK4ytcuWQxyAG5hOM37rbC6r5Zm0bezUef1yh95FTamS2PTsjcsJMu207eMuykNjGwsnjiyYdzdh33wbRvakB+UcXiqW41NdBMgydlJRcFeSE4= 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 1578230208113141.0832274339316; Sun, 5 Jan 2020 05:16:48 -0800 (PST) Received: from localhost ([::1]:42046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5lu-0006fY-60 for importer@patchew.org; Sun, 05 Jan 2020 08:16:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58221) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5U6-0001ai-14 for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5U3-0003zW-WE for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:21 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:60793 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 1io5U3-0003zD-QJ for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:19 -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-265-YyIp_V7VNBKIM5rG26RWCQ-1; Sun, 05 Jan 2020 07:58:18 -0500 Received: by mail-qk1-f200.google.com with SMTP id j16so23404712qkk.17 for ; Sun, 05 Jan 2020 04:58:18 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id h1sm22069389qte.42.2020.01.05.04.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:58:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229099; 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=pXEsl8xj2B6C4J6CzOpzs7IZM8KuBGBRcno+vmHdxQg=; b=EfA8MTu60O1m7qrsKBG1QQPXB713uxXTRW4kGjkR9HBk2lSfQCfyk/QPEjU+yi2ZB5sKz7 6bAGtti4p/EvO4MqMyKQHL2LbCjuqqD/H81swbDSWhnQi5B7q3PKQnRagloTtarjwye0ER RFjdmSagQIfV5qC7dxl3HTP9/XHoTKs= 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=MPPKzQOazirg5jBND3h1wpeXbc817RV9EQNRRNDvGLg=; b=Qsaiv4H9bJ41hfEFN4atjYTz1rcLalZGKhj2eDypJPgmnusqf7h44uqMoBmqVI9L6s gL59zkD56PPNEGNJWFtrClMaXdbQ7UTA7LF6umquILdzFoL7KwGppXwCrKxqt7C8bSNs CMz6exeYFmR+ibWH/8KOJ1w+Lxyqv61u0E/dAVPKop70vfO9QyP92nvJaOsLFb7GqUYD KB+ZkEqH/SS/X7Zn8E+qE7ttFoyFWTvIim/DGbF9YQRaDnzRU2E6GJFnkUCS1WbWTlwH H19YcYX6nzXQhdY8Gr9c45G8XZrrlwfrO64oJsqyLIJhm2HGQBhQjEtgMyNkw3dElfiF gDFA== X-Gm-Message-State: APjAAAVhpsjAxHuKOC2eFuCPKI7Me6BmQRoQIi2K7gqmCtPS1R4dfdNY rMfiClNcDGMoFI/xI3AVcUCp9wd9z/Gl0zwFWHgtGNIjbH9jACNCVIwR4NLqCQ82uU6ZKirmSpf ncpDmUIZRYYo3NWQ= X-Received: by 2002:a37:411:: with SMTP id 17mr81498011qke.40.1578229097210; Sun, 05 Jan 2020 04:58:17 -0800 (PST) X-Google-Smtp-Source: APXvYqyzhR2hq0tb0d1FUiBPp50koJazwOb6PwGgQDqTvTLccY/Q2MJNUK8xMjDvmIaM0lYOhHY2Pg== X-Received: by 2002:a37:411:: with SMTP id 17mr81497985qke.40.1578229096769; Sun, 05 Jan 2020 04:58:16 -0800 (PST) Date: Sun, 5 Jan 2020 07:58:11 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 11/32] numa: Extend CLI to provide initiator information for numa nodes Message-ID: <20200105125622.27231-12-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: YyIp_V7VNBKIM5rG26RWCQ-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 , 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 0854dcebdd..f5e2b32b3b 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -430,6 +430,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); @@ -557,6 +571,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 @@ -626,6 +641,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) { @@ -846,6 +872,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 */ @@ -913,6 +946,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; @@ -953,6 +1012,11 @@ static void machine_numa_finish_cpu_init(MachineState= *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 e9d6231438..b78bc52634 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -40,7 +40,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}[,...]] @@ -94,6 +95,9 @@ NOTE: this parameter is deprecated. Please use @option{-g= lobal} @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 @@ -168,14 +172,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 @@ -222,6 +226,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 Thu Nov 13 04:41:28 2025 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=1578229587; cv=none; d=zohomail.com; s=zohoarc; b=nlpDfMe2kBW7ZtvQLUYDFZI0O/vWT2dVFLGLgrN1EI/yeawVzCc/ysR5BDLUowXXQYTpobpqIVSp8wdmi4LjSskC7ctSDijNu2wbuv+1B9xVbDusBvkoP/bs5jd0jXYlZAyzZ7gj3Ur2eH0smEvlm2NXk1nCQSNPbMy8sVdI3vo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229587; 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=22EPts6aFtlxMBe62U24R+ZdRqDDBVDzjTf7DPsfcPs=; b=YtvrPV0zqj3WRNpl9TMhQpGi+cY/yXrHIrbIN51mkOuBEIrhhhmBzF2LYyiQ4QgQwLpdfTTF2XDWjMwZ0ZMMWMUJbCqYArIY3eyXvUf1dR9byzu/WEzORu703iFKvRQGC+wM9ZvCI6JX/0EF+6DuG3ti6jTR5pFkNAaMwQpfhqQ= 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 1578229587986239.78392518003716; Sun, 5 Jan 2020 05:06:27 -0800 (PST) Received: from localhost ([::1]:41922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5bu-0001sL-De for importer@patchew.org; Sun, 05 Jan 2020 08:06:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58238) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5UC-0001m9-Rb for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5UA-00049D-BP for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:28 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:23070 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 1io5UA-00047W-4Y for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:26 -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-42-fOw_jPIHPnCXkNTUNkKzvQ-1; Sun, 05 Jan 2020 07:58:24 -0500 Received: by mail-qv1-f72.google.com with SMTP id l1so10856568qvu.13 for ; Sun, 05 Jan 2020 04:58:24 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id i5sm21533273qtv.80.2020.01.05.04.58.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:58:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229105; 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=22EPts6aFtlxMBe62U24R+ZdRqDDBVDzjTf7DPsfcPs=; b=gYpXXU1EgmFR9tPLHh0ACkLyOK8jvSbnmgSwvuz1m/suWaf3oCkTXp7KkCYGtmh85EHgFM b+6LSXt77rLmlM3ElJKNhjM/Gz44MHebcGayitMRzycHwaYL3kPGHlM0+eA3eea+d0ZO+w tKGnukSB3dHOpGJEkwhKx7fkcSNvFHc= 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=xnCcrYb/jhhSnPfhxsRrpT5AqLZcj5F/dVmLqeFIs/8=; b=j8FBV1Nxj5FFqVVndH8IZk09UqpbJJBY32JBPmjHmTHvhoMIRxFcVoxMz1PM02HUHv oYXb6RGSOY8YhlVOfelvnIWQcEckIT/vYpbfwce23Vzy7uN2kZfXI4Zrb6/2JlD7n+Xq Emx2iORqCn+4vSikIQ6iL9NWO+KXiln8QAGyx89k0+NPQlmpZhd1RbEF30dqAphv+lXQ G5m5+iM1gVEWW5ecj97qClXptwk2Rbu13nGb3xS72tgKWsqFVBUIFx4bnVgw+puo2Lpm WBXrG3FuWlVeP0lUOc9ZCRMGRS6riiQRj91UHqFkTwRJUupwBLhKNcLLI/xBKbRclsya WJ/w== X-Gm-Message-State: APjAAAW7D3OWe+3nOksB073bNwUr/XXLfHlqQi1u4YoU5JS2A8W7r68R /rPgqTsiRYZOlWvg3WJfjDdrvGVuixhpj2B97foGRxvAED8l9GHEDunf4/arMQbB3NQS5OZdv3L b9kQJud0YkUXjGn4= X-Received: by 2002:aed:376a:: with SMTP id i97mr71175354qtb.44.1578229103434; Sun, 05 Jan 2020 04:58:23 -0800 (PST) X-Google-Smtp-Source: APXvYqwWWOnX7188edXN0m5BfBBmH2drir40KGQp0sJ/Wzka3fguk1UphiNgWkP2PioE8OOb4TPiWw== X-Received: by 2002:aed:376a:: with SMTP id i97mr71175332qtb.44.1578229102875; Sun, 05 Jan 2020 04:58:22 -0800 (PST) Date: Sun, 5 Jan 2020 07:58:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 12/32] numa: Extend CLI to provide memory latency and bandwidth information Message-ID: <20200105125622.27231-13-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: fOw_jPIHPnCXkNTUNkKzvQ-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-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 b78bc52634..a0c0bbb7cf 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -175,16 +175,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 @@ -263,6 +266,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 Thu Nov 13 04:41:28 2025 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=1578230337; cv=none; d=zohomail.com; s=zohoarc; b=arw3p5x3vVdImCToFOK9OkepgZSpiR5TnN0m1GTQllHQF/vqNtz+TFoupYx5Q8FvvcPGGyEXzWk53NkBqXu6dvPh76xhsaICJ+GIK1L1E87QUKqhjTbPvBG2FxeEhJu25uIWr0UEa0Ch12pvUw4FhlxU84N5fQti/f1vBciaDJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578230337; 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=gA+pwh7nEEbohLHaQ73B+nUfWUkuIF1GGYQVjzNVnqg=; b=hCIEUyxH5FDa8J+WigyyrDqmgKxrFpHTDU9cbk6DctF2s1pVBmuflkfEPLdhlpxfcB6m1RyGPaBQDfbAmyRxAg6fUnRv+Eg1KJENOO3H28/EBoTOry/H1YmwVQUVwaq6GWkqJDHCkmTxwJG+MEpDVFvwOd6Y2b29Tsx8zIJrPYI= 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 1578230337855862.2372050003305; Sun, 5 Jan 2020 05:18:57 -0800 (PST) Received: from localhost ([::1]:42156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5o0-0001f8-Ma for importer@patchew.org; Sun, 05 Jan 2020 08:18:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58262) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5UI-0001xV-7k for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5UG-0004N9-2O for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:34 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:42664 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 1io5UF-0004Lr-Su for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:32 -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-43-ODXVqlLSNwWC2YxQrfDW-w-1; Sun, 05 Jan 2020 07:58:30 -0500 Received: by mail-qt1-f200.google.com with SMTP id d18so15702147qtp.16 for ; Sun, 05 Jan 2020 04:58:30 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id c24sm19425257qtk.40.2020.01.05.04.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:58:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229111; 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=gA+pwh7nEEbohLHaQ73B+nUfWUkuIF1GGYQVjzNVnqg=; b=K741qEQImAeXm11twPZNjPR/A90oYDB5uwCqG0RIC51/i4RytwZ1JQfPBcneB15L3ZpPEt aI5nOUL6kLjKiZqVyz8SzYBl8b/xtasGrJ0OdxRjEuQma3hcqxF5Z7tnqFoLdzgx9Lflmo ix1R3fC7qpwM18FkPeCgLgSHZOpPQUE= 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=bjxdhZe8lLxQ+Az28/cWVrxvfjQRU8bK06t3mInr1NE=; b=eD31xLE6uclE3g1gBBTF0f8X4Vln1+MzQ4ufmlx2t/owZWvGm19W0S1EoegK3IjoB1 ch2oin5IaZDW6Oi1n5Y5qVVKGMtV/SfpqWn/UMg0U3H4iQYvZaw71vAJ3aT4M1aWQY8N mUIJky2cr1gKrKZVwlw0fgIbuusqwR/SuEvKTwcGvHfHifdY818YcVO0+hBsgWZHKoHH nUgcoNbgcztMEZKUM7yoOcU+r7Vd5fxShyLBvejLNDUst0hg0afYe3gm726Xy2vshdOC 6n4kZ+b/j45KUASS84LY/502Fr1XK8dTXzDlFXuezMSzgV2VXHny/m8oeN2vlQDz2+C3 7M3A== X-Gm-Message-State: APjAAAWb659dXIgCqBXH9tkllfep+WXJb5sgbNvLV/T55tMY+dtpu3KA xKpWPOEiSIgrzXmU3t+YSHZucGMr/ksK6hAPhtRxgvhjXfO9UV92FAYA2uBfKRyKG2Apok0Ye6I ub6xhJItBNWm/gN0= X-Received: by 2002:a05:620a:13e7:: with SMTP id h7mr80328292qkl.235.1578229109136; Sun, 05 Jan 2020 04:58:29 -0800 (PST) X-Google-Smtp-Source: APXvYqycIzJdKmm49Tdfu7vCsO3wdGwDQu8gqUTRwG3V8HUieebFn/Syo/IB0lWz8WYpwvC8vkDLdw== X-Received: by 2002:a05:620a:13e7:: with SMTP id h7mr80328277qkl.235.1578229108645; Sun, 05 Jan 2020 04:58:28 -0800 (PST) Date: Sun, 5 Jan 2020 07:58:23 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 13/32] numa: Extend CLI to provide memory side cache information Message-ID: <20200105125622.27231-14-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: ODXVqlLSNwWC2YxQrfDW-w-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 , 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..747c9680b0 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%u", 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%u", 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 a0c0bbb7cf..d4b73ef60c 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -176,7 +176,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}] @@ -184,6 +185,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. @@ -287,11 +289,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 \ @@ -305,7 +316,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 Thu Nov 13 04:41:28 2025 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=1578229786; cv=none; d=zohomail.com; s=zohoarc; b=O8WUY6Sszml/dFKaV8JZGFBJsZYATnMcn3Zw1MgY7XCJRffZCQ8dVKt5hkqWA5PSBlTBE0R8pcm/+49EhPKqU5rB08tum6lJ4vA+N91OnV/IKyULgixpNpuLUNddFmatWMFLna07qdA8elV60F5LGDTX7VTHZm5X3pMV9jxy2Y4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229786; 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=FcK7WigJMJDie4qherce/SQbHzZxCxCRnKQYLmv9Zf4=; b=MsBdbXoApWF8zABANKIeSYi6CFlayqY4zgSS4VYMwxicxhV58sgA1br8wXA2WoV3Hzj721WBjt4cWdFcVKwW8uXKz7xcpWOyNzE/Hzdh6beBDy1kuNafhwZECzhu72dx3OS14VAVoh2qc1v89W7oOkmplrdPoos2phZ3oCg4BZo= 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 1578229786791886.7990122654892; Sun, 5 Jan 2020 05:09:46 -0800 (PST) Received: from localhost ([::1]:41960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5f6-0006pS-Vv for importer@patchew.org; Sun, 05 Jan 2020 08:09:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58299) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5UV-0002GV-RA for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5UT-0004UX-LN for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:47 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:37784) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1io5UT-0004UF-7h for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:45 -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-3-RgzGmdr7PM6aSTUM6Vjogg-1; Sun, 05 Jan 2020 07:58:36 -0500 Received: by mail-qt1-f200.google.com with SMTP id l25so32703389qtu.0 for ; Sun, 05 Jan 2020 04:58:36 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id l62sm19332210qke.12.2020.01.05.04.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:58:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229124; 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=FcK7WigJMJDie4qherce/SQbHzZxCxCRnKQYLmv9Zf4=; b=Rpawkx/6qHWT3haWz2LM0Zl7HVJUHeBBtxme3YB/jmTrSLXveiEpFQphb4pNOHm8tTUU6t 2U7UGr9uh8Xjpgd+gTXSw79hi5o+IfXBX5YlevMxDlBoW+Gtzu5GvUt5V4w4GpduRPXATr m8+4sKCHGuNR6p/lR7ZcYvjodAOEmCU= 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=OKLjdvfCJDfY6fGqKWe65+lk7+R2Zab8RzeVnW/XRtE=; b=rmxyIo/8s68Pauu61LS298C9V/N8rToFixfcuuWZN0zZMdvxLvwwJ0e3GNpd3ikoe/ kVFeoa9TxD1J6mjvccnNEis3J+dUw7NEqqI+rOB5HcCRXLyCDghi3kV3bdnrcL5UXGHf 92K3ih20nJnDP8owLuyc3NA7zA9ej85aJ7/FrDDaQg5lgmXaroIInDjKOmmmR4l5oqlf StTnRxPBsbuLfA+DNAXMm65LVISxyuVVCKv0PlAnGKrrDVZqM93M9V5QNecOFhw7yLWP F57lQnlDW9STMSHErqq5HGRayNPsJ/DgJJecxdQE3Q1kMEqG161qdP5Cu3fW7ERKXLLw CRIw== X-Gm-Message-State: APjAAAVbSt7JGe9k/oPc2bNh1kCbgtYv5EspyBSkscsj/07n6XnSaWF+ tNI6vBK/i+/HYc2MqKg9xEkXGr22dGvaytshU+GDleHUhPRj0qbG5D6nNPqw9jng1We6khlcesW c6aHusjhGQeQqMb0= X-Received: by 2002:a05:6214:433:: with SMTP id a19mr4901277qvy.221.1578229115464; Sun, 05 Jan 2020 04:58:35 -0800 (PST) X-Google-Smtp-Source: APXvYqykHaEJ5zESx3tTYfnRu4LNEhEFA13FXQ+4h0rY/tvvT+Kg3QDJWcqiwfKoud2714EBpXGBeQ== X-Received: by 2002:a05:6214:433:: with SMTP id a19mr4901263qvy.221.1578229115120; Sun, 05 Jan 2020 04:58:35 -0800 (PST) Date: Sun, 5 Jan 2020 07:58:29 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 14/32] hmat acpi: Build Memory Proximity Domain Attributes Structure(s) Message-ID: <20200105125622.27231-15-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: RgzGmdr7PM6aSTUM6Vjogg-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 , 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 7b8da62d41..e25df838f0 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -68,6 +68,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 @@ -2835,6 +2836,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 99253057e1..777da07f4d 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 common-obj-$(call lnot,$(CONFIG_PC)) +=3D acpi-x86-stub.o =20 --=20 MST From nobody Thu Nov 13 04:41:28 2025 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=1578229573; cv=none; d=zohomail.com; s=zohoarc; b=UsIT54IRL5QMrQmCecs9+dngHXTTlrjhAL5FQv4IDP5qgu6X4V6Sw9UYqD1mF55sIeJ8jLcBvHyQ3ux9DX0mKbJROFcahIVoUcC9xVJbyhLNOcpQabh4mqJkst+yo4GuKXXCliKedeW7TWbwGqGPABlr7O9aYNHjdJMcVQpsh68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229573; 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=RAUtlSKfgHXYJU0J6+DxNQbKwZpsnWNrAQ/1wwkoKIiPm/0hj/Ytg5j2LunBOWBngBkPj/HgpL8/Ke47UUSY00IgiUavmOqq2dK9iUEBjd0Q5o5C3xRuNQCQ2eQS2A5dcBQ8xFM18MZeUHZnBRU2A2sm5zb9asjnAx0q4lVVK9g= 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 1578229573008938.880267405822; Sun, 5 Jan 2020 05:06:13 -0800 (PST) Received: from localhost ([::1]:41920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5bf-0001XN-Ce for importer@patchew.org; Sun, 05 Jan 2020 08:06:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58286) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5US-0002Do-Ov for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5UR-0004Tl-BV for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:44 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:58525 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 1io5UQ-0004TM-Uu for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:43 -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-82-mHrrq6p-MD6AGCdVuPssZg-1; Sun, 05 Jan 2020 07:58:41 -0500 Received: by mail-qk1-f200.google.com with SMTP id k10so5555502qki.2 for ; Sun, 05 Jan 2020 04:58:41 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id x34sm21526953qtd.20.2020.01.05.04.58.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:58:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229122; 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=jJ8h6cY35BQ8o9OY+nmhAn3Tpt4rd4kZ2Qys0oKkCUwqUZtUzwDxuK7Kqqon+QeVV/7AL3 bIlqCEGm3BcYhJ1tZSJYrhHeLuBYa6t1MPqA0FJWOsWFK140b0qvR4QIhNW0l4vFZH/Z7s C6JFfqUsdNynzaS/GQ53uATrNkr+3pE= 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=Fa/BnUpqq4ES6W4zqmrPAviMFIS1nsr5tFbXUNddTAtQgZzkRbM27RNxG8V3eVES8n cUnN15lpOUau0FKXcDHPb+p0NncgUGmFKeBGzkTogp+jW5tpdVngwqBvLFpgMHZg4x8d VQGhBVItOXWV9OQq6ICcNpOgv2rpZqf39VZTIJLCMT8Rg+YoOvLoaoB00mAf4d+VsQvQ GEbbW+3B8M2I3xwKRxiJnlf3EBItvmEuppMJMwzcrKEPQkH94FQznDcnCQKqBof1IdBr gzGK/eyfur//puSqp0lXh5t4E7I2U0jRL5oqU7lJ7LlbnM08N/6pjdRQVNohZzbWB+gx XI6A== X-Gm-Message-State: APjAAAXJoRJ975BRN5lcLAqeSECoF+UsKRGNv3O1+rxPmUjMnThMmx7b O+84bO8c3eh8V4vhImrJOtSKRSyxk29gxqSu05uEBLTNckZAeV4TTDyiJIs/BvTXQYaqov0HsBy NsBhTEQPsYgDA6Bs= X-Received: by 2002:a37:ad17:: with SMTP id f23mr77743834qkm.24.1578229120333; Sun, 05 Jan 2020 04:58:40 -0800 (PST) X-Google-Smtp-Source: APXvYqz3yS0YcgBKRJXQPkPysZ1JzZUTit0YkxE8FOChAtQzm4jJQ+bB0wHdbbF9fVlk4niqSDKGtw== X-Received: by 2002:a37:ad17:: with SMTP id f23mr77743827qkm.24.1578229120069; Sun, 05 Jan 2020 04:58:40 -0800 (PST) Date: Sun, 5 Jan 2020 07:58:35 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 15/32] hmat acpi: Build System Locality Latency and Bandwidth Information Structure(s) Message-ID: <20200105125622.27231-16-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: mHrrq6p-MD6AGCdVuPssZg-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 , 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 Thu Nov 13 04:41:28 2025 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=1578230415; cv=none; d=zohomail.com; s=zohoarc; b=MUBGUDJfhXQIweM2o4/4fMEr8hlSwH+lEANZD17BpkUE8s8duI3amtRVdfUa0lqe6HKYyoInRkIwyOlIgvlZ/XWAxPCGNnu0awAB70QyeV2ipmij6DfuMu6pfSOxdT2j88Bp8HcODseGt8wRkatwgjjiT7aCv3yuJh1uxRf88I0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578230415; 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=OoHy2DQogvu1FOH2/ylkgqv35EVmaMLq5QtUO8Z08RRl8kqSGvqkGStl6YomvtlpE4SB2isUazmbWmRvQX0BSB/RXeTKWofGfvwG+GXXm+DBRFaZnQcC7k9mipiVVA9oOaELwEsMzeFOhy58a6zWqd2nXZhWetzBddCEupCx7oQ= 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 1578230415345706.3722312916852; Sun, 5 Jan 2020 05:20:15 -0800 (PST) Received: from localhost ([::1]:42166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5pG-0002XL-49 for importer@patchew.org; Sun, 05 Jan 2020 08:20:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58312) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5UZ-0002IY-9g for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5UX-0004Vc-1f for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:50 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:20860 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 1io5UW-0004VQ-Ty for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:48 -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-123-_uWWBwY3OkiKc8wvD2MDUw-1; Sun, 05 Jan 2020 07:58:47 -0500 Received: by mail-qv1-f70.google.com with SMTP id g15so1525496qvq.20 for ; Sun, 05 Jan 2020 04:58:47 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id r205sm19240803qke.34.2020.01.05.04.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:58:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229128; 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=MvzvjLKifepsjH7JP2GXpuqgHVklmSqQ3EZ8kyqCVpaVUFKb1bXM3M6vL/Dua5YEPXeU2k uLBddzndqefI+ksF18dMDRHVJAgUgXDFCiS548RJ1rCyxNIdbUVIcFXRopBh9XAqXS3iEf hjTCCQeEnDFw4yL2cpk6pweYMDUVNUQ= 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=EmosQETVMbwdnA7EgZWM2PAf7gku5SItiM8BnUUf3U416yZ/pSqAvyqSRokzS9dQ/O NsmK/0hrd73M1JnhhInje4DNj9vepRDqW3Km1rnpWXlL64d1U5FlEHRA7vZAad3OHDD2 NhNQsmVXXhqbSva98CbnJN7WWAoHN7OTRnhI/dSB9v6LmD2ql5x3fIo4BkwJoeLt3MJ+ S69OLglXHLCCf8+8z6sFmxCexROAtiq+op0CnJim6vSSfpKXaQZINCHKIPq2ProbZFhN iQksNOaWSF+ehrnnaTVPXIMWfev8KRRObEeEu+shacWw1QYZSnh9BYlA/7KZiuUI9CYG z6oA== X-Gm-Message-State: APjAAAWz+pI2RudVCUtcxnDKAtpG2akR+GlGN1GCgSSHPQgT146gtTMc GCIJkGclJPKhuRet8FH2rzBFnHpUugzm+8GX2jrVDSGadWX5aXRxtD7K08W5qRXKPDXAjsMqbdu dhc3a1h8MHCJUo7U= X-Received: by 2002:ad4:5304:: with SMTP id y4mr36607099qvr.56.1578229126288; Sun, 05 Jan 2020 04:58:46 -0800 (PST) X-Google-Smtp-Source: APXvYqxRQqcUDUKSZqq1pvsfOKunrElGnlxpivWuMBHjXwcd3X3FQrY9iVzbmAKyDg3KesJHX8vN+w== X-Received: by 2002:ad4:5304:: with SMTP id y4mr36607083qvr.56.1578229126031; Sun, 05 Jan 2020 04:58:46 -0800 (PST) Date: Sun, 5 Jan 2020 07:58:40 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 16/32] hmat acpi: Build Memory Side Cache Information Structure(s) Message-ID: <20200105125622.27231-17-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: _uWWBwY3OkiKc8wvD2MDUw-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 Thu Nov 13 04:41:28 2025 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=1578229958; cv=none; d=zohomail.com; s=zohoarc; b=R8du9hij7pgVHD4kLgeAYCt8/QLKiuRTcp2Lr23KTI5JeS+YCGYOa27Eeui1gGaak+mNDTG75BOkkNla9wGHwVMCXMLe5+g40Up5koEfvzClcLTbcFAwK/xVB9aJe4uBOiKQtCM7/E7RWmCn2/bV9M60FYQJ7lj1N3edl5ngPBk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229958; 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=jHtELArEanflU6P8RMiPvTgVOvpnTRUMbOQ5MWe9OJQfgRmERCOUQ4eMM9ew3pPuRDSbz8RcRmZkdUpEUx2Z4lWqno5E9NIfmfXbPzwuIVv5g3Zk5nQ/qQaAY9bRhhdq2xGenM+RApZId6n+DFgVM4mPDeQmkehyM3Ljsi7MP6E= 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 1578229958407721.6285143730177; Sun, 5 Jan 2020 05:12:38 -0800 (PST) Received: from localhost ([::1]:41996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5hs-0001wd-Nl for importer@patchew.org; Sun, 05 Jan 2020 08:12:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58329) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Ue-0002P5-Ld for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Uc-0004Y2-MQ for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:56 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:60615 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 1io5Uc-0004Xs-Gl for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:58:54 -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-42-v8sHr3O7O-iI5spk3ou4Vg-1; Sun, 05 Jan 2020 07:58:52 -0500 Received: by mail-qv1-f71.google.com with SMTP id z12so14615907qvk.14 for ; Sun, 05 Jan 2020 04:58:52 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id k22sm19411576qkg.80.2020.01.05.04.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:58:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229134; 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=MaKs8nkc/jq51cG+GTk1zKtojP04zDADMyNE6dI2ynmkdv18t0MFTF2281M0MTZCCIyNYk afvO7rAcSMtrmeVNFOHilFFZ9yl7ex6pBG5qkO3yWnAfXP6xD00A6whX+5Lab7FJpBbG89 +zaQyiGMYhHSYAT/lZ20lSd0F5oTfBc= 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=lk1ppjU0PuxBXPsRxl/rLTuEgeD+jAftnSUUz2deDj7965IXv//fD2pkWAiexh98Vy M0uohXgty76QazwL3QKP3UY64/R07m2LwpZxjshQP0q+tqUd2jzb4s6SMM6DU+XvF1P8 VnNQzfnMrmxcU1sGOrckA6JY2FZqJj4UHsvGiDcme+K32HdJuXsXLwYASHnGedNS9s/y teH+2ySv05lQZAeiTlJH4CCkoWD+EEnUAA1AwI0WwSZyPa/34XcrPI+7ynoAbUJPojHP uQ3R8sn9jcvacf1L31qfoKoINlT2zRrTzTatN8OFP851rxSaK60zb/CWUBw2ORyDTlWi l44A== X-Gm-Message-State: APjAAAXPJcZp5Tszs7YK6d4ZidYQsK/CpLykeBMfP5kOgUuAZLginlrp Up5w8v+E6SP5SQ2T/LdI0W76vUsxBjasIJLLX7JxIMqIWUSna0a0BsLEVv5mT2zzUU5ef+lqBPO 66nUKnrUWf6zxBrw= X-Received: by 2002:aed:2ee1:: with SMTP id k88mr65834553qtd.25.1578229131934; Sun, 05 Jan 2020 04:58:51 -0800 (PST) X-Google-Smtp-Source: APXvYqzYJx2xmPYznWuqVSXuTPc+c2/tt2IaAZJJ6RX++fldw33YLJf6gYe3+POqKwZ4lBWKurjE1g== X-Received: by 2002:aed:2ee1:: with SMTP id k88mr65834545qtd.25.1578229131613; Sun, 05 Jan 2020 04:58:51 -0800 (PST) Date: Sun, 5 Jan 2020 07:58:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 17/32] tests/numa: Add case for QMP build HMAT Message-ID: <20200105125622.27231-18-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: v8sHr3O7O-iI5spk3ou4Vg-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 , 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 Thu Nov 13 04:41:28 2025 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=1578229714; cv=none; d=zohomail.com; s=zohoarc; b=SsG2/hviImRZCmdfn54SfOzZrkca0SKFwxeEd33Q0Lm1H+5GzE144GwVFu+R/X/zbPD85AVrlarSF8wNNmeFnyHA6N/O9RIPvoWY/FTLZPKR1pDa6+aMzhqPzQ9D3dHUS3XTng1FbbBR/LETJM/q7fKeKA1bPIqlcvqSdjzP6IQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229714; 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=ZtYURyag3DLg8nTLoi8QUVY5fdiTw/VqNJshcmNYPY8=; b=UtTVYa7V68oRSjXpSvddH5uArpiynUgNEk6MZK6O9VKqPdvn/9eMhFaMIgnhROkGWEynbDujIywlqDFQCADB443xnVZAlPrP79UcbFRb5GtlNo/pXmtru7QQbUWQioPx/mMwYSAN4d8uxpZW9t+SA0tuchNO9hSb7k63v70fDBo= 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 157822971496652.61074342297309; Sun, 5 Jan 2020 05:08:34 -0800 (PST) Received: from localhost ([::1]:41952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5dx-0005Ew-HA for importer@patchew.org; Sun, 05 Jan 2020 08:08:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58342) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Uk-0002YW-Nb for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Uj-0004hf-22 for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:02 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:26592 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 1io5Ui-0004gJ-TN for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:01 -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-326-hexgHBpRM3aMUq8li1tFUw-1; Sun, 05 Jan 2020 07:58:58 -0500 Received: by mail-qt1-f198.google.com with SMTP id d18so15702781qtp.16 for ; Sun, 05 Jan 2020 04:58:58 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id i90sm21633223qtd.49.2020.01.05.04.58.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:58:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229140; 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=ZtYURyag3DLg8nTLoi8QUVY5fdiTw/VqNJshcmNYPY8=; b=fAZlgszUjmCAJ9bHzD1k3GXgSWibWu0rtsNItHfGf+aCShI8fYnRDevWsQQXoJ7mZBzeoY Wp591MhfML4KYsWaWp/lRAphAsWUz9yRtDQ/53a0KCKimDqf2YzzlWNwZO5aQfFmyXZCyH lAbFCncg/gC1hGTkR8W9Vpv8rLSZo2A= 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=SruOAG0qaxCXWnEXh2DvWIZr1jCGMkEnWfc8/NLsCZo=; b=QZ0oW3CVvrexYLMec47o0ORI8pTkmpHl72y2lO2UE992EDuvSeok1UvGSzvhxX+Wme iXgxzmJh1p4b2fSj2qMrii/jp1L11XLxGkcsAuO0IzXmQpscl/U+YXDrCDe9a6BaiyqG z50AKkThlcqu166W1VM5GGen91vNH7+PyiW3wBfbfVj9FBS/bJGfMyaYrTFDxQP5ccxM a8Xxo5ovuIY28qRXl+yGe7VnNjMACBo4k4YCbx0qjj/ZeWzqyBMLdaKubT5wbF/1rnKP Ig0Yoqy9qOxh4bGOpUq+nYHkLb6RdBKijcLE57eNXpdQi7GKDKv/s8j2cpMi/Kup6nlp Xr3Q== X-Gm-Message-State: APjAAAXbAnq+aflMGpbQt9ztxXAoV1NqyPJoAByLL4H/ZH2PSc+4SvMj jK8sxmngDZIV3ga139SNHDL1mNBoukwHwnnMi8BZ90XWjTN8LoDuysdSWwLtQ7r/S6gRkxCn2VO gJto9uAFT3ruS7S0= X-Received: by 2002:ae9:e907:: with SMTP id x7mr79907341qkf.298.1578229137969; Sun, 05 Jan 2020 04:58:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwRKf0tmKYgAh3pkMnPtcG9U9GE+VIQmioCw6YOqtZ23/pBLNU7WWkITfJzlweXRCJbhXQcZg== X-Received: by 2002:ae9:e907:: with SMTP id x7mr79907322qkf.298.1578229137639; Sun, 05 Jan 2020 04:58:57 -0800 (PST) Date: Sun, 5 Jan 2020 07:58:52 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 18/32] tests/bios-tables-test: add test cases for ACPI HMAT Message-ID: <20200105125622.27231-19-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: hexgHBpRM3aMUq8li1tFUw-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 bc0ad594a1..f1ac2d7e96 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 Thu Nov 13 04:41:28 2025 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=1578230505; cv=none; d=zohomail.com; s=zohoarc; b=B8bKR46qV8q/LLGsDZeNy/rour17XovAiWyGV5pKx2kyaUWcpcEKk3P1yapipdzRkjOn3lVZX/sZvwqq+z2/psb1xRpw+POjxjOILCIv5TsR05gd0VhnQjGega2+yTGngU5Sg8knIT//EWWRegWgDhZ10/ETHZW5krBkFyVklDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578230505; 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=jbZw7S/Gyty9ntmhKn79Gnu/auVvu3lU4agdWnikiY/BxAmbWvw/kPuOMHeotKH9W1d7GeEGJn4Jnhl1LavwhfmA6/fRGRbFEBTMrX+JiS5DrtLd68Lwmyi405f3ChHL3Skve1F/imWbxI0dY4t9PcE3xdPcN8tXUqUt0ANqR14= 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 1578230505651734.0616121144568; Sun, 5 Jan 2020 05:21:45 -0800 (PST) Received: from localhost ([::1]:42190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5qi-00044L-BO for importer@patchew.org; Sun, 05 Jan 2020 08:21:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58356) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Ur-0002jw-8R for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Uo-0004rP-TU for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:09 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:33096 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 1io5Uo-0004rA-O5 for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59: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-343-1cE3_wfuMpiVlHpCQLXJ0w-1; Sun, 05 Jan 2020 07:59:04 -0500 Received: by mail-qt1-f198.google.com with SMTP id d9so28197112qtq.13 for ; Sun, 05 Jan 2020 04:59:04 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id 24sm19479964qka.32.2020.01.05.04.59.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:59:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229146; 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=giVT7CCUFqKCYnlxpqDL1mgn0agWfgffocxZEfydPCg8zFdy1R6LvCw7DJaVYTmABpqsJ0 NHOdSK93QpZOo3QxSIRdkO9WEliJ7dneB/dcn7sTzjbWuyNedxrYRXku7vysU2C+BnA1dh T7Tabz9PQ8ehCungzEpXebmeyRXZmng= 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=stdw2RaN/E3IIuGvQDvsGkD9jV5Nvx0bFkute0VTBWpPJmmp7bEynHXSf9Zb6Q70Iz 6kATrwJtQMDgIMwaZWf/zYcGcU+gam4x/qwk/ARak/PB4d803CoMuyVvgjgegWcRBoLN 5FP37VH9gFWWYkVOx2EzoQns81Fx228xfEYFdYqL9oFmNzL4ogp4/CNefWLYLHERBKYx +GHRinlMT+NzJhzaUOvOVHqKVgbfugT6j+wczTWRCLBX1CttUrLBuK4d0Tliu2mlYCWl vdNHswISmvnJjQOIDSl8C9mFPlwFilRMkS5jYbFTeqqxxxy/6GL/2D0xC4MuENgZoM+j v+bA== X-Gm-Message-State: APjAAAW6x2QdqRnwXTzkiOkP9A1oiS/sSl5eQpX9uDc2WPpbOLreKXv7 HdI2k3cLWcf0Z/WED/Ygf3To7hvDrdqkGwAHKbKMWGVWakh6B5JpAKcMhpBCCAjpFK4nWRNwfn4 f0hCOjHzaoiIN+YY= X-Received: by 2002:ac8:5205:: with SMTP id r5mr71909242qtn.230.1578229143456; Sun, 05 Jan 2020 04:59:03 -0800 (PST) X-Google-Smtp-Source: APXvYqzQRkcysvGWGQ807gxjlwp+IKQcuheRfZDxikDZ/b1ir1YfgDLPmPqCUUKOy1InFOttnrFkZA== X-Received: by 2002:ac8:5205:: with SMTP id r5mr71909226qtn.230.1578229142954; Sun, 05 Jan 2020 04:59:02 -0800 (PST) Date: Sun, 5 Jan 2020 07:58:58 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 19/32] ACPI: add expected files for HMAT tests (acpihmat) Message-ID: <20200105125622.27231-20-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 1cE3_wfuMpiVlHpCQLXJ0w-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 , Daniel Black , 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 1578229566471960.8031619219937; Sun, 5 Jan 2020 05:06:06 -0800 (PST) Received: from localhost ([::1]:41910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5bY-0001HG-Me for importer@patchew.org; Sun, 05 Jan 2020 08:06:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58368) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Uu-0002p4-EP for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Ut-0004sy-8w for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:12 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:50228 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 1io5Ut-0004si-4b for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:11 -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-120-6I7jbfCbN5eHIA-UCE-AHQ-1; Sun, 05 Jan 2020 07:59:08 -0500 Received: by mail-qt1-f198.google.com with SMTP id e37so32588131qtk.7 for ; Sun, 05 Jan 2020 04:59:08 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id w20sm21866786qtj.4.2020.01.05.04.59.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:59:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229150; 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=VAhh1MHtirf8mXwYD4GVOsRqRRy+5Mi8ZfkXggF+q1u9eUfREr62Uinhp/oVXnwt5lGsbw c8uvNuPn2V5EsR5YdI/4icIRMA4IIiF7JqM5UUvqG81FBmmtp9sX3wqeW2PG4GR0BeKOB2 M7Ali3Jm32xloisxfm8jxAxHm9hEnpE= 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=p6xYuncH/hbr0R+z0woYbvLW+N0iewTdil0IcUaTm0ETeXG1tqEo0iq0KEDv99XyUc 780iePeU8skMLdLb13OZOrRLUdBTBUmKAiET2IE24H7J7qIhaxGSbObHhPLm/K2Z3Js9 XjWp4tljyFZa5+el4DWjDZUITk6RCN8dQCHIlnjzUx54n/CBTAwrmL0G9ECFAzsjJ0nh eX9AG9j++qBA3Q5YXcned0ZLUg8e1m3EWu1DjjK0W2H8ZLwv0551pYnwdVuF03IEFQ93 W6YM6HcGNDma3jNwRHLBBop4430i2+Q74xiMwjv+TP0znpHBONTsofXw9rrE2uxtAFUj 07aQ== X-Gm-Message-State: APjAAAWac45FgWG4ju46exloibZflR4Lzl12MUv63EzD0OL3Rk3M57QL L/yPqubhr2jcQHRdqqghXMQqeqsEsL0MQ6CX4CxV8TG8WHMFM61bofA4Y49hjHVNrCxyiUt/vNz inXeUDVVfkqh+f+M= X-Received: by 2002:a37:7d01:: with SMTP id y1mr80866506qkc.452.1578229148067; Sun, 05 Jan 2020 04:59:08 -0800 (PST) X-Google-Smtp-Source: APXvYqxGujOsx4NP+1CFXxupJzzlOJdssoaxV4zMCAx30PyZDzYQ+eYl2U+ZoxK6yr4TnqcirQvEng== X-Received: by 2002:a37:7d01:: with SMTP id y1mr80866496qkc.452.1578229147827; Sun, 05 Jan 2020 04:59:07 -0800 (PST) Date: Sun, 5 Jan 2020 07:59:03 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 20/32] virtio-mmio: Clear v2 transport state on soft reset Message-ID: <20200105125622.27231-21-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 6I7jbfCbN5eHIA-UCE-AHQ-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 , 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 Thu Nov 13 04:41:28 2025 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=1578229706; cv=none; d=zohomail.com; s=zohoarc; b=i/adIFxDrEPhmIP2lxkp8RAn7ZlEj1wUNMK3Uc2w66zfks8HG7cccBrVZ9lMblWgPA5Yy76qKn33Zz57KUkKBeRyyrJ3iB4/gB6WuUXnTNg9kY+4H7CCpNsMfK4S3uT3gXc6Zm8tn08OierMY31QOK47B3eXQIhJypKIDpP6b4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229706; 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=PEltN350EVX8da6GLE6yKnLK3k5vhNaKgCZMBHDkT4WcSlitFK+SDpauhMnZlwxpcl5N40BlR3XjtT4gKakHQs6aILzBzOaodNfKEoCh9RIanTqDAicJlzUuxbl2ljfXvuGNoiUKPgT5JrbJpfq62CR/jZLbuvzjK9f+klEltC4= 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 1578229706541967.6626571843175; Sun, 5 Jan 2020 05:08:26 -0800 (PST) Received: from localhost ([::1]:41944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5do-00052B-Sy for importer@patchew.org; Sun, 05 Jan 2020 08:08:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58387) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5V0-0002x9-Ci for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Uz-0004vb-6J for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:18 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:36516 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 1io5Uz-0004vN-2d for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:17 -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-141-lmckzrOGOF-dLzInhdXWRQ-1; Sun, 05 Jan 2020 07:59:13 -0500 Received: by mail-qt1-f200.google.com with SMTP id x8so8877291qtq.14 for ; Sun, 05 Jan 2020 04:59:13 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id j185sm19255290qkc.96.2020.01.05.04.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229156; 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=a6LKUFXil7qctonNy/5ckdrx8Sewp5aB2Q77jtKSmqHYtzhRhFiuNq6EsSL/70fR9tbJz/ VfyBm8DLQzB3zU182K++FYoL57knzngWh7GQyKlRz9Mwe+nA//q54IqjrEhQ54+eNuryUq Gxyjn+LW1YHhSOtyM2R9WrCiLM4tvDc= 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=fNNwFmOLEUqdcN2Eln/ratQihuiiHXMw9TNUjs0yB1SZEcOY5aQkFWWDppedCc1RNb Zhfb0Eh9h5R5IpZa0t+PAR4E3twqEwJ/NsfGI0IMaJVHc7id3Lpn8mBwuj1Er9ikDXaZ JIvOQr0XgTHGuMwU+4iXd9A4148zrjq+Lgbb2MfuxM0oosulNlf/EuYtEDkUPhTSmUyn 72epi+D7M3A4coqwM1IYd+Kuwl2kpM+S48y7hlNRRKC9In9hRJcaDi9n/iHqW/AlcdEa WBvUqx/pRRojjqhyHLbnJSzQzwbNb7FRkMerLFKUCGi8gdqKU7KcOnZmIC0qs8Crk1pF 2kSw== X-Gm-Message-State: APjAAAWNhxknfimk6nGCVGTYEzNlbbbMRSs7KjchtpERn2hDn5TsPUds EnOsACbGmY2OwrZPMh/k7U3NOTbBgw+1KFIXzkLPeLK05qzrDzBdHu0eCM6J9Kski5IG44GBCk7 c8R++AKo8C0YENh4= X-Received: by 2002:ac8:410f:: with SMTP id q15mr71046061qtl.192.1578229152727; Sun, 05 Jan 2020 04:59:12 -0800 (PST) X-Google-Smtp-Source: APXvYqytPrZ3BXHjaiZtYcG36Pw+7AzrXNsb0T0z5iNf8O9aAHxyA0vEXx5CnlbC2xhDeGifiK+fvg== X-Received: by 2002:ac8:410f:: with SMTP id q15mr71046051qtl.192.1578229152544; Sun, 05 Jan 2020 04:59:12 -0800 (PST) Date: Sun, 5 Jan 2020 07:59:08 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 21/32] hw/pci/pci_host: Remove redundant PCI_DPRINTF() Message-ID: <20200105125622.27231-22-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: lmckzrOGOF-dLzInhdXWRQ-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 , 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 Thu Nov 13 04:41:28 2025 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=1578229853; cv=none; d=zohomail.com; s=zohoarc; b=jpEexX5Og/RkFwbZNWJqgWe3rpxTxGueLOxXeaYH4qeiVeavnggJkXxbSAEd2yPkGM1+U8fPrsM/E1W+4AlczNnSQr3xnfwjqhiMPYobNemHl4MwCuYViH8yc3x8yzn7rn/uo+4+oOS159bXq5+iAb4jUFOTY6YPrvRuLnfIh0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229853; 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=GoJX3RXU2TG7rgcbViYeGM0Tx4bUlSOl5lNSiFlLLZPihqoTNRHSx2GGT8fFJ1ghZyCW1P5lrPUi1SxboGknNgXA7FR3rJybMcqSk5gakfKn5NPtCjHNodBqcGtW9bA6vcVRzFK5HhsLXjxHkzrbbrHaO8Kqc9LNn2n42jcTP4Y= 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 1578229853696854.8554658494579; Sun, 5 Jan 2020 05:10:53 -0800 (PST) Received: from localhost ([::1]:41969 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5gC-0008Pp-04 for importer@patchew.org; Sun, 05 Jan 2020 08:10:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58402) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5V4-00032m-48 for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5V2-0004xC-Vn for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:21 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:34133 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 1io5V2-0004wp-RV for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:20 -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-213-fCsge2F-PGqIu3qZiBaeEQ-1; Sun, 05 Jan 2020 07:59:18 -0500 Received: by mail-qv1-f71.google.com with SMTP id p3so6445846qvt.9 for ; Sun, 05 Jan 2020 04:59:18 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id f4sm19082258qka.89.2020.01.05.04.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:59:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229160; 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=S7EW6eFzeabOJsimzcFvugXWdUZJbWwa0RN27fkF9x7N1fiJq9iV2VIy9lWqaeMzCiDdAh zRMty6mcfUPDvld6fbD/QGcebQWbcg4B916DF0maKGnbkIoX1eZfUqkQACVCsugDeT2TDY DHrH18BzQevl/aIYFoRHDqPqVIShJSo= 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=ujjOgt9aNRUcf+0LotGmuVHslMtHYXVJtg3xN1L71Q1hHqY226MgtpCbasPjghayry cdOXuBvGQJLsJwe8U2bzQzSgrRLwz9jUeGuiI+IQPlnY+p9R7/8KAHsmmJQfJQfcz4mJ jhoi4cGGNcHwpsxWpo+TrIIPrpktei3LLAgb7dY1FQePLXR3oTmQZTWWu75+lllWBjWh bVO03FVQZU/bC8Wp2L4rsQxJGm9kMlRFAvnIMOKPjqtcEj4jwi9wfvxDVp5QDg9LfuBT XDebw/HY3B1n4ax4nYIlNF9ptJ6w4xs8qA4+NNcdq6qoowCo3Xr50vpWFFqaR4pvhIy9 R2zw== X-Gm-Message-State: APjAAAVOg93HKc177MiHQ+KOl8Wt3P2RagImmmz22aZwGPtUv3mwMTDS vwfRmFSm5cORJmcZ8pda8jBZTxBIBZ0s+ti09Rmm8dwEc4mlLa9XSGpkyMd2KV1nu2qGqh8mIqB Gv3ofab3U6QvfT18= X-Received: by 2002:ac8:31f0:: with SMTP id i45mr71927446qte.327.1578229157404; Sun, 05 Jan 2020 04:59:17 -0800 (PST) X-Google-Smtp-Source: APXvYqyWMcYFeCQL+hxuvjqX/2J5hH6/mtPZrR5nM8FCmZmwzrzWsGxrmi1aGhdpm4DL6F0LXtcWaw== X-Received: by 2002:ac8:31f0:: with SMTP id i45mr71927442qte.327.1578229157239; Sun, 05 Jan 2020 04:59:17 -0800 (PST) Date: Sun, 5 Jan 2020 07:59:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 22/32] hw/pci/pci_host: Let pci_data_[read/write] use unsigned 'size' argument Message-ID: <20200105125622.27231-23-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: fCsge2F-PGqIu3qZiBaeEQ-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 , 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 Thu Nov 13 04:41:28 2025 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=1578230042; cv=none; d=zohomail.com; s=zohoarc; b=DLYTAn5wcJFLOrtVKMpa2PtLWZG3LdjBSK02cTAMrwVAcaUCq0nEgN122YeQy68zZGbNqRHJuHNbrzFmxMP7yGDx1d8Xl2uLSwR5UPMOkr0i478QxQzO1Ci0BgsiPHi+AyEfi3T3E+tdX2QmBY71/u6zpxH5zckbfFF68jfMpdg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578230042; 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=mq4rfy96UjxpR8WNZd48vPgXV8rR126906sEFdsiDy3qKO8WrH9tmujJrc1Baurh8GIxEhkjAIwp/S3oxhRF6ye8JF02Z6I4JMvigrlgDiYk0mXkHJFYbDJN1GIpMH8L/tGhMUnvQv9mslIJ+WqFUislmVTF1C9/H67ckRFUS8Q= 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 1578230042352800.261762878383; Sun, 5 Jan 2020 05:14:02 -0800 (PST) Received: from localhost ([::1]:42006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5jE-0003k2-Mu for importer@patchew.org; Sun, 05 Jan 2020 08:14:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58419) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5VB-00037y-3u for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5V8-0004zN-Ox for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:28 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:50979 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 1io5V7-0004yo-7E for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:25 -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-279-2VnyM1ZWM9ipVOx8nip_oA-1; Sun, 05 Jan 2020 07:59:23 -0500 Received: by mail-qk1-f198.google.com with SMTP id m13so15990814qka.9 for ; Sun, 05 Jan 2020 04:59:23 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id a144sm19514167qkc.30.2020.01.05.04.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:59:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229164; 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=OF2ZOxzV52pigYgr/FOwZszhRhu0a1DH3htaxD82WOqoPF/xBaK8GaodJC3XDYXoyDrJNH jHsoor2xGdq6wTuXBDaWoEGLnc7xPKqtEsOsZJ8BZSNG+AE9zGqIXDMz/XktM5HDPhrLy9 5RV7PE7gSjjIWJXkMVezCmVVtPT59Q8= 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=Ukpp35hCgPiubElzfD6mWLXUKMX9jp83rRakuhFvEi3HhNZ2FUYL2FJ9LNpHSQqsOQ aiR9ScGp/A+8kDP8BE99txDWYI7kyrGqguRvNsx8A0H3SrixUNH3BzRg5V5HHyYxMmPU M72BSNHrvATAT2JZlp4ILlgnPLlH1D5IxwF9alEX7ClwFg5QSMyyMtNfMdR/wvncDe/2 CPf8DRO2KC5+R9dXbOsoIu+syauZ37o75BasuVieGIsphzNWpOGizCN0iEORrgw7zuY0 nOpIRpQHmNjUnlSeKlDzqfs/Z3D3Xp9H8XaD57kqbVUMbM2tRWFsENM1eYECrw3lCxAJ Xxtg== X-Gm-Message-State: APjAAAVLtIzoNquacz6nHFQmT4QWmkd3pV1a5g7Pr4Zu4uU5P1Gd61Mu PPGV7grXrPR3oeITTgxQTmYemSIy1hHMueR+p5AA1dOcDKpTbpjJQclaiNQfj4ScmZ3z6cIX+iR i+ywtg8gBTNSg81A= X-Received: by 2002:a0c:e14f:: with SMTP id c15mr72896496qvl.169.1578229162588; Sun, 05 Jan 2020 04:59:22 -0800 (PST) X-Google-Smtp-Source: APXvYqwP5ytGsY9TTehJKJQpzrrDPmEX7umvl06dlEwjDfqHui9pbk4YeG000yt7Mem7JjJvM6/PNA== X-Received: by 2002:a0c:e14f:: with SMTP id c15mr72896482qvl.169.1578229162374; Sun, 05 Jan 2020 04:59:22 -0800 (PST) Date: Sun, 5 Jan 2020 07:59:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 23/32] vhost-user: add VHOST_USER_RESET_DEVICE to reset devices Message-ID: <20200105125622.27231-24-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 2VnyM1ZWM9ipVOx8nip_oA-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 Thu Nov 13 04:41:28 2025 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=1578230157; cv=none; d=zohomail.com; s=zohoarc; b=QuorLw5HL0J4M1Af8Mal72liHOBQGWdulAz7NqiPoYzYb/JYWZzwfgtnwXCuOsKOxxQ7azYfgVsn+VXdGlUetoape3nGFbevLcAHd+iVZz3q2VG5q2H5lcjRcK64I+vB14JC5gFDedfOP5MjJkCAet6xolpsGA41qufPYJXyGJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578230157; 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=hJguP15fdAlGpVfTRTT3ROhqqOtU5pM62lFKna8ZsqoXdyI3hyXMiuCDgrjQvvMuaso0W3KlKuoByvUWPoGRZSq5AWMiRNK2zza4Cj2Aohx8XTiWLeytHZv/HAO/VfTTxgl8gr/rv25X1wAE/9kuuQiXq1TYMZ+Or27fH9Zs9yg= 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 157823015761853.71153161533539; Sun, 5 Jan 2020 05:15:57 -0800 (PST) Received: from localhost ([::1]:42032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5l5-00062X-Qs for importer@patchew.org; Sun, 05 Jan 2020 08:15:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58432) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5VE-00039Q-4s for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5VC-00050q-Nr for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:32 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:20941 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 1io5VC-00050Z-BT for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:30 -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-385-446R_KkeNHS8sGuEDRlUtg-1; Sun, 05 Jan 2020 07:59:28 -0500 Received: by mail-qv1-f71.google.com with SMTP id dw11so9423063qvb.16 for ; Sun, 05 Jan 2020 04:59:28 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id i2sm21781164qte.87.2020.01.05.04.59.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:59:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229169; 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=XzFADBfPi//VV0Ai7NsP6gFNyHIhfSwWxD7ack2wx1beSxMR9kr+cG+/shF6eskbkMvJFo +KT0u5V/oWqruFIAbKdcl6jzt6o0FnPgCaGekBv7U/z6duPtKwdeAODoNo1J7sAfP6fOCA uhQiZzNUA9UsLnscPYyYaenldciyBbU= 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=cI6YHn22ZcgIQgSmZoCPnI4jhEJLS3UfMMCYzQaEq9SMKuuyUjywSfzstUInALGgz+ xd8jcG3RJn7jX4uBGZya7pumNVl8Kjqh+Ub8kb+9L1iEURVGSQvHufOLKQObApyfDkEk 8JyEKJJhH8PEy+HAcJ9j+I6zcn6HQ84q55iK+mcvssJ4+NCwTStNAtlzmGlNKGLtF025 Jn9hXknzUXT2euEg0SKMlMom4hNiCr8nY9jeF7X2mNO9eQOclFvZ18lVKJRCwwreSsUJ lPMEm3+EoYB+x0r68z02S7nJZuLbb2ZBOEdTo02MLYPYnvVXSrIeMb5CPqpRKx09fg2e 4L0w== X-Gm-Message-State: APjAAAXAwNs7QQE5RiSBX5oiA/D/dQtZrzrqATSaSXcniJC0VCG114Ct YzeqgQMd7DwFzf7P0xyGtoT3erqQwogcp/FfZZEMjB9HFXEjysQFK2NWAzCf2RBsjTunLQ1avJx 9jpnPanYnI+V7mCQ= X-Received: by 2002:ac8:6f73:: with SMTP id u19mr69716430qtv.102.1578229167660; Sun, 05 Jan 2020 04:59:27 -0800 (PST) X-Google-Smtp-Source: APXvYqxCgE25FG/Tf/Z2EBEsHhuhHaNSKyMSSfLa3+wZKPDw2XksJHT87pj5XBG8KWsUHS+nqUXNlA== X-Received: by 2002:ac8:6f73:: with SMTP id u19mr69716422qtv.102.1578229167500; Sun, 05 Jan 2020 04:59:27 -0800 (PST) Date: Sun, 5 Jan 2020 07:59:22 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 24/32] vhost-user-scsi: reset the device if supported Message-ID: <20200105125622.27231-25-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 446R_KkeNHS8sGuEDRlUtg-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: 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 From nobody Thu Nov 13 04:41:28 2025 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=1578230575; cv=none; d=zohomail.com; s=zohoarc; b=U00RJILHuGgwAj8WYq8AUzQLUTXpXtDUZYzj+0v96STqiX/O1PPi7iPvWtwWukdV7eVXMKQqBhW+t8knH3GIOwmEDqX2i6xkfOXX4/LVlKd8PuOBT6m4KI2v1SO9mfjrnqcnLBLZCvV/Y+nuFEYBpkLg9n1mDaNjjehw5N4iZYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578230575; 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=piqn6mX5WQ96VESO5T0tIJ0XhrZt2DhdjHLkZukt+8U=; b=RIjUP/zqsUh9aOsE3HDC6KLbbufX320xg+FSuPSE4Noabakgxu3yMTGQnoFLk0Prb65hI2O+HSsuyviPzmXvrLqYeuCSCastivX+tGGS6o9msglIPGQJuZgav5VGHc+l8Vge64RVa3DEsZCj9gAEAeDuF/hJoXFYtggyoBmMiIc= 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 1578230575110527.8386855410301; Sun, 5 Jan 2020 05:22:55 -0800 (PST) Received: from localhost ([::1]:42200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5rp-0005XP-Vq for importer@patchew.org; Sun, 05 Jan 2020 08:22:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58451) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5VK-0003FF-JK for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5VI-00053O-G4 for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:37 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:48350 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 1io5VH-00052Z-8T for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:36 -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-425-ttzw6hjUO_2pK-pmpzhRkg-1; Sun, 05 Jan 2020 07:59:33 -0500 Received: by mail-qk1-f199.google.com with SMTP id f124so27901821qkb.22 for ; Sun, 05 Jan 2020 04:59:33 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id y18sm19181449qki.0.2020.01.05.04.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:59:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229174; 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=piqn6mX5WQ96VESO5T0tIJ0XhrZt2DhdjHLkZukt+8U=; b=XJyH0jJUzyFwSbHC9JQjYVPRlMtHzOtH17OUmJD6CBLsMk4E3lGatjVUy6tuLRxZDHtc5F 3YOD9WUofhDmyLRloD2qvEOREE4aVVQ8/AhfhCzoolM5odL/Z9mcmsNOw1lX+p9nY+RH8m cumYKuSBnEu5ccMvJiW5RsO5TIDLzhU= 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=tN9j8nC8UNjEIUbDqAKywg3EszM5OfgJu5L0vZrOdtE=; b=mE1eY0VIkdKDGZI9kbrPuI5u8vMt9b8fsEF/fCWqEoOUUAR7/K3UpN6a9WTAXYLYNF TH4zWSxULC5ykVK70ax1MY/ISHa+j/jB5pDC2kuRtITzxG1StvmkB941vLa+pWO3l5Mn dzJZA8oE6ohy49J7hpJzpP7/aMbocPNcJIFh4cykxvF6clJcpd0NhhUc2c38GIyE4515 ml331Z6U1kUQC1ccibcZwBUV7c6+XmXBXeoi93LL9+jKnYNVOLIZ647aJbmTiOA+sGrQ o5h49pgUTs3DuKDMWiXYHwVN1Ggl8v2UMf65p7ZNKn0YEInJPftq10wrqCVP0NdQoQ3L D5Bw== X-Gm-Message-State: APjAAAXa7KCiRoBEcFmpdTucMrgeeqH8e8YGA9TysttL5yzGlOmxoViq bKQyOHriKVd9LiJz4w+6LkGe7/enDaitrxzaxQsgeg3dhFs4gOiU+lGyA5YlMDWszj/xmBBbrdU VwZtWnBdStXICktk= X-Received: by 2002:ae9:f205:: with SMTP id m5mr79836653qkg.152.1578229172800; Sun, 05 Jan 2020 04:59:32 -0800 (PST) X-Google-Smtp-Source: APXvYqx6knIIBe9G49vwGlkHeppCUmTLTDkQIfw5EwZRyeYQjj03pzRlChJ4afyO9qLBP3p10OO0kw== X-Received: by 2002:ae9:f205:: with SMTP id m5mr79836633qkg.152.1578229172577; Sun, 05 Jan 2020 04:59:32 -0800 (PST) Date: Sun, 5 Jan 2020 07:59:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 25/32] hw: fix using 4.2 compat in 5.0 machine types for i440fx/q35 Message-ID: <20200105125622.27231-26-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: ttzw6hjUO_2pK-pmpzhRkg-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 , Denis Plotnikov , 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: Denis Plotnikov 5.0 machine type uses 4.2 compats. This seems to be incorrect, since the latests machine type by now is 5.0 and it should use its own compat or shouldn't use any relying on the defaults. Seems, like this appeared because of some problems on merge/rebase. Signed-off-by: Denis Plotnikov Message-Id: <20191223072856.5369-1-dplotnikov@virtuozzo.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc_piix.c | 1 - hw/i386/pc_q35.c | 1 - 2 files changed, 2 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 721c7aa64e..fa12203079 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -425,7 +425,6 @@ static void pc_i440fx_5_0_machine_options(MachineClass = *m) m->alias =3D "pc"; m->is_default =3D 1; pcmc->default_cpu_version =3D 1; - compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len); } =20 DEFINE_I440FX_MACHINE(v5_0, "pc-i440fx-5.0", NULL, diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 52f45735e4..84cf925cf4 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -354,7 +354,6 @@ static void pc_q35_5_0_machine_options(MachineClass *m) pc_q35_machine_options(m); m->alias =3D "q35"; pcmc->default_cpu_version =3D 1; - compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len); } =20 DEFINE_Q35_MACHINE(v5_0, "pc-q35-5.0", NULL, --=20 MST From nobody Thu Nov 13 04:41:28 2025 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=1578229866; cv=none; d=zohomail.com; s=zohoarc; b=Vc+S4Z+F5YmMsqVhhFAXC+72/u+UKdsXVMiFWvF1vmp3KeapmWOwE4WKegcRoGvZwetTKH1kUA71y5ITIZDdxlzY8/4muFQwCkdAtSIrHH96fBq6z6bILw2kr7g6RPM9tQpUtZPkW4xMAp3DRomr61ZR7/hSlq/fbA8KJAuhiR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578229866; 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=2Ylx5GMCaMZp5iEuVGZsy2s+VkTVg2pcAcgR2+7fYJ0=; b=T4g44GXAPpEdYOLEEOBaR8HkMhjg1zqMNrGEQOhPVXu5DDVfR8znTKzBOr8398UisXX8ehX87rCSK9ieDx1XQjXLsOezEHews3KtZ+zX1EDG1kI1ePeAcM5JlZjbfakBsi8w5IQOPZsBowe8Gi9K4lIgAALsyQc/z7eSyE6Z4Jk= 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 1578229866510823.7391532837161; Sun, 5 Jan 2020 05:11:06 -0800 (PST) Received: from localhost ([::1]:41986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5gO-0000JR-Tp for importer@patchew.org; Sun, 05 Jan 2020 08:11:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58489) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5VQ-0003Jy-7w for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5VO-00055g-CH for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:44 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:48645 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 1io5VO-00055F-8L for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:42 -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-212-G_vL3i6bMVCJk7RoFs_fkA-1; Sun, 05 Jan 2020 07:59:39 -0500 Received: by mail-qv1-f70.google.com with SMTP id e14so2703676qvr.6 for ; Sun, 05 Jan 2020 04:59:39 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id q25sm19414839qkq.88.2020.01.05.04.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:59:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229181; 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=2Ylx5GMCaMZp5iEuVGZsy2s+VkTVg2pcAcgR2+7fYJ0=; b=Szf2chEfTr/VnaI0v4P0XU2/ccr2ExOoblwragw9YyF63OmGz+rl6Sb7Svha1RvyGpb3mL TBXliN4XEUFg9Pb7TNmZKcknumU2sbfMCaP0E6LzoeKdcDUXyGlOUDTcSfwLKEDy+jd9N/ dEIF03ym7GnPUQsYy3qeaA5a7dVrefY= 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=SzSzAFhPxlDqQXytAG1grvJYugc66X5amic6XLexT1c=; b=ZjulMY1ULxpTe5N9vi7+G+rpQzPkiw5moZYm83YquK3iUzjDIkOn/2ocyqc5yNPSwi 651lQo0AePa4Ejy/5WiQkzeBRJlQIYMOUVg265koc0IkraaE75LJixbgFPD6WTdcA346 F+CKkeEwR5H50irFpPWhs41RHfatU91EEIa/L/l/CJPlRoRcyBzot+QUOzSaYVe6Xc56 86r2M5B+W+EDe0yLT0N7BsD1n/5CuHXO1nxioA/hcjzzk1EvSd2P2PRF3MOry9zyN5xD u3M4lhVKplhX3pG8YXTzvPX2KaPg264isS3ztBNlmffl7vbMehesSYgO/HlJVoevDnWa RMGw== X-Gm-Message-State: APjAAAW+amgshzOhhtqVZmXJiWTARo2XLH+BwxduJHczVtu2cHZV7tLH oalPWt+A6e/w8jBZm0q8qr9tKPfUKaKFFPhzEbKcunjENqsLfPDE0sfogs3eB6z/N4xBGGwEgEY nQpByxLFS/1BPywo= X-Received: by 2002:ac8:3364:: with SMTP id u33mr72208578qta.267.1578229178816; Sun, 05 Jan 2020 04:59:38 -0800 (PST) X-Google-Smtp-Source: APXvYqycmoQXVfPDqV4zvkkNI68xtw+P5M4BmYvu+4ttC8Ds+58OR+RXDQkqEhm6GlPOwEf6HAD2+w== X-Received: by 2002:ac8:3364:: with SMTP id u33mr72208564qta.267.1578229178569; Sun, 05 Jan 2020 04:59:38 -0800 (PST) Date: Sun, 5 Jan 2020 07:59:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 26/32] virtio: make seg_max virtqueue size dependent Message-ID: <20200105125622.27231-27-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: G_vL3i6bMVCJk7RoFs_fkA-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: Kevin Wolf , Peter Maydell , Eduardo Habkost , qemu-block@nongnu.org, Max Reitz , Denis Plotnikov , 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: Denis Plotnikov Before the patch, seg_max parameter was immutable and hardcoded to 126 (128 - 2) without respect to queue size. This has two negative effec= ts: 1. when queue size is < 128, we have Virtio 1.1 specfication violation: (2.6.5.3.1 Driver Requirements) seq_max must be <=3D queue_size. This violation affects the old Linux guests (ver < 4.14). These guests crash on these queue_size setups. 2. when queue_size > 128, as was pointed out by Denis Lunev , seg_max restrics guest's block request length which affects guests' performance making them issues more block request than needed. https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg03721.html To mitigate this two effects, the patch adds the property adjusting seg_max to queue size automaticaly. Since seg_max is a guest visible parameter, the property is machine type managable and allows to choose between old (seg_max =3D 126 always) and new (seg_max =3D queue_size - 2) behaviors. Not to change the behavior of the older VMs, prevent setting the default seg_max_adjust value for older machine types. Reviewed-by: Stefan Hajnoczi Signed-off-by: Denis Plotnikov Message-Id: <20191220140905.1718-2-dplotnikov@virtuozzo.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-blk.h | 1 + include/hw/virtio/virtio-scsi.h | 1 + hw/block/virtio-blk.c | 9 ++++++++- hw/core/machine.c | 3 +++ hw/scsi/vhost-scsi.c | 2 ++ hw/scsi/virtio-scsi.c | 10 +++++++++- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index 9c19f5b634..1e62f869b2 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -38,6 +38,7 @@ struct VirtIOBlkConf uint32_t request_merging; uint16_t num_queues; uint16_t queue_size; + bool seg_max_adjust; uint32_t max_discard_sectors; uint32_t max_write_zeroes_sectors; bool x_enable_wce_if_config_wce; diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scs= i.h index 122f7c4b6f..24e768909d 100644 --- a/include/hw/virtio/virtio-scsi.h +++ b/include/hw/virtio/virtio-scsi.h @@ -48,6 +48,7 @@ typedef struct virtio_scsi_config VirtIOSCSIConfig; struct VirtIOSCSIConf { uint32_t num_queues; uint32_t virtqueue_size; + bool seg_max_adjust; uint32_t max_sectors; uint32_t cmd_per_lun; #ifdef CONFIG_VHOST_SCSI diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index b12157b5eb..9bee514c4e 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -913,7 +913,8 @@ static void virtio_blk_update_config(VirtIODevice *vdev= , uint8_t *config) blk_get_geometry(s->blk, &capacity); memset(&blkcfg, 0, sizeof(blkcfg)); virtio_stq_p(vdev, &blkcfg.capacity, capacity); - virtio_stl_p(vdev, &blkcfg.seg_max, 128 - 2); + virtio_stl_p(vdev, &blkcfg.seg_max, + s->conf.seg_max_adjust ? s->conf.queue_size - 2 : 128 - 2= ); virtio_stw_p(vdev, &blkcfg.geometry.cylinders, conf->cyls); virtio_stl_p(vdev, &blkcfg.blk_size, blk_size); virtio_stw_p(vdev, &blkcfg.min_io_size, conf->min_io_size / blk_size); @@ -1138,6 +1139,11 @@ static void virtio_blk_device_realize(DeviceState *d= ev, Error **errp) error_setg(errp, "num-queues property must be larger than 0"); return; } + if (conf->queue_size <=3D 2) { + error_setg(errp, "invalid queue-size property (%" PRIu16 "), " + "must be > 2", conf->queue_size); + return; + } if (!is_power_of_2(conf->queue_size) || conf->queue_size > VIRTQUEUE_MAX_SIZE) { error_setg(errp, "invalid queue-size property (%" PRIu16 "), " @@ -1267,6 +1273,7 @@ static Property virtio_blk_properties[] =3D { true), DEFINE_PROP_UINT16("num-queues", VirtIOBlock, conf.num_queues, 1), DEFINE_PROP_UINT16("queue-size", VirtIOBlock, conf.queue_size, 128), + DEFINE_PROP_BOOL("seg-max-adjust", VirtIOBlock, conf.seg_max_adjust, t= rue), DEFINE_PROP_LINK("iothread", VirtIOBlock, conf.iothread, TYPE_IOTHREAD, IOThread *), DEFINE_PROP_BIT64("discard", VirtIOBlock, host_features, diff --git a/hw/core/machine.c b/hw/core/machine.c index f5e2b32b3b..ec2e3fcb61 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -29,6 +29,9 @@ =20 GlobalProperty hw_compat_4_2[] =3D { { "virtio-blk-device", "x-enable-wce-if-config-wce", "off" }, + { "virtio-blk-device", "seg-max-adjust", "off"}, + { "virtio-scsi-device", "seg_max_adjust", "off"}, + { "vhost-blk-device", "seg_max_adjust", "off"}, }; const size_t hw_compat_4_2_len =3D G_N_ELEMENTS(hw_compat_4_2); =20 diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index c693fc748a..26f710d3ec 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -275,6 +275,8 @@ static Property vhost_scsi_properties[] =3D { DEFINE_PROP_UINT32("num_queues", VirtIOSCSICommon, conf.num_queues, 1), DEFINE_PROP_UINT32("virtqueue_size", VirtIOSCSICommon, conf.virtqueue_= size, 128), + DEFINE_PROP_BOOL("seg_max_adjust", VirtIOSCSICommon, conf.seg_max_adju= st, + true), DEFINE_PROP_UINT32("max_sectors", VirtIOSCSICommon, conf.max_sectors, 0xFFFF), DEFINE_PROP_UINT32("cmd_per_lun", VirtIOSCSICommon, conf.cmd_per_lun, = 128), diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index f080545f48..9e343f241a 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -659,7 +659,8 @@ static void virtio_scsi_get_config(VirtIODevice *vdev, VirtIOSCSICommon *s =3D VIRTIO_SCSI_COMMON(vdev); =20 virtio_stl_p(vdev, &scsiconf->num_queues, s->conf.num_queues); - virtio_stl_p(vdev, &scsiconf->seg_max, 128 - 2); + virtio_stl_p(vdev, &scsiconf->seg_max, + s->conf.seg_max_adjust ? s->conf.virtqueue_size - 2 : 128= - 2); virtio_stl_p(vdev, &scsiconf->max_sectors, s->conf.max_sectors); virtio_stl_p(vdev, &scsiconf->cmd_per_lun, s->conf.cmd_per_lun); virtio_stl_p(vdev, &scsiconf->event_info_size, sizeof(VirtIOSCSIEvent)= ); @@ -898,6 +899,11 @@ void virtio_scsi_common_realize(DeviceState *dev, virtio_cleanup(vdev); return; } + if (s->conf.virtqueue_size <=3D 2) { + error_setg(errp, "invalid virtqueue_size property (=3D %" PRIu16 "= ), " + "must be > 2", s->conf.virtqueue_size); + return; + } s->cmd_vqs =3D g_new0(VirtQueue *, s->conf.num_queues); s->sense_size =3D VIRTIO_SCSI_SENSE_DEFAULT_SIZE; s->cdb_size =3D VIRTIO_SCSI_CDB_DEFAULT_SIZE; @@ -954,6 +960,8 @@ static Property virtio_scsi_properties[] =3D { DEFINE_PROP_UINT32("num_queues", VirtIOSCSI, parent_obj.conf.num_queue= s, 1), DEFINE_PROP_UINT32("virtqueue_size", VirtIOSCSI, parent_obj.conf.virtqueue_size, 1= 28), + DEFINE_PROP_BOOL("seg_max_adjust", VirtIOSCSI, + parent_obj.conf.seg_max_adjust, true), DEFINE_PROP_UINT32("max_sectors", VirtIOSCSI, parent_obj.conf.max_sect= ors, 0xFFFF), DEFINE_PROP_UINT32("cmd_per_lun", VirtIOSCSI, parent_obj.conf.cmd_per_= lun, --=20 MST From nobody Thu Nov 13 04:41:28 2025 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=1578230789; cv=none; d=zohomail.com; s=zohoarc; b=KXNS12sUBAJr8t6RIf4/Lr84vQkMeWcGwWuNnz/DVxXdiFVpWojnHKBnMRV3La+5j18geBD8DemOR8/aSX5o324zTO/E2AvUbIi9h6yySJwQnFRm95EM07O5c2RIskivJ58wohKXpaSaoDfCOzHfNd9IMcZZaxZ5ouFj3I9r5L8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578230789; 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=HtbxL2MG3al1vaYV6o8j0WZPnL+D8nNZeJUMf96yEUQ=; b=FUp3cOIrEN9lmPXcGMM+WNCFcQutwLNmmkf/+46ty3BlXDOeIvSWTcn4us9M/8zVekEQT9SQgQ+fd7Ifng6rpfYgJc6KHpAeC7PA+XPBVrbPSuFFSlallA9s69eRwgI+XcvvG45/0qz2Kigtu56SFfv+u4d1f78vpgsEayigaRU= 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 1578230789519388.2000488256649; Sun, 5 Jan 2020 05:26:29 -0800 (PST) Received: from localhost ([::1]:42256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5vI-00007d-Dy for importer@patchew.org; Sun, 05 Jan 2020 08:26:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59035) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Yg-0006yG-P5 for qemu-devel@nongnu.org; Sun, 05 Jan 2020 08:03:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Yf-0006m5-8y for qemu-devel@nongnu.org; Sun, 05 Jan 2020 08:03:06 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:57934 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 1io5Yf-0006kD-4T for qemu-devel@nongnu.org; Sun, 05 Jan 2020 08:03:05 -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-156-qoPiOJZFP6ugyY8vDIY7fg-1; Sun, 05 Jan 2020 07:59:44 -0500 Received: by mail-qv1-f71.google.com with SMTP id v3so27072963qvm.2 for ; Sun, 05 Jan 2020 04:59:44 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id m27sm21789537qta.21.2020.01.05.04.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:59:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229383; 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=HtbxL2MG3al1vaYV6o8j0WZPnL+D8nNZeJUMf96yEUQ=; b=bLQaAGRnLJx3PMQnq1N5SLK82ewyA358xWsjKpB7Tgl9+WvH5nT1g5rXfmrqXhAQeyhDXP COK+P81L4dnFvd5FFRXv9/VRiPJpAk03yqkW2svSORlPzlqicISGPvn+b1V9/hwRINITpi CMbF4im8UMJmWukbHrpZG6Nk3Nmmk2U= 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=ukejZrijNO6M+6ThiPk3cjbO646qqmDoI6mt9ROtSGs=; b=P5up20XUwOC5UxnQCLA9P1X6A1JLXxx1uNszVWLdsUC0nXWCLv1R/4GKr68qsBu50J jANWDc0deNvBn9gv3qCcuQmBWnOkx6EEZQ8+LQ2c1aAXuopCjFmjawzXIplm39nzJwdV zIeZby03fLJf2Hpen5HNaBRiSnHhpeNRhfu6aAb36jl4IrKRjL68mfESnQB51130CSxB LkQU8nTkvlkrPCeF5SIAQqCwfewUGmbtUgoAy/FzYVh2qzbibPux6laBBWr68wD/tISx uFOkWu1HV9so9nQmAtcJblyjlYndXeLheDwSUZ2vZDehbCiuW1I2aTGUg3j9JYjGQKZK wExQ== X-Gm-Message-State: APjAAAWgN53dxEoYFQxjxBl6+OFtz/YFGEipwYd7mI+KZOD7TETe417v agzH/WHsq6gORALJO8GB0Syx6MEqx5Ey28QSi6Ur5PHn6XlFcYe2/RBE0qDuT8P/4OnjUeHPPOG wYPzbDcDemPd4eEg= X-Received: by 2002:ac8:258f:: with SMTP id e15mr73255591qte.241.1578229183563; Sun, 05 Jan 2020 04:59:43 -0800 (PST) X-Google-Smtp-Source: APXvYqyKc5umtmayycgq0ZcXZwoFcvt65BRY15Zyct+A7zhNUnCIV+Li9PFf63MO/EJaAW9UsW4k7g== X-Received: by 2002:ac8:258f:: with SMTP id e15mr73255584qte.241.1578229183362; Sun, 05 Jan 2020 04:59:43 -0800 (PST) Date: Sun, 5 Jan 2020 07:59:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 27/32] tests: add virtio-scsi and virtio-blk seg_max_adjust test Message-ID: <20200105125622.27231-28-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: qoPiOJZFP6ugyY8vDIY7fg-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 , Denis Plotnikov 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: Denis Plotnikov It tests proper seg_max_adjust settings for all machine types except 'none', 'isapc', 'microvm' Signed-off-by: Denis Plotnikov Message-Id: <20191220140905.1718-3-dplotnikov@virtuozzo.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/acceptance/virtio_seg_max_adjust.py | 134 ++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100755 tests/acceptance/virtio_seg_max_adjust.py diff --git a/tests/acceptance/virtio_seg_max_adjust.py b/tests/acceptance/v= irtio_seg_max_adjust.py new file mode 100755 index 0000000000..5458573138 --- /dev/null +++ b/tests/acceptance/virtio_seg_max_adjust.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python +# +# Test virtio-scsi and virtio-blk queue settings for all machine types +# +# Copyright (c) 2019 Virtuozzo International GmbH +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import sys +import os +import re + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'pytho= n')) +from qemu.machine import QEMUMachine +from avocado_qemu import Test + +#list of machine types and virtqueue properties to test +VIRTIO_SCSI_PROPS =3D {'seg_max_adjust': 'seg_max_adjust'} +VIRTIO_BLK_PROPS =3D {'seg_max_adjust': 'seg-max-adjust'} + +DEV_TYPES =3D {'virtio-scsi-pci': VIRTIO_SCSI_PROPS, + 'virtio-blk-pci': VIRTIO_BLK_PROPS} + +VM_DEV_PARAMS =3D {'virtio-scsi-pci': ['-device', 'virtio-scsi-pci,id=3Dsc= si0'], + 'virtio-blk-pci': ['-device', + 'virtio-blk-pci,id=3Dscsi0,drive=3Ddri= ve0', + '-drive', + 'driver=3Dnull-co,id=3Ddrive0,if=3Dnon= e']} + + +class VirtioMaxSegSettingsCheck(Test): + @staticmethod + def make_pattern(props): + pattern_items =3D ['{0} =3D \w+'.format(prop) for prop in props] + return '|'.join(pattern_items) + + def query_virtqueue(self, vm, dev_type_name): + query_ok =3D False + error =3D None + props =3D None + + output =3D vm.command('human-monitor-command', + command_line =3D 'info qtree') + props_list =3D DEV_TYPES[dev_type_name].values(); + pattern =3D self.make_pattern(props_list) + res =3D re.findall(pattern, output) + + if len(res) !=3D len(props_list): + props_list =3D set(props_list) + res =3D set(res) + not_found =3D props_list.difference(res) + not_found =3D ', '.join(not_found) + error =3D '({0}): The following properties not found: {1}'\ + .format(dev_type_name, not_found) + else: + query_ok =3D True + props =3D dict() + for prop in res: + p =3D prop.split(' =3D ') + props[p[0]] =3D p[1] + return query_ok, props, error + + def check_mt(self, mt, dev_type_name): + with QEMUMachine(self.qemu_bin) as vm: + vm.set_machine(mt["name"]) + for s in VM_DEV_PARAMS[dev_type_name]: + vm.add_args(s) + vm.launch() + query_ok, props, error =3D self.query_virtqueue(vm, dev_type_n= ame) + + if not query_ok: + self.fail('machine type {0}: {1}'.format(mt['name'], error)) + + for prop_name, prop_val in props.items(): + expected_val =3D mt[prop_name] + self.assertEqual(expected_val, prop_val) + + @staticmethod + def seg_max_adjust_enabled(mt): + # machine types >=3D 5.0 should have seg_max_adjust =3D true + # others seg_max_adjust =3D false + mt =3D mt.split("-") + + # machine types with one line name and name like pc-x.x + if len(mt) <=3D 2: + return False + + # machine types like pc--x.x[.x] + ver =3D mt[2] + ver =3D ver.split("."); + + # versions >=3D 5.0 goes with seg_max_adjust enabled + major =3D int(ver[0]) + + if major >=3D 5: + return True + return False + + def test_machine_types(self): + # collect all machine types except 'none', 'isapc', 'microvm' + with QEMUMachine(self.qemu_bin) as vm: + vm.launch() + machines =3D [m['name'] for m in vm.command('query-machines')] + vm.shutdown() + machines.remove('none') + machines.remove('isapc') + machines.remove('microvm') + + for dev_type in DEV_TYPES: + # create the list of machine types and their parameters. + mtypes =3D list() + for m in machines: + if self.seg_max_adjust_enabled(m): + enabled =3D 'true' + else: + enabled =3D 'false' + mtypes.append({'name': m, + DEV_TYPES[dev_type]['seg_max_adjust']: enab= led}) + + # test each machine type for a device type + for mt in mtypes: + self.check_mt(mt, dev_type) --=20 MST From nobody Thu Nov 13 04:41:28 2025 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=1578230060; cv=none; d=zohomail.com; s=zohoarc; b=S5RrEnPsqnef5X9eI0e7Q1UaTFPHxk9/G+NXPlSoRuWmkXH/isT2I1uTKWIDHfDC9OBZtNMSnC0C4MwPlp+fITjP+9Z4iJE3unb1s8NxgjYdH5XKbRFSxd557rl7u0X0x6Wmu4qVcs0UNB5UxwrHQiEbsdKzpKY546atggWaLio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578230060; 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=10wNZRiSDwsgBzUvgX+qZm4UOG4d0UwTiZy8rXJV4jo=; b=aptoJpZ9VJCtMtp3dT3Ignq2F5FcmJFy1FuTkQRk0lKhMxWkR9qI2eOaASaYP5FzLCUJMhbQNH80Q2OYZo4DqarlwJ/IY6/ze4e6BfUhIKyWFYb2xVdsFXVoLKvKMBMnJrnFDF+ORpNHcy0+OveKQ/wASkVYY5gXpCu+VWp0MW4= 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 1578230060538483.6006896981138; Sun, 5 Jan 2020 05:14:20 -0800 (PST) Received: from localhost ([::1]:42012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5jX-00045L-BR for importer@patchew.org; Sun, 05 Jan 2020 08:14:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58557) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5VY-0003V1-KM for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5VX-0005Ao-GC for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:52 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:23482 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 1io5VX-0005AH-DI for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:51 -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-357-MnzbPnS9MoWseXuWKW-kGA-1; Sun, 05 Jan 2020 07:59:49 -0500 Received: by mail-qt1-f199.google.com with SMTP id e8so8949920qtg.9 for ; Sun, 05 Jan 2020 04:59:49 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id t198sm19356680qke.6.2020.01.05.04.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:59:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229191; 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=10wNZRiSDwsgBzUvgX+qZm4UOG4d0UwTiZy8rXJV4jo=; b=YDjq19pyxb3ybffHqs3+MxNRgnqNU09FHrhfOM2G8S9S2CtJqDI9KPSgrNvIQSsGOx+FKv NYW9QItIMa9X8pqAfsuobwWv1xmtObqFkjlgfL7vkMfGUV2CD8rXG6QGb05ErwlVzm6we0 lfvPNGDfKPZQ3DMKE72C+L7aLn8OI7E= 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=tfGwPPQntx/q9Ytbl/8/C6b7fB9jJ0SAUnXApOete/4=; b=PcNs4JhKexwrXgb7CG3jpqw3x6xSDXfCg7qNg2Gq7VyZ8hHxumir3DchfVioOyi+ux aOC9sQIrETegtCSxcV0i5hR3KMsZQe0raBPFWiUhlFfVE/zlhA9ejLv2l8YNFsrg8MJf Zv6X/t2BVBhCd6UP6JjoFWI9hrD6O09ezjVki0yfUjkDdkP2ROHJJBwdo+DS3yU7KUVl MAkMm6m3W1/YNNZptBHrcSbDF82qt/KS9yI+NelW7xIcrqegvcYeuixKbo3SdLHDDps1 m8bSb9k8B4rRIKfwJ2dRfCRk1C3Om7FmLmX3ogNJ2mi2oz7TIeerJ/tMQjazagx/ALdg atDg== X-Gm-Message-State: APjAAAXHvrHYY8g3XIrfJny2iJNT2YhwxqOjCiC4iNVieg9aHPEYhWkF 0ItexzHZIMO/0iewdQADTXaXKkn7K4Fd+q2hjL4JTy2oYvtMvr/6E64nBitxy6QP6HTEnKKf//y X/GIlCR8cL5DH/7w= X-Received: by 2002:a05:620a:228:: with SMTP id u8mr78749096qkm.88.1578229188590; Sun, 05 Jan 2020 04:59:48 -0800 (PST) X-Google-Smtp-Source: APXvYqxOE4cIY1bNLTLu0Bu78IPE9J/LJAq1L5FwOKszwHvLSvf0wCD2P/qs4S0HjmVaD/b7kzC+5g== X-Received: by 2002:a05:620a:228:: with SMTP id u8mr78749091qkm.88.1578229188391; Sun, 05 Jan 2020 04:59:48 -0800 (PST) Date: Sun, 5 Jan 2020 07:59:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 28/32] virtio-mmio: update queue size on guest write Message-ID: <20200105125622.27231-29-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: MnzbPnS9MoWseXuWKW-kGA-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 , Denis Plotnikov , qemu-stable@nongnu.org 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: Denis Plotnikov Some guests read back queue size after writing it. Always update the on size write otherwise they might be confused. Cc: qemu-stable@nongnu.org Signed-off-by: Denis Plotnikov Message-Id: <20191224081446.17003-1-dplotnikov@virtuozzo.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mmio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index ef40b7a9b2..872f2cd237 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -308,8 +308,9 @@ static void virtio_mmio_write(void *opaque, hwaddr offs= et, uint64_t value, break; case VIRTIO_MMIO_QUEUE_NUM: trace_virtio_mmio_queue_write(value, VIRTQUEUE_MAX_SIZE); + virtio_queue_set_num(vdev, vdev->queue_sel, value); + if (proxy->legacy) { - virtio_queue_set_num(vdev, vdev->queue_sel, value); virtio_queue_update_rings(vdev, vdev->queue_sel); } else { proxy->vqs[vdev->queue_sel].num =3D value; --=20 MST From nobody Thu Nov 13 04:41:28 2025 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=1578230647; cv=none; d=zohomail.com; s=zohoarc; b=ZsaG8zO29gSEm3I9LK4nSN79ifg7MRr3UvfFxabtLHjI0kkGzadPAY9lQkjwr8WwktLUB/HnoDgagqwZYdBok75XvpseffbmLjOraJNLveqUPtggTRetZtiMCW0Y6U26mJuzw5YBqUD8jY4bmndQyYyopqmm4xGeNAY0mfHy8Jw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578230647; 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=9q2/1/1fqOdhU65sqIDbx6cBRpFU6//iIePNlnfAizE=; b=nM/wMFRxqzM/8koI5GGlNIGuiTb2GX2/CBZ4G4x9PHIDWRg9jj/FgCaYqz/aGkCnvL6QpBDQe97Rl2XK2l8R9/Nairs3kTPLl50AZgKMuGr9H9hX2KyCgD7kuVCfOAZu6WULB2NKBnl6KHxrHBIhlmIjZW+JVB/nWlf8gIQng1A= 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 1578230647294895.4074402674473; Sun, 5 Jan 2020 05:24:07 -0800 (PST) Received: from localhost ([::1]:42210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5sz-0006UE-HL for importer@patchew.org; Sun, 05 Jan 2020 08:24:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58593) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Vf-0003fh-ID for qemu-devel@nongnu.org; Sun, 05 Jan 2020 08:00:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Ve-0005Ej-BQ for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:59 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:43385 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 1io5Ve-0005EO-8J for qemu-devel@nongnu.org; Sun, 05 Jan 2020 07:59:58 -0500 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-79-4qQwvfqVPNmJdX9zDKUzNA-1; Sun, 05 Jan 2020 07:59:54 -0500 Received: by mail-qk1-f197.google.com with SMTP id u10so27961759qkk.1 for ; Sun, 05 Jan 2020 04:59:54 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id u16sm19167732qku.19.2020.01.05.04.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:59:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229197; 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=9q2/1/1fqOdhU65sqIDbx6cBRpFU6//iIePNlnfAizE=; b=OjRfw+NMs41nSoMlEG/YbhP+Lz3YVrRiS7scHtqW79I5S5NjkiPQsk3HjX2dm78v/t4fgo CLL5sXA47C18ontdafgwQQDHyIL+EJEj8R+59O8+IHfcUTBH+jCls9Nol+bEAW8m04YHxR MGvbWlBs8R23qx9KulbI/88NNLKMsSk= 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=6oUZcRx6oHUh2LroAUnKmJ6d2Eg7LapR5X4J56q3mek=; b=UaBF4CFjVwvEiH4/j3qFSr+ZqELKF//Dw22YkcUM5uhk77RqS5uikDKdmOs02KRd00 FEsez2o8sD7+bF5c4n86H4z8QNNxJ4cXATq8ESpTr9+ziRsThLhz8KlxoYNo7XXaKYeY SuQtE2nQX5iHEMqJpNDJRvEWp6Npu7CDOjM0Fs+mKGmsxDFuW/BM8BP/bKMloOrSkKQY Sm9YbMCsdbZTa04yCjIivy7iFZO350ESHdwSM5ycGAmHBQ41bd3pzuhZP21OUw7K0dGH HVtT9ZluTrJ3xZciDmxO92OpPOzpI6egwliEuw/2vhp3gHpVqfQ0/S+5bN61mB2wBayq 8glg== X-Gm-Message-State: APjAAAVPofe0irk7LwMDbXY8pUroZ0gGifAsVNtEjG9WxoL3jaGGlZ+h uNA6CQlGctJAkEWlF5j9+FFw97Ln/OmHbSUEEYq7opsyBadZCp63D4KnmarHJ+coJv03fnCUimp y0UfrLHdTI+Mwrdw= X-Received: by 2002:a05:620a:1265:: with SMTP id b5mr78724809qkl.172.1578229193528; Sun, 05 Jan 2020 04:59:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzkuvvhVbwLf/pPx09Q3HwkhYyNZksOS8UoPgk6pUpkdprImtvdLmq5f+sdetSvVYGWv1j4Eg== X-Received: by 2002:a05:620a:1265:: with SMTP id b5mr78724803qkl.172.1578229193320; Sun, 05 Jan 2020 04:59:53 -0800 (PST) Date: Sun, 5 Jan 2020 07:59:48 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 29/32] virtio: reset region cache when on queue deletion Message-ID: <20200105125622.27231-30-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 4qQwvfqVPNmJdX9zDKUzNA-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 , qemu-stable@nongnu.org, Yuri Benditovich 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: Yuri Benditovich https://bugzilla.redhat.com/show_bug.cgi?id=3D1708480 Fix leak of region reference that prevents complete device deletion on hot unplug. Cc: qemu-stable@nongnu.org Signed-off-by: Yuri Benditovich Message-Id: <20191226043649.14481-2-yuri.benditovich@daynix.com> Reviewed-by: Michael S. Tsirkin 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 95d8ff8508..7b861e0ca0 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2344,6 +2344,7 @@ void virtio_delete_queue(VirtQueue *vq) vq->handle_aio_output =3D NULL; g_free(vq->used_elems); vq->used_elems =3D NULL; + virtio_virtqueue_reset_region_cache(vq); } =20 void virtio_del_queue(VirtIODevice *vdev, int n) --=20 MST From nobody Thu Nov 13 04:41:28 2025 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=1578230249; cv=none; d=zohomail.com; s=zohoarc; b=PFh8MetVdL2tm3X1mZmqOexkiFZ6Hwg1/LCzdhVZ/A+TNd5mTNdUImWNJXV7lbsy4eE+xWCJrvhRdV450hCI8DlS85Xz9IjAfy5ztWgnYhwoBkIu4I01YK0KArwSDHLs80ML4ORpHhEqcIZ3N3IQvondDIcVzA9CPtZUBE8lOB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578230249; 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=BgmNsnDUrIKv5qIqtQ+hIbBMXsq7KvX1kSU3ybRDZeQ=; b=L7n8xsO3IhAuHKqwpMK7gZsOv0nMF8vQIwTGtCTqAAVNI81SJpdMvb41NxNlP+UuCR9vlClqeE5XBXmUxtFDee7eTCj6gTT3a1D0ZDhYSOWPznGxE2k3Nc0OgjPP64H2/++tXwT9/5VQ+0ieAFsU1MLaGgBgRZhOptb+790SlzA= 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 1578230249419925.1467781333108; Sun, 5 Jan 2020 05:17:29 -0800 (PST) Received: from localhost ([::1]:42074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5mZ-0007kV-Pu for importer@patchew.org; Sun, 05 Jan 2020 08:17:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58625) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Vj-0003jy-2O for qemu-devel@nongnu.org; Sun, 05 Jan 2020 08:00:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Vh-0005HE-Nb for qemu-devel@nongnu.org; Sun, 05 Jan 2020 08:00:02 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:23445 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 1io5Vh-0005GZ-Gl for qemu-devel@nongnu.org; Sun, 05 Jan 2020 08:00:01 -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-50-jw3MDuN8OFuZnxySen45cw-1; Sun, 05 Jan 2020 07:59:59 -0500 Received: by mail-qv1-f69.google.com with SMTP id j10so2759180qvi.1 for ; Sun, 05 Jan 2020 04:59:59 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id t29sm18626355qkm.27.2020.01.05.04.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 04:59:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229201; 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=BgmNsnDUrIKv5qIqtQ+hIbBMXsq7KvX1kSU3ybRDZeQ=; b=RciQZePOm70DAm57Ot+NWxHWOMKeZjivap2a9gw2AWerHZzMRAbSoxpLMgIPkx0ugLiR12 vPOhgBpnrLotab4Rok1aM8j464BWgmN1C7QgqmtIPC4lRrTSXYDkBFGolB51ByzRWshKIS 81PZWIPaceCpUNjTPFFvh+/8eygw0s0= 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=tdoWlLoYwJDJiT74CT7GYIP+izHUlkgXXi1RbTtf6v8=; b=CoHqpNhrCqzo8ugyK0eCbPAQZP6MM+53yJwHM8RB1TiEeqhwLrMeHUYtgGiz4Pp0xN KI2o/D0DCEZ+5AkE5qfruhm1ExHA9rlM8i9x0HSC0+K8LNNyuNF5f3+rgp4H/CaJurv1 NKyydIYOMlJJO9chWSDbzQWeSa91D8VLcKRNl5Zev7nSrKapToFNfaVLPHbXwQI4nD5h +EBs/epW2+rhYq8bsk9pIkAaFbYOM3SlcmqA6K7hNS8on3pqlSd/3Qf90ISrrjDvApY2 Xs9EfPupGTHdC6JstbVKW8+dBJ7HeRJcMxBDlb3DFWgcBLr7kbHGH0MaTyASTKQ489Q7 xckg== X-Gm-Message-State: APjAAAXdQWTizB0fyqo+7Iv6n81c12L0w+4erTsuu9c0HqsYhS7yov4M hPRA48mpIUdORW8jVESeJD4H1ckUsioAJb7UpQRjkaz7XLvHnnzdrNSKOKITXLsW3xa6yQr5L2m 3F2HjSpcorhdM2U0= X-Received: by 2002:a37:6cc1:: with SMTP id h184mr77141179qkc.96.1578229198623; Sun, 05 Jan 2020 04:59:58 -0800 (PST) X-Google-Smtp-Source: APXvYqwpj+KnaJfccbiF/CfsiYRydssjgq27XCEF2rQy1KfGYj6TbF1wmVWRF/GMaFw3zhUFUfoF+Q== X-Received: by 2002:a37:6cc1:: with SMTP id h184mr77141168qkc.96.1578229198396; Sun, 05 Jan 2020 04:59:58 -0800 (PST) Date: Sun, 5 Jan 2020 07:59:53 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 30/32] virtio-net: delete also control queue when TX/RX deleted Message-ID: <20200105125622.27231-31-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: jw3MDuN8OFuZnxySen45cw-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 , Jason Wang , qemu-stable@nongnu.org, Yuri Benditovich 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: Yuri Benditovich https://bugzilla.redhat.com/show_bug.cgi?id=3D1708480 If the control queue is not deleted together with TX/RX, it later will be ignored in freeing cache resources and hot unplug will not be completed. Cc: qemu-stable@nongnu.org Signed-off-by: Yuri Benditovich Message-Id: <20191226043649.14481-3-yuri.benditovich@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index db3d7c38e6..f325440d01 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3101,7 +3101,8 @@ static void virtio_net_device_unrealize(DeviceState *= dev, Error **errp) for (i =3D 0; i < max_queues; i++) { virtio_net_del_queue(n, i); } - + /* delete also control vq */ + virtio_del_queue(vdev, max_queues * 2); qemu_announce_timer_del(&n->announce_timer, false); g_free(n->vqs); qemu_del_nic(n->nic); --=20 MST From nobody Thu Nov 13 04:41:28 2025 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=1578230708; cv=none; d=zohomail.com; s=zohoarc; b=cy5jsPkWRBSh0VbOfZdnAZSn9/YlXxsSs1gVs6GgZmEP1rW0EI7k0ktVy6TP/brjO869ZGZvwlzIdCIDVTuT+7t5Pr0z+WTLJAY0htRJ35E4W5qNus+L8fdVw1gfPWDxwEbT4xIujDetzbvTZGyPY2OBqHeQLpnTM1E7dnOS7jk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578230708; 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=s9CW2f1wTLCUXOOV0nNq1e86u0ryEb/Y8cd2jez9DrU=; b=gMKlb/5x++UB0nS01PS73MudIkSS/V67ZkWTrwlKAt5Z4StCnXX11W+YJrckGEs1v31UruxgnvmZRh+qet98uagn1KxcXT7KkggJqyeK3satG8237DmL8NTkZhEIWkUUiM2kwMc30GcZJtjw9dDOBMAIMYnaGiGGHWkVewHJCi8= 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 1578230708247783.4237613944804; Sun, 5 Jan 2020 05:25:08 -0800 (PST) Received: from localhost ([::1]:42234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5tz-0007Of-4X for importer@patchew.org; Sun, 05 Jan 2020 08:25:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58720) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Vu-0003yb-LE for qemu-devel@nongnu.org; Sun, 05 Jan 2020 08:00:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Vt-0005Ru-EF for qemu-devel@nongnu.org; Sun, 05 Jan 2020 08:00:14 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:50057 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 1io5Vt-0005Rd-AN for qemu-devel@nongnu.org; Sun, 05 Jan 2020 08:00:13 -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-369-CFWs4czvNCC8Nve4bMLopg-1; Sun, 05 Jan 2020 08:00:07 -0500 Received: by mail-qt1-f199.google.com with SMTP id e37so32589460qtk.7 for ; Sun, 05 Jan 2020 05:00:06 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id y18sm19181850qki.0.2020.01.05.05.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 05:00:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229212; 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=s9CW2f1wTLCUXOOV0nNq1e86u0ryEb/Y8cd2jez9DrU=; b=adeg4H9fCNd9GFf5q42EKg/OdcN3yfY4muJAHf1zG2nH9aBrKbN3T6KzfMaAapjasStNAR BEQFtc2IB8ojB1KJ5HFtstxtCSc7EqkPth//Qrv0TG68jw15Dwi+B5EuExaggDRKEsRRqL xmECrj0p67djJMaaR6DhyHd90hjrgKY= 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=pNIx/NiIdCE26OJhITv4+Fn8KZTuaXrKqh88qEn+vzc=; b=rCzX4CMQjz8gu9qd8R/tLwXsI/TI0z/07Z5WYu/xpBBB5dpQRZHXmQ/zuTT5L4nwWM Zvf/wFlgZWSvu/zPrN42jKZdtPWUK/82m1E1BKcC8p+RV+6NQppvXcFC66HieAfIFc0S iW0Jeo7IFKu1K4uyaUKdCfJ7xNbV5o+Axt40RRi+wzf0iqCoxmjlAKnIey6Htzm6GBIT h3sBclruYPfVHvLfSLLsi+cX+VIkcGTIFBM4AWFiuTw8kt7pTZas2beOG2hJ8mfFiX+n AMbcw6uxxI8DJBI8kd6czAaYEjKFeAof4j/SUR2eB8+8rN5zi8S2cCFnDK6AFuHcTRye Vv7g== X-Gm-Message-State: APjAAAXB+mXXr6n/m6w0Hstz0yjgggQWdU604mu4GA+/mgqfQnKN7o7Y kRmJ4bJh4Oz85VNK+sp5iaGmlqXBzzblZyyoFT/QXktU7KhvxAthPY2MScAPlEKk83aHYETvT1u qOyRYMzym3VzLtb4= X-Received: by 2002:aed:2a87:: with SMTP id t7mr59400344qtd.384.1578229205355; Sun, 05 Jan 2020 05:00:05 -0800 (PST) X-Google-Smtp-Source: APXvYqwzmhbBoRU0CKNJ7Jwdq4kaoke+znnw9ZVMiFTafmdUCOiILtGzMv9d8B6A27Lcb5YPRoeVeA== X-Received: by 2002:aed:2a87:: with SMTP id t7mr59400328qtd.384.1578229205200; Sun, 05 Jan 2020 05:00:05 -0800 (PST) Date: Sun, 5 Jan 2020 07:59:59 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 31/32] intel_iommu: a fix to vtd_find_as_from_bus_num() Message-ID: <20200105125622.27231-32-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: CFWs4czvNCC8Nve4bMLopg-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 , Kevin Tian , Jacob Pan , Yi Sun , Eduardo Habkost , qemu-stable@nongnu.org, Peter Xu , Liu Yi L , 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: Liu Yi L Ensure the return value of vtd_find_as_from_bus_num() is NULL by enforcing vtd_bus=3DNULL. This would help caller of vtd_find_as_from_bus_nu= m() to decide if any further operation on the returned vtd_bus. Cc: qemu-stable@nongnu.org Cc: Kevin Tian Cc: Jacob Pan Cc: Peter Xu Cc: Yi Sun Signed-off-by: Liu Yi L Signed-off-by: Yi Sun Message-Id: <1578058086-4288-2-git-send-email-yi.l.liu@intel.com> Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index ee06993675..609b80750a 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -948,6 +948,7 @@ static VTDBus *vtd_find_as_from_bus_num(IntelIOMMUState= *s, uint8_t bus_num) return vtd_bus; } } + vtd_bus =3D NULL; } return vtd_bus; } --=20 MST From nobody Thu Nov 13 04:41:28 2025 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=1578230285; cv=none; d=zohomail.com; s=zohoarc; b=MxZUmFV77AYTP1J5wa2oS9aLe0DKFWTDMsSC/7rcGNd9RHcpVDXxDNrU86A8538NCIBEpuGonFIs0kgop1fsUCzv4VPgJvfwye3F1VmQxRMIbGw0a9lMxi8lI+thB538AnMgUFZA8FZIb0PTQw9cp0c1VuDwPyd0M47rzPLa9Eo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578230285; 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=VvaA+Bcc2Gxeb7XmQhJgoMxxUrIKTcdYM4rBXSKaGgM=; b=UUogC8PwKTcERkPYArhWWByeWK+nzVQu1MuBcFKADYVm/r28thz8rN+ReqLrIhBS7vaC+Oa97KSCsnpuGhS/wjw+8XfE/ZYurob049F5Cw4BqSfXrRmX2FuxOYGCV87CIhv1vt7cuCOKmGprOI8UMIjyrjXHnZWCM1SnT5IxzPY= 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 1578230285306258.14926247954077; Sun, 5 Jan 2020 05:18:05 -0800 (PST) Received: from localhost ([::1]:42086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5n9-0008V8-RX for importer@patchew.org; Sun, 05 Jan 2020 08:18:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58737) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1io5Vx-00042w-NM for qemu-devel@nongnu.org; Sun, 05 Jan 2020 08:00:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1io5Vw-0005TY-5m for qemu-devel@nongnu.org; Sun, 05 Jan 2020 08:00:17 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51030 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 1io5Vw-0005TM-11 for qemu-devel@nongnu.org; Sun, 05 Jan 2020 08:00:16 -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-245-BJ3nyWm0NYO_dGScZqZQYQ-1; Sun, 05 Jan 2020 08:00:12 -0500 Received: by mail-qv1-f71.google.com with SMTP id v5so32900480qvn.21 for ; Sun, 05 Jan 2020 05:00:12 -0800 (PST) Received: from redhat.com (bzq-79-183-34-164.red.bezeqint.net. [79.183.34.164]) by smtp.gmail.com with ESMTPSA id q25sm19415327qkq.88.2020.01.05.05.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 05:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578229215; 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=VvaA+Bcc2Gxeb7XmQhJgoMxxUrIKTcdYM4rBXSKaGgM=; b=VOtSxsZpO1BoD5HEBi3+gueKbrW20FWxrgY7vzlNOeGHK2/7kmB7GC4Qkgo0ZSZf3dN9q1 1UOXgVGx5WWv8VSrrs/4lhR5iSOyfB6R0H7vt35PDG+ZJxp2nWbpWdN9JJ/mLn0fPMWf4u YToD4sn7I7K18LyI8nvoK5X4w7d6IEY= 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=aNLKl1oKPF+kDyM8hwhwxdKmZvFLTYfwlNBJlJeT2zg=; b=UqqEX3AR2K9ROaiJYNFhXo49ef6hGNrDa9ygWNjVVlWKFgpJXWnc9dajZRBTnYcn25 og7MByccklhn2TruuDCsaSQeTZX7o2MFByVur3W6yWG8HZZDaLt/VE/fk7M/WtEEaYUo Y0HavswsBPdPf/DqQpMhv+tUlTYWV/OlqCrcX7QISBlN+Jmn3JjBTd4Z5SVO4HTfF8o1 DFmA+0YwxVipW7FYnrE60f6viTmJ/GSDwFq68uDpIGD1zhgR/NVwPWgBwEQNlcz7b3ox x3FES+JZSAth115DwFIh6nhBl29XKG3RjHv413yrVna1L5RLOlAH3jsoPhbAlkce06iu LqLA== X-Gm-Message-State: APjAAAUkXIpC4D0LGZ1/ghojBfrszPE2p6vf/IiSe4//N+qYuCydWUs/ 00Un32aUfy8KkoGY4EflgcdJzcMotIIhrjPaK0HPMjNHlmTonZD6IPOBpNpW6RxZN84C6wxyPQs 1mBcbIy0Gt3Mvm2w= X-Received: by 2002:a05:6214:1772:: with SMTP id et18mr39343901qvb.154.1578229211856; Sun, 05 Jan 2020 05:00:11 -0800 (PST) X-Google-Smtp-Source: APXvYqwMKh8VtuZnkWcWHJLEF8OmGmsU0HxtpqN5DQIXpP8bDy+Hffc5juG13QqEpIkYS1AsMLQBUw== X-Received: by 2002:a05:6214:1772:: with SMTP id et18mr39343872qvb.154.1578229211561; Sun, 05 Jan 2020 05:00:11 -0800 (PST) Date: Sun, 5 Jan 2020 08:00:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 32/32] intel_iommu: add present bit check for pasid table entries Message-ID: <20200105125622.27231-33-mst@redhat.com> References: <20200105125622.27231-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200105125622.27231-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: BJ3nyWm0NYO_dGScZqZQYQ-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 , Kevin Tian , Jacob Pan , Yi Sun , Eduardo Habkost , qemu-stable@nongnu.org, Peter Xu , Liu Yi L , 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: Liu Yi L The present bit check for pasid entry (pe) and pasid directory entry (pdire) were missed in previous commits as fpd bit check doesn't require present bit as "Set". This patch adds the present bit check for callers which wants to get a valid pe/pdire. Cc: qemu-stable@nongnu.org Cc: Kevin Tian Cc: Jacob Pan Cc: Peter Xu Cc: Yi Sun Reviewed-by: Peter Xu Signed-off-by: Liu Yi L Message-Id: <1578058086-4288-3-git-send-email-yi.l.liu@intel.com> Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 1 + hw/i386/intel_iommu.c | 92 +++++++++++++++++++++++++++------- 2 files changed, 74 insertions(+), 19 deletions(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index edcf9fc9bb..862033ebe6 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -479,6 +479,7 @@ typedef struct VTDRootEntry VTDRootEntry; #define VTD_PASID_ENTRY_FPD (1ULL << 1) /* Fault Processing Disa= ble */ =20 /* PASID Granular Translation Type Mask */ +#define VTD_PASID_ENTRY_P 1ULL #define VTD_SM_PASID_ENTRY_PGTT (7ULL << 6) #define VTD_SM_PASID_ENTRY_FLT (1ULL << 6) #define VTD_SM_PASID_ENTRY_SLT (2ULL << 6) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 609b80750a..a523ef0e65 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -686,9 +686,18 @@ static inline bool vtd_pe_type_check(X86IOMMUState *x8= 6_iommu, return true; } =20 -static int vtd_get_pasid_dire(dma_addr_t pasid_dir_base, - uint32_t pasid, - VTDPASIDDirEntry *pdire) +static inline bool vtd_pdire_present(VTDPASIDDirEntry *pdire) +{ + return pdire->val & 1; +} + +/** + * Caller of this function should check present bit if wants + * to use pdir entry for futher usage except for fpd bit check. + */ +static int vtd_get_pdire_from_pdir_table(dma_addr_t pasid_dir_base, + uint32_t pasid, + VTDPASIDDirEntry *pdire) { uint32_t index; dma_addr_t addr, entry_size; @@ -703,18 +712,22 @@ static int vtd_get_pasid_dire(dma_addr_t pasid_dir_ba= se, return 0; } =20 -static int vtd_get_pasid_entry(IntelIOMMUState *s, - uint32_t pasid, - VTDPASIDDirEntry *pdire, - VTDPASIDEntry *pe) +static inline bool vtd_pe_present(VTDPASIDEntry *pe) +{ + return pe->val[0] & VTD_PASID_ENTRY_P; +} + +static int vtd_get_pe_in_pasid_leaf_table(IntelIOMMUState *s, + uint32_t pasid, + dma_addr_t addr, + VTDPASIDEntry *pe) { uint32_t index; - dma_addr_t addr, entry_size; + dma_addr_t entry_size; X86IOMMUState *x86_iommu =3D X86_IOMMU_DEVICE(s); =20 index =3D VTD_PASID_TABLE_INDEX(pasid); entry_size =3D VTD_PASID_ENTRY_SIZE; - addr =3D pdire->val & VTD_PASID_TABLE_BASE_ADDR_MASK; addr =3D addr + index * entry_size; if (dma_memory_read(&address_space_memory, addr, pe, entry_size)) { return -VTD_FR_PASID_TABLE_INV; @@ -732,25 +745,54 @@ static int vtd_get_pasid_entry(IntelIOMMUState *s, return 0; } =20 -static int vtd_get_pasid_entry_from_pasid(IntelIOMMUState *s, - dma_addr_t pasid_dir_base, - uint32_t pasid, - VTDPASIDEntry *pe) +/** + * Caller of this function should check present bit if wants + * to use pasid entry for futher usage except for fpd bit check. + */ +static int vtd_get_pe_from_pdire(IntelIOMMUState *s, + uint32_t pasid, + VTDPASIDDirEntry *pdire, + VTDPASIDEntry *pe) +{ + dma_addr_t addr =3D pdire->val & VTD_PASID_TABLE_BASE_ADDR_MASK; + + return vtd_get_pe_in_pasid_leaf_table(s, pasid, addr, pe); +} + +/** + * This function gets a pasid entry from a specified pasid + * table (includes dir and leaf table) with a specified pasid. + * Sanity check should be done to ensure return a present + * pasid entry to caller. + */ +static int vtd_get_pe_from_pasid_table(IntelIOMMUState *s, + dma_addr_t pasid_dir_base, + uint32_t pasid, + VTDPASIDEntry *pe) { int ret; VTDPASIDDirEntry pdire; =20 - ret =3D vtd_get_pasid_dire(pasid_dir_base, pasid, &pdire); + ret =3D vtd_get_pdire_from_pdir_table(pasid_dir_base, + pasid, &pdire); if (ret) { return ret; } =20 - ret =3D vtd_get_pasid_entry(s, pasid, &pdire, pe); + if (!vtd_pdire_present(&pdire)) { + return -VTD_FR_PASID_TABLE_INV; + } + + ret =3D vtd_get_pe_from_pdire(s, pasid, &pdire, pe); if (ret) { return ret; } =20 - return ret; + if (!vtd_pe_present(pe)) { + return -VTD_FR_PASID_TABLE_INV; + } + + return 0; } =20 static int vtd_ce_get_rid2pasid_entry(IntelIOMMUState *s, @@ -763,7 +805,7 @@ static int vtd_ce_get_rid2pasid_entry(IntelIOMMUState *= s, =20 pasid =3D VTD_CE_GET_RID2PASID(ce); pasid_dir_base =3D VTD_CE_GET_PASID_DIR_TABLE(ce); - ret =3D vtd_get_pasid_entry_from_pasid(s, pasid_dir_base, pasid, pe); + ret =3D vtd_get_pe_from_pasid_table(s, pasid_dir_base, pasid, pe); =20 return ret; } @@ -781,7 +823,11 @@ static int vtd_ce_get_pasid_fpd(IntelIOMMUState *s, pasid =3D VTD_CE_GET_RID2PASID(ce); pasid_dir_base =3D VTD_CE_GET_PASID_DIR_TABLE(ce); =20 - ret =3D vtd_get_pasid_dire(pasid_dir_base, pasid, &pdire); + /* + * No present bit check since fpd is meaningful even + * if the present bit is clear. + */ + ret =3D vtd_get_pdire_from_pdir_table(pasid_dir_base, pasid, &pdire); if (ret) { return ret; } @@ -791,7 +837,15 @@ static int vtd_ce_get_pasid_fpd(IntelIOMMUState *s, return 0; } =20 - ret =3D vtd_get_pasid_entry(s, pasid, &pdire, &pe); + if (!vtd_pdire_present(&pdire)) { + return -VTD_FR_PASID_TABLE_INV; + } + + /* + * No present bit check since fpd is meaningful even + * if the present bit is clear. + */ + ret =3D vtd_get_pe_from_pdire(s, pasid, &pdire, &pe); if (ret) { return ret; } --=20 MST