From patchwork Thu Dec 19 13:28:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 182114 Delivered-To: patch@linaro.org Received: by 2002:a92:d0a:0:0:0:0:0 with SMTP id 10csp502232iln; Thu, 19 Dec 2019 05:45:07 -0800 (PST) X-Google-Smtp-Source: APXvYqygVKvZI+jrzM+gapq/WbuJYE+paqvKSWD7tRw8SpyaztpMvr8mGJLXQWcldQskrHl6JQK5 X-Received: by 2002:a9d:7e8c:: with SMTP id m12mr9235059otp.346.1576763107803; Thu, 19 Dec 2019 05:45:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576763107; cv=none; d=google.com; s=arc-20160816; b=muvmxp/Xo92PVbSsB9i5f19buAhlcWi830wAuldE4N+wFh7+R8YqXS1Znp75v4Dylo t7qpDaO7snTsQuOS15rGLvoZZR5SvvjvR6KNTTSQfZOMIgVWWYf15vq4T1A097cvD9Y3 SuRU6PRADE8GHtQpZfulatwhyxehuJq57Vh2JKA+WjzPtyWTHtjkxSh1tV1Zqr4W9Rs8 h07lLYkUFhelHHb5n0+4IygQY6KrPuu5lEpdJT+L1gnbuOLytZ8EmsADkHdhQTfcSoCe 3r9eczllh/5CPxD2J+NwQZThS+RFTQC0/NfNQpZ5L3hZRoxPmHPy38zdW/PTKqj9fSEK 23zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :content-transfer-encoding:in-reply-to:mime-version:references :message-id:subject:to:from:date:dkim-signature; bh=75DSOPWG53BQMc2DQp8pZrGaf6WLAio2xZatEQc8yH4=; b=f/LrBBA9LF51pqoKHlmwUD6YRLlpv8JRS6XaJcR0jsYGim5qFrk+dVM6R/J4/RkPS7 jvvVYg0UByaGdRaCYsn15uDLVMsdcsMUoZGOuJ0U1dAlJvlUA/aa9CZf65LX96crgNHV VO6OR/ZAnAu+rQFjbYpgM+qT1dlJ4JbKYHzFVRnsyb9DqV0ehIj0VPtlHyI3o9dZbGOm TtTqkJqu/qO7VsvHlyrzsKR4P9cFpRylNtTo/A9/90QcvXyxR5BKuDcFTfhAq94JRd9G b3f0ioXlq+xVKBePKnqje1lL8gcSNcCd6Sjwx7HipP84p5haNIDWW0kS1AgY6I/eg8Zb nbDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=bCw93670; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v26si3381142otj.0.2019.12.19.05.45.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Dec 2019 05:45:07 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=bCw93670; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:41764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihw70-0008Fz-Ml for patch@linaro.org; Thu, 19 Dec 2019 08:45:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59298) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihvrI-00038B-Lv for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihvrH-0001At-7m for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:52 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53709 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihvrH-00018S-1O for qemu-devel@nongnu.org; Thu, 19 Dec 2019 08:28:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576762130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=75DSOPWG53BQMc2DQp8pZrGaf6WLAio2xZatEQc8yH4=; b=bCw93670+cKN95kV1tGrsJIdEP+XnOy1/gNZgO9cOSY/UH93ZFIYEZxcxjyUuwfjKIsBJB JoxEkQoDOYubQikQBvpz95cdtaQ0zrx2kzsxEHyjjXFhksDrvR204bBnEPqECUXdhdYhOq FCTBgCP8nXlHy+H2+nHfsUUQ3QQJbyk= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-329-qT_j1qUPM5aF4VeMou0eBg-1; Thu, 19 Dec 2019 08:28:46 -0500 Received: by mail-qk1-f198.google.com with SMTP id n128so3603113qke.19 for ; Thu, 19 Dec 2019 05:28:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ilfUa7pwbD2DsrhFhXRw/VkM07xbn4jtSmYjKOWR/YA=; b=Ef7bBZp6vnpmW+e4AlJ9Odhx5bwo5T4ep8DpiUCufhmWyxmumdBsX9zvaSTwtkAvJ8 3vQvuc2O1ZPHcKgLxsbgcvitHSShCXF5SJV/I18efDXI60Cs0FeQKfhSSPT7CWAxDA/t jezBngeGhti46yQrrH2r2JXBFJ44vGgF8kTMsrIMvrpnuF31yzaBV8L6L7LAlyxwJtEy yjTRVyDtiki+ZO/0r6a2/DP9jKhw8HGdvOpbymskcBwhQERyS1tchci7dgu7SQl0fDB4 5OYycfGwt3yOBynx3p4kBPeSLhCnb7DZIwYY526aLFT2cMYaYn8ysnR3SzbjVyau7An2 TRPw== X-Gm-Message-State: APjAAAWSz62qSNRDQM2u4aNWjGSuqYouNZiOEMvodnT1rjG7YZ9d2ABX SlSDQ80QqTm9wKcig+1l7v7Twp4f86/bagIuAz6dByK4zeNn7ZKlfQSm64Mb5LFXR8++871GCLR bMBbzO5/Y467rjow= X-Received: by 2002:ad4:59c2:: with SMTP id el2mr7209425qvb.152.1576762125891; Thu, 19 Dec 2019 05:28:45 -0800 (PST) X-Received: by 2002:ad4:59c2:: with SMTP id el2mr7209407qvb.152.1576762125640; Thu, 19 Dec 2019 05:28:45 -0800 (PST) Received: from redhat.com (bzq-79-181-48-215.red.bezeqint.net. [79.181.48.215]) by smtp.gmail.com with ESMTPSA id i6sm1707884qkk.7.2019.12.19.05.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 05:28:44 -0800 (PST) Date: Thu, 19 Dec 2019 08:28:41 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 20/24] virtio-mmio: Clear v2 transport state on soft reset Message-ID: <20191219132621.16595-21-mst@redhat.com> References: <20191219132621.16595-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191219132621.16595-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: qT_j1qUPM5aF4VeMou0eBg-1 X-Mimecast-Spam-Score: 0 Content-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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 (virtio-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(+) -- MST 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); } +static void virtio_mmio_soft_reset(VirtIOMMIOProxy *proxy) +{ + int i; + + if (proxy->legacy) { + return; + } + + for (i = 0; i < VIRTIO_QUEUE_MAX; i++) { + proxy->vqs[i].enabled = 0; + } +} + static uint64_t virtio_mmio_read(void *opaque, hwaddr offset, unsigned size) { VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque; @@ -378,6 +391,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, if (vdev->status == 0) { virtio_reset(vdev); + virtio_mmio_soft_reset(proxy); } break; case VIRTIO_MMIO_QUEUE_DESC_LOW: