From patchwork Mon Dec 23 16:42:27 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: 182413 Delivered-To: patch@linaro.org Received: by 2002:a92:a146:0:0:0:0:0 with SMTP id v67csp657319ili; Mon, 23 Dec 2019 08:56:17 -0800 (PST) X-Google-Smtp-Source: APXvYqzVp1n1CNzysv95HiYhbNOis3tirG7rvHG6jQSfdgEnKx6Ctbw7atdxGeJJjVVKPWtPUebw X-Received: by 2002:a0c:ebcf:: with SMTP id k15mr19760427qvq.217.1577120177028; Mon, 23 Dec 2019 08:56:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577120177; cv=none; d=google.com; s=arc-20160816; b=bLWvAuHrS/xzwNInSz5QGQiaPIjJiW5Kysj3eKt2K4Y0PVe7GXGFwKX9sp5P+Z1WqZ HRaZ9jQrh+In+MrFp86sCM+gTkBNXLJwnUrKiffALgBcIp7XiV3FJDghMNYqaXKVk4dZ 9HrzMwSh7FV2NwcH5FzcBmG5fkoFPVYQ+cPaalicQy/iF1UKzo3FGetUXAgAKYMs6Uy/ 0tUthYXR5LK5dT8g/KrLHsqx9AOLd8xuZrwPWrI8CUU1IwXqbSxdDahdEaRJjY9NuJLq PrJA8VglDaMlW2NrRWUoziO/ekFAFpjk7atP7gKu2wp65EpNHFcIOzc9yH2aVmpnE6Wj AnrQ== 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=DQfwZjhQQH80BJMK6YU4yYZlZssOjyQBZf1imqLxURSDPqxrAT+G1lTnEFQxUf0qGi t2bwcfILObcGij2HSrS9lICcGq6VSMvmFPILhxRPt5n+FzLurmnA/jxVwZBn2Xra7xeT TZ7xbRmgwl2TGpPcnyIzV8dNxe461IzJ2H3I492NyHnITj4BMqCBt4jkMCV6oaYeeurV bHa5I7GxTO8MB8mE3J5rtUKdvW0zFY79RND1awjVPQjqmju26NQnPKy2lYoCuTfDUDZu XnzSmvU5u1bv+2Z+H787RzmJ2LRmsKicbQZ3RyoWS3mfHArN1dOXAKD2jnWCIMHIORTe xERA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=MvKf8mhd; 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 i144si9108683qke.199.2019.12.23.08.56.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Dec 2019 08:56:17 -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=MvKf8mhd; 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]:58942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ijR0C-0004W2-55 for patch@linaro.org; Mon, 23 Dec 2019 11:56:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41603) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ijQmx-0004um-Lz for qemu-devel@nongnu.org; Mon, 23 Dec 2019 11:42:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ijQmw-0005fd-F4 for qemu-devel@nongnu.org; Mon, 23 Dec 2019 11:42:35 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:31952 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 1ijQmw-0005fW-AE for qemu-devel@nongnu.org; Mon, 23 Dec 2019 11:42:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577119353; 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=MvKf8mhdtAVS1YDci5jzkmolEDoLljx6ImgTYT2W1WWb/us8t8gx7L0+fPcNy1CDW6/N6G IzvwmU31/Ym88Duy7ExaLRj25v4be0TrZ4k5juJEM3olGq3h7+SY85ONUXBWJWPpzdTDJ0 jAjdDgJ+VQLUF9oLBZeQkLf4wGl11xs= 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-55-_H6PHU9xN1O2uiYDMDvANw-1; Mon, 23 Dec 2019 11:42:32 -0500 Received: by mail-qv1-f72.google.com with SMTP id z9so7330438qvo.10 for ; Mon, 23 Dec 2019 08:42:32 -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=IYYKEyDbxuqT/sbb5UtOBlio9PlGnSQNSZzUvgpoDkwLZuW/KlBON7aKFH2S0omveN 7fOSgHB2ZLrGcbnUyJDPKngfrJ9+hxLgkZB1vTHx7/7XmO65TRwPJI7B+8POuKUQT9wW II+HtiFeAi7hhCl3dR8UlsrNcQrvjXC/VgBVBxc+OMWleAZX2CxW7E5hmbLICKic1kDm TzvKrCIMcD+NgusSLqg6w543qumj06OwJxFgv6hmd8iBd0hbyAoubYJwid2FdSaqmzfl Z3sHddaR541gnQmxGHuY9P/2EYRxEXjRm2PlW1aKc0kPTyIm01I3oxCkoL1lRa8kw/vO 6icg== X-Gm-Message-State: APjAAAXpvASqtjzFB/ePREJ88VH65PCCaKbM1a7ki2GdZdx4plzGF2jV thgDdrluQdrv5LeY4NcOa/IvckpPhJCBCxOR3kXK9Ktp0/EMpKrJznVlrrShg0QZKJ4K9W6lARW PyXw7lrmTVd4VYok= X-Received: by 2002:ac8:328a:: with SMTP id z10mr19131609qta.355.1577119351673; Mon, 23 Dec 2019 08:42:31 -0800 (PST) X-Received: by 2002:ac8:328a:: with SMTP id z10mr19131601qta.355.1577119351494; Mon, 23 Dec 2019 08:42:31 -0800 (PST) Received: from redhat.com (bzq-109-64-31-13.red.bezeqint.net. [109.64.31.13]) by smtp.gmail.com with ESMTPSA id u4sm5838216qkh.59.2019.12.23.08.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2019 08:42:30 -0800 (PST) Date: Mon, 23 Dec 2019 11:42:27 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 20/27] virtio-mmio: Clear v2 transport state on soft reset Message-ID: <20191223141536.72682-21-mst@redhat.com> References: <20191223141536.72682-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20191223141536.72682-1-mst@redhat.com> X-Mailer: git-send-email 2.24.1.751.gd10ce2899c X-Mutt-Fcc: =sent X-MC-Unique: _H6PHU9xN1O2uiYDMDvANw-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.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 , 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: