From nobody Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578383813; cv=none; d=zohomail.com; s=zohoarc; b=LOTBWcqn5Mja0Nrb/ZMGXbQb2zYlivoh9NFw+0AMcSGdqZzVGy5/boG6EQyragal1gKnG4FENlzoLjU7eXn9CrR7LBYTI8KzrQADi/JzdX0q+VxWj2ZZHcs3x050ZQ0VEX53Jq5vuSyB3F/qxWOt0lzK5Is6r3VVKEOJsRLup8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578383813; 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=kAC59IVF3BooSxQxG5TLAz7oSU/+dhNoRGh+Nc44q0TVPdB2t66vx0MapVm6uvno8z03mdGh96mET9K2ZrTojXIUct+dSmGyrn7syELyDcyJpIViQx7LLq6dANU+CeCTHrW8jnS9JEcsr968354aHRCGZ+xl7x75PxfcspkuPF4= 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 1578383813539796.6229969831245; Mon, 6 Jan 2020 23:56:53 -0800 (PST) Received: from localhost ([::1]:44190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojjN-0002ib-Ao for importer@patchew.org; Tue, 07 Jan 2020 02:56:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51583) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojOb-0003hV-Rb for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojOa-0007DY-Ed for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:21 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:46347 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 1iojOa-0007Ct-AV for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:20 -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-145-78WXmuAXO1KyuZUMz2cnVA-1; Tue, 07 Jan 2020 02:35:18 -0500 Received: by mail-qt1-f197.google.com with SMTP id r9so11393037qtc.4 for ; Mon, 06 Jan 2020 23:35: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 i28sm25247073qtc.57.2020.01.06.23.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:35:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382519; 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=gilRTb6p/oHNDPkyEdtyowHhuopnKkdY3QSaxHLE3kHxZ3mnAA+ikxOF8b5/WxwsfunK5y pqec5MzMxYRz5WwSzfjMexB1nfgZERVoQwFi2r40vWGuRJGLKeOAe9ZWnzUKZeP6pH6XJX aR7dkkW6OpsaZRf3Hp3vFlttjdbBRuk= 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=gOoHEMU8nxHGj93WKoiLbqnksV5oqlfJKopQfIiyk90jdb8xTlKGmWStN+rrO88W/T tQYDO3SEdB5ziwWAbw4g/hVcZ3M7UX8/2cElpS1DAY7Kg7urDZzestH6vYCxYgTWjSt+ spDrSkxBSGr60yaamnwBUBH/OxNuUw+dWGYMvqna8u+DJ+lBFbSOwF6JUcWrGpoRUBZe 1wtiGtr7tDtT4ut/0Whv+IVuH2S+N0QP5vdGiLTTczT6v4ySVTvpDtyeFL+UV/1dnxaR EFrXFpZwEiV7k6caU5FeRxQmUwErnkLqbnIE17+pcbbGS/FFVUhfckd2UaGAiQVSA97r ckSg== X-Gm-Message-State: APjAAAVQmzOZt1bBoYIPz5i+C3zn6EB9BHxQKP44b274TWjVenJtiorG 8+tba4Wewd0YLqsxl4VKFndGzlaioOeMhtsf0EJbDLfPPHKbB68oI8p3DQ1ZPRiXwWLlUgjViTj 4gCxw1W9SwajJT9E= X-Received: by 2002:a05:620a:147c:: with SMTP id j28mr78142492qkl.13.1578382518046; Mon, 06 Jan 2020 23:35:18 -0800 (PST) X-Google-Smtp-Source: APXvYqwwNwktsZs5/b/1iC+2fvpm9h55X9qtq0lkJgTRivz28wZ2Ck6BnP2/SjQyelPOxTQo/PvDtA== X-Received: by 2002:a05:620a:147c:: with SMTP id j28mr78142482qkl.13.1578382517856; Mon, 06 Jan 2020 23:35:17 -0800 (PST) Date: Tue, 7 Jan 2020 02:35:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 01/32] virtio: add ability to delete vq through a pointer Message-ID: <20200107073451.298261-2-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 78WXmuAXO1KyuZUMz2cnVA-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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578384578; cv=none; d=zohomail.com; s=zohoarc; b=cyQS2BjADk0qHeYqKcjlPzxccRgFj9omEOgEjb89+GIfpGIYntUAo3mraCDSD4Ju7FHRSBA93CdKIvTCifAC8NwvNtq+PiQHuNYFXCLtAqRon10YAQdADq+t8TilWjQc+kCV5eZi+wTplaYmqbS+WV/DCw3OIMCz4DP8uuF/rWU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578384578; 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=AB/gRiwRKUFAkheuq3ZQ1Yj0ypUz1ydfvPSivsnxk2jLjgniDzkVxWM59Z3fmyxYhGYxk8N+5gXbOefn4DgMsdQxGMZwAyH/o/4kqVXJE5kxCzdUvmRlRyqjvfwpS4NjGfXOEEYWWEzjutYN7a87lwugo2UVGie7qGF0t7wX6f8= 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 157838457833247.19828090939086; Tue, 7 Jan 2020 00:09:38 -0800 (PST) Received: from localhost ([::1]:44122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojab-0003EP-Qt for importer@patchew.org; Tue, 07 Jan 2020 02:47:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51603) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojOg-0003uI-9e for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojOe-0007Gx-TR for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:25 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56243 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 1iojOe-0007GU-Pb for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:24 -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-370-i6RM7ghxNbG91c40pTq2WQ-1; Tue, 07 Jan 2020 02:35:23 -0500 Received: by mail-qk1-f198.google.com with SMTP id f124so31118403qkb.22 for ; Mon, 06 Jan 2020 23:35: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 r205sm22044943qke.34.2020.01.06.23.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:35:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382524; 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=A+lbb6xik6xx3tfdSdOe1A11GGlq1drlLiYCDPpW+CmqVpcBHg38GCkzBz7yH59l6iRm8j 02Luq0vArAGK2wRh5jufFsF0sQ3rYiXDUVFf4+UKi61ipRq4chvPhb7o5wdtLz6Yk2nJKi SRUwGOAn12QXAeslvGjjJXoQK4FWAek= 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=eozGsTopnyAWBrSaP+j/jDAfh1GSs5tsNeeONmH0F+jGYIaJKnK63oArDkRQlvXUTX h+K0Lxl52KBRmhNfJAlkh1j5dTg2djnNfRCqlSOoj3vZC4YfmroC64W1b6tTOpzz9EZJ U6ebOlFyYF7m+qUMvVkv8OWNRKBl4yW4ZZ8+44RNaVgdcRMemAFZArI4tDJJNEJzG53h HRavLke4L46XPJaORcq4mLbfXw5jWqOj1RduWBOpedBm/PTGBCwW+epEwr1QpmkECVuq mmqJpXJIlf/zNnfCYRIDDjXE+fPBJ+L42sWn0yWpag/Ms6+AY9r9jF9/lgIvSvCxW/XC myDg== X-Gm-Message-State: APjAAAX6r8yInjdir+cvxShJ9OWKv5Smap+m3NcKSJAiC2TOTycm1U8y QxT+MbkOJSnjxy3MPQv1TyCApq7eDIBX3z9HAfnjeQurp6Sa1gALGothC+5PGGICstq9EVg+0NE +PR5bATbdoAFGu6w= X-Received: by 2002:a05:620a:16c6:: with SMTP id a6mr87981106qkn.140.1578382522512; Mon, 06 Jan 2020 23:35:22 -0800 (PST) X-Google-Smtp-Source: APXvYqxhLAdtiJPhE/aI4ePsC2UQ2u1aXK7XFKiPt5F8mBUxv5K/6rfSATmfaqEXSRnZqWhgvblc8g== X-Received: by 2002:a05:620a:16c6:: with SMTP id a6mr87981096qkn.140.1578382522334; Mon, 06 Jan 2020 23:35:22 -0800 (PST) Date: Tue, 7 Jan 2020 02:35:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 02/32] virtio: make virtio_delete_queue idempotent Message-ID: <20200107073451.298261-3-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: i6RM7ghxNbG91c40pTq2WQ-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578388850; cv=none; d=zohomail.com; s=zohoarc; b=gzjklTtjMvP6uVyJqAiZgcDi5YVGnvlOdOTvkKvVtIXuV3M7G1YZ9Ye7KDL9Ef2DZB3AnOJztmq2GjsiNfZ3gNwU7Y4D3oeyWahViUi6qxs20nV35eoZ7Zjwrtt4PAHixDVYsJtTK6RuKGdEkZHeSRTd6yCsZRKZRepgLKTNn2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578388850; 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=TCFKmQIF/aa+q9QjQpmROXxGXgaNu3CreurXlHpxrMeod0XSlL/KLOWbX7SUTQDl4wffk0OIg2YYrL+UY4w5H3gRvMDUvIojs5ognQ/YIBZfQPDaW3YymcvnAZ/+Gw5naCMVynVxAfWn9V+Wa25gH7thzhJrTg7unT8A3GXWhqo= 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 1578388850188201.02926991202264; Tue, 7 Jan 2020 01:20:50 -0800 (PST) Received: from localhost ([::1]:45142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokzd-0005IK-Rq for importer@patchew.org; Tue, 07 Jan 2020 04:17:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51629) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojOl-00048y-Tg for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojOk-0007L0-HS for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:31 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46325 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 1iojOk-0007Kk-Cl for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:30 -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-6-Xs1pmwo_P82CIKaNgD1wBw-1; Tue, 07 Jan 2020 02:35:28 -0500 Received: by mail-qv1-f72.google.com with SMTP id e10so5026143qvq.18 for ; Mon, 06 Jan 2020 23:35: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 l6sm24706349qti.10.2020.01.06.23.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:35:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382529; 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=TQk1IKEjfRKTdYumTDvk+ymVW5pqvbycq9UOkAq9ktkSVtu8rAz1BR6J1pkR0EzMcuJC6K 3WQ5pk3mnONKH8dqzBNxNLxzHMqC3hrcNpNiILQIfCgb2SaMyH9EC1J0GZUTdhvzB0Ys2d cEUhtQySJrAId/1fc1eat1oaBpbSJDs= 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=DQybrRaMXVNnFincXpXoKjgN0fDKJra08XNUwz+UqYoQ5MI+tQz22CZrIcnM8nDt+g Rtpk9UkLM4vrSbgq5MZF4ofBRgx6b5I0SDgpEoBZmv72S2oV3g4NwIekACSGePfiVmcB 0Hb9/oARagWB1II2NBJeYf9RXhA9pst4ABIPMbu+SP+kXRyzebZX/WPUwjHSnkh30pna GwItg/FwuhBbHmOx+86fx+fA6QiScy/u0wqJJszOUSOogD37PEChGohU93viXydCD3y9 Hts/Ejfjq0y1frnlphYXM9nbmUgnnQ8RJWYaxFjdNgTVfivepDNY/DpvtYzSq6xt9PKa LYMg== X-Gm-Message-State: APjAAAVeo54ViXS5aLJtHGgN9tcVUB2Ek7CFbZfvaaehk5SgjzpjuaSr JpO+d29ES7L6pgVgwD8dM6yv8R+ONaIjwAvDYuEjDmPIUcTKHnbo7cQ/Tg9fxzzHP+H6yvUYFjf 89ShSBiGW11q+3cM= X-Received: by 2002:a0c:c18f:: with SMTP id n15mr70463499qvh.35.1578382527541; Mon, 06 Jan 2020 23:35:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwSOqp9wdGe6au8cm40/OOAUPV0iuTj/AEBQBzXV3xgoPZJm4OQ4+chno8vYFA6+p5ya98VMg== X-Received: by 2002:a0c:c18f:: with SMTP id n15mr70463489qvh.35.1578382527347; Mon, 06 Jan 2020 23:35:27 -0800 (PST) Date: Tue, 7 Jan 2020 02:35:23 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 03/32] virtio-balloon: fix memory leak while attach virtio-balloon device Message-ID: <20200107073451.298261-4-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: Xs1pmwo_P82CIKaNgD1wBw-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578390035; cv=none; d=zohomail.com; s=zohoarc; b=lvYKjm5teWwuqSPia/Lj8SxfbMeFpJDSp4XpsEP4/7JTwYoHsIucoYBoc+M2biCOR34k/LNMcAjEajkpBS97UXHQtZz4tgHNTeZ2ORck0MNOFkO3CgSqlRcvK6ogc19t1OWi3/QeBMddLcIObR86nQXChrXHrzJf7DXNEdA51Ac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578390035; 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=fWS554r8AuzysYntVvdRe8r2gTWbL4qM2zDZuccEpIuCuzjOXZyxeOOYZdNpm9LxQAWRU5L2AcaihdeaTfQ9eGzuNYvQdFR2IRZFNAypMzDXkZY4nXFE6AfeCC1reW7Im2ajsS+7i0xd1iETIVBMoFigktMimiudNRPIeJl9uqY= 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 1578390035144996.7972162098808; Tue, 7 Jan 2020 01:40:35 -0800 (PST) Received: from localhost ([::1]:45384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iolLk-00053c-AL for importer@patchew.org; Tue, 07 Jan 2020 04:40:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51671) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojOr-0004QZ-HA for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojOp-0007Oi-Vg for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:37 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:39203 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 1iojOp-0007OS-RM for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:35 -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-261-JPcXG3FtMx-4m4293IqxJg-1; Tue, 07 Jan 2020 02:35:33 -0500 Received: by mail-qk1-f199.google.com with SMTP id 24so19533221qka.16 for ; Mon, 06 Jan 2020 23:35: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 d5sm21367620qtk.96.2020.01.06.23.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:35:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382535; 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=WdAa70i7xLvjO1zsyMCX01K+L5r9iMvG1U9omGZw72T6VM15F7Pd3MSmqCL9O/p+D6UnmT xNM1zIx+PhtskRnvjsCECKuvZmxNHg5X7mh3jAM5u6JZpZq9ifXCCp62kKkXiNkuefY0n3 SGkKuoCNLAZuia5YlJ71UbSLJ4pFBiA= 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=WtSRqdd7DZBhOSHKzDgyorKu/BpliDt/hnI05oAMUPzoQNDtSIKNFfD8Nhvx6W6qOZ TPDLngbGRkOJS/IXGPKpMGzhcW5oZFoo7o5zXdQ8ehKFDe632Hqh3nivfbnBw23EYeDv cGpbyBga8D/yJhWBRUJCUE8VIX6fsLFGL2iQkZUCxsPk+jJYqsARZV+Wc1/6BYDbcZMa f6xuff0MzrB21imPFxzbAHRneeBJGF0HCZudwaw6oV8eabNUF15k/rpjEJxHzsSv5Y+e 0UOmWeqDcmqbsQARuWbQqiI5eutZee8FUPxlmcgwRdoxyhfh7wg/eDHw00g1NZ6Vzko/ aO8A== X-Gm-Message-State: APjAAAVFLh06rUybIED1TkHM5lXRvXN+TZ3Yc7JWoklrc2IZyH7lIcYV G4WlAeY0NOtHzMRFUxTZh5ROAqcBiS18dqe7ji8kW0aZl3rjWD1pxVsuJSWlukpdt+8tEleMsXo qF56/qs6qbcWyNOc= X-Received: by 2002:ac8:4a10:: with SMTP id x16mr77211027qtq.371.1578382533045; Mon, 06 Jan 2020 23:35:33 -0800 (PST) X-Google-Smtp-Source: APXvYqxXXUsgb1tFKZVVnJc4c9Dx8hlj36CENQ7Ymj6ynLjzWachi2rZOjgDXNXX9O4yyRojY2LejA== X-Received: by 2002:ac8:4a10:: with SMTP id x16mr77211011qtq.371.1578382532880; Mon, 06 Jan 2020 23:35:32 -0800 (PST) Date: Tue, 7 Jan 2020 02:35:27 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 04/32] virtio-serial-bus: fix memory leak while attach virtio-serial-bus Message-ID: <20200107073451.298261-5-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: JPcXG3FtMx-4m4293IqxJg-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: 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578384197; cv=none; d=zohomail.com; s=zohoarc; b=dgiSM6GHY7YYAj6+T/NKTlfTVjSNkFyBGPaKGyViZnujpl0i1fF85rg+XLjMOVX9c8hlY9LVAD7EcD6uWH2hqEFLVn6CAt9lIsbwQxZYshpo/TtZxhaXxbyJb5QJ3E4NyKJqs3fJy07VwIRXA6Oc8xMqeE2Sru02X4toMWz8BFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578384197; 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=XLai2yfOL+GWRLzWxuIEq5lQ8TX0TUM2sdG4nRUNMggO0VeeSYoJIlCYAsVNDIC+mmkP3dr2p0P4jKboC30IGrPbl1FhZ4KWc4sV2bQqApXICo/xn151z0Qy7t0sSxdT2JiLgzjQ4os6UEXUxKVDayLgOFAYcUPcUh/HH5m2Qwk= 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 1578384197943508.4220017091633; Tue, 7 Jan 2020 00:03:17 -0800 (PST) Received: from localhost ([::1]:44262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojpY-0006wW-6v for importer@patchew.org; Tue, 07 Jan 2020 03:03:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51686) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojOv-0004W4-Tk for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojOu-0007Ru-R1 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:41 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46386 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 1iojOu-0007RJ-3w for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:40 -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-306-NL-lLGPHOJyWC4QFG6FwSw-1; Tue, 07 Jan 2020 02:35:38 -0500 Received: by mail-qk1-f199.google.com with SMTP id s9so17952826qkg.21 for ; Mon, 06 Jan 2020 23:35:38 -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 f26sm24528080qtv.77.2020.01.06.23.35.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:35:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382539; 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=aMg31D+0nhGp4C+H98QK8ZhQeumsQh5dRJvd5woXheNbqhmn146sTgyDen04qPyDREgm3X +82RDFXrr2PoI/gWwVFD/omuhHdTeq4XIQMnoFb6JKGAz2t7Lb7i/tpLK6e0EDG+fR2zjL 4B1ycsM2ggrxh8KEtP3yQUTLicn1z3Y= 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=J2nQwWc2/XwEDSd4y26bpc/eLYyshDm5GrcfKwGqNdV2Os+vJyqwLe67HCKVrWfHNx Iku07ds0GIv2/jTUd1mP5F/rN4B+qcK6qAANAH3Z/vqnX1XoVze5eHM3ZWMxt77QBRAQ vZMfuu2oiWTO4+aZNrGQKH1GHtM5hqmLCWc5w7zk1h+xW46+wNVfnOitGS29CVYmjYnM mBmWxy1XxtJyM3lYLx6j0K3LPOZdWpep2D2xtbet6aR8hJD/RsuWgokse0HE6lyQY6MF Yhl/J3jN1Lyl1qLtoesQwmAkDZSWkSnMxP9xh7BPRjY8CkWjOEo7MNoCEUtQ98bii7S+ brtQ== X-Gm-Message-State: APjAAAUYYTizZB8qZ3E86dB8kmxuBL+aaKdQT3/u2m2E38+GBlRL1Uob O+qrK3nxtdHPbVaArcozUsgbgpAUv4hj2JR3q8T3JcKBItS+HMlqDhMB/1Pk+Z9cMNmg6zo9u17 pjxsGPZmK0bCgpkc= X-Received: by 2002:a37:488f:: with SMTP id v137mr83780580qka.16.1578382537525; Mon, 06 Jan 2020 23:35:37 -0800 (PST) X-Google-Smtp-Source: APXvYqwkv1oPWjt7rNZi7HGQoXoGN2d6pjc1qSoK9A9XbpiK5tTkFajzlSADCJRwp6WnQgLHoDKpXQ== X-Received: by 2002:a37:488f:: with SMTP id v137mr83780569qka.16.1578382537312; Mon, 06 Jan 2020 23:35:37 -0800 (PST) Date: Tue, 7 Jan 2020 02:35:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 05/32] virtio-input: convert to new virtio_delete_queue Message-ID: <20200107073451.298261-6-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: NL-lLGPHOJyWC4QFG6FwSw-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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578384358; cv=none; d=zohomail.com; s=zohoarc; b=iRJ/VSkcO/7eBFEk1rHjKMBTUrxPL8vr7kaH8bivOOZHYyB/kVfzJj28AD7ZFUGzjqNC1A0Xrz2bnr6pVONaAZGzQeSAbwkshCZdsbMbHISMiN5in+V113yZqkPn5yyfLRmQ+jmzorJdRiyVl938U0KU9Kf9aXL86Be+1gCoBf8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578384358; 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=VL/tQgl7KKvkCkXk+1jkxJ1g2hmAQcAPHFGFSLydpxJ1SPte4F4WEKUXDhynUrWPB2c8k6Ik+4fi3Lp4S3xDnheb3wS9OB0C9cqwfitnr7SS/LkGTW3HvpJ8sdE7FDhFeVAwd44zgO99dQ0uZ19PTjj/f3dV5+uib7g+ES/smyo= 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 1578384358652922.9639145924862; Tue, 7 Jan 2020 00:05:58 -0800 (PST) Received: from localhost ([::1]:44304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojsB-0004HQ-Px for importer@patchew.org; Tue, 07 Jan 2020 03:05:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51699) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojP4-0004Zi-N6 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojP3-0007Wd-LP for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:50 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:20474 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 1iojP0-0007Ur-Dd for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:49 -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-94-G3m3jKvvNdaGHMZlVlcbMg-1; Tue, 07 Jan 2020 02:35:44 -0500 Received: by mail-qv1-f69.google.com with SMTP id z12so17940086qvk.14 for ; Mon, 06 Jan 2020 23:35: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 t3sm24870210qtc.8.2020.01.06.23.35.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:35:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382546; 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=HogvtyXI3VzvlEmTLBmAnzwCYyLYGEk+AUY8MWTpWARDkIvigMXz3nk2iU+oLYFGYD6MaN lOTWnJ4CtczqYLqd64w2zvH1qkEka0hvBoctE4DBqmlkDjEU5VFq4dr/xzq5a4FnkEyghF wK0V32mHe4WSNgyw2BOFehfuf3mUKME= 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=X46Ft6HaYu8J8Cxo+dYAMb4vuJPJwDwwbcDSI0bqFhXId3x1Fryp1UyPoF+qasRHU7 di0gvyccUannn33fJIl6+CnVVCH4nmBoNG98rFOcWMGrJuhbE9574sj+8nAmVcj24znD u7Lt8PX5R9D87AX31OJ1unP7Lz8dHZKGNI3mKTCio0Gu68hHyAjsZYi5OwAg6gtcoGix k6JVdAVgz+rijTyuklMkmwiwOa3i27SpYAwBCGiR29I0wDssRO37KooRoFl4IwP0Ueng Ba7QiRCppS/kMHpX9kl8iRv+PXF3JU4bTD+IkaSGpWQQPKzfcZV2YPAqJdrcxxQVH9ss 7Jfg== X-Gm-Message-State: APjAAAUa1Tzv3FFQpasDvynw8MK6uyvdQrQcDTpYqK1t6buTXlE6PELi BG+zGCwyZyRaKGdtY6OnYzRUWScUH/fnoJIrswHW3ZcppOfbB4FmKY7aHdBtznpBRlPetz7v/y2 ob+nFqnMw4fMWQC0= X-Received: by 2002:a05:620a:21d4:: with SMTP id h20mr81885584qka.468.1578382543028; Mon, 06 Jan 2020 23:35:43 -0800 (PST) X-Google-Smtp-Source: APXvYqyatL31mOxSE5z9V23HTQJKxL0TSnNxOQcFDqsEtK3Fs7Qqf2TobbCX3OyucIah+RFEObT/xA== X-Received: by 2002:a05:620a:21d4:: with SMTP id h20mr81885570qka.468.1578382542828; Mon, 06 Jan 2020 23:35:42 -0800 (PST) Date: Tue, 7 Jan 2020 02:35:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 06/32] intel_iommu: fix bug to read DMAR_RTADDR_REG Message-ID: <20200107073451.298261-7-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: G3m3jKvvNdaGHMZlVlcbMg-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578385561; cv=none; d=zohomail.com; s=zohoarc; b=VX8sTdjgp/zd4YP55VNXryjen4t3VSBAhoYCtR/GslPajrLP9bIJ0OV4SZw2lMIzyaa02pDaCS4QSaJlGhAmKtiFZiNg7CliLNY3E0QGUyhcqmizKy2H0TZgTnn+HMnvyQ7HVrVFRAPmKLNb5hWOirfHdVJhARppzo47OeRE78s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578385561; 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=c/t8OsZZ23qWOFPDmlGWiyrclhtqXcPhmkGyXHXhSI4pM4yfi3LyTMMFb+VXOmpeocAjcSQ6OKsKLnJ85wVVikBfXZr0SKK0kNItrJqp/JC63k6DVstTuNnF3K8LtlcRxkEFgmeihVVB8dnn6rhvh2OFH3W3f5KSPmTbK4zBjkQ= 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 157838556130174.49521198197624; Tue, 7 Jan 2020 00:26:01 -0800 (PST) Received: from localhost ([::1]:44378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojwP-00078G-JO for importer@patchew.org; Tue, 07 Jan 2020 03:10:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51709) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojP5-0004bX-KM for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojP4-0007XG-HJ for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:51 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:37594 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 1iojP4-0007Wz-CG for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:50 -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-226-i2jC-62pOhqrjGIzyDgrsQ-1; Tue, 07 Jan 2020 02:35:48 -0500 Received: by mail-qk1-f200.google.com with SMTP id l7so16546045qke.8 for ; Mon, 06 Jan 2020 23:35:48 -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 m21sm22113021qka.117.2020.01.06.23.35.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:35:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382549; 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=Y9ct+XcwJiQC/imycXOpu/HO9khtT1Y88tF2pW6BW93YukcB0UCaXXpOIaXGkaJAObz1NW i2a9b696bEk16NysyyCveuAltBqoYyOerLrNJGYH+AC5phFCgSGmyWcJ5U+8r4rcRSx4Pc /SEL9RHwZJXKr92mhAEplBa4/Dm8RIM= 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=XFr74cYx6Fj8lKJPKFFROI3a4nVEP/cBgMfCVEtB1zQ4RLgKAWTbEyuzhAzXwCc0mj bLNhrqvb6vhvCEHHikyBnsP9YlCaZrVo+7ULcn9/cinuHzphuoBVj0Obzk85TPQgyvBZ NtlTUu+QztUhFDDCJDuGeBu/88D8Uil4aLcXYi9Bj5NmzsgVLIDzojzGHnq/kHQloaPe uw8idZHxbzmny2BIkySqFhpFJ04IJ4gdkjEK3tmHTfzfjIHJ5ESyeMr+h94x/PmDoSlZ IKYYI77T1OGIe1RlkNtdToeXqmvHyhMaXvDb069PamuQVOW0wbt5rwKPTa/zaXX58PIO dteQ== X-Gm-Message-State: APjAAAU58hJ8emhigI5aXWdCYQz0BAx4ULupE0ee2G3dA2FAr7m1XVsV MMC3a/paEX8R34emxxSg6nhI3RwPcvB+YcLtLtsJhvtiz1OVrJ7tUSlZksWB5VOtbpimV1lrxlx c+/U9aZXuBjGnC+4= X-Received: by 2002:ac8:242f:: with SMTP id c44mr78996053qtc.346.1578382547794; Mon, 06 Jan 2020 23:35:47 -0800 (PST) X-Google-Smtp-Source: APXvYqyR7xt0JiL9+zmugKMMLof0eL2+o8nL+0WdanrXzF3RHvH0T/wl9N+KMYU2yfUJ7ePzcrN82w== X-Received: by 2002:ac8:242f:: with SMTP id c44mr78996043qtc.346.1578382547606; Mon, 06 Jan 2020 23:35:47 -0800 (PST) Date: Tue, 7 Jan 2020 02:35:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 07/32] virtio: update queue size on guest write Message-ID: <20200107073451.298261-8-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: i2jC-62pOhqrjGIzyDgrsQ-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578383808; cv=none; d=zohomail.com; s=zohoarc; b=d/KzZhor+/2oDaLLmYG3HKBhHwK1hHaRxegF4H5qkrrIndma+hgOi3Kp0SqVrqs0PoSYPC2RG98wSt9JV+LTvujWoQ+OgwkK6n4fpXhml9nUbc0jQVZCngIzrd/vQt7vRrOFRV7J2tzKWzoO+2qUHsmF8iyKRpoBrNCmD4WPX68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578383808; 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=MAQw6hk+vV7BNPRIwu7L/B6K8i0cYPG7VreDPaxWh2ivggQCTc4eAISBocKL+AmCmY7lOQwoV/YD2S66etiqgTQ3Ly5C8AIpcedxRkhDysl/2WBS5g+ueHLBl24x+HgBzMuQmR5HjelvJVKnG/1c/D0Vo7aYSHsjZ3Auvtia8IE= 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 1578383808469105.56005794166504; Mon, 6 Jan 2020 23:56:48 -0800 (PST) Received: from localhost ([::1]:44188 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojjI-0002OG-6l for importer@patchew.org; Tue, 07 Jan 2020 02:56:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51731) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojPC-0004v3-Ml for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojPA-0007ap-Fj for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:58 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:40847 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 1iojPA-0007ab-Ak for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:35:56 -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-256-eZ9fAXglMueiu2UdG7fc1w-1; Tue, 07 Jan 2020 02:35:54 -0500 Received: by mail-qv1-f72.google.com with SMTP id u11so28871077qvo.8 for ; Mon, 06 Jan 2020 23:35: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 n7sm21976750qke.121.2020.01.06.23.35.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:35:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382555; 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=i51eotLkD9GSvqdxJDY/rOgym0RgXIyWrF6hrwqd2SfQg2jMcfNT3nHKDCZnITLU12uTKo 4GTkT0prQYSBwcMx2xT/VUtpu9g8rPe+TatJ1T/lmWCySC+NcNNn5X0s3eMv79IwWTPIQN PSkXJ31gX3GrWpH+kN/SDHahA3P40ts= 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=CB8Vh/cOPh/RWpqSzeDngAw/wDh/8EkZPurZSAbFE730W7Hkm+ry2H3zo5B3+DL+cI rC9Drvs1zCSKF3Jtu4+IjUf14tw8Y05X09hbM5l35rVtXuNrg1f01V903VwCzK2pzplp HVT1d6E8Fw1S6pDnmvVicbEYxSCmenB1NebFoCV7HjnnMAVgztki4LoUO6jN1EYKUDkm 6LfS7wR875MHeyEZ7vIAdtFRzLUiT/3GKpG6rXuR4e6MfiX4O1OKPM/e8ZpjpP2nZbmx GUlF7hg7Y6PKfjVFWFaz5jpViA51dsumZoHDtA1RwFQI+2VHNG7UOd4KhasdChjp8u+j a/sw== X-Gm-Message-State: APjAAAWtlvGwY+6aMVTy+Esmfr3Ocv/oAKAxkOyOP8NVyDLSr2P86/QL jG1d41vloNLaZgAiBBhoS9jQCyuc8inh1jnLLK/VN5NGXudHXNINQ6XueP4Eefe+q2FF8g97uFu kaxO24sl56CeOwjE= X-Received: by 2002:a0c:b025:: with SMTP id k34mr81697765qvc.170.1578382553089; Mon, 06 Jan 2020 23:35:53 -0800 (PST) X-Google-Smtp-Source: APXvYqxSfx1I+1Cbtue3c4bZsx73oyv86fIoutuNcCCarDsSEyVZZQ4EH/pylYN5UAZEeqUkwCAxUQ== X-Received: by 2002:a0c:b025:: with SMTP id k34mr81697749qvc.170.1578382552737; Mon, 06 Jan 2020 23:35:52 -0800 (PST) Date: Tue, 7 Jan 2020 02:35:48 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 08/32] virtio-pci: disable vring processing when bus-mastering is disabled Message-ID: <20200107073451.298261-9-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: eZ9fAXglMueiu2UdG7fc1w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578384766; cv=none; d=zohomail.com; s=zohoarc; b=DF9AaEIQvu6cuhtE4n4EwNbMxszIIl9mYwzCs1bQt/jUWHqoBw5EjIxVvfnBc72ijrZ3s7ognpv1pU2HWkxesC0nOoqcPLwLUWXYWj1/sVWkdHjw8rAxCeu3o4G7O33At9fdA2vJM8zRAm/nONSZVFM16unbQTd8kWY7v7CXUYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578384766; 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=DIhpn/Njql2YPzgUebhCVwlj3V1+37SrTBZvYOxZyHZkjrMxqjldv3+Fhf2Ww1a2ODmh88fejBl2WH4njg3OmBmSGNFMs3KeNoXszv+93dKUc2i+pWvOA/PwRIk9kH4q5C9dTceJ9j2Cvn/usSt7VtIqk5HlKiyGl1hfStmgQjw= 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 1578384766637348.5441396926933; Tue, 7 Jan 2020 00:12:46 -0800 (PST) Received: from localhost ([::1]:44402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojyk-00031K-N9 for importer@patchew.org; Tue, 07 Jan 2020 03:12:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51758) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojPI-00057p-A6 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojPG-0007e5-IJ for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:03 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:60485 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 1iojPG-0007du-Ek for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:02 -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-23-c2H7NctTPy-pMV7lO2k2kA-1; Tue, 07 Jan 2020 02:35:58 -0500 Received: by mail-qt1-f197.google.com with SMTP id e37so35931077qtk.7 for ; Mon, 06 Jan 2020 23:35: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 u15sm21999829qku.67.2020.01.06.23.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:35:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382562; 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=EUwtVQ633ugwwJ955WJAJBmY5lSYaP0R8d3RlgwlaHf1A8fJ0UUZklrRWapNGuGwN8HNtj hF6+kL32QY0mGWxrgHMfZe9haqbvCv5sboZPwPJIAiRfFEAjV2Ku0IHlxQObhJIeYkgGfF C/AOLh9ETjycm2AC+eVc1/hchNSQirQ= 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=N2/GvsOjw13SkZ0uNikrrgFn3WDbumUXDJLMdSv9Lp71LQfhJWi78+dZZju6z7Zk44 AvXzzJLsece+2JS5NfZvwUe35rItDbcFT4z5VxZK73FRhf1BTXBaeMGG92OoJ2zaDfgl knt0yNiOiunoVWNccFFW5lziyeH52c/xEcoKpYjgQI8InJlmhX+WEzD9qMCV+jQPhRSr B7I2xMfN6ovZBmKk+2diBDIiYghVmVtOfrbWgnAQWU7deGx2B1160M9qYY8hDi9h0ADz KqeD/nPnR+h6l9S5WCs2dU0bkrTcqxjlnGRTjVAxX9OH5h/wMO/n8O9xymptuVkTyWEm cfWw== X-Gm-Message-State: APjAAAWsdrkIweHqnol5YN54UzgE1uf22B1iwuAKRKXT/5CgubX8jAxp ozI2G49/iOHfpLXSLAan4qIo+rskrgHxQQSEQkUXbUEhsqNVJdz4HAKOIAErxGRo0HPstPWVFxg 8lf7Q2JH5Eady1F4= X-Received: by 2002:a05:620a:1227:: with SMTP id v7mr12066157qkj.225.1578382557294; Mon, 06 Jan 2020 23:35:57 -0800 (PST) X-Google-Smtp-Source: APXvYqyNlIg/pf9+BEIA0P3YXKNuszfONQF0anTzcPbUaKBPoZ7wosF1eE8513NvW4Msk7XIP5ggAQ== X-Received: by 2002:a05:620a:1227:: with SMTP id v7mr12066138qkj.225.1578382556914; Mon, 06 Jan 2020 23:35:56 -0800 (PST) Date: Tue, 7 Jan 2020 02:35:53 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 09/32] Implement backend program convention command for vhost-user-blk Message-ID: <20200107073451.298261-10-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: c2H7NctTPy-pMV7lO2k2kA-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578385348; cv=none; d=zohomail.com; s=zohoarc; b=nxJJ/mjP/Taz3pP9u5jF0GlajP3bsoBN8xJg90qJPXjVrWKoYWFoZuALYwGDI2i7BwHyhkwWTDaX+/ft/vTtQxxQ6bPDEg6HleZgeTJ3r1ZWxCA2ytVhiz+Osb3duVruJCAMZVg49ZrrTn2hQiMkJbh6Arw8dPwhBIj8kUFAhEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578385348; 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=AAL6AaR58bnME1pVMRD4sciUdrVA11ald53+iE+V/4fzEiiR7Q2Pd3kwAcavzN64FIH8X3lXm5QkN0FWb/fTN0hI/xWicmnQHHukzU3zzrfTt4tYifgGAicT42IQtIf5Pbt2N4paboovh6gKuWK9svfp58emdGoGowW2fEcFec4= 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 1578385348141919.546106207685; Tue, 7 Jan 2020 00:22:28 -0800 (PST) Received: from localhost ([::1]:44522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iok88-0005av-GB for importer@patchew.org; Tue, 07 Jan 2020 03:22:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51771) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojPL-0005Ez-28 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojPJ-0007fi-6O for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:06 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:44045 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 1iojPJ-0007fR-1h for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:05 -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-30-P4YjSryYOIyAmt6QiWv3YA-1; Tue, 07 Jan 2020 02:36:03 -0500 Received: by mail-qk1-f198.google.com with SMTP id a6so1818848qkl.7 for ; Mon, 06 Jan 2020 23:36:03 -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 r37sm24889260qtj.44.2020.01.06.23.35.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:36:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382564; 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=fPyCKIjePdaUwI//TKcaHe7ESs2iipUwaLRw2S7gIYiHUZmk/6VYVrKhcY8lm3uxjn964z UBIzaTNwFZUCnD0FBNTbKDQYDftYUabaj8MAO2Nr6G4R5hPZc1LosePGUoj9lmBWX5pDFt M4gVLPiLJdrl0jOV75vCjX4xdk8/YFU= 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=tE8txtbcjWeRYWpG9ETQLjMKK0AgrphOhV32BLwh5cSmt1ws930TEeCTkV3oKDAu3j zfrnQFVgtCB0U2eqW1t0GkPKReY1Oa9fiLDy6S01RS6U2wZ3Zb7Oh7ZKqGd3HjXTfjll ycDuKbFG2pJKqh0ZaTwTs7tgCGXLKGqeFkIzF5MIX38tLnAqsY+sYtTSXzwuvoHs5z5C pYvblafyT8w8xqaGw2frx7jqJE+LTI8AImGdmnGNnhzyKJIdlDjewYQQPpw2orWOKa2V eH0et+PaPif7lVdBweDXZTF+/XQRCNrHK70t9vrgMwW+bJoC9NnCIT53n9Sfbs0hvF/B NIoQ== X-Gm-Message-State: APjAAAUx1ys8/z971XdeUY0NTRrlkvNtJWhLvGeeutUa+OuCPWy7XS7c qnVpmWB+t9HX/eGi7yyXjRKvHuJNEDPHGTu0NMOiJhrnnoXBP1qJkxFSBxlFl60hEwx3En8vhA4 d+jSy2jti6vcG4oU= X-Received: by 2002:a05:620a:74f:: with SMTP id i15mr89033207qki.93.1578382562572; Mon, 06 Jan 2020 23:36:02 -0800 (PST) X-Google-Smtp-Source: APXvYqxgzb9UzEfNOwS9WvoZxKtWM6MJjpMAV0FDBmm4BIhXQ3JT0KfR9OhnEaPnZ1aRINcSh4MU1w== X-Received: by 2002:a05:620a:74f:: with SMTP id i15mr89033190qki.93.1578382562306; Mon, 06 Jan 2020 23:36:02 -0800 (PST) Date: Tue, 7 Jan 2020 02:35:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 10/32] virtio: don't enable notifications during polling Message-ID: <20200107073451.298261-11-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: P4YjSryYOIyAmt6QiWv3YA-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578385715; cv=none; d=zohomail.com; s=zohoarc; b=foEGwC1OdDPdabpHxrKbZ3o0TcB5el2H+PhoyqOkRYgJOasAViBXYGresPN5M5166Deey1tBUGzc9HFeA4majJEMzrhWFBoXNiZj9GDSL1Z6lgQUAw66MRPtPwYkrtzpYBBudD6WIHJKCKKBAas31exBR77qls9BNPEOz7uuA4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578385715; 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=MAGcuOwLniZqp9Rwl1qAHlwxTEgkK6a3d8GzjGYlOkbmekljB5FiTHoTIB+G7vwMzzvPkdkA2mF3uzTKxrv3xvIPxDWhY6/t2gJRYlGq6OSIXWJDNUa32jMtVD1oPq+9eh3nxBrXrzk0lCFeoh3j7znHQcBdO8uQrqZWkq1lWpc= 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 1578385715586120.62241422255215; Tue, 7 Jan 2020 00:28:35 -0800 (PST) Received: from localhost ([::1]:44606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokE3-0002kf-PR for importer@patchew.org; Tue, 07 Jan 2020 03:28:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51811) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojPT-0005PZ-GQ for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojPP-0007kl-6z for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:15 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:24475 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 1iojPP-0007kN-03 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:11 -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-438-5lcbFu6XNpGYljEfVnFSKw-1; Tue, 07 Jan 2020 02:36:09 -0500 Received: by mail-qk1-f198.google.com with SMTP id l7so16546541qke.8 for ; Mon, 06 Jan 2020 23:36:09 -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 l17sm22090382qkk.22.2020.01.06.23.36.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:36:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382570; 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=gzsmgJVgmNseW0R89bDurxMJW7NTEgOFXXgg5bYkdlcqmfBAvtIOZ6ZwRjNHaYHCdf2YPR Tfp1clr9WqpUyzBQ+N5T4XyNVCUo8vbhr+YRBahWN7aV6RsZ2G+eB8SEhi8OsyUBi0gS4V RJT83+BDaiR2Hrj+O0h3S1YrVbjWFPs= 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=GbKg9I86IbqfDcmjqSnWo1xax29qAuEUr31zOwUmNXghzBZTdXPkwydBcqK8oQc/Em AHZ0ppBqdVuHQN+aanFBI1bxVA8m9ZobWEFk6XBXqzx2LynGXhOOSKGBp8+Rl+8HNJRu /02nEOqs5Gw36jAFoahgvCdSLQ2uVwgrwiFHxmQllmBFUYtJCoNDDrTXOjcaAbEM73JU kv40mFLQlZy5KQWj7F134k4JiOZKah35PhWux6uYBQWvdweQ2tGmq6fKEhCFQsUmnJjg cDX3gtW0LAqOpBjZCN+AnU1/1hSdPgnavLpnWh80R/nObZOJEXUdgYJY7HxiErTI0+83 0FLg== X-Gm-Message-State: APjAAAW8JZ5ZmBtepyls1rCVob6p5NwIogMNiXvAq2HcwNmfobf/3Dr3 C2gyxkmPeRJ3vLvr7qTp/c+3CVOJsVr7r8ZgYvy/eaGfBQaTvIAphbG3fo4b1jSU8RA/dBiX4kp 4XXL8dYht4OIZqfM= X-Received: by 2002:ae9:e40d:: with SMTP id q13mr88401233qkc.2.1578382568247; Mon, 06 Jan 2020 23:36:08 -0800 (PST) X-Google-Smtp-Source: APXvYqz7VizsjOq+UEdvWGxb2t2vuRxCPl4fW2Jjnpdgqw9WpzvGcYwY2mvglzlT3mFq8gQX3nQqiA== X-Received: by 2002:ae9:e40d:: with SMTP id q13mr88401203qkc.2.1578382567800; Mon, 06 Jan 2020 23:36:07 -0800 (PST) Date: Tue, 7 Jan 2020 02:36:02 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 11/32] numa: Extend CLI to provide initiator information for numa nodes Message-ID: <20200107073451.298261-12-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 5lcbFu6XNpGYljEfVnFSKw-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578384284; cv=none; d=zohomail.com; s=zohoarc; b=eox94H9VRaJruT8dC9cEOWWrLSejil5aWwy4RqSYe7EMpkrXSBYSYreDgdrnqfKewVECZ/3ohLANvHx3PDZjraOTUIpNTBkTzOYtZiBUVtE88+tkh/2jtxMtoFvX+i8ALpyg9jvZv/xyBWhv1+Bdi8c43o7l/mzSdlxegWfinck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578384284; 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=UolYhpvn61sIvu1g23nQ3vshePdBvAziGROMjQ+Mk5XskG051Ku1OrZkGoPJDXKC/VpVHxlcSHLEs374yZTbbOuT8J82phOLUr/U2+pcBrh9Cd+OEvQhpU0mVBsbEv9vM8BF/OHeC6EIYmcG9cvEUxiDiX03Q6UELyEZzB3rBL0= 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 1578384284428425.4202210315641; Tue, 7 Jan 2020 00:04:44 -0800 (PST) Received: from localhost ([::1]:44294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojqz-0002G6-K9 for importer@patchew.org; Tue, 07 Jan 2020 03:04:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51840) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojPZ-0005Tg-Ci for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojPV-0007nr-1r for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:21 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:57183 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 1iojPU-0007nU-On for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:17 -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-204-UhmOe4wyNF6ftWXUhkWk4g-1; Tue, 07 Jan 2020 02:36:15 -0500 Received: by mail-qk1-f198.google.com with SMTP id f22so11034670qka.10 for ; Mon, 06 Jan 2020 23:36:14 -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 v4sm24613139qtd.24.2020.01.06.23.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:36:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382576; 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=BJFNQNaP7ONv2sQepcVR3EYytt0vbsVnLZ6c8QM8LEPrKUU/r5JvbRQaMU5rKB3JpQOH2X JIUKT/5GCr2Q2Eaarwj9+HgF78J1RT9pEN6lFHkhgtto0309QNdeydQvzUsIsgV87IojMC +nAMv39eM2A8GpBC+f2sVtG87ZWW0Fw= 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=st53gJDfuSMU06ymFshcnNJpDroXojzELBRS7HDn7FfDuDelCWTf97RME8cwqoy9aK 2ySbYlueXJZO6qtgjjHBgizqSvGGXztMOx389PSEgs1TmNO4F+nPFM+ZcUAF7IyniEwM od0VYLJ6PivE8Kn+QvRpH88iHBpqzllRJeWVlwamuyguBRSDUkJhrX/BRPhImhD9Pzil 39C7IE9iTCedCwOlX7J6kCJ4v+Qhx0572b+RhrKmf8OXDPaKOEFjnBfIADCBVzvdrHEO 7bZGkZ8l+Lze74BCZDOl3PmWwu7TK5qISIZvtbqCJ9OgxGe2HJuxLW6mmC51KYQYuGtr mZ4g== X-Gm-Message-State: APjAAAWYhLppMBSBdwnwkw7napuQH6NBzgTPYDNPJL+wy8Mzg07DvYB7 CuhcA13x73+5AUMZKUe1EqjuV4ea/UG6VzOXEMDHN06+rAHfaoIt79O4fRbGZ3VuNseu+Ug+9pU U+JAVMBubtkzDol4= X-Received: by 2002:ac8:36dd:: with SMTP id b29mr77487487qtc.285.1578382573869; Mon, 06 Jan 2020 23:36:13 -0800 (PST) X-Google-Smtp-Source: APXvYqxET0ysr7suDjYkf5hzPt07yG2FhHPDadZDqcO+Q9JUffEYxqCKrEYddDTslzesdO28xQjIxw== X-Received: by 2002:ac8:36dd:: with SMTP id b29mr77487463qtc.285.1578382573307; Mon, 06 Jan 2020 23:36:13 -0800 (PST) Date: Tue, 7 Jan 2020 02:36:08 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 12/32] numa: Extend CLI to provide memory latency and bandwidth information Message-ID: <20200107073451.298261-13-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: UhmOe4wyNF6ftWXUhkWk4g-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Liu Jingqi , Tao Xu , Markus Armbruster , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Jingqi Add -numa hmat-lb option to provide System Locality Latency and Bandwidth Information. These memory attributes help to build System Locality Latency and Bandwidth Information Structure(s) in ACPI Heterogeneous Memory Attribute Table (HMAT). Before using hmat-lb option, enable HMAT with -machine hmat=3Don. Acked-by: Markus Armbruster Signed-off-by: Liu Jingqi Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-3-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- qapi/machine.json | 93 +++++++++++++++++++- include/sysemu/numa.h | 53 ++++++++++++ hw/core/numa.c | 194 ++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 47 +++++++++- 4 files changed, 384 insertions(+), 3 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 27d0e37534..cf8faf5a2a 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -426,10 +426,12 @@ # # @cpu: property based CPU(s) to node mapping (Since: 2.10) # +# @hmat-lb: memory latency and bandwidth information (Since: 5.0) +# # Since: 2.1 ## { 'enum': 'NumaOptionsType', - 'data': [ 'node', 'dist', 'cpu' ] } + 'data': [ 'node', 'dist', 'cpu', 'hmat-lb' ] } =20 ## # @NumaOptions: @@ -444,7 +446,8 @@ 'data': { 'node': 'NumaNodeOptions', 'dist': 'NumaDistOptions', - 'cpu': 'NumaCpuOptions' }} + 'cpu': 'NumaCpuOptions', + 'hmat-lb': 'NumaHmatLBOptions' }} =20 ## # @NumaNodeOptions: @@ -557,6 +560,92 @@ 'base': 'CpuInstanceProperties', 'data' : {} } =20 +## +# @HmatLBMemoryHierarchy: +# +# The memory hierarchy in the System Locality Latency and Bandwidth +# Information Structure of HMAT (Heterogeneous Memory Attribute Table) +# +# For more information about @HmatLBMemoryHierarchy, see chapter +# 5.2.27.4: Table 5-146: Field "Flags" of ACPI 6.3 spec. +# +# @memory: the structure represents the memory performance +# +# @first-level: first level of memory side cache +# +# @second-level: second level of memory side cache +# +# @third-level: third level of memory side cache +# +# Since: 5.0 +## +{ 'enum': 'HmatLBMemoryHierarchy', + 'data': [ 'memory', 'first-level', 'second-level', 'third-level' ] } + +## +# @HmatLBDataType: +# +# Data type in the System Locality Latency and Bandwidth +# Information Structure of HMAT (Heterogeneous Memory Attribute Table) +# +# For more information about @HmatLBDataType, see chapter +# 5.2.27.4: Table 5-146: Field "Data Type" of ACPI 6.3 spec. +# +# @access-latency: access latency (nanoseconds) +# +# @read-latency: read latency (nanoseconds) +# +# @write-latency: write latency (nanoseconds) +# +# @access-bandwidth: access bandwidth (Bytes per second) +# +# @read-bandwidth: read bandwidth (Bytes per second) +# +# @write-bandwidth: write bandwidth (Bytes per second) +# +# Since: 5.0 +## +{ 'enum': 'HmatLBDataType', + 'data': [ 'access-latency', 'read-latency', 'write-latency', + 'access-bandwidth', 'read-bandwidth', 'write-bandwidth' ] } + +## +# @NumaHmatLBOptions: +# +# Set the system locality latency and bandwidth information +# between Initiator and Target proximity Domains. +# +# For more information about @NumaHmatLBOptions, see chapter +# 5.2.27.4: Table 5-146 of ACPI 6.3 spec. +# +# @initiator: the Initiator Proximity Domain. +# +# @target: the Target Proximity Domain. +# +# @hierarchy: the Memory Hierarchy. Indicates the performance +# of memory or side cache. +# +# @data-type: presents the type of data, access/read/write +# latency or hit latency. +# +# @latency: the value of latency from @initiator to @target +# proximity domain, the latency unit is "ns(nanosecond)". +# +# @bandwidth: the value of bandwidth between @initiator and @target +# proximity domain, the bandwidth unit is +# "Bytes per second". +# +# Since: 5.0 +## +{ 'struct': 'NumaHmatLBOptions', + 'data': { + 'initiator': 'uint16', + 'target': 'uint16', + 'hierarchy': 'HmatLBMemoryHierarchy', + 'data-type': 'HmatLBDataType', + '*latency': 'uint64', + '*bandwidth': 'size' }} + ## # @HostMemPolicy: # diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 788cbec7a2..70f93c83d7 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -14,11 +14,34 @@ struct CPUArchId; #define NUMA_DISTANCE_MAX 254 #define NUMA_DISTANCE_UNREACHABLE 255 =20 +/* the value of AcpiHmatLBInfo flags */ +enum { + HMAT_LB_MEM_MEMORY =3D 0, + HMAT_LB_MEM_CACHE_1ST_LEVEL =3D 1, + HMAT_LB_MEM_CACHE_2ND_LEVEL =3D 2, + HMAT_LB_MEM_CACHE_3RD_LEVEL =3D 3, + HMAT_LB_LEVELS /* must be the last entry */ +}; + +/* the value of AcpiHmatLBInfo data type */ +enum { + HMAT_LB_DATA_ACCESS_LATENCY =3D 0, + HMAT_LB_DATA_READ_LATENCY =3D 1, + HMAT_LB_DATA_WRITE_LATENCY =3D 2, + HMAT_LB_DATA_ACCESS_BANDWIDTH =3D 3, + HMAT_LB_DATA_READ_BANDWIDTH =3D 4, + HMAT_LB_DATA_WRITE_BANDWIDTH =3D 5, + HMAT_LB_TYPES /* must be the last entry */ +}; + +#define UINT16_BITS 16 + struct NodeInfo { uint64_t node_mem; struct HostMemoryBackend *node_memdev; bool present; bool has_cpu; + uint8_t lb_info_provided; uint16_t initiator; uint8_t distance[MAX_NODES]; }; @@ -28,6 +51,31 @@ struct NumaNodeMem { uint64_t node_plugged_mem; }; =20 +struct HMAT_LB_Data { + uint8_t initiator; + uint8_t target; + uint64_t data; +}; +typedef struct HMAT_LB_Data HMAT_LB_Data; + +struct HMAT_LB_Info { + /* Indicates it's memory or the specified level memory side cache. */ + uint8_t hierarchy; + + /* Present the type of data, access/read/write latency or bandwidth. */ + uint8_t data_type; + + /* The range bitmap of bandwidth for calculating common base */ + uint64_t range_bitmap; + + /* The common base unit for latencies or bandwidths */ + uint64_t base; + + /* Array to store the latencies or bandwidths */ + GArray *list; +}; +typedef struct HMAT_LB_Info HMAT_LB_Info; + struct NumaState { /* Number of NUMA nodes */ int num_nodes; @@ -40,11 +88,16 @@ struct NumaState { =20 /* NUMA nodes information */ NodeInfo nodes[MAX_NODES]; + + /* NUMA nodes HMAT Locality Latency and Bandwidth Information */ + HMAT_LB_Info *hmat_lb[HMAT_LB_LEVELS][HMAT_LB_TYPES]; }; typedef struct NumaState NumaState; =20 void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp); void parse_numa_opts(MachineState *ms); +void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node, + Error **errp); void numa_complete_configuration(MachineState *ms); void query_numa_node_mem(NumaNodeMem node_mem[], MachineState *ms); extern QemuOptsList qemu_numa_opts; diff --git a/hw/core/numa.c b/hw/core/numa.c index e60da99293..34eb413f5d 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -23,6 +23,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/units.h" #include "sysemu/hostmem.h" #include "sysemu/numa.h" #include "sysemu/sysemu.h" @@ -198,6 +199,186 @@ void parse_numa_distance(MachineState *ms, NumaDistOp= tions *dist, Error **errp) ms->numa_state->have_numa_distance =3D true; } =20 +void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node, + Error **errp) +{ + int i, first_bit, last_bit; + uint64_t max_entry, temp_base, bitmap_copy; + NodeInfo *numa_info =3D numa_state->nodes; + HMAT_LB_Info *hmat_lb =3D + numa_state->hmat_lb[node->hierarchy][node->data_type]; + HMAT_LB_Data lb_data =3D {}; + HMAT_LB_Data *lb_temp; + + /* Error checking */ + if (node->initiator > numa_state->num_nodes) { + error_setg(errp, "Invalid initiator=3D%d, it should be less than %= d", + node->initiator, numa_state->num_nodes); + return; + } + if (node->target > numa_state->num_nodes) { + error_setg(errp, "Invalid target=3D%d, it should be less than %d", + node->target, numa_state->num_nodes); + return; + } + if (!numa_info[node->initiator].has_cpu) { + error_setg(errp, "Invalid initiator=3D%d, it isn't an " + "initiator proximity domain", node->initiator); + return; + } + if (!numa_info[node->target].present) { + error_setg(errp, "The target=3D%d should point to an existing node= ", + node->target); + return; + } + + if (!hmat_lb) { + hmat_lb =3D g_malloc0(sizeof(*hmat_lb)); + numa_state->hmat_lb[node->hierarchy][node->data_type] =3D hmat_lb; + hmat_lb->list =3D g_array_new(false, true, sizeof(HMAT_LB_Data)); + } + hmat_lb->hierarchy =3D node->hierarchy; + hmat_lb->data_type =3D node->data_type; + lb_data.initiator =3D node->initiator; + lb_data.target =3D node->target; + + if (node->data_type <=3D HMATLB_DATA_TYPE_WRITE_LATENCY) { + /* Input latency data */ + + if (!node->has_latency) { + error_setg(errp, "Missing 'latency' option"); + return; + } + if (node->has_bandwidth) { + error_setg(errp, "Invalid option 'bandwidth' since " + "the data type is latency"); + return; + } + + /* Detect duplicate configuration */ + for (i =3D 0; i < hmat_lb->list->len; i++) { + lb_temp =3D &g_array_index(hmat_lb->list, HMAT_LB_Data, i); + + if (node->initiator =3D=3D lb_temp->initiator && + node->target =3D=3D lb_temp->target) { + error_setg(errp, "Duplicate configuration of the latency f= or " + "initiator=3D%d and target=3D%d", node->initiator, + node->target); + return; + } + } + + hmat_lb->base =3D hmat_lb->base ? hmat_lb->base : UINT64_MAX; + + if (node->latency) { + /* Calculate the temporary base and compressed latency */ + max_entry =3D node->latency; + temp_base =3D 1; + while (QEMU_IS_ALIGNED(max_entry, 10)) { + max_entry /=3D 10; + temp_base *=3D 10; + } + + /* Calculate the max compressed latency */ + temp_base =3D MIN(hmat_lb->base, temp_base); + max_entry =3D node->latency / hmat_lb->base; + max_entry =3D MAX(hmat_lb->range_bitmap, max_entry); + + /* + * For latency hmat_lb->range_bitmap record the max compressed + * latency which should be less than 0xFFFF (UINT16_MAX) + */ + if (max_entry >=3D UINT16_MAX) { + error_setg(errp, "Latency %" PRIu64 " between initiator=3D= %d and " + "target=3D%d should not differ from previously ent= ered " + "min or max values on more than %d", node->latency, + node->initiator, node->target, UINT16_MAX - 1); + return; + } else { + hmat_lb->base =3D temp_base; + hmat_lb->range_bitmap =3D max_entry; + } + + /* + * Set lb_info_provided bit 0 as 1, + * latency information is provided + */ + numa_info[node->target].lb_info_provided |=3D BIT(0); + } + lb_data.data =3D node->latency; + } else if (node->data_type >=3D HMATLB_DATA_TYPE_ACCESS_BANDWIDTH) { + /* Input bandwidth data */ + if (!node->has_bandwidth) { + error_setg(errp, "Missing 'bandwidth' option"); + return; + } + if (node->has_latency) { + error_setg(errp, "Invalid option 'latency' since " + "the data type is bandwidth"); + return; + } + if (!QEMU_IS_ALIGNED(node->bandwidth, MiB)) { + error_setg(errp, "Bandwidth %" PRIu64 " between initiator=3D%d= and " + "target=3D%d should be 1MB aligned", node->bandwidt= h, + node->initiator, node->target); + return; + } + + /* Detect duplicate configuration */ + for (i =3D 0; i < hmat_lb->list->len; i++) { + lb_temp =3D &g_array_index(hmat_lb->list, HMAT_LB_Data, i); + + if (node->initiator =3D=3D lb_temp->initiator && + node->target =3D=3D lb_temp->target) { + error_setg(errp, "Duplicate configuration of the bandwidth= for " + "initiator=3D%d and target=3D%d", node->initiator, + node->target); + return; + } + } + + hmat_lb->base =3D hmat_lb->base ? hmat_lb->base : 1; + + if (node->bandwidth) { + /* Keep bitmap unchanged when bandwidth out of range */ + bitmap_copy =3D hmat_lb->range_bitmap; + bitmap_copy |=3D node->bandwidth; + first_bit =3D ctz64(bitmap_copy); + temp_base =3D UINT64_C(1) << first_bit; + max_entry =3D node->bandwidth / temp_base; + last_bit =3D 64 - clz64(bitmap_copy); + + /* + * For bandwidth, first_bit record the base unit of bandwidth = bits, + * last_bit record the last bit of the max bandwidth. The max + * compressed bandwidth should be less than 0xFFFF (UINT16_MAX) + */ + if ((last_bit - first_bit) > UINT16_BITS || + max_entry >=3D UINT16_MAX) { + error_setg(errp, "Bandwidth %" PRIu64 " between initiator= =3D%d " + "and target=3D%d should not differ from previously= " + "entered values on more than %d", node->bandwidth, + node->initiator, node->target, UINT16_MAX - 1); + return; + } else { + hmat_lb->base =3D temp_base; + hmat_lb->range_bitmap =3D bitmap_copy; + } + + /* + * Set lb_info_provided bit 1 as 1, + * bandwidth information is provided + */ + numa_info[node->target].lb_info_provided |=3D BIT(1); + } + lb_data.data =3D node->bandwidth; + } else { + assert(0); + } + + g_array_append_val(hmat_lb->list, lb_data); +} + void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp) { Error *err =3D NULL; @@ -236,6 +417,19 @@ void set_numa_options(MachineState *ms, NumaOptions *o= bject, Error **errp) machine_set_cpu_numa_node(ms, qapi_NumaCpuOptions_base(&object->u.= cpu), &err); break; + case NUMA_OPTIONS_TYPE_HMAT_LB: + if (!ms->numa_state->hmat_enabled) { + error_setg(errp, "ACPI Heterogeneous Memory Attribute Table " + "(HMAT) is disabled, enable it with -machine hmat= =3Don " + "before using any of hmat specific options"); + return; + } + + parse_numa_hmat_lb(ms->numa_state, &object->u.hmat_lb, &err); + if (err) { + goto end; + } + break; default: abort(); } diff --git a/qemu-options.hx b/qemu-options.hx index 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578386240; cv=none; d=zohomail.com; s=zohoarc; b=gnOYtqInLF9l2cpROJqq9Pab7eCOrDNFqrHEe0Sasv5HWaHBYs0q4D9xAdGpPI9q9giDZdw7H5w6dWGaoxArMIxffKUaoG8APJI+FLo/3oydzUhhsHoffW9uX2Usa8pidqtCQPgxONgjc5hBDv1yKk2Rvq4lDkxBgV4sjV8D0tg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578386240; 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=IhmX4tEMxfrtTb/4TgCnpxp557U2bm63ZB+XdBOdNgUT3z1UUddzW5AqO8rqY8QqdQfNtoUUEKaIqo6LcBuvG+mRENBmPE/UoW2ht+NnNxVd8WlIj8OZ3zzZ+YNxVVMvhL/5LMQqUWaudidm+JeMeZP7WB0p6PxHSf1FwfOJyIQ= 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 1578386240814657.2315338076019; Tue, 7 Jan 2020 00:37:20 -0800 (PST) Received: from localhost ([::1]:44666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokJH-0006Qt-Kh for importer@patchew.org; Tue, 07 Jan 2020 03:33:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51884) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojPe-0005YG-IZ for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojPa-0007rv-F0 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:26 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:26122 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 1iojPa-0007rH-8Q for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:22 -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-26-CksBGDZTOJeHcnYwm0xR-Q-1; Tue, 07 Jan 2020 02:36:20 -0500 Received: by mail-qt1-f199.google.com with SMTP id m30so36042925qtb.2 for ; Mon, 06 Jan 2020 23:36:20 -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 k1sm20977240qtq.86.2020.01.06.23.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:36:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382581; 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=EHuNqm+3YXpGO69x/e5UdDFvwspkfGD5Z3vrmeiRaCarWR3zce0VxTNhVCQe6+bNHk34J6 Q67sffxb6WogQWd3zsCcKcphZ/YmFF7jLY0Yx02+i+KMw2N1holOFNjrWPvLquaHIR+2HH fcFPwc8rM8a33vxm4sWYs1MJn6BgiTA= 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=Ejh++3E02qKnFp5ZXp4EDGq6ahyLoCFd4isg9ylPT4LWYs0NXTjntz19tJk5m3+gvg i++/tVi0UeqQRm4aeioW7X5hjvtFjhf4s4Hd40zRLt4ZKqALoEFO0JzF7pxbBbxWKGrF k6R++2+HG6OXky7m1HufRlC9w/wMRPMBXTNcN+IdzC8tugq+Kx6uWcB8N4y+4ifyhPFd HBat9Y6nt3KSj9YvGYKrW2OHeUBUj/mpypgU809aDay93CT9Zo5eenJZGWXp/I2KA7tp S3dweU4miWBIJpgHmdktNa2qV+MgkMs0yJhA480hEmB3H8h8TwWlICdt5WiaJ3pOBMUh 0IIw== X-Gm-Message-State: APjAAAVZ4TLXu0eNH8d3Vu+kcPdPfhjQQvM4yBsHr3jOUiaY6TryHm8t x9BFnrb48zZttfrqgeGcd9v4WD5spUUmG4r2aWI1A9qlrQdAUfNjzbJlgrUdmkbThiuAwHjzRLj FqkpAsorbF/zxcrc= X-Received: by 2002:a37:4bc6:: with SMTP id y189mr85993035qka.18.1578382579549; Mon, 06 Jan 2020 23:36:19 -0800 (PST) X-Google-Smtp-Source: APXvYqz2w4kwOuH/cjY8Q5NiS+FwUbMdwfUgaG4y6aSfTa5uNYS6oMboVa616DwBCY4kKAz2wvfUwA== X-Received: by 2002:a37:4bc6:: with SMTP id y189mr85993017qka.18.1578382579113; Mon, 06 Jan 2020 23:36:19 -0800 (PST) Date: Tue, 7 Jan 2020 02:36:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 13/32] numa: Extend CLI to provide memory side cache information Message-ID: <20200107073451.298261-14-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: CksBGDZTOJeHcnYwm0xR-Q-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Liu Jingqi , Tao Xu , Markus Armbruster , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Liu Jingqi Add -numa hmat-cache option to provide Memory Side Cache Information. These memory attributes help to build Memory Side Cache Information Structure(s) in ACPI Heterogeneous Memory Attribute Table (HMAT). Before using hmat-cache option, enable HMAT with -machine hmat=3Don. Acked-by: Markus Armbruster Signed-off-by: Liu Jingqi Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-4-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- qapi/machine.json | 81 +++++++++++++++++++++++++++++++++++++++++-- include/sysemu/numa.h | 5 +++ hw/core/numa.c | 80 ++++++++++++++++++++++++++++++++++++++++++ qemu-options.hx | 17 +++++++-- 4 files changed, 179 insertions(+), 4 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index cf8faf5a2a..b3d30bc816 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -428,10 +428,12 @@ # # @hmat-lb: memory latency and bandwidth information (Since: 5.0) # +# @hmat-cache: memory side cache information (Since: 5.0) +# # Since: 2.1 ## { 'enum': 'NumaOptionsType', - 'data': [ 'node', 'dist', 'cpu', 'hmat-lb' ] } + 'data': [ 'node', 'dist', 'cpu', 'hmat-lb', 'hmat-cache' ] } =20 ## # @NumaOptions: @@ -447,7 +449,8 @@ 'node': 'NumaNodeOptions', 'dist': 'NumaDistOptions', 'cpu': 'NumaCpuOptions', - 'hmat-lb': 'NumaHmatLBOptions' }} + 'hmat-lb': 'NumaHmatLBOptions', + 'hmat-cache': 'NumaHmatCacheOptions' }} =20 ## # @NumaNodeOptions: @@ -646,6 +649,80 @@ '*latency': 'uint64', '*bandwidth': 'size' }} =20 +## +# @HmatCacheAssociativity: +# +# Cache associativity in the Memory Side Cache Information Structure +# of HMAT +# +# For more information of @HmatCacheAssociativity, see chapter +# 5.2.27.5: Table 5-147 of ACPI 6.3 spec. +# +# @none: None (no memory side cache in this proximity domain, +# or cache associativity unknown) +# +# @direct: Direct Mapped +# +# @complex: Complex Cache Indexing (implementation specific) +# +# Since: 5.0 +## +{ 'enum': 'HmatCacheAssociativity', + 'data': [ 'none', 'direct', 'complex' ] } + +## +# @HmatCacheWritePolicy: +# +# Cache write policy in the Memory Side Cache Information Structure +# of HMAT +# +# For more information of @HmatCacheWritePolicy, see chapter +# 5.2.27.5: Table 5-147: Field "Cache Attributes" of ACPI 6.3 spec. +# +# @none: None (no memory side cache in this proximity domain, +# or cache write policy unknown) +# +# @write-back: Write Back (WB) +# +# @write-through: Write Through (WT) +# +# Since: 5.0 +## +{ 'enum': 'HmatCacheWritePolicy', + 'data': [ 'none', 'write-back', 'write-through' ] } + +## +# @NumaHmatCacheOptions: +# +# Set the memory side cache information for a given memory domain. +# +# For more information of @NumaHmatCacheOptions, see chapter +# 5.2.27.5: Table 5-147: Field "Cache Attributes" of ACPI 6.3 spec. +# +# @node-id: the memory proximity domain to which the memory belongs. +# +# @size: the size of memory side cache in bytes. +# +# @level: the cache level described in this structure. +# +# @associativity: the cache associativity, +# none/direct-mapped/complex(complex cache indexing). +# +# @policy: the write policy, none/write-back/write-through. +# +# @line: the cache Line size in bytes. +# +# Since: 5.0 +## +{ 'struct': 'NumaHmatCacheOptions', + 'data': { + 'node-id': 'uint32', + 'size': 'size', + 'level': 'uint8', + 'associativity': 'HmatCacheAssociativity', + 'policy': 'HmatCacheWritePolicy', + 'line': 'uint16' }} + ## # @HostMemPolicy: # diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index 70f93c83d7..ba693cc80b 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -91,6 +91,9 @@ struct NumaState { =20 /* NUMA nodes HMAT Locality Latency and Bandwidth Information */ HMAT_LB_Info *hmat_lb[HMAT_LB_LEVELS][HMAT_LB_TYPES]; + + /* Memory Side Cache Information Structure */ + NumaHmatCacheOptions *hmat_cache[MAX_NODES][HMAT_LB_LEVELS]; }; typedef struct NumaState NumaState; =20 @@ -98,6 +101,8 @@ void set_numa_options(MachineState *ms, NumaOptions *obj= ect, Error **errp); void parse_numa_opts(MachineState *ms); void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node, Error **errp); +void parse_numa_hmat_cache(MachineState *ms, NumaHmatCacheOptions *node, + Error **errp); void numa_complete_configuration(MachineState *ms); void query_numa_node_mem(NumaNodeMem node_mem[], MachineState *ms); extern QemuOptsList qemu_numa_opts; diff --git a/hw/core/numa.c b/hw/core/numa.c index 34eb413f5d..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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578384747; cv=none; d=zohomail.com; s=zohoarc; b=kUAzbzhPCWdRLTyzBMUw4NAbuGVn/YIjaTyg0mOj6Jp7VtLpE+M65+0Z/ywiH2JDC7g0UX2IwqVFcYKJCPOCxtKtlZMp4S6Q5vzTTQh+Joq+JGDtvYTH2bUmUFKAON4h2uWB3xjYyUdRlNQo6JsvJb4TuPzhBhoEQrRRKRrkbxc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578384747; 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=VsOYep8LZfygEeWjZAfRSxSa+cfoU1f8VwGH4DxsU5JXNwAP4Jue9CczbWtL1NeRy031eZIZhz0vKLkJaU+th5OKFTtcDzST0ozFhWY2dGRioazSBX3XResQ5jBwRWKKI8HWvkjZIQw1B3wBnBN+K26nNNXNWmdaAsJS/VfIk+M= 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 1578384747519568.5934813210204; Tue, 7 Jan 2020 00:12:27 -0800 (PST) Received: from localhost ([::1]:44400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojyR-0002XA-Qp for importer@patchew.org; Tue, 07 Jan 2020 03:12:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51936) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojPl-0005gN-T3 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojPh-0007wg-Aq for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:33 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:33738 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 1iojPh-0007wM-5Q for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:29 -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-136-niXntfV7OSKLizpzBDEjkg-1; Tue, 07 Jan 2020 02:36:26 -0500 Received: by mail-qt1-f200.google.com with SMTP id p12so35900096qtu.6 for ; Mon, 06 Jan 2020 23:36: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 p185sm22139710qkd.126.2020.01.06.23.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:36:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382588; 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=Z7ZSmvRLT6WPdPBhZyEd2eSLLKP+uo5yJTJJcFKqA/0NXEHsD6XTJ/VoMIo7Bw33Uiym32 Q7/uArJfj23te21AFFq9rjYfsv1V99WkoExCn2IOfjpB0+lTWke2pO0vMNzUAw1xejH0rF W3TfDT1S/V+o5y5DuzYj+dh6XTrfmv0= 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=P17ZlzSZ1vQCD8U1DOCy0S7sWC6ikMdSO7fyBmWFe3vlro8lCQc5IUeEl587D8Iai8 gdS5z8r6c1788AVzw7B2o9/sz4QxuSxrlY3xiesyNVE/+v8w7AD3Fdr/F0RR7bbkxf65 E8V/cctyJSpYKiJTnheu8lFcKqyTRgZsPN2GNqNh9LuyWecCnuDV7nxDWGXPUrUdZyXk XqtwO7c90QJlTXvYApSNVf+2y2taIxiME+ayhPJrfsPNToxehN+QXu1M/C4WsZh4ZZYa FowdTLz7oaXNS/NjRqj5uktQJe7ZTmFR5lJb+VhJNXL4eGCDyjMkXmVI/4wTSBcSc2qP XREg== X-Gm-Message-State: APjAAAW4dYRm597hu1CNbckXYRYYynOp/z2X2nboKavMKDXeIEM89Hk8 JvFDeWha0eR41tg/ArPrqGhU56gusFegVrMIUmkrCHwr1wNpZLSGP6CL3ZyNd0JRbszAl+tFjcJ Oy5IXBzPphyC1LYE= X-Received: by 2002:a0c:ac4e:: with SMTP id m14mr80435420qvb.37.1578382585698; Mon, 06 Jan 2020 23:36:25 -0800 (PST) X-Google-Smtp-Source: APXvYqz0HdfNbG6wiu8D1U4XBcuQImR/uzu0X0TPGF2o9jVW9FsE/VdpFW81d7NYrJ8vcG/bU1GQqg== X-Received: by 2002:a0c:ac4e:: with SMTP id m14mr80435393qvb.37.1578382585294; Mon, 06 Jan 2020 23:36:25 -0800 (PST) Date: Tue, 7 Jan 2020 02:36:19 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 14/32] hmat acpi: Build Memory Proximity Domain Attributes Structure(s) Message-ID: <20200107073451.298261-15-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: niXntfV7OSKLizpzBDEjkg-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578385336; cv=none; d=zohomail.com; s=zohoarc; b=AcD9tYyj3O+bBoXGwuEpAgWsw2CrALSuAgwWKqAwtxtV0Iuy9pXhkID+LmchJIPGSgFcs4nTdY8ds233WeUHQWxhTZSizj523XNEKhezYviFeiOPKMDiHm3v7wTTTtvKmpWqrjjZngc79YMVQyY3hootbBEEH+/avb0uYLOdYgY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578385336; 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=OJJ5jnLzGQvF9Zz5F3XDdWFcWN3jL2rv27Mr58QKAhKjHiBDzRc34IceaYms1hAyGrH7HHG5tk3dVGbyc+f5xabj9o4pmXJBbzXuf9DZ5XSuwR9Edn2jeN464gYFXwI4owkNH7ICRGFVnGzI/sXPAV8u4Odrh9QhZjBl29hyUO8= 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 157838533600342.35268952095544; Tue, 7 Jan 2020 00:22:16 -0800 (PST) Received: from localhost ([::1]:44512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iok7w-0005Ce-Cf for importer@patchew.org; Tue, 07 Jan 2020 03:22:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51949) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojPn-0005nZ-Od for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojPm-00080N-4P for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:35 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:59060 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 1iojPl-000803-Vx for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:34 -0500 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-59-r7ojF80DO-eYCH1c1k6H8Q-1; Tue, 07 Jan 2020 02:36:31 -0500 Received: by mail-qk1-f199.google.com with SMTP id 143so30947373qkg.12 for ; Mon, 06 Jan 2020 23:36:31 -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 z4sm21857065qkz.62.2020.01.06.23.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:36:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382593; 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=QDlmWqwuYEUoC4UopyGW4dvLCebh1Ibyx04W4RYzBzEJRCvxFJNpDpYNiBEhmg7ZHQCpdK QXhjmW7VTcGBbyOdgjboddxqEqU0T50Xu0UDtJtoZqBkcBvPXi5fttSsIqcK3JN+G8IZfc 3lFcLRmexNAjDUHcNclfkU9CjznP4WU= 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=gUWBUwjbI8DgJgN6tpu5T+k1x6l27CKs71RIT59IwfWsi9XzuQAAR2rDhQyb5y9tLh 6+xnFvkJCs/OjeRsuFd41LZ+Z72trxXT/UcJffGkngwx1B0XhBpFs3AMwze/UAB64C6T /ZxuOuy/PS/DqgVZzV8x2bTV6xvSvek+s0hozkF0JUe9ha7iRiq7Z+jBth31BjzxOKzv AWsh9ybCwGlNGVRSaxD8/ZvFVjpAsklRkXrtWLYBbhRFBXpSQhCRnzsJMMK0tNAB2HtL pZrpy0kOPMQjMXLa0rdM6d9G4HKhUdYDm7ZxW3GhzxL9wa57Xq9FvYppEl6svCZqZ/wP r5/A== X-Gm-Message-State: APjAAAXEcpCJGlCj0GmKWzY+d77d2ntsQMDEGtweOni/5I2xWVr4MEcB sl+yODJvnY4sIx7xlqV/eKZWFOph/V/knOaGL6syK8IpsgrQ/RMJuPl5togETiBs5QXekOVegI8 /maP6Ict7eHgv6Q4= X-Received: by 2002:ac8:104:: with SMTP id e4mr77608290qtg.37.1578382590657; Mon, 06 Jan 2020 23:36:30 -0800 (PST) X-Google-Smtp-Source: APXvYqyTWFpHD2gso5//KlOp7VgleXoOPMrcO41QFNikqu5aUarexVbW5RBlAxE+6O3Mnn0vGMEtiA== X-Received: by 2002:ac8:104:: with SMTP id e4mr77608284qtg.37.1578382590433; Mon, 06 Jan 2020 23:36:30 -0800 (PST) Date: Tue, 7 Jan 2020 02:36:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 15/32] hmat acpi: Build System Locality Latency and Bandwidth Information Structure(s) Message-ID: <20200107073451.298261-16-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: r7ojF80DO-eYCH1c1k6H8Q-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578384904; cv=none; d=zohomail.com; s=zohoarc; b=EiFi2LPm5AIF1zevctalM7s4t2AE4UZoBuKclrna7vOc9+yUtofqtzZ/NtHxZ8kg4pJfNNT82Lm0YPEDu+a+Vl79qs36WJaM6cVjUMgPf3Z5Eivn+0np4eqnD9S/BG4U/sTunalLybRn8eIfq1+dIDqWLGHKU6RxK0ahr1OWJ44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578384904; 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=EDRAGomYoUfPlk0t7WZwi8Vx53yH5e/xWFbibFrG7e43r+ZE7vUT3xeLGlkUMFDw6+CqbN2m+w19J2VVhN7ZobjUFtei+d2CUeXjw4kZLUucbrREeaOr7FxT+fNZJlc7dtT4SEF/bBZVEm4V9O4ZuHu4xMLcdfh8dubxu8FXdqI= 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 1578384904985760.2269588335326; Tue, 7 Jan 2020 00:15:04 -0800 (PST) Received: from localhost ([::1]:44374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojwO-0006wZ-V5 for importer@patchew.org; Tue, 07 Jan 2020 03:10:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51963) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojPu-0005uY-20 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojPs-00085B-Dn for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:41 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:26541 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 1iojPs-000842-9E for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:40 -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-422-xfTkEZejP4GCaFEPe-eWAw-1; Tue, 07 Jan 2020 02:36:36 -0500 Received: by mail-qt1-f200.google.com with SMTP id m8so35948168qta.20 for ; Mon, 06 Jan 2020 23:36: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 s26sm16975956qtc.43.2020.01.06.23.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:36:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382598; 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=MmVHLMOzwAr578ncGXgLUzmp+SWf8ikT7/H1NC/sJTu+u2G63j2AkEACKnc+Kyn8pmiTcg xgQviF4AnKi8lPMajNz6butcVF5xZEAOi7T+ce4rqgh1UUFkeNuNZZIF2jGhloeTNFIq/4 4QNO0t+Xnlb9rdWhFll8dZYAilg8U10= 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=icdov4ueYrQeEuBVsRNsMWeYd71ZwmPhHC7l3byNRs4OFktsIquDCLnadYXVmyCF6p c2zp5c4450ZebN6j5IKH1MFp2NRgJAX37yPILh+HR/DPoFJ+ukaL2sKfcycsS/ydpTGJ 9uvfhkkl2rXZRlK/sQD95dkdqUr/zVFZfzvEe0YEA9JYUT3tyY0vTb9Gzi9s92C5VA52 s9u/znzCf+/J53B1kugdVcogGojQdo0oQLYhilbeHsp+fKbFoAvwb3hrKBpwCaERyn3m jMlJqjo6Z/5vmqKBVZd6tbXX4hspEKfWUgMrRlQ0KITMiRtAaCW4fyXK67EoGUw8Cscj 6wfA== X-Gm-Message-State: APjAAAUJetK4MZBDagQFnZ9a6zkJC6EDrVKeL1eOdCe571h3PZhLJIiR 7JMjx6/oXwclksGTkORz1YH8uxJuyEPnhMR7pvFY3GEHtGRsYAMZ0Um/kFSLYfOpUPyIWraruKG RQ38/uVAxLbb6paY= X-Received: by 2002:a05:620a:1522:: with SMTP id n2mr85666494qkk.108.1578382595949; Mon, 06 Jan 2020 23:36:35 -0800 (PST) X-Google-Smtp-Source: APXvYqyz6pl8zFpcEK0xj0IlNyKQYBvvlIpoiqaXAy2U2WlrHfqYW22eacSwJJKE7UbIBQ4g6GK67w== X-Received: by 2002:a05:620a:1522:: with SMTP id n2mr85666480qkk.108.1578382595710; Mon, 06 Jan 2020 23:36:35 -0800 (PST) Date: Tue, 7 Jan 2020 02:36:30 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 16/32] hmat acpi: Build Memory Side Cache Information Structure(s) Message-ID: <20200107073451.298261-17-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: xfTkEZejP4GCaFEPe-eWAw-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578386729; cv=none; d=zohomail.com; s=zohoarc; b=Whqoiov1XgEpDyxtAC7bu6sGjsJPlRuTkopK/PvIg0nCTKhAogPWqZAKx8Wvsbor6UgbUlsYiCbVvTbsbjsvf+QutcfvZxaQH/zX37+GZTiFTpuDo1Y752HB5zuTEV61rmm2+TF09Tudz5Ejqx/u1QxmDnqt2uO7S9bhqRDkh1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578386729; 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=FJm6otbwIgm9Ug11ClbEZ4EAsiT0thF/xIn5DVwuOqy9WvUDohvTcmgPNnxs7inm1fTu7BkCA9dHh5O+cagNybWxOesRT9cVEORFMgTGrKoELQOOSd7ZSFxWdd5omeCnzIAFk9XzGwxlNIGJBOMucOroW2Ip+dqIP3OnAGab1NE= 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 1578386729595649.8250007629584; Tue, 7 Jan 2020 00:45:29 -0800 (PST) Received: from localhost ([::1]:44722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokNo-0002Ts-JF for importer@patchew.org; Tue, 07 Jan 2020 03:38:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51998) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojQ0-000629-1j for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojPy-00089o-0r for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:47 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:60095 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 1iojPx-00087u-RS for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:45 -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-116-Sa9NJoSzPla0ZBlAknvmUQ-1; Tue, 07 Jan 2020 02:36:42 -0500 Received: by mail-qv1-f69.google.com with SMTP id p3so9745616qvt.9 for ; Mon, 06 Jan 2020 23:36:42 -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 k4sm24081530qtj.74.2020.01.06.23.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:36:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382603; 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=WGSpRDnUcRYmcpH01Zt0NbIR3uFcN+E+KhxQ9zvpL7qYzcI7nRG3Cg4yEcianFCBGgYhiz 093+1mAUpUIIIt0N9/rKB2+BFI0zws+D7Va4lkvEEaCZZ8Tat7PmU/1+JzSB7edU/CraP5 OO/WdwbkKLfeLL6diB/dDvMhQ1ieWNI= 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=U4xRbLqMmIj1ukJZUVT8TaJbTZhLydYpElDagoUymK8Q9UuJowGKgnj/Zyzkzx/ApW H1TaDIcQlSnvweay23wZB71bX7KfHab4DTvXxnu+bB4M0oUupn5GfPsFYFM/O9z8G/zO IzCqjslqU1Rl8guiyJI1RgMgeJDoJDEPKEsmdocCdMrUm3n4mdDch1/Ev2MuVvLyuC6l WpZzpKggtbuEN1aIVwuUrBf49q7DtETxD8pVK/XQUYdxvBxUzQr40kHslVOpBdyemE5C HIjx9U93ZdZnehlig1o6lvWPxZ1PwjHO3rLfOpf6t8RcJukqnx5KjXAhZbi27ZOKcWP/ 8ocw== X-Gm-Message-State: APjAAAWIJF+pE3gkblbBZWVHK/hfl2HrpeIo7YJysYQrKPwd8Px3XtIn KWFymXQJqCg5iEbID/X2/o2khXHe48GY0MFZqevL3W3ffnsJn9OssvsKqJna6XmbZd+c1r1To75 xmjElHM5/ooSxdaI= X-Received: by 2002:ac8:5457:: with SMTP id d23mr74635799qtq.93.1578382601567; Mon, 06 Jan 2020 23:36:41 -0800 (PST) X-Google-Smtp-Source: APXvYqyzvPkt6eep4BbXLO2a1oKyby3ON5MvxTFUIzJzegaLl8FH6PV2kHJ2MEFncepF6HX9q14H7Q== X-Received: by 2002:ac8:5457:: with SMTP id d23mr74635779qtq.93.1578382601130; Mon, 06 Jan 2020 23:36:41 -0800 (PST) Date: Tue, 7 Jan 2020 02:36:36 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 17/32] tests/numa: Add case for QMP build HMAT Message-ID: <20200107073451.298261-18-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: Sa9NJoSzPla0ZBlAknvmUQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Tao Xu , Markus Armbruster , Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tao Xu Check configuring HMAT usecase Acked-by: Markus Armbruster Suggested-by: Igor Mammedov Signed-off-by: Tao Xu Message-Id: <20191213011929.2520-8-tao3.xu@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Igor Mammedov --- tests/numa-test.c | 213 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 213 insertions(+) diff --git a/tests/numa-test.c b/tests/numa-test.c index 8de8581231..17dd807d2a 100644 --- a/tests/numa-test.c +++ b/tests/numa-test.c @@ -327,6 +327,216 @@ static void pc_dynamic_cpu_cfg(const void *data) qtest_quit(qs); } =20 +static void pc_hmat_build_cfg(const void *data) +{ + QTestState *qs =3D qtest_initf("%s -nodefaults --preconfig -machine hm= at=3Don " + "-smp 2,sockets=3D2 " + "-m 128M,slots=3D2,maxmem=3D1G " + "-object memory-backend-ram,size=3D64M,id=3Dm0 " + "-object memory-backend-ram,size=3D64M,id=3Dm1 " + "-numa node,nodeid=3D0,memdev=3Dm0 " + "-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D1", + data ? (char *)data : ""); + + /* Fail: Initiator should be less than the number of nodes */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 2, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); + + /* Fail: Target should be less than the number of nodes */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 2," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); + + /* Fail: Initiator should contain cpu */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 1, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }"))); + + /* Fail: Data-type mismatch */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"write-latency\"," + " 'bandwidth': 524288000 } }"))); + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"read-bandwidth\"," + " 'latency': 5 } }"))); + + /* Fail: Bandwidth should be 1MB (1048576) aligned */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 1048575 } }"))); + + /* Configuring HMAT bandwidth and latency details */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 1 } }"))); /* 1 ns */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 5 } }"))); /* Fail: Duplicate configuration */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 68717379584 } }"))); /* 65534 MB/s */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 65534 } }"))); /* 65534 ns */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 34358689792 } }"))); /* 32767 MB/s */ + + /* Fail: node_id should be less than the number of nodes */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 2, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* Fail: level should be less than HMAT_LB_LEVELS (4) */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 4, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* Fail: associativity option should be 'none', if level is 0 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 0, 'associativity': \"direct\", 'policy': \"none\"," + " 'line': 0 } }"))); + /* Fail: policy option should be 'none', if level is 0 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 0, 'associativity': \"none\", 'policy': \"write-back\"," + " 'line': 0 } }"))); + /* Fail: line option should be 0, if level is 0 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 0, 'associativity': \"none\", 'policy': \"none\"," + " 'line': 8 } }"))); + + /* Configuring HMAT memory side cache attributes */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); /* Fail: Duplicate configuration */ + /* Fail: The size of level 2 size should be small than level 1 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 2, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + /* Fail: The size of level 0 size should be larger than level 1 */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 0, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 1, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* let machine initialization to complete and run */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, + "{ 'execute': 'x-exit-preconfig' }"))); + qtest_qmp_eventwait(qs, "RESUME"); + + qtest_quit(qs); +} + +static void pc_hmat_off_cfg(const void *data) +{ + QTestState *qs =3D qtest_initf("%s -nodefaults --preconfig " + "-smp 2,sockets=3D2 " + "-m 128M,slots=3D2,maxmem=3D1G " + "-object memory-backend-ram,size=3D64M,id=3Dm0 " + "-object memory-backend-ram,size=3D64M,id=3Dm1 " + "-numa node,nodeid=3D0,memdev=3Dm0", + data ? (char *)data : ""); + + /* + * Fail: Enable HMAT with -machine hmat=3Don + * before using any of hmat specific options + */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'node', 'nodeid': 1, 'memdev': \"m1\"," + " 'initiator': 0 } }"))); + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'node', 'nodeid': 1, 'memdev': \"m1\" } }= "))); + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 1 } }"))); + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* let machine initialization to complete and run */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, + "{ 'execute': 'x-exit-preconfig' }"))); + qtest_qmp_eventwait(qs, "RESUME"); + + qtest_quit(qs); +} + +static void pc_hmat_erange_cfg(const void *data) +{ + QTestState *qs =3D qtest_initf("%s -nodefaults --preconfig -machine hm= at=3Don " + "-smp 2,sockets=3D2 " + "-m 128M,slots=3D2,maxmem=3D1G " + "-object memory-backend-ram,size=3D64M,id=3Dm0 " + "-object memory-backend-ram,size=3D64M,id=3Dm1 " + "-numa node,nodeid=3D0,memdev=3Dm0 " + "-numa node,nodeid=3D1,memdev=3Dm1,initiator=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D0 " + "-numa cpu,node-id=3D0,socket-id=3D1", + data ? (char *)data : ""); + + /* Can't store the compressed latency */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 1 } }"))); /* 1 ns */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," + " 'hierarchy': \"memory\", 'data-type': \"access-latency\"," + " 'latency': 65535 } }"))); /* 65535 ns */ + + /* Test the 0 input (bandwidth not provided) */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-no= de'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 0 } }"))); /* 0 MB/s */ + /* Fail: bandwidth should be provided before memory side cache attribu= tes */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240= ," + " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\= "," + " 'line': 8 } }"))); + + /* Can't store the compressed bandwidth */ + g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-nod= e'," + " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1," + " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\"," + " 'bandwidth': 68718428160 } }"))); /* 65535 MB/s */ + + /* let machine initialization to complete and run */ + g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, + "{ 'execute': 'x-exit-preconfig' }"))); + qtest_qmp_eventwait(qs, "RESUME"); + + qtest_quit(qs); +} + int main(int argc, char **argv) { const char *args =3D NULL; @@ -346,6 +556,9 @@ int main(int argc, char **argv) if (!strcmp(arch, "i386") || !strcmp(arch, "x86_64")) { qtest_add_data_func("/numa/pc/cpu/explicit", args, pc_numa_cpu); qtest_add_data_func("/numa/pc/dynamic/cpu", args, pc_dynamic_cpu_c= fg); + qtest_add_data_func("/numa/pc/hmat/build", args, pc_hmat_build_cfg= ); + qtest_add_data_func("/numa/pc/hmat/off", args, pc_hmat_off_cfg); + qtest_add_data_func("/numa/pc/hmat/erange", args, pc_hmat_erange_c= fg); } =20 if (!strcmp(arch, "ppc64")) { --=20 MST From nobody Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578385700; cv=none; d=zohomail.com; s=zohoarc; b=gIMB+9pXtGUQ14xrx+XkEI2snU2X2wCcHgrVeCtIVppcUBLszg3iX/vNnYGDCr42MPp629UfkglfFAyT6QpJIgG/QCo8qJLy/YBDz79b10ctEPGi5eZJ1bt/r4hVpFTItVNVkEM9pQhHUUlX8RJ5YyLxMsnjjmr5i2SENxdUAmE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578385700; 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=T/XN5YhNwFtG+RO3c5qJJUNy/w3WksEwykLZP1v7R276fXkDQs6IOJpVCm1/ZLAIoSn8EatXXL835LL2a2aNy9rTygMI5DJWfIKHdSZZuwq19A+SkdwkaGBASRuX1eE6N05qhUFgsqI9Zff23+uVjUNudC8P6XmImh0GGRRwx1k= 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 1578385700076369.0537477577632; Tue, 7 Jan 2020 00:28:20 -0800 (PST) Received: from localhost ([::1]:44604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokDo-0002H0-U5 for importer@patchew.org; Tue, 07 Jan 2020 03:28:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52022) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojQ5-00067X-Uj for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojQ4-0008FQ-Fg for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:53 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:54345 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 1iojQ4-0008DN-AV for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:52 -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-217-TKGg7BPPMreWkE9uNfwW2g-1; Tue, 07 Jan 2020 02:36:47 -0500 Received: by mail-qt1-f200.google.com with SMTP id g21so8469370qtq.18 for ; Mon, 06 Jan 2020 23:36: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 m95sm22011247qte.41.2020.01.06.23.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:36:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382608; 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=HTnAhciMiEbkk8QOz1gbxOPzj8mybzLCwbYp/uNHeGj9gijwbr7Z+fac5NWvU5QgUAIw6F pF5O/2S4rzbwf3MfByl+yy9ZiUSoDl6S5Wy64rUvfvrgB5OgQDX8KZ7mttcQqbp9y1URRu AExxobqhc4wFqx4/AuP8DWZx5x6ld/s= 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=Bo78tR1X1Jh9hlYJ9qXuQq+myWGmWzzPGLwpJhqZQaLeXTlxc9OFkxTtVflEuiBBDx Qpr7569ZPKizz8a9p7Lbq9ADEN8BAO6wIqOmpeTpe9G2rdYacMjFdt5zwBzpPgflgto6 B0MLgnDqpmip4Ds4l5A8orioW9PDcq4YHnPN/QsPFYiizhTVZZGd0eIxzgGV+Oa0P2c8 Sjm5T9dnz7LWvqKrv0fyWrnXk/CrVMO86aSeFkFvGYjfQiNP7k91dSXe9AFKcpw5Fi1L HnvE+vpTDXptWFSC5zbGRpKJRGrcigVKeCJlrbFWbmPiwsR7SSWnwt87CuqsMvG/0WDF 5coQ== X-Gm-Message-State: APjAAAW+nfnASFSLsC9MmpCIU5LRTrsvq4Vy9zBOwYLl1u49j3hSiNEk oBb0yw4Q7H8edwReK51YTNYE66ESHlYsFRg4fnEXQHitUiNcbYPxZH2VqC4LQ+0Q5mhcrxysILj KOvZX8ooqmWEUKDA= X-Received: by 2002:a37:496:: with SMTP id 144mr86454037qke.338.1578382606903; Mon, 06 Jan 2020 23:36:46 -0800 (PST) X-Google-Smtp-Source: APXvYqw/6q1YXJBxffKyRn0E0xYUUbSR9GFpdGWfp0NOjwr7Il1G1JBt07MOIqkAX5v03kva6Oa1bw== X-Received: by 2002:a37:496:: with SMTP id 144mr86454023qke.338.1578382606628; Mon, 06 Jan 2020 23:36:46 -0800 (PST) Date: Tue, 7 Jan 2020 02:36:41 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 18/32] tests/bios-tables-test: add test cases for ACPI HMAT Message-ID: <20200107073451.298261-19-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: TKGg7BPPMreWkE9uNfwW2g-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: 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578386691; cv=none; d=zohomail.com; s=zohoarc; b=VTWexZAdVA5fGBclWfPAcApebmG37TR1zb2zg27zXHxLhcY0Mjud8RQTsLSGVV2Hf70iLBFVDpXVU6wl48vkeiy2DL/Wj8MdJqxZGO+uxYy2HNeIs4RwULE8zrBe+qSDIW8O0XV5/Mr/0kqzQPPLfz4a/J8jOoE2T1ZbClCxTK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578386691; 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=LikLqUQEOnyqdqJ+R7d1VasYdnxdErwp29GaEx739I5trSq0MqHuITN02wiUnfi7GbKO8Kbx3myiCOAqD+NVCuYVS4x1gk565lMctFr0LmMDt2Vj96VJqA+bH6JogOgOKHt7SXHI/wFJujBuVyJxgQOetifS/5jqDsY3dQpdSH4= 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 1578386691375992.4679006003769; Tue, 7 Jan 2020 00:44:51 -0800 (PST) Received: from localhost ([::1]:44788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokTo-0000yw-2Y for importer@patchew.org; Tue, 07 Jan 2020 03:44:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52033) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojQ9-00067b-JI for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojQ6-0008Gm-FB for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:57 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:51491 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 1iojQ6-0008GU-AP for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36: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-277-LhHthnTYMNuTcPQHLTgGeg-1; Tue, 07 Jan 2020 02:36:52 -0500 Received: by mail-qv1-f71.google.com with SMTP id k2so36046546qvu.22 for ; Mon, 06 Jan 2020 23:36: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 k1sm20977779qtq.86.2020.01.06.23.36.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:36:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382614; 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=QUKXML7OWtq5AbGqQ4p5LDpQmTyXveaErvR9sBRvRfgrEVzaQ11ATfOWtvj/fGkaJ5q5kf d4V66uQ68yAPv5RUgfLNLBpRQ+ysS5WVpVr8f1Jv3RpZtuGUhgnFs0bTbwKk8eeMvYA2HW OLOL02jqAt75TTEs8QYBviZCpO7c6wo= 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=VXAof5Y/rVWBkaCM0er94VfZEHTC7d/YJrpuyhDYcPvMKN955BOah8do+MQKoXCbtn qwtk//4cWSpYWeRd3fQ50LmyF+tGLflOnME5iN3S8VF182LsSav+tUMUL1E2Kjannd7i LRiH+sQBPu06HAyaRW2okyTaC5WTCgxzJa0Ke0xi9vAi5zJENECXweW5CZiT8tqBWN7m 5W1wYkGreG36keVZ5BZydSmlV9qqBHCH6O0oGwUjHb/SQez4B5HwxvbBI1vLcL9Fv5Ow BAI/suGcYHyOTbBRXsAc/fsqGUZi6INSa+4TKTCy8psBaQDVjbldoY+a7lxLXMYZXPqy n7Kg== X-Gm-Message-State: APjAAAUIyRJfjoUwYh4fjKux4DpoyR89QOQ4wC0PhsoyefNNUaHnish8 a7iDmjtFQPEilZ8ED3de/74M45Mq/8BXygXLHx2An0N3TjJNhysMyah+NYZnFxceQu/V6f3lr/6 DEB5G4W3/ubXjewc= X-Received: by 2002:a05:6214:118d:: with SMTP id t13mr80174300qvv.5.1578382612088; Mon, 06 Jan 2020 23:36:52 -0800 (PST) X-Google-Smtp-Source: APXvYqxNWAYtGHsc0rdrtLMRRU5IZmRwpz+LXyW4hNNM43Xujr2WnG3PKNHmSencGT4tsOR1cc7BBQ== X-Received: by 2002:a05:6214:118d:: with SMTP id t13mr80174274qvv.5.1578382611612; Mon, 06 Jan 2020 23:36:51 -0800 (PST) Date: Tue, 7 Jan 2020 02:36:47 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 19/32] ACPI: add expected files for HMAT tests (acpihmat) Message-ID: <20200107073451.298261-20-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: LhHthnTYMNuTcPQHLTgGeg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann , Shameer Kolothum , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michael S. Tsirkin --- tests/bios-tables-test-allowed-diff.h | 8 -------- tests/data/acpi/pc/APIC.acpihmat | Bin 0 -> 128 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 0 -> 6455 bytes tests/data/acpi/pc/HMAT.acpihmat | Bin 0 -> 280 bytes tests/data/acpi/pc/SRAT.acpihmat | Bin 0 -> 280 bytes tests/data/acpi/q35/APIC.acpihmat | Bin 0 -> 128 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 0 -> 9203 bytes tests/data/acpi/q35/HMAT.acpihmat | Bin 0 -> 280 bytes tests/data/acpi/q35/SRAT.acpihmat | Bin 0 -> 280 bytes 9 files changed, 8 deletions(-) diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test= -allowed-diff.h index 3c9e0c979b..dfb8523c8b 100644 --- a/tests/bios-tables-test-allowed-diff.h +++ b/tests/bios-tables-test-allowed-diff.h @@ -1,9 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/APIC.acpihmat", -"tests/data/acpi/pc/SRAT.acpihmat", -"tests/data/acpi/pc/HMAT.acpihmat", -"tests/data/acpi/pc/DSDT.acpihmat", -"tests/data/acpi/q35/APIC.acpihmat", -"tests/data/acpi/q35/SRAT.acpihmat", -"tests/data/acpi/q35/HMAT.acpihmat", -"tests/data/acpi/q35/DSDT.acpihmat", diff --git a/tests/data/acpi/pc/APIC.acpihmat b/tests/data/acpi/pc/APIC.acp= ihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a21f164699bfccd8992ea1bdb57= 17f2dc3025496 100644 GIT binary patch literal 128 zcmZ<^@N{lqU|?Xp<>c?|5v<@85#a0y6k`O6f!H9Lf#JbFFwFr}2jX%tGJA8l)n3DUlYJT5~Da#Tw;OmQgB5 z;e`?xQH-Fp0w_-I0@g(f^nx~cZ9hWu2zi9`6;d?uRn+h7awwY80?9=3DQh?+C!o9~>N zIp@p_4clm3JxpZZtF6 zQqyh}m`6RXM_sK?U7@Go8VvOxF_0>z{4Y}*=3Dowjb~^1iRBDC2O&%H{P469?*Yd<3S)Dt4h6;IOcSyOPx- z!WD4$wLe@U78=3DP|`7%3EwMsS4-eFO_K#izg#6ML(cR4Bz6PvU5R=3DuHvG+44E7K{9y z6ECfDk9kauEHJ*xci0Y#Ozbje@9J977{a4bE#a@qaH9S|m${5%)E3*q|Ah$V>+HR5 zu5SznPS1`HR78A%sRS%2D~3MY#1jLL=3DEdA9|33PCl*Ly0kI^5oPz%fKV$A2xtyHao z-0T&jGLuo6h>LZR<>Hx$h*$A9Bj&|{_)z>HriG$3SBz5nl+Y*)M?Vn=3D&ffb~t1uE{d-UPP0&mPByb5_OVD*q(BW%2Nc(JOlG3`}LFI|f`=3DSey^@YH<&jQ>9`(iJt-z0wM57Jv?U^J)4RXZ+GHZiZuivg zZGaL;n`&*%U|YQl-P^pE?zTj1*ln||$CE>;08qMnTSSIE#X(PW*rT&8@3Y-ap)w>c zd$`4zcfSRD54Sk;wjR1IcCXcUod*{#N6A~t70Nbl)vsq2eC6nCk-qYZHe0!lRqZA2 zi%uI!pXiIEwp6*U*AoELv*{_3{BnXN{9xN>e`_EP71Ng*)#Txr%OxH~VrDldeQQa<8Ge8=3DJMn+3DE47N^G3vzH=3DWh8`3cdvXO%`;klFjC_}?-2FHc0qdkOl%cqf+NSnr(A-=3D_dWw&8kU!5Ae#H60Rg?h_=3DNlq`P6jF9mmnKqB)ShY&cQg#u0?%&`j zQ7BN5I`NVGHp^B}!6vPml`UkK;4co4N%PL1?(Xbn+DFnnxbOw}EpV#LQGS;#I_{Ye zbGVO{g3JVSP@2b>jf!bzw(k6Sn~H{F8nwEJI1et3EHwE)Jt(s(vC}! zP9%M zs8J=3D79qOhAjU~ZX)99Y|i26vsLo)X}(|#xac-TX&D(R{{<3yLb5kU3)V)~po`^Blz zDbrMGnlwd!dig~mK;Oii(44~9LGvUWYI z9!00zR9E{I0;>@_0@|ja^FE-c3n;Y(#Az1y;TN|PVS?}tAV}K@)5_wVL)n@A1f^zp z@^|E&fr5hckg4+YDW(Q8)tEl{?8|AYKvD9JMAQw8pprsv_&o!2c#{mw<^Hecw6i8M zV{lN@GzSMYnmDKrt65%FGb%2WlInVl3Z1_cgBt)!nD#CzUyjj9F?_uSPmPfdORxE* z`~`%nYeDs*OMFo3mWBA|!$}swQ=3DbBgzVKFko_e0*3i^4FXFo#yJT;Uj{qXzGXiy3S zBVEAh6Jfq4DE5pg2M7Q9DbRfL!;#$mhG2-}-_m1q$81!w)DkM~dLM1B#FK{3k23?Y@DG5!5LM7{@gieM*uS(V_37ras zN>;q117D}ZpzlalRYKKJsANq`XgUn~u4J8&(3w!EWSy1J*)V89vLf<>X=3D$NQ$@-Fn zz7z&6O4gGSdNLF$Sx-smsW7N6S?45lE)*(RPfO_OFsLC}&q(N*P^e^`m(ckzXi2i3 zmC&=3DHP|5nTguWaGU6HJ>Na!n}P|12uLeCus)ynh6jannpOWkkdA+k@kZrc}B2&iU( zkRd^8mLZ@b1)2^Cq?x?mPU01_Z=3DMiD(R;0w^3bjitO7+I4R>CfqbaPX|iu4b)+6IEy#y@m1HD=3D)MtG8P`^wv!ddD& zzI>?nXNek Qg_O1sXWa%LGz<~_AAR>eTL1t6 literal 0 HcmV?d00001 diff --git a/tests/data/acpi/pc/HMAT.acpihmat b/tests/data/acpi/pc/HMAT.acp= ihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c00f7ba6cd0acecbc4b158f430d= 29b2f32988522 100644 GIT binary patch literal 280 zcmeb9bqtYUWME*L;pFe^5v<@85#a0r6axw|fY=3D}!1~h;SWIjwBokmuNOFc;30ICth zW`eR`Fhdzga*PcB{=3D?M+<&o8c*vJ6H|M&lYJ;*!-WC@U?fIv`?15Cr@;rh|!0TAyG A0RR91 literal 0 HcmV?d00001 diff --git a/tests/data/acpi/pc/SRAT.acpihmat b/tests/data/acpi/pc/SRAT.acp= ihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1dcae90aec688e88f9d212e632f= aaaaf2e0dc7bc 100644 GIT binary patch literal 280 zcmWFzatx7RWME)C;N1+c3F q8VCj-m|+T0)xmizPc?|5v<@85#a0y6k`O6f!H9Lf#JbFFwFr}2jX%tGJl1TZsreZQ3+HD9Lq;HVsVfQY0;|Op$crfCjjB<5o&q zWT7}k(jb7O0QuoVfrNF?-snJw-g@gb{u6R*fS!8oH7Md!)c4Ko$TLd{h!53)oNxBM z@0+(fGjFv^zvFkmxxkneRIYmUPO);m<@xBd7-Q6?Z>N#D!FqdsrPjA{sf^Xz&xtlZ zDz^KqU%6JZ{<0l@9)@>53ay(FyY+>0@7B%egO9^oj6iSSia4i+v%&kFO22pD@s`&p z+5LLM&zHaAw%zw+D{c47ew*3-YYpFWo0I*k9WQhD4d(f;tPD3N2HS;s?(~9xt$n+^ zboujF?vx+=3D>Yu;4`v%Vdu!?UR-)j+lgztrXIUG8l4R);ei7t+<4Cg-^h{Lkap(9a9 zJ@@mni&Cu|zTpJ69Bb9Cx2jz=3DRtqD<*l<4Tt!}{bjD7W8j%9lL4#o2?S2z7)tL^uT z?xlXGTV@gUgb{V!{A0+SaG3ve5VAp-J32aK!XDpf7<-pFmnWa6;m~Qr>B}}c<-Ryo7{D?H(`vN0Qat4O-d+<|Fva(Hs<(fJ z+RVEel+(<@R|Q|qR@YAnR5is92z3gmD)Y+KP0Op`quIiTbNTcOX;qP`^$wnEcRdu9 z*DQx?L?d0~r)pNjBIcydGplCpvR#(SzRP+CKijDI$MAI8of7BcSfU_?EMyi~ud&zg zeLe-Hy@RKNtJjW+v-3%!%_q(?hk!3Z%P}y++(miDY5d_Zi?e*l?q`k*I()ijy_0?? zZQJMfM4@U1=3DVV1Gny}(o7pI{Ua#EUy>4#}%pLax>bxO0ENW)WVICM@=3D%#(VULLM7=3D z>{i2DXKucaZ!6lS$obQ&7F`0z`;S;It#-FHxAE5ATrPvz!?Ue?l6%tcb!MvAPktZXV3Yw8jHF$)&&Iv>3gkUP@gk-A0Bh+N>GQXlHuL&^cx5M5ycJhE8tiN=3D+lozsTSX;UXcUFVFUbH>m)W9mex>zp-o z&Kf#rO`QmJosOZ?F?2enPK3J7f}yiu=3Dq#8z5$ZbU44rd^&N)*jLS5&)p>y8QIdAGj zsOxkMovxwNHFYA?b)GVGo-%ZvGIb)7Yv;XrcQ*q&eMj@(}vE|rcQ*q&P7A# zqM>uq)QM2nc}6hH@lJR~Fe~w9cSbV3M#1vZ4{0T6amW0AdNs3g@H<(up|rjI|8U2GbN!aB&L!E1C>~1pc<46 zR6+%l3=3D|$|V8TE(C>f}P3MLsSLZuT1DzSnI1J$5ppb{#WWS|I@P8g`f z3MLFxgOY(ts9=3D(TB2+qIpb{&XFi;Ij1}dR~Nd}5g>4bqwtYE@GH7FUVgbF4ZC_<$Z z1}d?F2?N!jWS|l%m}H;`l};F_#0n-1RD+U%N~mCxfg)5oVW1K#m@rTcN(L&Sf=3DLF7 zQ0at$N~~bQKs6{CsDuh887M-f69y`=3Df(ZlFpk$yDDwt%T2$fD4sKg2;3{-=3DXfl8=3Dg zl7S*rI$@v^E0{1)4N3+op@K;Uicsl$|V8TE( zC>f}P3MLsSLZuT1DzSnI1J$5ppb{#WWS|I@P8g`f3MLFxgOY(ts9=3D(TB2+qIpolaB zMWh=3DjLft?SY6hw?VW1k53{+#1foe<`sK$hWYD_XvjY$ToF=3D3z@69%d=3D$v`zG8K}mD zfoe<`sKz7%)tF?U8WRSJNL^hRC?Z@jaWct35#lnakeKS+!axzJa|;7Sq|PlFC_;5^ z$v_eM%stzOg|cCOApTiBq<=3D{7XX&fl+yBK2Y5Fgfo)ys32&>iJD#LNND)iyehi@}H z8`-K-d!0UN^ij9n`NmeKYYnH~<9pk92r_lZbMD2)me-yFpj|4=3D@Z2X^HboDk@SpNs z>f;mmY((#E^I1kM45E!EBh5+NBb3$u;(0typ@%g#hTSPF@cB<>*i;(s#;|`g?8M0C z&dTQ!Gz5&M>=3Dycdqr=3D{(Hs2FHv-G5c9nyeAe7fIhcdWbH@ffH)^~cpKiRyT)@V%>7 zwCWX6y@K)S)hq7!>XqI>K-#@Tb)I^R@}5@S6Xm@`dGCbsUR>T!mdE3=3D@2%d~%KM_c zpD6F2P~MNrSCi#4k5Rs=3Dm9L8O)kOK~3FWJC`SoP^iN`3vu9aUG<<}GC*H0+F9+$5r z%V!^>d`&A~6Xk1(^0gDn*W&W^WckU*C|}pg*G2hyqI~^?@^zHY&{mc#@5u6M^T2Hd zJ!TV6EzLeRE0#RIXkEwYlFOJE%yhWd7)dAl#-ro;WqNIKa!Hr>d)UNF<)re-9a>>HbIWS*Wj z)8S5MB%SOt(>XuT9?75S1eN%OM%H0i_jrwwPvhCVbLB<(9>L=3D`9z9WSwW}R9Upba3 zTx!~DT`Sh#yc7NI?cWx6Z@=3D~C+q=3DKM{TAz4UaPqg&)aFvYu4BKuk%(O55VD0u+7}p zc|7*tzd%8m6+L=3D-?=3D?0%me&qmw!G?e~v(DuTyOnf%MDWA|5z5HXC-t zs1s9v<%ST2vB>dFm%Ub_R9Y#~2;@7O33tisuD_ZZ^1(Ly&?}WnJJhtOxw7NdvmORA z)w^)xg^YTEKypdO(NVOW>_**)g~PLhA@!7EV^vIFs#$o6N6D02O3R%fi$S^j) zTc7bd-llz$3@iMioEwCA^$|uanG`2`Sj&tE5*Gz$E(ynVu%eNX0UcT4{f*49KAK8g z+VQD)dNdc{$TePQFy&qCbn_<(9ece-1`EZ}&KO-0PbGT^`g*bxr(o>pdLO(*6AUX7 zf0(P7S@t2#FHFav+%4p|&G7#}-5I(wcv;xZkr=3DkU^E%e_^?>z0*vQbd6t|8>0^F7z zC$KD$AlIkGB36u+%sNiyp2Om(wW|GUX%*L8ydI;4LK6i`XF^-wLA@on=3D;_vGt5hys z!gy(o2e*I!=3DI*=3D2?U7|JeMziu+?;Z@Nb9@a3fdN)0`SG&LAfedCNfJeNo4jLK~Q|{ z_8)d=3D)35`7vrX^zp4Uz^jfpa*gLb7^#77+;O=3D>mKYF+Oad;8Ch!I#-(9#lJhE1(G+ z(9{d6SNeDl{L~n9I-uPpxLSP~A04mg&Wro&;naY}gjaI7x$jv))7xNfIUC^Au}8XXzbmHOiLrd+G+1CIuZwOgqmZ z&8ax1J?4)C(cBC1AraODHr4xB!9bslTx^nc;BEfH{KLFu zqu-J<=3DUW_pm_LrE#T@!ZpIIC;ivAs^zZ4TkFY-VnVp8>3AMz-Z` HcG>>`zx=3DOx literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/HMAT.acpihmat b/tests/data/acpi/q35/HMAT.a= cpihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c00f7ba6cd0acecbc4b158f430d= 29b2f32988522 100644 GIT binary patch literal 280 zcmeb9bqtYUWME*L;pFe^5v<@85#a0r6axw|fY=3D}!1~h;SWIjwBokmuNOFc;30ICth zW`eR`Fhdzga*PcB{=3D?M+<&o8c*vJ6H|M&lYJ;*!-WC@U?fIv`?15Cr@;rh|!0TAyG A0RR91 literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/SRAT.acpihmat b/tests/data/acpi/q35/SRAT.a= cpihmat index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1dcae90aec688e88f9d212e632f= aaaaf2e0dc7bc 100644 GIT binary patch literal 280 zcmWFzatx7RWME)C;N1+c3F q8VCj-m|+T0)xmizP (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578387120785624.5971915401742; Tue, 7 Jan 2020 00:52:00 -0800 (PST) Received: from localhost ([::1]:44880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokaj-0000LH-GU for importer@patchew.org; Tue, 07 Jan 2020 03:51:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52044) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojQC-0006EZ-Cb for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojQB-0008JU-2x for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:00 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:52339 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 1iojQA-0008JB-VG for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:36:59 -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-123-3Tvah6I9MKCEEQrTnwcGkQ-1; Tue, 07 Jan 2020 02:36:57 -0500 Received: by mail-qk1-f197.google.com with SMTP id d1so8965590qkk.15 for ; Mon, 06 Jan 2020 23:36:57 -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 r37sm24890198qtj.44.2020.01.06.23.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:36:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382618; 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=KgZS6Xd5jxKfp3NbWbLm6BB6Sa8HLmygrTGlxP+hN2WhbcH4v+r7mewGQu9ovllzOhXFzW hfIAmt3Xwi2Rbql9CrFpeJgNaIgK3Vz0x8ZE9UZkkYG2Wxx1jl+fZVMB+USGh/8g9bkkQb PUaJFMe1ikfd+AbpRMpI9sk+KzZhv7Y= 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=KpgXOz6kQ9CU/rQQ03eFzsTWlpDoFbvJwxAfi/iPZkVkTwRA6sVkKj75txY2Y6RrzQ 1ZD5N5giUdQaQMx3DKQPdzSTayDXfkouC+1FGC1gZ56T7IiBkmCwdLe6eR1JXU6+n4Tn v4RWTelmKRK2vwVeEeY/GnkMpb0kl5DA74l9zCk/k6VyxZerCn75Uqw8yK7o0hWW4Wvz X3dKBH2iiuBYtV9jEHc6Xf0EGUzv/FtLFyOkj+TLgaDg+UuHC0Q3a02SBBoVSsEM0la8 PPHZZ1z+fFT281abhaCZD90T6ldh55sY1hk9QPUli5PpaCqPPZA1iPPFZsuhiy5qcNje BL4g== X-Gm-Message-State: APjAAAXY3z0Tm1x3EZH+h/kgoIZMxF3vChPk4CKEpgmrDGGvrBESa0+g b4SGF2IUyDXyUzWMkHCYTJaSamozj6V0Aznxb40/FlprWHPAFlc6kt0VjTS9pCBwtsJa/A4MUNt bRZlvw8OlUrVtq4A= X-Received: by 2002:a37:8e44:: with SMTP id q65mr86111629qkd.70.1578382616620; Mon, 06 Jan 2020 23:36:56 -0800 (PST) X-Google-Smtp-Source: APXvYqy+l3SXlWn8LCdeJOb1ypyIkmqnRvy/c2C0QOGdX2WZO6Dq1ZXTXQQA5mrqvvEsJXuW3KvO6Q== X-Received: by 2002:a37:8e44:: with SMTP id q65mr86111617qkd.70.1578382616357; Mon, 06 Jan 2020 23:36:56 -0800 (PST) Date: Tue, 7 Jan 2020 02:36:52 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 20/32] virtio-mmio: Clear v2 transport state on soft reset Message-ID: <20200107073451.298261-21-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 3Tvah6I9MKCEEQrTnwcGkQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Sergio Lopez , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker At the moment when the guest writes a status of 0, we only reset the virtio core state but not the virtio-mmio state. The virtio-mmio specification says (v1.1 cs01, 4.2.2.1 Device Requirements: MMIO Device Register Layout): Upon reset, the device MUST clear all bits in InterruptStatus and ready bits in the QueueReady register for all queues in the device. The core already takes care of InterruptStatus by clearing isr, but we still need to clear QueueReady. It would be tempting to clean all registers, but since the specification doesn't say anything more, guests could rely on the registers keeping their state across reset. Linux for example, relies on this for GuestPageSize in the legacy MMIO tranport. Fixes: 44e687a4d9ab ("virtio-mmio: implement modern (v2) personality (virti= o-1)") Signed-off-by: Jean-Philippe Brucker Message-Id: <20191213095410.1516119-1-jean-philippe@linaro.org> Reviewed-by: Sergio Lopez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mmio.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 94d934c44b..ef40b7a9b2 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -65,6 +65,19 @@ static void virtio_mmio_stop_ioeventfd(VirtIOMMIOProxy *= proxy) virtio_bus_stop_ioeventfd(&proxy->bus); } =20 +static void virtio_mmio_soft_reset(VirtIOMMIOProxy *proxy) +{ + int i; + + if (proxy->legacy) { + return; + } + + for (i =3D 0; i < VIRTIO_QUEUE_MAX; i++) { + proxy->vqs[i].enabled =3D 0; + } +} + static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned siz= e) { VirtIOMMIOProxy *proxy =3D (VirtIOMMIOProxy *)opaque; @@ -378,6 +391,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offs= et, uint64_t value, =20 if (vdev->status =3D=3D 0) { virtio_reset(vdev); + virtio_mmio_soft_reset(proxy); } break; case VIRTIO_MMIO_QUEUE_DESC_LOW: --=20 MST From nobody Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578387594; cv=none; d=zohomail.com; s=zohoarc; b=hE18YK+7tBy3zJ+OrkmS6Ji8Y3nI5+Wwg6/BHzH7ueJvPx76sk2XWiAFcEAjcPiJQmpvaN9DArpS/uBiur8hhGT9FNCDUH93mRno+YGEGuRjOIsD/ytl4RNtQYlYg+c5vtgc1Nh8QGxdCetH0Ij2eY6ZlxEKMj6jUdlWrcV5LBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578387594; 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=n/51JFFBFR36AcpfXLknJjYOpQZOO3px9v1RgFEda5yLVUrBo7KtkgrooqwP9oeOm52Ybl74nM/yNZHfxMZk/8yYU15VIju00Yjo9h7uEyEvA24xTHhIa3I3A8cRg6GAoFmhh6csQAbxypkZPgExtlBjQuMxUXfjEd/zekz9qtw= 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 1578387594831555.6560682177824; Tue, 7 Jan 2020 00:59:54 -0800 (PST) Received: from localhost ([::1]:44950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokiN-0001kO-P7 for importer@patchew.org; Tue, 07 Jan 2020 03:59:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52056) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojQN-0006Sm-FR for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojQI-0008OP-Nr for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:11 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:60504 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 1iojQI-0008Lt-Jf for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:06 -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-400-wPz_Jjr-PTC6m_gBat38Mw-1; Tue, 07 Jan 2020 02:37:02 -0500 Received: by mail-qk1-f200.google.com with SMTP id c202so1847284qkg.4 for ; Mon, 06 Jan 2020 23:37:02 -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 f23sm21893397qke.104.2020.01.06.23.36.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:37:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382623; 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=cM9WxUMVWuBf0T7EGgH0rJtxZX3rY3KCWsedHRB39AiouVaDMsptClYh06A4TGcExBXvT0 S9HVTfD7JOrNYYBE1m65tAVJs211fMsDrokUfqb1j9ZiarOpn3c6w1Y96nNBWFOetR7INv yReGl7owaPQlNpKPj0e+JZ3VgvDA+L8= 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=YgE4MB77G2PBWE3n0a2O4TgKy+0nlzrSrWT/DJr5EgSncANh3l9gfSaeUUsXVYt67B WK9MU8UrF5TT7/4mfsBIFTF2XI/3Ire5J0Jb3hyMcTDhbu5hBqb0jTn2GiHFiN/S0aGl z+W90Z9fAkn0CgRMLBvb7+2Y/lnx6rzqK+zPjS0Ayr7EcEjWv/PxYYVkEkwI044x8edc S5Aow3pyC3RIPukHB0KtpyheqPRc+H4tIIZLV3xfZSOVLw6Lqg5TAbbSNxj7fIeUkNbz yr4HMWB9niDMRBYELHH3FC+ZhMZ6aU5Mos5msGUU0pWCfIDUhrqV3bAeo+4wyaxV70PW lE6Q== X-Gm-Message-State: APjAAAUF3H1rMldP2QkKhy81LSYNwXbGvF8a5mTOHOAoL9Br5P4xJ952 +TiQzadEOiGgDMcROhudLZwHOC+u3FUjpJOIRSpAJTSIq4AT3yduVPVbdjeqEJEM4wsn1IO+sIZ u9UymhsWxQhIeMKM= X-Received: by 2002:a37:a30a:: with SMTP id m10mr83251752qke.56.1578382621467; Mon, 06 Jan 2020 23:37:01 -0800 (PST) X-Google-Smtp-Source: APXvYqyEd4WjDrVFcGasoVsd/g+4kPqonsObYlED8RjNgSWxRh6zeMJySjnWk0gcA0KgreenRlLQ/w== X-Received: by 2002:a37:a30a:: with SMTP id m10mr83251745qke.56.1578382621260; Mon, 06 Jan 2020 23:37:01 -0800 (PST) Date: Tue, 7 Jan 2020 02:36:56 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 21/32] hw/pci/pci_host: Remove redundant PCI_DPRINTF() Message-ID: <20200107073451.298261-22-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: wPz_Jjr-PTC6m_gBat38Mw-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578389627; cv=none; d=zohomail.com; s=zohoarc; b=e/inlAbcwD6wa/kYjSBEADjq4zMaZONq+45rD8SeDBSID1yBbIb9enbW830Y+BxPoxAuQh2FXdpjJn+IzJF0OnYc7fF416Yw1WZREoflPTV0wdQSgyn+AKcZvcoxypIzFVDsQqIARS4sDSsfSDQorrshj+LUW3Fhs8q2Bg7BvXo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578389627; 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=YB41YAwwA8SAWvw5CwZgRl5y1PzwOLije9jLyBOhk71SItmoeh+BHcCPWs6rCHZI/5QR8VU2NxN5f9vh8VLK8iHlkLlVOVHdY0o1PDm0ZkbzNrBLOjGdV1Ni+HuKYxtig/hzU5C1jVZLu469ULXYLBeIxg1anGdkHgDL8bUdsBc= 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 1578389627087561.4961581078804; Tue, 7 Jan 2020 01:33:47 -0800 (PST) Received: from localhost ([::1]:45274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iol8e-0006EH-EQ for importer@patchew.org; Tue, 07 Jan 2020 04:27:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52535) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojSA-0002nG-Pt for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:39:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojS9-0001Qz-HL for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:39:02 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:44894 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 1iojS9-0001QZ-D8 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:39:01 -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-282-L6Bu27xiPbiWuIfgyjvcGA-1; Tue, 07 Jan 2020 02:37:09 -0500 Received: by mail-qv1-f71.google.com with SMTP id n11so36111338qvp.15 for ; Mon, 06 Jan 2020 23:37: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 j194sm22072669qke.83.2020.01.06.23.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:37:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382741; 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=Yut060G6jXelUx3LdePcJ0YFgFmea9lpPIYSNM7O9+a/MZsGrlMSCvMYJAxfFweWZxFDVr MecLqxUhaf8PxE3no1X6mGjtcYICk59+vadDtQVraure5eyNppNwRtRwzdhT0wYRiDf57z PqxSELK7KWzqJ94Xbguk30pCfrSfWgQ= 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=spLasPldmFO/Fz2Cb8udsSJyNalydJOH+JX+BCdTXi8jsT6GK0XsoRGxY2Q4fXAt2m b5HVCpHOdFgaXZ9RCpQgLvpejZAoeZwjjQnm1tRBffM9sc9pPHxI9IekBScmEiXmdLfo CyY3FelbfRFYQORTRvb+aaojYJqLEC9FJM5zLvrtQ7KgCNOaWDL/Q9T2O2E96vALra+a F2+Vy5qpvWwYlJDsf3NFDHDJNUYqTZjLZ0R1epV6QHtVKpKz85Wqyj0L4DzGoljl9Rat d7mxXRB+GvNuO/JKwPVTpKkBB+ZwO1dGurlRY9jQVHQ6TTzCpiyGe+6AbgEMaW+5Fk8p up5w== X-Gm-Message-State: APjAAAU5FC70K05O757ZTvpUTvwkFg0/NTJdzDvQ89LgXa6RJd2wZOhM M9F2w7utdIEpyHY8YVuW9i3huOPkKRqJWjKap73kD6Q9CWbmJ/sv6JVA0nkoZvsPxfzgFAkY/bx aRBvkxBJ+hghF4aQ= X-Received: by 2002:a37:e312:: with SMTP id y18mr88627004qki.250.1578382626005; Mon, 06 Jan 2020 23:37:06 -0800 (PST) X-Google-Smtp-Source: APXvYqyLRgD5T2iwhQwjVEw5plXhkS2IFiChVBYXgc7TQD1LlCFQnhXxmd2PCgVlnIFZZXOeyl1FYg== X-Received: by 2002:a37:e312:: with SMTP id y18mr88626992qki.250.1578382625785; Mon, 06 Jan 2020 23:37:05 -0800 (PST) Date: Tue, 7 Jan 2020 02:37:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 22/32] hw/pci/pci_host: Let pci_data_[read/write] use unsigned 'size' argument Message-ID: <20200107073451.298261-23-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: L6Bu27xiPbiWuIfgyjvcGA-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578386506; cv=none; d=zohomail.com; s=zohoarc; b=Wq2PsCzJ9KJlotngEhuCPR24C4ewgqpjVT6t6PbACihlh1rHKQDJkdMDRzBN8YUWAZ0cFLb+F1uA6YWFU/GXa6cI74jdrWaeoXW01BeltwTI1RjoQA2+LWjhut1kifc+eLnPyMKGpmRsMtS6iuyJ8E+8wuS5j9QtF6+4JnKCPZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578386506; 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=eL7ShKewWHUFyiGbxTXg9cxly04/UDKu1bol00b0Qw7LQKuzCuhKdVLJ5IegjCq8u3xpyT+3PUpHNuztQy+/61WtwMy83jI3QTrJyj81efN0gO+NDH5p+vtYNlDrmryD1WbNdVFop2sPogGRj3Cbh+1nYR2j+Q22iXsuLg1t4Q4= 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 1578386506661718.8830605365215; Tue, 7 Jan 2020 00:41:46 -0800 (PST) Received: from localhost ([::1]:44750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokQp-0000Wo-Q7 for importer@patchew.org; Tue, 07 Jan 2020 03:41:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52075) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojQT-0006cB-Ql for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojQS-0008UU-AC for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:17 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:51310 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 1iojQS-0008Rt-6T for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:16 -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-78-ZNWMLvW2PZmpzb7drDApPQ-1; Tue, 07 Jan 2020 02:37:11 -0500 Received: by mail-qk1-f197.google.com with SMTP id f124so31120662qkb.22 for ; Mon, 06 Jan 2020 23:37: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 w20sm24937356qtj.4.2020.01.06.23.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:37:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382632; 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=jAkpqcBNhq2bL/yMuvIcgAYjcIkclpEm3oav1tECmFnSpXVocx9D81jFoARJza0Z5184rY az0bD+9o7DAe+QrRwRYQL1m9k7AgInO8ER7ahzdzwyOnRcWOy+7UxuwdZS9lKlnHn7zO80 k2vRJJbTBgNIl7Eh8uUJ+grx2CuFVIg= 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=OvD+V1gmDQDU57JJUToP6kTxAocOdW2y2hYeOW3Ekbjz3XNGtXb78bHzNWmi9aXldA hdAXKFRiTdbePwd0ZIqwGZn9Tsbek2VT4hB8ZFX0qv4x7vfMcl7za+a7Op0L11ASZ7Gj LdtAUWd0N6yb6rkmpeYNV/mhCoNmsx5AfCH0wFCJlSI7s2dCIVtazMo27rNmDqwriIyG 2575R/Gw6xjUNa2Zk2OpRbIYiEB5hosPmhlrkEsP+qcEIuMy1bh2jq23zdSmQ3mkHMDy rJpOvuc4QvGy4lJl7k3cnbiRthiJknKJ5ajww2ZkRXPGvLH8RZG+mloIPbU0qlEd+QkU /h2w== X-Gm-Message-State: APjAAAVeMUZMh+Kj/1o9TSvApsxDRMKdEvMdyKiIZsZNJYJ/J0ykHOTZ FH9KF3xa9Pq/VAzi5cHmEvXfZQ6LAL9gt0sIeu1pxma8VhDjF3zqGrxhvH8V8Udf/GasY4eDk4R 7+IAnB1dtVgM28yg= X-Received: by 2002:a05:620a:14a2:: with SMTP id x2mr87591279qkj.36.1578382630731; Mon, 06 Jan 2020 23:37:10 -0800 (PST) X-Google-Smtp-Source: APXvYqyiIb/URXkFZljVHs/rTZTTzqzTtW7o5REey1kTCC0F3MOkRAfV4sEIHbB0D1K9fgqM2ZBGLw== X-Received: by 2002:a05:620a:14a2:: with SMTP id x2mr87591275qkj.36.1578382630498; Mon, 06 Jan 2020 23:37:10 -0800 (PST) Date: Tue, 7 Jan 2020 02:37:06 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 23/32] vhost-user: add VHOST_USER_RESET_DEVICE to reset devices Message-ID: <20200107073451.298261-24-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: ZNWMLvW2PZmpzb7drDApPQ-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578388118; cv=none; d=zohomail.com; s=zohoarc; b=EYX6qhDAVN8gYbT8+zifbP0Lil0pmdSrWWZ42OqcWcc6QQu9SWoI0ueFokgI4Jhk0GlPQgKQEqMXncQdJRZxaBPlUWhkBwbZqgORNAXCcjigJ1doZchSZD+h1ZVh9y+puQ7NM10+7zj4QYAQYhE31Sm/K9mcMAWaSkutr9tygIE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578388118; 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=URr8BRHpiQ1PcFvPNaIE5NhbRfdzGPAisoT2gH6qY4cWN1KtZkGLfWFIwUzBM7DM9PuL/kFqgQOtpJ4u1yAdfT30vvW19Y0zssNfaqZt+/xo7Oh6gOEFaSEfn0XvLn0v/wb70FRIhH7VdrQLy5a0YiycZOyyF9iMcxly2l+O8FQ= 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 1578388118007428.46414342155447; Tue, 7 Jan 2020 01:08:38 -0800 (PST) Received: from localhost ([::1]:45066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokq1-0003iJ-Fb for importer@patchew.org; Tue, 07 Jan 2020 04:07:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52104) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojQW-0006hC-3d for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojQU-00005R-Kc for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:19 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:33410 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 1iojQU-0008WK-GH for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:18 -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-290-JTX6WB2VN0mMeu8uGfm9Hg-1; Tue, 07 Jan 2020 02:37:16 -0500 Received: by mail-qt1-f200.google.com with SMTP id d18so19070208qtp.16 for ; Mon, 06 Jan 2020 23:37:16 -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 p19sm25008954qte.81.2020.01.06.23.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:37:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382638; 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=R0zTNpiFzFzCekl+tFMgbbeCJ5piH+3iUFGwSA0B0DYy4DU3K6BhtkvV7ZAjYEyEaVbEEk /SMiXBqcOZR0zYFcx1pvw7AaQW4tFrnoe/cDhYqKmLJGPGdX0nk1726417j9VujGOcIWyU dlhG8EjA8TZPoFs/MAlDcodJe6ia41c= 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=JbXt0AT1D13pB1CPI7xq8u2x9QFMzXsOMwVQOpBRDrowbNI0XNGJnlbe2YL4jqseUk PBKVY9oehjakV1jaQWpDafPx9ieZQnoiVNKEUSYcieCiGaT+ZgEgeV+YmpeGrYOx/WCY 8tLcC/ZUOloA1Q8urkKuKkE/VWpMKnRbN3P4E17mmWf3TsMJPFciad3+pISXo5SZI2XN aVDBr5qDFH3kSg0hjDw89NLs5Es0fneVFukNT5FVDv0rQvUbWYvHTFooGRtC+H5rOobS HPv2lBPDBio/Mmx/7T+DtT/SyO/lTgZXcBfnYoyRVn09+tklSMssnbUA/G4VNV5SDJYl XoTA== X-Gm-Message-State: APjAAAWhBbgYEuooif0tMB/hyh8gycmB6ZOot+vp7pkM6F7NUCag/s+A qmo7dmV7crmYwuohs7kWAmKL19jLGJmHtsgCVMAiXKsO4SB5n/k5D/qvzxL1s1ACTtv49fggxs5 lhPzxiolMO90DLLI= X-Received: by 2002:ac8:454c:: with SMTP id z12mr78356990qtn.123.1578382636023; Mon, 06 Jan 2020 23:37:16 -0800 (PST) X-Google-Smtp-Source: APXvYqx3Vwgep2tNLi6KTR/rSWiF9ixPIZ1K02S9NiBerJDf87G5XHEOqFQ4DZoRzCZfzZ3974koeA== X-Received: by 2002:ac8:454c:: with SMTP id z12mr78356982qtn.123.1578382635847; Mon, 06 Jan 2020 23:37:15 -0800 (PST) Date: Tue, 7 Jan 2020 02:37:11 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 24/32] vhost-user-scsi: reset the device if supported Message-ID: <20200107073451.298261-25-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: JTX6WB2VN0mMeu8uGfm9Hg-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: 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578386194; cv=none; d=zohomail.com; s=zohoarc; b=QSypnd6gcSKMSCSz1bJQA3AxOcbgTLYkE6JYn3BroGX4EWY+74bmXGfsXOGXPOWZirYzB1itCz8jgqHdwyNCutrAZsoH4pYu6d4ZpNSE+leVnZxd+nzWfEQU+7fuRkYGZwY2PSsTubPFonZ5uxHsPjnI32E03lMfWHBY+j/v3wM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578386194; 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=XZBaniciMXg7BoxRsRjSzmorxvGazU5au5MFVHzbxywzsVunHNAjMqpAFFlb+Qw0QxAXJSvjo9S7WD0GhpQdqzkY0oZ/7tNdi8FW3k1u6rzESFZDy/cDA3Mhnyw2Sr2SY15qElC/qSHRFMoA6STESFrqvocU6VYnn5tt/0xYGZs= 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 1578386194263766.608548525059; Tue, 7 Jan 2020 00:36:34 -0800 (PST) Received: from localhost ([::1]:44690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokLm-0003zg-Qf for importer@patchew.org; Tue, 07 Jan 2020 03:36:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52127) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojQb-0006tu-50 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojQZ-0000A7-U7 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:24 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:28432 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 1iojQZ-00009x-Pz for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:23 -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-123-O6-u6SRnOEC0QFpTZ2qvAQ-1; Tue, 07 Jan 2020 02:37:22 -0500 Received: by mail-qk1-f200.google.com with SMTP id s9so17954995qkg.21 for ; Mon, 06 Jan 2020 23:37:22 -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 s11sm22092051qkg.99.2020.01.06.23.37.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:37:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382643; 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=A4ytv43VKnsoMaR69viToAq9TcBgNE6YRpxB+xb8I5hkzItI09eYdQuEvV4TROAmRJLs2F cJ4YKfulmsk93d0KJa5DmCb6V8UmuQo/xFrBdXMmVNERj9QkcQFTNnFJr6EvNImuXvgOTr IpUTdmjrOAHIpBP74l1zONsk6VIiwJQ= 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=eaNSplboNvez4aQoLhHgXGiPh4Wtbh/0AYvK/21tZoSJGxqJPT5L28hdasEZcA6Cf0 x8D2stClMKptc03QcGh+7ghKguwbWr/4PKNnECE0da41sdbZnFbpnY5TsSIAfupuOgR+ RbhLJMJZ00BojRUg3dvN1S7qxeA/UAtlPT9FkeW58tZl/+iEIE4a2n0Szcc9OT2sOMFT 2Hm5Oa6HFvBQAHBxgUcY1gwvcJDfRd2b544RmnxB/NYtWqugpEGEfXTzwgpFMXEJoXm5 NiTThNh5vNebmSKBwiRSY1FK8OgUm5lSPPjrk0ljko+pDBEN6MDRhHg/n6LF+fJceeEp v6Kg== X-Gm-Message-State: APjAAAVlRZc2u+jh78P+bkxl3rw14VfhWhRRUQCEW5NPW09bSBQGGkWU t59t6b+UWOUBWi9Ed41kdZN2BiXDYPdC7F66BsQwBWrvJp3g1p7HoIFBk0vy6lXkfdVWIRRjOGj h1EegvlE10TgQibU= X-Received: by 2002:ac8:4306:: with SMTP id z6mr77900317qtm.178.1578382641201; Mon, 06 Jan 2020 23:37:21 -0800 (PST) X-Google-Smtp-Source: APXvYqxG3hPL0OzKLLPNAeMXfVNwymQXzp2t7vdkRIRXEQDi+v6DXYUsrmIysbRJQAXG66+RW7NPsw== X-Received: by 2002:ac8:4306:: with SMTP id z6mr77900306qtm.178.1578382641015; Mon, 06 Jan 2020 23:37:21 -0800 (PST) Date: Tue, 7 Jan 2020 02:37:16 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 25/32] hw: fix using 4.2 compat in 5.0 machine types for i440fx/q35 Message-ID: <20200107073451.298261-26-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: O6-u6SRnOEC0QFpTZ2qvAQ-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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578386973; cv=none; d=zohomail.com; s=zohoarc; b=YmvjRSUytTK/+On1OhLm5ZY0gzlAKo9u0Ek6YZDnfL1CIYE0fNTnr6FLP+bSqRwfL3Yvv6Y3TMbS3A7mwgKGVAQhFknG3sFjluvInH7z6RqR7yD+bXU/CuGdz3U5Z3xKpZ6U657KsVIvIhKve+O/xYUA4EBmfajN/ojqGYpAL1g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578386973; 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=Z13KJ0vWOirv0bpEydzTz+1MhtfDLJdvDbH6dIjPp+0=; b=MuJuLqHNcsiXzlJV+ZH7mU5flatgpqvZl8XJ02YZXgYvS8MfB3xq31rE2VsaWkxd+9As2A6cb/DQUCFg90dPnGKOEzbSe1vSwia1BYxsHKl+AOelVKXxy3v4BoaYK/ZzbBKQcwNCNAh5a11grYCkAq9M0Penk/fnkF+de1emKwA= 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 1578386973767235.14588125189334; Tue, 7 Jan 2020 00:49:33 -0800 (PST) Received: from localhost ([::1]:44858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokYN-00044S-8A for importer@patchew.org; Tue, 07 Jan 2020 03:49:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52171) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojQl-0007Ib-GX for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojQj-0000G1-B1 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:34 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:28727 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 1iojQj-0000FJ-70 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:33 -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-386-WLej38HRMcOCJ_2DwwJYbQ-1; Tue, 07 Jan 2020 02:37:27 -0500 Received: by mail-qt1-f199.google.com with SMTP id e8so1857223qtg.9 for ; Mon, 06 Jan 2020 23:37:27 -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 d9sm24344017qth.34.2020.01.06.23.37.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:37:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382651; 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=Z13KJ0vWOirv0bpEydzTz+1MhtfDLJdvDbH6dIjPp+0=; b=N0WEWC7rg3CV72ws4Okp7XTVdXmL15t30eTiSaiD0Tb8x2O0enqx5U/nB/f2NYTI/pY1+Q Xd7LHc8fdOa/IZix0vjl+k1tpjFsvB6lHygLdoO6v2ZzPdWpjRNhA7DTL2NtYR52AQoJdE nA13Zc62TCoesqg1CBHhL8xg+T0vxC8= 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=fzSk4nDQJOb6ecY+TCyTxG5Cc5pBBrBejXKsi0VExAI=; b=H3JXYT9s3a3mZlssh0LQ4pb9NUn8L1ApG7Qs8DsYUQHHKab6nEyrlKZ1kL45OjTsI4 4aK75XLKtduNgm1uW+NW4pBj7CVJoOjh37MzM/ZBJ7g8/ZzMMtjHxTGL4OL7ogRYxeR4 25KnO1N2LONtzpQ9W3QnTnoE43kOIMlzxbqIOKEdsldHBIJnVhJGStZwCTMRYetcBQLA sMgKx34YGqX72i8fQAwJi+2rC88c2BwwJDlBxL1jwku0YHWxwlPdK4ue3KDUsAtwDKIP ZFxOhkk8O7JSZHyotCSONkZQyfnED+U9yRpfPvre11A9fzswMWAHZ3/Qdc7ENtyGMz8j GWYA== X-Gm-Message-State: APjAAAXwi1v6p+bxtJQRtarMnQK6hj/wjP3/PC3ErM96WurVT9SG1VM1 Y2P+iRYKxygkLMCUhN4IXwN4GSdyTvJx47ojRRF1jsj4oTYGCGEUMTyJi3k26EUxtSagQcvqpJV bTGbyYgrbML3k4WA= X-Received: by 2002:a37:674d:: with SMTP id b74mr88918847qkc.396.1578382646805; Mon, 06 Jan 2020 23:37:26 -0800 (PST) X-Google-Smtp-Source: APXvYqwp8YcJm+o6+dy/0uRxKLdlpYKF3NZ68pi9pgS6YV2D8MY8zPwWps5HkJbNGph1g35cEDpbKg== X-Received: by 2002:a37:674d:: with SMTP id b74mr88918828qkc.396.1578382646411; Mon, 06 Jan 2020 23:37:26 -0800 (PST) Date: Tue, 7 Jan 2020 02:37:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 26/32] virtio: make seg_max virtqueue size dependent Message-ID: <20200107073451.298261-27-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: WLej38HRMcOCJ_2DwwJYbQ-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 , 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..4bc73a370e 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 %" PRIu32 "= ), " + "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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578387383; cv=none; d=zohomail.com; s=zohoarc; b=fmys3OJryc/rGrXtKef9LxAmIYgGZrb3ci8CgRQyQXQBXntImQ5ERL91jr9Ebu65mM5udlx8tDAbh/J4KA0WHMZPW8nQw2sf/k3/ccPgpxLHN4T+IrWoIe5wTmPgVRI4HL6AVh6NC7mMiDlFxtQDpbjPLfyCiVXzPrbFxJxu7Rs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578387383; 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=POVYfRx4kK0IhsQyzvmuWrQOARA0vzDYky2qKAHppxJAT1anhXz5/F2vj6UPV0a30MJTn6PA0GH/+0QgGl6B3r9XfXd/i7Dm5VaLwdht7wlN4D3iznthekcwqTVyUtw2WZvsm5ePh7FP5b0H2L+hEfEIsgxQz012breGuQEINlM= 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 1578387383756665.8224084036616; Tue, 7 Jan 2020 00:56:23 -0800 (PST) Received: from localhost ([::1]:44918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokey-0002SE-7j for importer@patchew.org; Tue, 07 Jan 2020 03:56:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52183) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojQn-0007Ou-VR for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojQm-0000Hc-62 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:37 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:60457 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 1iojQm-0000HK-2c for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37: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-389-PjGMBhgLM8qSql_lQMTc7A-1; Tue, 07 Jan 2020 02:37:32 -0500 Received: by mail-qk1-f199.google.com with SMTP id f22so11036141qka.10 for ; Mon, 06 Jan 2020 23:37:32 -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 d9sm24344120qth.34.2020.01.06.23.37.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:37:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382655; 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=VNLW0zzj8xuEaXdetn6pioUwsj0EZPXu1siovzjUBPk0DAOOE9XBnD6EhuYQR3WKcXwFmM vlWttF0ouo6cUuege3Yo34+6AnCYtaXIHZ4l9BVfJ3HdYCZVoaTXyqDNJfwn3pCKSqWZN6 +kWe8+Wf3pHJp7+N4q/U42iuyglAnRE= 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=KCHG2hJBQe0KXV9+Fp+1I7D8puybQvBbbZ8mLQUzsLaDzZZ8FVhHMZ3Nw8xbpZ7PTG VRojxEhUlWOlNT9paohaS+Bp982x8T7NOblC7LehCx14QyT/AqrN+zVMdGTF0uJziDy2 xXbgik/i5IRWftMkRjgyEfmBLDJBp5nNAyGjZtUZTIyODu3QypmCDkQUelm/Tw0m9YMb iYmILo3OdjfxvNuLDNQ7YX5e8f+xodKapqgzRNWjZfi/ht5QpRlbq9p9AwKTG7TmrRxi 8m/VXJMLTnQAsF5WHTDOSBC8TOqjll8XpumkRSi3TwgsSYqmTAYXljriHAUk99x4HyCh JCjQ== X-Gm-Message-State: APjAAAVXPZhJFPNgBM0rjJ9GuE+Na3h/szjr4REAbeOKRgD40HB49jmu 2sJlPSgDeyyhidmbRAT7YgsT38Wq83v9urTxZyx4neja3ay0Qv0kQLB4SII8HiQ5MjTmIkniVZQ xN6RxB9RNjoRfepQ= X-Received: by 2002:a05:620a:a02:: with SMTP id i2mr85645561qka.264.1578382651126; Mon, 06 Jan 2020 23:37:31 -0800 (PST) X-Google-Smtp-Source: APXvYqyJ6204VEsuvbO0n2PbiYzlsc+9g9qVZlBL39W9F+YV5smHEVhc6kuVKQuF7dYE8r7Gp2lHFg== X-Received: by 2002:a05:620a:a02:: with SMTP id i2mr85645547qka.264.1578382650830; Mon, 06 Jan 2020 23:37:30 -0800 (PST) Date: Tue, 7 Jan 2020 02:37:27 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 27/32] tests: add virtio-scsi and virtio-blk seg_max_adjust test Message-ID: <20200107073451.298261-28-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: PjGMBhgLM8qSql_lQMTc7A-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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578387269; cv=none; d=zohomail.com; s=zohoarc; b=JMjQFBTvdHz7WfU/CA0WhukhUXhqFwASg5Uxnb74wenXAQDD/eMLBkTyebxJKx+oRFSKB7Pqd6/jDvD7bqNl5PDrHNn2kp/OsJoIOwu59+qT8nj5SMu4yhrzMJEa36QkjN6dICVgzVg0Sj0gjOGUHSVwAZtu+m+MHPeqRAC/TlQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578387269; 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=cb8tA5xOcGbMtuTCGpEJQEoZ1VTanDaXOjVBw+s+QRiCqtu0DAF69FZ4jap85U437yYhq50q6x9y/E/rbfRPO9JOKG+BlS0v8kFOWX6aVeO4yqP13864OF+Dy27T1LJNN3WzGooii/qchPD/rZeM9xzzgCDpkM1GYzZsoXReV5k= 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 1578387269818655.1428808422414; Tue, 7 Jan 2020 00:54:29 -0800 (PST) Received: from localhost ([::1]:44776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokSB-0005vT-UD for importer@patchew.org; Tue, 07 Jan 2020 03:43:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52201) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojQq-0007T0-0T for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojQo-0000Jj-Lr for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:39 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:49227 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 1iojQo-0000JO-Iq for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:38 -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-293-1TY63rK3Mu-rjYGwW7Dh-g-1; Tue, 07 Jan 2020 02:37:36 -0500 Received: by mail-qv1-f71.google.com with SMTP id e14so6012498qvr.6 for ; Mon, 06 Jan 2020 23:37: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 g62sm21970507qkd.25.2020.01.06.23.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:37:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382658; 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=KnwMTUT/ayyCjRT9/F1OjAWgzc9bS1MFh1gX5FleiI2frAtBsNT7r9hUiIi1CaGiBt0ZPF lNQEGw9FI2h6HipH47B9wDyIHKplxxfAvvfTc9bs4U6RFn27b+Na+tys9QfhKxNNt4EJiM 24y9Ggr4d4BgSjRBrWtmLarMOF7zGmI= 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=fMB6Tc784QkPBIVsVDZcRVxvsSHhHngMsmInkoBE+UDjxR4V34D+SldNULYMlCR9ek 7nW7NJomDMIAgvoe3nSQ2tW2UMA7NVAIgUtZlZDa1022p6GqgOE0+KYS1aQlil7gsOdv pT5WcCZbi/JkDEvwSv+st70xfPGaSzOV9flKY9JsXxVX97jUhqHea50lAIWxj21+c/L4 0Nf4TwZkcp+yJ5a2x8rkuJYRZobpoV0P1VKAzdY/Er5d40Y3Sy8Dkr+QS9XOtScoFK4K YZ2420CxNiUGheGuYXOi+jSMe3TA+2slMXgoeyh/K6CfkOb1eEs/8nsibJfde66EVM3z pN7w== X-Gm-Message-State: APjAAAWxIPOXOVTZCFPvr0YZJK008tSArnxuf5QDfnLlwzVJ037xwMIH Dy7kqtGIVotfIycP3liL+o50QN5gUp0hn3RXOuyvygO7RER3wb2eMRgYPpjrh/blqypqUolfmQZ S6p27ryxcQ+VDRg8= X-Received: by 2002:ac8:1c43:: with SMTP id j3mr76672176qtk.316.1578382655130; Mon, 06 Jan 2020 23:37:35 -0800 (PST) X-Google-Smtp-Source: APXvYqy5QKrWDYKpdXFMExmNHnQzb+SllAW9n6qaWuM27WedOIDrFvFG5tLHhnUb8G37wskVZ3RO0g== X-Received: by 2002:ac8:1c43:: with SMTP id j3mr76672171qtk.316.1578382654978; Mon, 06 Jan 2020 23:37:34 -0800 (PST) Date: Tue, 7 Jan 2020 02:37:31 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 28/32] virtio-mmio: update queue size on guest write Message-ID: <20200107073451.298261-29-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 1TY63rK3Mu-rjYGwW7Dh-g-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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578386996; cv=none; d=zohomail.com; s=zohoarc; b=kF9K1LjHZx/3RKkMxasdWGT3L5DZJkFJs7KGO9mBLjtqSn5RKz3qb65kgGEQKL3+/+WvBn81SEZNnT7QbQ8XwGSFO57KeHxbEFxmtQhZTdVYChoqdDrDOOlhAhYfvj9NSZB3Y5AuPLPeeor2h/1m5TdwPzP16phMxgnB5ynJwII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578386996; 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=AXDnc+5FtPU/wHSMf2d4d5lZqNnLuDc/IiBk08k86OtCjCQQVtMjCxAhfugr8zPuYLi7UaVd8zLQI3vcaRsU9AynysepeAA7+D9GSVvhd008T2AU518i3jp8P3nclGxMXGDKr6+lkc4PbOiaqKpXZi8LVXkkL7taUeL9BTjh10M= 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 1578386996238282.2946572126425; Tue, 7 Jan 2020 00:49:56 -0800 (PST) Received: from localhost ([::1]:44862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokYj-0004rk-Fx for importer@patchew.org; Tue, 07 Jan 2020 03:49:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52223) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojQt-0007dW-Sv for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojQs-0000MR-6I for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:43 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47862 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 1iojQs-0000M5-2h for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:42 -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-204-NabluuqIOPupEz_Y4IMGuQ-1; Tue, 07 Jan 2020 02:37:40 -0500 Received: by mail-qv1-f72.google.com with SMTP id g15so29363714qvk.11 for ; Mon, 06 Jan 2020 23:37:40 -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 i5sm24521666qtv.80.2020.01.06.23.37.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:37:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382661; 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=fcG0G5RdjQZn0BM1EjT9CO2vJXyEjD1ms5AwMgNVmyvMyWF8wjtnAHDK1oKXIJoE1U1Cm4 a8RpTes/ruuY8isy7uwdv4JN5yP+m6HKDH44lvmkDpIDQouJwiWVc6e/tym0X2F0EKL4P9 E02P9CYy48SSMK2BzvWw9LWrkkXkFvo= 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=o99HeBRQ1Hx5WlFXv2hnSrq1SrqL6Vx0NMSeGqhb67Zi5trEw3xu7rRyN69jEA7cl5 WCY/l2rbtvhNBQnsN0VRUgfT9KSGw6el06QmLZJLv5d0qzaf8H8ayRgHEZwn9Mg7eyZ7 seQgvbqFXFD2rpeYcKuLNzjAQpYm7L3LDVS7h5My8XAhaZNFtwL2mi798lGnNvuUQ12a 6qUNNxo9bMQxCQtfLOakQZpejUM4EyX29+Avdad5V8RzeU3g8Ya6KpMoceqpSrRR+ROz OIwbnBo8DJbW7LQpP9GkLwssGc9DlHZsZvt4ghlDcgNPtuRxO8VDgEEQdfgC6pOrqrp0 5T7Q== X-Gm-Message-State: APjAAAWq+PqhvLqdILcIreGbORl7nIP1ltMR2bY43n6cvTyqi8AEzsjO IywdvG0Rlq1stdvbuRqsTI0NIIIqApc2NcgYw4H8Jhu2M2KLuSWnCV8KEa7txQEF+9yiHEDYYyV Tln8MkGayYtdpcpw= X-Received: by 2002:ac8:5257:: with SMTP id y23mr77909428qtn.88.1578382659641; Mon, 06 Jan 2020 23:37:39 -0800 (PST) X-Google-Smtp-Source: APXvYqxcUQfprY/T4508lENvp8oBfEOEzWlLY6q23kLzPLB+gdUaLOioi+0xbGUCJ7iqUqW8Fj7d6w== X-Received: by 2002:ac8:5257:: with SMTP id y23mr77909422qtn.88.1578382659494; Mon, 06 Jan 2020 23:37:39 -0800 (PST) Date: Tue, 7 Jan 2020 02:37:35 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 29/32] virtio: reset region cache when on queue deletion Message-ID: <20200107073451.298261-30-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: NabluuqIOPupEz_Y4IMGuQ-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578387393; cv=none; d=zohomail.com; s=zohoarc; b=WjHLQtaIsfoWMOzbah/rLTJKPjtfr9bI1hr1A8xecuD0Z7/E8yazH82Kk+sUyvJdU3U98n/azWL4QkAicy8TrOPQ1O76v6QiGC5HCgXnynxna0/lgqRPqR6ebUabGJR1VWD0z4OR+KhZaY0awYuX3UNyC+1Zt7pSaMFYrvGDvt0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578387393; 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=BXrCrk+8pV5g3goljs/obUogNyo0nrFgYYhNN8sbcrn95N2Njttat88yJaoQLqKETgY3Rlt0x3VM0mZt9JZ1WHt0qEV4PZOCaef/hnJzpxYO4miC6+Vh/vkQoBTKrmFLj7OfYbp/fpI4K4aVygv63L/5ZG41LhDUOwrcvAYU4P4= 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 1578387393143238.93516248953097; Tue, 7 Jan 2020 00:56:33 -0800 (PST) Received: from localhost ([::1]:44922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokf7-0002z9-I5 for importer@patchew.org; Tue, 07 Jan 2020 03:56:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52253) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojQy-0007s8-P3 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojQx-0000Qv-HS for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:48 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:30856 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 1iojQx-0000QV-EF for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:47 -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-308-p44CKW4mMgS9BL4wCQ6dFQ-1; Tue, 07 Jan 2020 02:37:45 -0500 Received: by mail-qv1-f72.google.com with SMTP id e10so5028767qvq.18 for ; Mon, 06 Jan 2020 23:37: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 186sm22061395qkm.93.2020.01.06.23.37.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:37:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382667; 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=bDGDxwYxjgq1328Mz46Yrp2hhwQ89NsGHwJ1x1hw0a1YtCZp2ANgGSQSrOPwx9Yp5Na2v+ 5TIaTeI1lv+nsv5MxNe9h3qylQqfZzh9zz7tH+i7M1S65KExkRonM3s8pcWnUnXjFTgg/2 ppEPResQ1/mQbZuFu/9Il2hoJJl072Y= 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=fAWLH+/kc3cPjrSKMp2sN6eh39gCOc4viI1hAW/3JPBnNl03kyhbDc2lE3eOxFZHq5 46Da3CGZEt6fxgwKJx6HTv/CLD2FLr5CCqCD6mP1/bQp9bvKVvctzzFgY3U/maT2ms/K qKDDpm0Beyo9HdCbxd+O/GvCAwFZEz5IK7YoU1CIr2hiE75F/Y5Sb+YrcAUWZIlz3f/C LzBk4jq0RJfq18x6KESpXmVcEMizEeOP1DXE6Z8oh/y6YFV/0hsh6OIkqPy/a31nbcIl JYRc0kYj8jtc6N94lgMA2uAIuAaBhuC1F2evlzYqD0Oybj9ZoEo9qqVpXz9v+yl01I1m csHQ== X-Gm-Message-State: APjAAAXz9rCodn5yCv1HoY+D2oWQBN1sQ3F8k5QzSx5EHkqQrBbhVxyC gdiGLa+9uOFGj3AU25Yj1yRSXHKP6dhbjjl+YCcsNb90ZiWNDTypJbOHt429c9S4P02QVrqN6bs FpcnuxiPZ9p6V56s= X-Received: by 2002:ae9:eb56:: with SMTP id b83mr84984609qkg.123.1578382664490; Mon, 06 Jan 2020 23:37:44 -0800 (PST) X-Google-Smtp-Source: APXvYqxkxVXy8Z6rbJqWbSG3GqdciP9jGj9AX7KTv1EPoDdYvT9CajzD+HKFvSQ0i7kK3JHCoK+fIw== X-Received: by 2002:ae9:eb56:: with SMTP id b83mr84984601qkg.123.1578382664283; Mon, 06 Jan 2020 23:37:44 -0800 (PST) Date: Tue, 7 Jan 2020 02:37:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 30/32] virtio-net: delete also control queue when TX/RX deleted Message-ID: <20200107073451.298261-31-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: p44CKW4mMgS9BL4wCQ6dFQ-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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578388496; cv=none; d=zohomail.com; s=zohoarc; b=HLffSGAiZGtcC2eg0ZNMrxRHPBnRFOR5ROxpcJKeTmDTaSm2NfOyh4e1RlV3JppcS5/GmJPz081S4Phh1ZkMapsMaUQB+hMY2fYh+CD3YAu1zo+AK7Dm7MjK0av5eRnvDwMiN4ETH9iJYS5QCqy4liu7mhwiMJLlwxIMLAlE2Kk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578388496; 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=SpTiyYE3PlOp2Ck1px/5iPWYpNR7L/AUBGmFy5M5BnkKY1TWbizfpN7H6LTpW0Dl9L7LzAqeyzU8UkLPfS7QpS3yn9xHD3Kptb2yvVFI/ifC0n1WsMMVgHf3jBJQKl952gAdhxDtz4PXFyFugo7M+a5bc502OawrlaJTE7JFP58= 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 1578388496747601.7835745346763; Tue, 7 Jan 2020 01:14:56 -0800 (PST) Received: from localhost ([::1]:45116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iokwv-0005HL-F2 for importer@patchew.org; Tue, 07 Jan 2020 04:14:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52271) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojR4-00087R-OS for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojR3-0000UA-D1 for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:54 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:46338 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 1iojR3-0000Ty-9U for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:53 -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-364-9xiM6zbuMO-cKVfxZz6BQQ-1; Tue, 07 Jan 2020 02:37:51 -0500 Received: by mail-qt1-f197.google.com with SMTP id o24so30926973qtr.17 for ; Mon, 06 Jan 2020 23:37:51 -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 x19sm24688703qtm.47.2020.01.06.23.37.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:37:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382672; 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=XklovNJUDxm3oN1jFm4oY7G9eZKkSf2RydtN+8cJrZnCzS8lUEH9NQv1zkwJJ3zJ1Bg9yv NH89VpdKhWl0SOSMpSLphcwSIACO0E36+IQ1sA8wWHP87E+RGYpObKJEDvKKWrc0/qg16j 55ptChwUUuMcn07Ok1xGu0MGZr+J1UM= 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=qWjBjIuvLlKodFuc/x9DwNfrEZzYCvtDavzefzhOKdkuP3U1z2h7cIrc4ZZAE09PMX POIuX/cMOOe1HnBAiVr8pkdmBLzNqATEFDp4N9ERZpw/xZZCeLCjkSFvrlsLSEYLsA3o lXLkrH7RL/bxP3badkRnNtRdBsAoJ3y/HBHNG61Zsg2BGDByQQuQZe1Ut/Ukyi19sZRc Q1mvybtcWl+ZHIjxWIplM2dhUGwcbjRjuSUTuDFxhi3yOjvPpJcZ6BvwgNTfRwcu3+sm TK5lgmt4fnWc7neRse1W3zxsHE9BM4N1Fz5VKVgepDFivuJ2DemT7wiRy3lBmRg3I2yn I/Kg== X-Gm-Message-State: APjAAAUKGgdIbxZwbc6cNtHiUssN/14IbKeCE/86eLQ6/TPzXOFFPqHQ d6O1fl/8wVgKiJjS5dt3W1PdiUdTVidazxLQ3uMYPAlaWHFNF+ytryKsAbvcFtm/Q14aN7sryBg 4yWsnCegu+iBCogk= X-Received: by 2002:a0c:c542:: with SMTP id y2mr8192839qvi.225.1578382670544; Mon, 06 Jan 2020 23:37:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxgYOWgdZPNRKFI/m8rAelRQ8xkjuX4GuLjRjJZ3OrZEWiR6go3CWQki2q9x5DhlL4L0NsH8Q== X-Received: by 2002:a0c:c542:: with SMTP id y2mr8192821qvi.225.1578382670343; Mon, 06 Jan 2020 23:37:50 -0800 (PST) Date: Tue, 7 Jan 2020 02:37:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 31/32] intel_iommu: a fix to vtd_find_as_from_bus_num() Message-ID: <20200107073451.298261-32-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: 9xiM6zbuMO-cKVfxZz6BQQ-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 , 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 Tue May 7 08:16:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578388965; cv=none; d=zohomail.com; s=zohoarc; b=bs+S03+z6k1t/+0Mwj+vly6CDBatn9VtQji3iiU0N2vRQ/aZQnKMDhxxPbV1kfYs8Z6kqpuqTQcHZV3g4wekn/tpr5lSCRgDDN/DgdPm6QXaDui0L9BwGzR3RJSXzY9nhu1Tn3IJf0ooR2BXLKJf+wk92qOtGqJvjmrZLutffW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578388965; 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=UNJ07a8aiRr8zyIxwHrbPq9u7ztFiPW/ST9wXmtSX6sfx8NH4ADP62txDjoTUdYE7VJrXJXq2i+/937T6qmjtXf7M/ZoyZM8t6IKftS/RhWLsy7KttbAaK6Qv7pkb3fkH2aGVwtjzevFHQXwEaMss8+4luS1O7A88MIMz//3XiM= 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 1578388965659308.62870568139806; Tue, 7 Jan 2020 01:22:45 -0800 (PST) Received: from localhost ([::1]:45184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iol3O-0002fG-9v for importer@patchew.org; Tue, 07 Jan 2020 04:21:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52305) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iojRB-0008QO-Dx for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:38:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iojR9-0000YH-CJ for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:38:00 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51008 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 1iojR9-0000Xp-8i for qemu-devel@nongnu.org; Tue, 07 Jan 2020 02:37:59 -0500 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-129-lwJJX_C6OtGlEUbSnBzPFA-1; Tue, 07 Jan 2020 02:37:57 -0500 Received: by mail-qk1-f199.google.com with SMTP id 11so1073650qkk.11 for ; Mon, 06 Jan 2020 23:37:57 -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 206sm21934715qkf.132.2020.01.06.23.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 23:37:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578382678; 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=IRFpRRJOx2UuFDJnUz+gpbX1sIQa/UcpvW3Mov1GoAhPjik3k1Dcl54iqAoyBBMtV+HieK SFO1k00h+LVY4UkhD+oCutwoxVLkxqogePA/BlKt1yaEFpIGgkBuhofF+n578/ox9OE8OK 6+Ek0Rn5weEvyY1p5RTG1xeEPBfZsSI= 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=OAsRnBzE89EUQ8kNL64U0f2Z1vryGUsrCtA+CWGU0HTgYEVvn3b8XQQORuccUR5j+Z UdhLt0xf7XJxDZbhd58l4qSgc5c5hjAFIg1xz7YPVIK2kn0PRxNJmFM8YjH3qR7RHSYi hQAhkhkaMDyntA6C8vCL2gUx8GcCjtQOgOSzOTiOHP5HoVCSqLSA+GqzD2ZCHNWP9eVD qN81F8FiAudMMXM4/tJ8MwWnEmY8Vnn9Knq84WPSzqDpGI48swZ4r+75cR5s9kL/mUr2 xXtbNxYhxRcHnpv3zrddO1ju7Xw8e4YUyts42kaceP0p0AnlnhmpSLVbYYkB+ZP/p/My DywQ== X-Gm-Message-State: APjAAAX0W7hudEMHEXaahU+sVFYysssbFuHOnXe0ZZi1f+Y3VHUpkJXM nkZzbqGbTOcqYl5VrmY2/o7ngZBMtQADFlzCrZDzC9+ZfudqAZLsJTcv9fAUJZqhoYaiHsGAK/Q qXvCVm4kgxnj2dQY= X-Received: by 2002:ac8:fae:: with SMTP id b43mr77177632qtk.122.1578382676810; Mon, 06 Jan 2020 23:37:56 -0800 (PST) X-Google-Smtp-Source: APXvYqz8h5b/WEK/65xUI9oWNKNah/cUPsqlWkg/0sMJ1AESErN/KqiQA4BhfkOw10NqINfB8g2Qxw== X-Received: by 2002:ac8:fae:: with SMTP id b43mr77177614qtk.122.1578382676608; Mon, 06 Jan 2020 23:37:56 -0800 (PST) Date: Tue, 7 Jan 2020 02:37:50 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 32/32] intel_iommu: add present bit check for pasid table entries Message-ID: <20200107073451.298261-33-mst@redhat.com> References: <20200107073451.298261-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200107073451.298261-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: lwJJX_C6OtGlEUbSnBzPFA-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