From patchwork Sat Oct 26 19:40:01 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: 1184850 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 470s6L1VGpz9sPL for ; Sun, 27 Oct 2019 06:50:50 +1100 (AEDT) Received: from localhost ([::1]:41780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOS5I-0003e9-3m for incoming@patchwork.ozlabs.org; Sat, 26 Oct 2019 15:50:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51187) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iORuz-0001Z5-Br for qemu-devel@nongnu.org; Sat, 26 Oct 2019 15:40:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iORuy-0000ZS-7w for qemu-devel@nongnu.org; Sat, 26 Oct 2019 15:40:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38376) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iORux-0000Z6-W0 for qemu-devel@nongnu.org; Sat, 26 Oct 2019 15:40:08 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30BC883F45 for ; Sat, 26 Oct 2019 19:40:07 +0000 (UTC) Received: by mail-qt1-f198.google.com with SMTP id m20so6313472qtq.16 for ; Sat, 26 Oct 2019 12:40:07 -0700 (PDT) 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=KP66ySUJcxSFVWfRvNJdHRlnkYPP/qKoNHIn6pXPGCo=; b=LzKgsb1XOCKtwLhzhzSKOY3ytLyexNcVrlr3Ip984/6r6qjLywT//5tKuyS1L8rbk6 xqNpogPlfhSAAk82uKkaElFGAWa0/nqkcdK1C8irCYqD2W3dqp0DV/EWMD140exY46wf jG84/I3CP24LLBovZJdWlYnVemYumc6u11WBNrPjUcwOVjpv8de40YgBMjLWr7w4FKMF GBxkL/Jyb/1mtvVocn/uECGvqTuiUa8mHM2k6+W2ZiWTWfjvDO5oMWXH9nr46Nqzd3wA XGfYsvbCCC69CNkGPEO7c8cyl5UeG5ByR0hvtGDDaD0yC/t2mJZp3L6mbw+L2Kd3GDEM AhUQ== X-Gm-Message-State: APjAAAWDmG/uYFlH9tJBQg4gT7uztLg83lXuBqVKFezZ8JuHj0MiNCKG /THlud/Go1CRUXmdBK4F8Bl73ZIiQ3A5LZy08S1c/GdjYwNYcZ4I/uu16G6IlQOr0s/BDoKY0pI 97OQndlDxzUR9J2s= X-Received: by 2002:ac8:6b0e:: with SMTP id w14mr4574780qts.238.1572118806033; Sat, 26 Oct 2019 12:40:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFExXTE3s0yO8K49hToexbf73mp7QuQ5BpDP4CEtutac8ORrJHLADBiPBFBsngqldC1VPAJA== X-Received: by 2002:ac8:6b0e:: with SMTP id w14mr4574774qts.238.1572118805861; Sat, 26 Oct 2019 12:40:05 -0700 (PDT) Received: from redhat.com (bzq-79-176-10-77.red.bezeqint.net. [79.176.10.77]) by smtp.gmail.com with ESMTPSA id p59sm2845525qtd.2.2019.10.26.12.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Oct 2019 12:40:05 -0700 (PDT) Date: Sat, 26 Oct 2019 15:40:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 10/25] libqos: read QVIRTIO_MMIO_VERSION register Message-ID: <20191026193824.11926-11-mst@redhat.com> References: <20191026193824.11926-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20191026193824.11926-1-mst@redhat.com> X-Mailer: git-send-email 2.22.0.678.g13338e74b8 X-Mutt-Fcc: =sent X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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 , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi There was no real virtio-mmio ABI change between Legacy and VIRTIO 1.0 except that the Version field was incremented from 1 to 2. However, QEMU does not allow Legacy drivers to perform VIRTIO 1.0 operations like accessing 64-bit feature bits. Since we will introduce 64-bit feature bit support we need a way to differentiate between virtio-mmio Version 1 and 2 to avoid upsetting QEMU when we operate in Legacy mode. Stash away the Version field so later patches can change behavior depending on the version. Signed-off-by: Stefan Hajnoczi Reviewed-by: Thomas Huth Message-Id: <20191023100425.12168-3-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/libqos/virtio-mmio.c | 3 +++ tests/libqos/virtio-mmio.h | 1 + 2 files changed, 4 insertions(+) diff --git a/tests/libqos/virtio-mmio.c b/tests/libqos/virtio-mmio.c index d0047876a8..7154b03c1d 100644 --- a/tests/libqos/virtio-mmio.c +++ b/tests/libqos/virtio-mmio.c @@ -223,6 +223,9 @@ void qvirtio_mmio_init_device(QVirtioMMIODevice *dev, QTestState *qts, magic = qtest_readl(qts, addr + QVIRTIO_MMIO_MAGIC_VALUE); g_assert(magic == ('v' | 'i' << 8 | 'r' << 16 | 't' << 24)); + dev->version = qtest_readl(qts, addr + QVIRTIO_MMIO_VERSION); + g_assert(dev->version == 1 || dev->version == 2); + dev->qts = qts; dev->addr = addr; dev->page_size = page_size; diff --git a/tests/libqos/virtio-mmio.h b/tests/libqos/virtio-mmio.h index 17a17141c3..0e45778b07 100644 --- a/tests/libqos/virtio-mmio.h +++ b/tests/libqos/virtio-mmio.h @@ -40,6 +40,7 @@ typedef struct QVirtioMMIODevice { uint64_t addr; uint32_t page_size; uint32_t features; /* As it cannot be read later, save it */ + uint32_t version; } QVirtioMMIODevice; extern const QVirtioBus qvirtio_mmio;