From patchwork Mon Mar 7 10:01:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 548861 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp1544951mag; Mon, 7 Mar 2022 02:12:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjJP8dQIxtRsFE0N6K/x0JQ8x0UDjokzAC0iuwPfeldyuwqtZhurBWOZxLvpbTJlxzQ2qO X-Received: by 2002:a37:ba07:0:b0:47e:15a4:231a with SMTP id k7-20020a37ba07000000b0047e15a4231amr6333075qkf.472.1646647964617; Mon, 07 Mar 2022 02:12:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647964; cv=none; d=google.com; s=arc-20160816; b=jlOBo65fzed7/NQxvuMWAg0y7GJzghzzccf64iZBzgOiBUJ562atYcCcMVdndZVfDq ZbVMP3ZbJoeMOKa0zUXIFY1g0g0BMrcqfdvemDeUMvuo1ER5nTUCEQPNPaY02II9NgWm oraMwmZ9uHs3cdvFZinkja3d6p9CXMGq1Iuft4kKnnUpCFcBKozgM/xOqPD5097NwpMJ yI6iU/0LnzX+TIyKAi9zmM//ITwm90flIkGHDu0KMK0KXZHY+XIYamBY2TXsB1aNJeB3 CVVnZPCC6vZaz8rQa/hxdpIXE39dp/cd/gCuK0PGYNeDYg6MwTbahuBZWlRP85um0r4T s8VQ== 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-transfer-encoding :content-disposition:in-reply-to:mime-version:references:message-id :subject:to:from:date:dkim-signature; bh=xYUjGCjqDKAb5NDT97RnxRdsQlEA2CnL9zsqzwpbiAQ=; b=Z98TVX7SUeVWD21gD6ewyE1YtUC4X6CUuYnHY2PbOtK9T7xs3ThSxRk9r47z1WlxcN CCaX9OfNYop5ie8pC9UkKD5HZWiwizhwsKuXpqd4v3myDJmJlo2D4ltPQ0AkZWTmoy+q IyOCqbLiI609AWJDDcOT974grbUHuwRoTOcMPd0ZXGZoX1jQAF0IFlA/FlV9nTwdA/r5 uBFnHcHheIdvaYteSNcQLVlqC8wFoxKyH4w2i1c/UTedPc6j92zLGBI2uSx+cu/o8LUP +fI5xgM60mYaTB1XrH5gzwzuf6YfIqKqecxpjTaa+9UoR7Y/WHt5fPa3CbFMRBTFhCYg 2Ang== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=eoPD3Ro9; 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 u20-20020a05620a121400b0067b31aafbddsi607582qkj.127.2022.03.07.02.12.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 02:12:44 -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=eoPD3Ro9; 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]:47328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRAM8-0001Ee-7o for patch@linaro.org; Mon, 07 Mar 2022 05:12:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRABs-0000UD-D2 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 05:02:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28152) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRABn-0002hT-AI for qemu-devel@nongnu.org; Mon, 07 Mar 2022 05:02:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646647322; 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=xYUjGCjqDKAb5NDT97RnxRdsQlEA2CnL9zsqzwpbiAQ=; b=eoPD3Ro9b7e/OA2V/jBSK3E9cMcgKWOh20hzU8RyKvQFB8k7iNSDguKI4F0o9nLRjrkUXa QwptJfxYu/JsPfF4v1Il3zD6WQwlYnq8CLZ0P0MEI1SFQw+lMBxBw4hykUgL4/gLynNYls 04z6I7TUvkKT7GCISGEmEI/Cg6rKSHk= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-184-8LRMnF3TMMa8IFvh4cubZQ-1; Mon, 07 Mar 2022 05:02:01 -0500 X-MC-Unique: 8LRMnF3TMMa8IFvh4cubZQ-1 Received: by mail-ej1-f70.google.com with SMTP id le4-20020a170907170400b006dab546bc40so3492319ejc.15 for ; Mon, 07 Mar 2022 02:02:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=xYUjGCjqDKAb5NDT97RnxRdsQlEA2CnL9zsqzwpbiAQ=; b=kYrs23zC9N9pJK2p51C3pZw5sxhTe9ffTNLYv0ngyGZ63RC7QD5a+KWZF+0K6gXsjQ nwgTGD2UZl3qqIfTCCy3o1jdquj2ZYIQcNfNJWXzmD2FyuIQ9YAm9OF+/BGff38QmBMt JkDj4hp7ApRezFxn1EBZVOdN23V24ZlZz1WHJJrVpKsw5Yo6WM4wuE1qmbSY3SgMaevt 06+VGgjjkR98wXS20IS1hrnMYdTHoHJhYzmmCpOjtX4j9CihwljXtlXUf9fdFYrIRG9a I5h07BV/lk2Rd/nc4kjhaDcAWXFbagmPqE85eG1pKcoA/C8EmsvBZiZSdwCg2UkYGk4Z IB+g== X-Gm-Message-State: AOAM530IYg43XPOh1gwuPaRQ+NR/tkQ8qSUOgIhwraWM82GF3+gGuNdP 0ML9D5FFrJJ0gELZ7iLHngiZVT2mwz6uhhOl2+AEdNM9wA8tijxFmup8KlQd9oADbjg5dA4qiFg qHx4mT+YMHbX1CRUG93EempcqpE54XXYmTuEILqFtjgpvwF5SHUQPNmz7+4V5 X-Received: by 2002:a17:907:7d94:b0:6db:207:c0cd with SMTP id oz20-20020a1709077d9400b006db0207c0cdmr8218415ejc.362.1646647320114; Mon, 07 Mar 2022 02:02:00 -0800 (PST) X-Received: by 2002:a17:907:7d94:b0:6db:207:c0cd with SMTP id oz20-20020a1709077d9400b006db0207c0cdmr8218395ejc.362.1646647319880; Mon, 07 Mar 2022 02:01:59 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id y18-20020a170906471200b006da8a883b5fsm4528304ejq.54.2022.03.07.02.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 02:01:59 -0800 (PST) Date: Mon, 7 Mar 2022 05:01:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 12/47] hw/vhost-user-i2c: Add support for VIRTIO_I2C_F_ZERO_LENGTH_REQUEST Message-ID: <20220307100058.449628-13-mst@redhat.com> References: <20220307100058.449628-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307100058.449628-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Viresh Kumar Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Viresh Kumar VIRTIO_I2C_F_ZERO_LENGTH_REQUEST is a mandatory feature, that must be implemented by everyone. Add its support. Reviewed-by: Alex Bennée Signed-off-by: Viresh Kumar Message-Id: Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-i2c.h | 3 +++ hw/virtio/vhost-user-i2c.c | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/hw/virtio/vhost-user-i2c.h b/include/hw/virtio/vhost-user-i2c.h index deae47a76d..d8372f3b43 100644 --- a/include/hw/virtio/vhost-user-i2c.h +++ b/include/hw/virtio/vhost-user-i2c.h @@ -25,4 +25,7 @@ struct VHostUserI2C { bool connected; }; +/* Virtio Feature bits */ +#define VIRTIO_I2C_F_ZERO_LENGTH_REQUEST 0 + #endif /* _QEMU_VHOST_USER_I2C_H */ diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index d172632bb0..42c7f6d9e5 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -19,6 +19,11 @@ #define VIRTIO_ID_I2C_ADAPTER 34 #endif +static const int feature_bits[] = { + VIRTIO_I2C_F_ZERO_LENGTH_REQUEST, + VHOST_INVALID_FEATURE_BIT +}; + static void vu_i2c_start(VirtIODevice *vdev) { BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); @@ -113,8 +118,10 @@ static void vu_i2c_set_status(VirtIODevice *vdev, uint8_t status) static uint64_t vu_i2c_get_features(VirtIODevice *vdev, uint64_t requested_features, Error **errp) { - /* No feature bits used yet */ - return requested_features; + VHostUserI2C *i2c = VHOST_USER_I2C(vdev); + + virtio_add_feature(&requested_features, VIRTIO_I2C_F_ZERO_LENGTH_REQUEST); + return vhost_get_features(&i2c->vhost_dev, feature_bits, requested_features); } static void vu_i2c_handle_output(VirtIODevice *vdev, VirtQueue *vq) From patchwork Mon Mar 7 10:02:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 548862 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp1545563mag; Mon, 7 Mar 2022 02:13:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfdrh5i23NrqDw10prWNkRAHmn4O76tryQw0lK2QAMN2ZyaMCWSekqO9fGj7544VzQ5v+Z X-Received: by 2002:a37:5445:0:b0:607:cb8f:c853 with SMTP id i66-20020a375445000000b00607cb8fc853mr6309981qkb.631.1646648021938; Mon, 07 Mar 2022 02:13:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646648021; cv=none; d=google.com; s=arc-20160816; b=gGqpLGioi6Z4G6ruu+N5G/+hJhCf/XGdtdcC6TgLRavKCoZb4OI7XYT8wa1dkVgxcB ABPi6/QVvUY4UvvAkwYBRGrtmZL/w2pY0hXnr9geOZghuPy6uzMrUc2CwZd0gPZwuxcf KCwgKrrqmtsecAyopUPrqyq7qAqsgqa+U7T3W0c+re90WR0vmDWjam0Xlie57cBhOU16 zy0KT3eUQiOW3Frb3t36zoj+N5ypv836tRhU8fQFrmMVbhlzJoxPszXerCuQag0hn7Yo xTRwI75qUzZW+X1ACd8gmJLXEElqlx75eH5qm+Pa9GMu7vqv45XwexY6mZmiGcET2tJu eldw== 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:in-reply-to :mime-version:references:message-id:subject:to:from:date :dkim-signature; bh=AvJNwnWWD1CymBBhgu2K/AQWWIjBAXRCR+0fK9AzI+o=; b=xO/Yzo4JtRXN+IYl5pATCeTSqwy0kcIoHNeM1wDDmXhYBC+gjM+AaKoTqGIXQE/782 rP/3FbiBnPMyAZM9pxN5IKzT3+3IY7AT0hM/yiLm9KjmuPHbVV3oxkyG23uGyj6LyLfb jm6TbmHWHst8CB7MQohkfCHq+iFwQlf7dIsXLzGrQ3ctlA10aS/37LSUZD40/sRgp/YH HZVfl+G4PazIrG8vfzGUmd4qKHH6f60PzgYfiMeFDCQ2wH89khjcFkZPRZ7QUWVfyXa4 QbG6A0akHePR1G4z0BllqaO6Kj1DHZ2HQKI1rHoQ9RH/1EVSoUb3tPxssI4RGMrt1t5T tp0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=XBAjaKxF; 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 g7-20020a0562141cc700b0043307da6f24si5523071qvd.565.2022.03.07.02.13.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 02:13:41 -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=XBAjaKxF; 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]:49894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRAN3-0002xj-Ge for patch@linaro.org; Mon, 07 Mar 2022 05:13:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRAC7-0000sq-Um for qemu-devel@nongnu.org; Mon, 07 Mar 2022 05:02:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:59607) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRAC5-0002ke-VE for qemu-devel@nongnu.org; Mon, 07 Mar 2022 05:02:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646647341; 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: in-reply-to:in-reply-to:references:references; bh=AvJNwnWWD1CymBBhgu2K/AQWWIjBAXRCR+0fK9AzI+o=; b=XBAjaKxFZ+iN7HmiPTy/lnc3QRzRIneTHN7mH0eCmtEvkuYUxThU7OaGqVD99bq4ayhXSv CQv3uwd+xi8pZum3DwOHKWdlqB6C0XzpOfAAvDq5ETePIw7Eplin2qN/z3MQA7i/TQkmrH uHJYoEkBsa9YPHQ5JvIDMlD/68dBj+k= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-287-EZJqqqapPCKF927wfj-sKA-1; Mon, 07 Mar 2022 05:02:20 -0500 X-MC-Unique: EZJqqqapPCKF927wfj-sKA-1 Received: by mail-ej1-f70.google.com with SMTP id m4-20020a170906160400b006be3f85906eso6756777ejd.23 for ; Mon, 07 Mar 2022 02:02:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=AvJNwnWWD1CymBBhgu2K/AQWWIjBAXRCR+0fK9AzI+o=; b=m8B0moQXNTKYFSottZNHT3tUlavAJvTfDqC6appeWdkJGL8TGpURCk1Gh/CzTce4Ge W4CMsDX9sX9Eg+p0mTupQgxI49HyHqIJLAoN3DI/XKqX5VDFWmpD7X0QZYonRLvWM5Fm S/NtqjASpqzEcm0+QLWQXB3Y4ojGprqvjnHqzBRtdem7qSQMmtcw/A7UCw3TRzqil4UE vQaJi1XyztMu+ADnzG3bdqAc3F2J3uVzmniY+JmeKLaFfOqjOZ3iz7oazB/y9UZn3jW5 BWpqfpLpjFa3HULC5BxNYFpzeuyU0C5bxJHOxSywsh+Of5wQi4VOatQwp0KAV40iGZtx m8Aw== X-Gm-Message-State: AOAM5336K7I5cNZ4losPi2Yp9JuGBglRbsgdMhbEgjxwHsz5avNA+Jmj D/wGu8GwoEjkzswKirU/RXHGi+9jHDyaDbkGFCB5fNMr250dBs2y9Xxnq8AHHJDIyFq5wdxYq4l 5kONyoiBjUGMpwGQUtT5R18f7s4Oc1ldmBEcaOLPQVthPr8587bmEYQL6hB3+ X-Received: by 2002:a05:6402:3586:b0:415:be04:2b10 with SMTP id y6-20020a056402358600b00415be042b10mr10337612edc.120.1646647338584; Mon, 07 Mar 2022 02:02:18 -0800 (PST) X-Received: by 2002:a05:6402:3586:b0:415:be04:2b10 with SMTP id y6-20020a056402358600b00415be042b10mr10337589edc.120.1646647338272; Mon, 07 Mar 2022 02:02:18 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id d8-20020a170906640800b006d5853081b7sm4554243ejm.70.2022.03.07.02.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 02:02:17 -0800 (PST) Date: Mon, 7 Mar 2022 05:02:15 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 18/47] virtio-iommu: Default to bypass during boot Message-ID: <20220307100058.449628-19-mst@redhat.com> References: <20220307100058.449628-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307100058.449628-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cornelia Huck , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Jean-Philippe Brucker Currently the virtio-iommu device must be programmed before it allows DMA from any PCI device. This can make the VM entirely unusable when a virtio-iommu driver isn't present, for example in a bootloader that loads the OS from storage. Similarly to the other vIOMMU implementations, default to DMA bypassing the IOMMU during boot. Add a "boot-bypass" property, defaulting to true, that lets users change this behavior. Replace the VIRTIO_IOMMU_F_BYPASS feature, which didn't support bypass before feature negotiation, with VIRTIO_IOMMU_F_BYPASS_CONFIG. We add the bypass field to the migration stream without introducing subsections, based on the assumption that this virtio-iommu device isn't being used in production enough to require cross-version migration at the moment (all previous version required workarounds since they didn't support ACPI and boot-bypass). Reviewed-by: Eric Auger Signed-off-by: Jean-Philippe Brucker Message-Id: <20220214124356.872985-3-jean-philippe@linaro.org> Acked-by: Cornelia Huck Reviewed-by: Eric Auger Tested-by: Eric Auger Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-iommu.h | 1 + hw/virtio/virtio-iommu.c | 60 +++++++++++++++++++++++++++----- hw/virtio/trace-events | 4 ++- 3 files changed, 56 insertions(+), 9 deletions(-) diff --git a/include/hw/virtio/virtio-iommu.h b/include/hw/virtio/virtio-iommu.h index e2339e5b72..84391f8448 100644 --- a/include/hw/virtio/virtio-iommu.h +++ b/include/hw/virtio/virtio-iommu.h @@ -58,6 +58,7 @@ struct VirtIOIOMMU { GTree *domains; QemuMutex mutex; GTree *endpoints; + bool boot_bypass; }; #endif diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index aa9c16a17b..4ca36db4ac 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -24,6 +24,7 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio.h" #include "sysemu/kvm.h" +#include "sysemu/reset.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "trace.h" @@ -728,8 +729,7 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr, .perm = IOMMU_NONE, }; - bypass_allowed = virtio_vdev_has_feature(&s->parent_obj, - VIRTIO_IOMMU_F_BYPASS); + bypass_allowed = s->config.bypass; sid = virtio_iommu_get_bdf(sdev); @@ -831,13 +831,37 @@ static void virtio_iommu_get_config(VirtIODevice *vdev, uint8_t *config_data) out_config->domain_range.start = cpu_to_le32(dev_config->domain_range.start); out_config->domain_range.end = cpu_to_le32(dev_config->domain_range.end); out_config->probe_size = cpu_to_le32(dev_config->probe_size); + out_config->bypass = dev_config->bypass; trace_virtio_iommu_get_config(dev_config->page_size_mask, dev_config->input_range.start, dev_config->input_range.end, dev_config->domain_range.start, dev_config->domain_range.end, - dev_config->probe_size); + dev_config->probe_size, + dev_config->bypass); +} + +static void virtio_iommu_set_config(VirtIODevice *vdev, + const uint8_t *config_data) +{ + VirtIOIOMMU *dev = VIRTIO_IOMMU(vdev); + struct virtio_iommu_config *dev_config = &dev->config; + const struct virtio_iommu_config *in_config = (void *)config_data; + + if (in_config->bypass != dev_config->bypass) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_IOMMU_F_BYPASS_CONFIG)) { + virtio_error(vdev, "cannot set config.bypass"); + return; + } else if (in_config->bypass != 0 && in_config->bypass != 1) { + virtio_error(vdev, "invalid config.bypass value '%u'", + in_config->bypass); + return; + } + dev_config->bypass = in_config->bypass; + } + + trace_virtio_iommu_set_config(in_config->bypass); } static uint64_t virtio_iommu_get_features(VirtIODevice *vdev, uint64_t f, @@ -963,6 +987,19 @@ static int virtio_iommu_set_page_size_mask(IOMMUMemoryRegion *mr, return 0; } +static void virtio_iommu_system_reset(void *opaque) +{ + VirtIOIOMMU *s = opaque; + + trace_virtio_iommu_system_reset(); + + /* + * config.bypass is sticky across device reset, but should be restored on + * system reset + */ + s->config.bypass = s->boot_bypass; +} + static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); @@ -988,9 +1025,9 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) virtio_add_feature(&s->features, VIRTIO_IOMMU_F_INPUT_RANGE); virtio_add_feature(&s->features, VIRTIO_IOMMU_F_DOMAIN_RANGE); virtio_add_feature(&s->features, VIRTIO_IOMMU_F_MAP_UNMAP); - virtio_add_feature(&s->features, VIRTIO_IOMMU_F_BYPASS); virtio_add_feature(&s->features, VIRTIO_IOMMU_F_MMIO); virtio_add_feature(&s->features, VIRTIO_IOMMU_F_PROBE); + virtio_add_feature(&s->features, VIRTIO_IOMMU_F_BYPASS_CONFIG); qemu_mutex_init(&s->mutex); @@ -1001,6 +1038,8 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) } else { error_setg(errp, "VIRTIO-IOMMU is not attached to any PCI bus!"); } + + qemu_register_reset(virtio_iommu_system_reset, s); } static void virtio_iommu_device_unrealize(DeviceState *dev) @@ -1008,6 +1047,8 @@ static void virtio_iommu_device_unrealize(DeviceState *dev) VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOIOMMU *s = VIRTIO_IOMMU(dev); + qemu_unregister_reset(virtio_iommu_system_reset, s); + g_hash_table_destroy(s->as_by_busptr); if (s->domains) { g_tree_destroy(s->domains); @@ -1141,21 +1182,22 @@ static int iommu_post_load(void *opaque, int version_id) static const VMStateDescription vmstate_virtio_iommu_device = { .name = "virtio-iommu-device", - .minimum_version_id = 1, - .version_id = 1, + .minimum_version_id = 2, + .version_id = 2, .post_load = iommu_post_load, .fields = (VMStateField[]) { VMSTATE_GTREE_DIRECT_KEY_V(domains, VirtIOIOMMU, 1, &vmstate_domain, VirtIOIOMMUDomain), + VMSTATE_UINT8_V(config.bypass, VirtIOIOMMU, 2), VMSTATE_END_OF_LIST() }, }; static const VMStateDescription vmstate_virtio_iommu = { .name = "virtio-iommu", - .minimum_version_id = 1, + .minimum_version_id = 2, .priority = MIG_PRI_IOMMU, - .version_id = 1, + .version_id = 2, .fields = (VMStateField[]) { VMSTATE_VIRTIO_DEVICE, VMSTATE_END_OF_LIST() @@ -1164,6 +1206,7 @@ static const VMStateDescription vmstate_virtio_iommu = { static Property virtio_iommu_properties[] = { DEFINE_PROP_LINK("primary-bus", VirtIOIOMMU, primary_bus, "PCI", PCIBus *), + DEFINE_PROP_BOOL("boot-bypass", VirtIOIOMMU, boot_bypass, true), DEFINE_PROP_END_OF_LIST(), }; @@ -1180,6 +1223,7 @@ static void virtio_iommu_class_init(ObjectClass *klass, void *data) vdc->unrealize = virtio_iommu_device_unrealize; vdc->reset = virtio_iommu_device_reset; vdc->get_config = virtio_iommu_get_config; + vdc->set_config = virtio_iommu_set_config; vdc->get_features = virtio_iommu_get_features; vdc->set_status = virtio_iommu_set_status; vdc->vmsd = &vmstate_virtio_iommu_device; diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index f7ad6be5fb..a5102eac9e 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -89,9 +89,11 @@ virtio_mmio_setting_irq(int level) "virtio_mmio setting IRQ %d" # virtio-iommu.c virtio_iommu_device_reset(void) "reset!" +virtio_iommu_system_reset(void) "system reset!" virtio_iommu_get_features(uint64_t features) "device supports features=0x%"PRIx64 virtio_iommu_device_status(uint8_t status) "driver status = %d" -virtio_iommu_get_config(uint64_t page_size_mask, uint64_t start, uint64_t end, uint32_t domain_start, uint32_t domain_end, uint32_t probe_size) "page_size_mask=0x%"PRIx64" input range start=0x%"PRIx64" input range end=0x%"PRIx64" domain range start=%d domain range end=%d probe_size=0x%x" +virtio_iommu_get_config(uint64_t page_size_mask, uint64_t start, uint64_t end, uint32_t domain_start, uint32_t domain_end, uint32_t probe_size, uint8_t bypass) "page_size_mask=0x%"PRIx64" input range start=0x%"PRIx64" input range end=0x%"PRIx64" domain range start=%d domain range end=%d probe_size=0x%x bypass=0x%x" +virtio_iommu_set_config(uint8_t bypass) "bypass=0x%x" virtio_iommu_attach(uint32_t domain_id, uint32_t ep_id) "domain=%d endpoint=%d" virtio_iommu_detach(uint32_t domain_id, uint32_t ep_id) "domain=%d endpoint=%d" virtio_iommu_map(uint32_t domain_id, uint64_t virt_start, uint64_t virt_end, uint64_t phys_start, uint32_t flags) "domain=%d virt_start=0x%"PRIx64" virt_end=0x%"PRIx64 " phys_start=0x%"PRIx64" flags=%d" From patchwork Mon Mar 7 10:02:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 548863 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp1551327mag; Mon, 7 Mar 2022 02:23:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmkuoEiED3zV2lMxcqI659UNTBw6wuOqMP/vAW/qvlLQaeogl+ECUhDoVfux/uw145DbKz X-Received: by 2002:a37:9d91:0:b0:47a:520b:e7d8 with SMTP id g139-20020a379d91000000b0047a520be7d8mr6138261qke.26.1646648583534; Mon, 07 Mar 2022 02:23:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646648583; cv=none; d=google.com; s=arc-20160816; b=UEmTD1vmnO2t7ul+0OSbYk5A9TajqfVD9RYT2Bt0AUDHYdh7TJOVcCBnVnnNNZZRok lbH8eHW2TfvghM87Qq3uJ4WRfRD8wW8P9nqXBXYUFgNRLnvCX5dhBuhS0/8yVC4sZswf hhwzMp9y1yxNh+polAe3aOrA7/O4XF7lsQwx9802qm/lvketvoBHr59Cm5dVQsVYOlUF Gw1obPbQCgFzEXcto3jl2NoMi5JvU1KytIbXcsenP7ul8DhKsIaSquQZ2QicXgGWI+iH WHXn1SMN4Dx8bX6j8iIMIOljE66J275uKMVxCSb2tYVYr4LF4PwRm2j6GGxyrFL4ZoTX pnUw== 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:in-reply-to :mime-version:references:message-id:subject:to:from:date :dkim-signature; bh=JMuvtu5n6lVU0KTov6tttqgUMeVGZs5d6LsC2M1zLP4=; b=uQhLq9DOij7ngGOMHRrohdFDUK6GTx8OxUYmSrAOhvXKxhu9g4233u+41TV4YBcFH2 kf7FFWwU/e+T+/4YcV10TSUw9wsCizjEgoydUaC5tI2yMFB6S6UqZzYJ0OkslUSPuV69 GkwYe2oFbCnDgPlulZ8WxyBP6EAh5pDnDdyWWebHmvN2m4RkUEsIlKlDIuv2TEflY3Xq WBjwNumbDxupB0tRrbOKx2q6hk8yaQ+xfRYZN0RnniIVJ0OT5hNPruu5/euOFp42vWYI lcw8VCGn/HGY4umj+mtgE3E8PnDpxIhZD6Z+mggHO9jUDMxiUsnNwW8FdE/w80Rbkg03 QUoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=GRCiLZVa; 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 l12-20020ac8148c000000b002de064282b3si4425379qtj.116.2022.03.07.02.23.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 02:23:03 -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=GRCiLZVa; 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]:44930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRAW6-00021x-VL for patch@linaro.org; Mon, 07 Mar 2022 05:23:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRACA-00010s-QM for qemu-devel@nongnu.org; Mon, 07 Mar 2022 05:02:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34984) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRAC8-0002kx-UZ for qemu-devel@nongnu.org; Mon, 07 Mar 2022 05:02:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646647344; 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: in-reply-to:in-reply-to:references:references; bh=JMuvtu5n6lVU0KTov6tttqgUMeVGZs5d6LsC2M1zLP4=; b=GRCiLZVa0mta6RAiGV8TxZ+jZJS58TuzWrYE93CGME2DaNQduhYx8SBEzRu3ydkuIJ8B7y ELVS6c2xcdFjEd+kDxvz6kmVulstjTPqtn/fMJo64m20xe2YqXN17VvZ97GC6NJqWW5i71 pn6p4gFp6lG5tuITfZb2SuegUeuP99o= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-538-UCvsyqx_OE-5J2vuU7gV5g-1; Mon, 07 Mar 2022 05:02:23 -0500 X-MC-Unique: UCvsyqx_OE-5J2vuU7gV5g-1 Received: by mail-ed1-f72.google.com with SMTP id co2-20020a0564020c0200b00415f9fa6ca8so4848258edb.6 for ; Mon, 07 Mar 2022 02:02:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JMuvtu5n6lVU0KTov6tttqgUMeVGZs5d6LsC2M1zLP4=; b=BKoFLWNq/fiv7haBkzencqEoIYBi5fK2v4fTk8ThDpnx29jeI9LYJcmHc28S1hPY9o Yd4zSlTRUtJCKW1qm5jivKzq0Dj6PyDtlt1jUXEsYmHNsPnvvUBNqUcHzv2sJygKbthz ldLXkKomz4ZwaQHZhTQzEsEvxAy+/DXMNHXPjLHKBFRv7KVGjSIMBBhjqqK15c1I2W0X b6AH39QUlxFFJCH0PER7bdmpKlDcYATs/V6NGRJ6wAxta12IA50dQm0CS5cKMJ9N6kp1 gCCXNDpxWajUL1vcAJDKzYtaI7ONYfq1RlCpf6E8eRTpE/FQbtYJKDVVgZOvOwWlUwNA 7Wrw== X-Gm-Message-State: AOAM5319Q0OCAPCChUwcTFSYfDrPOC6ByiYBb/mXup7eZ4wms67HAwwj 9wswExmlxbvJ8XlBHtcnP3KnDqrhaSYV7dEE3XG+wYokX/UNTcD/432OyywsGuFc08/fueaMiEE 4oV6vm4+cq6m/7QjYjYxiVIT2p9kRRzLXmqcPUq5SqHaGY/4NfHdFx2ldVqhI X-Received: by 2002:a17:906:a057:b0:6cf:2736:ba65 with SMTP id bg23-20020a170906a05700b006cf2736ba65mr8587857ejb.171.1646647341892; Mon, 07 Mar 2022 02:02:21 -0800 (PST) X-Received: by 2002:a17:906:a057:b0:6cf:2736:ba65 with SMTP id bg23-20020a170906a05700b006cf2736ba65mr8587835ejb.171.1646647341632; Mon, 07 Mar 2022 02:02:21 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id o23-20020a170906861700b006da745f7233sm4521160ejx.5.2022.03.07.02.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 02:02:21 -0800 (PST) Date: Mon, 7 Mar 2022 05:02:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 19/47] virtio-iommu: Support bypass domain Message-ID: <20220307100058.449628-20-mst@redhat.com> References: <20220307100058.449628-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307100058.449628-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Cornelia Huck , Eric Auger , Jean-Philippe Brucker Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Jean-Philippe Brucker The driver can create a bypass domain by passing the VIRTIO_IOMMU_ATTACH_F_BYPASS flag on the ATTACH request. Bypass domains perform slightly better than domains with identity mappings since they skip translation. Signed-off-by: Jean-Philippe Brucker Message-Id: <20220214124356.872985-4-jean-philippe@linaro.org> Acked-by: Cornelia Huck Reviewed-by: Eric Auger Tested-by: Eric Auger Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 4ca36db4ac..239fe97b12 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -43,6 +43,7 @@ typedef struct VirtIOIOMMUDomain { uint32_t id; + bool bypass; GTree *mappings; QLIST_HEAD(, VirtIOIOMMUEndpoint) endpoint_list; } VirtIOIOMMUDomain; @@ -258,12 +259,16 @@ static void virtio_iommu_put_endpoint(gpointer data) } static VirtIOIOMMUDomain *virtio_iommu_get_domain(VirtIOIOMMU *s, - uint32_t domain_id) + uint32_t domain_id, + bool bypass) { VirtIOIOMMUDomain *domain; domain = g_tree_lookup(s->domains, GUINT_TO_POINTER(domain_id)); if (domain) { + if (domain->bypass != bypass) { + return NULL; + } return domain; } domain = g_malloc0(sizeof(*domain)); @@ -271,6 +276,7 @@ static VirtIOIOMMUDomain *virtio_iommu_get_domain(VirtIOIOMMU *s, domain->mappings = g_tree_new_full((GCompareDataFunc)interval_cmp, NULL, (GDestroyNotify)g_free, (GDestroyNotify)g_free); + domain->bypass = bypass; g_tree_insert(s->domains, GUINT_TO_POINTER(domain_id), domain); QLIST_INIT(&domain->endpoint_list); trace_virtio_iommu_get_domain(domain_id); @@ -334,11 +340,16 @@ static int virtio_iommu_attach(VirtIOIOMMU *s, { uint32_t domain_id = le32_to_cpu(req->domain); uint32_t ep_id = le32_to_cpu(req->endpoint); + uint32_t flags = le32_to_cpu(req->flags); VirtIOIOMMUDomain *domain; VirtIOIOMMUEndpoint *ep; trace_virtio_iommu_attach(domain_id, ep_id); + if (flags & ~VIRTIO_IOMMU_ATTACH_F_BYPASS) { + return VIRTIO_IOMMU_S_INVAL; + } + ep = virtio_iommu_get_endpoint(s, ep_id); if (!ep) { return VIRTIO_IOMMU_S_NOENT; @@ -356,7 +367,12 @@ static int virtio_iommu_attach(VirtIOIOMMU *s, } } - domain = virtio_iommu_get_domain(s, domain_id); + domain = virtio_iommu_get_domain(s, domain_id, + flags & VIRTIO_IOMMU_ATTACH_F_BYPASS); + if (!domain) { + /* Incompatible bypass flag */ + return VIRTIO_IOMMU_S_INVAL; + } QLIST_INSERT_HEAD(&domain->endpoint_list, ep, next); ep->domain = domain; @@ -419,6 +435,10 @@ static int virtio_iommu_map(VirtIOIOMMU *s, return VIRTIO_IOMMU_S_NOENT; } + if (domain->bypass) { + return VIRTIO_IOMMU_S_INVAL; + } + interval = g_malloc0(sizeof(*interval)); interval->low = virt_start; @@ -464,6 +484,11 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s, if (!domain) { return VIRTIO_IOMMU_S_NOENT; } + + if (domain->bypass) { + return VIRTIO_IOMMU_S_INVAL; + } + interval.low = virt_start; interval.high = virt_end; @@ -780,6 +805,9 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr, entry.perm = flag; } goto unlock; + } else if (ep->domain->bypass) { + entry.perm = flag; + goto unlock; } found = g_tree_lookup_extended(ep->domain->mappings, (gpointer)(&interval), @@ -1139,8 +1167,8 @@ static const VMStateDescription vmstate_endpoint = { static const VMStateDescription vmstate_domain = { .name = "domain", - .version_id = 1, - .minimum_version_id = 1, + .version_id = 2, + .minimum_version_id = 2, .pre_load = domain_preload, .fields = (VMStateField[]) { VMSTATE_UINT32(id, VirtIOIOMMUDomain), @@ -1149,6 +1177,7 @@ static const VMStateDescription vmstate_domain = { VirtIOIOMMUInterval, VirtIOIOMMUMapping), VMSTATE_QLIST_V(endpoint_list, VirtIOIOMMUDomain, 1, vmstate_endpoint, VirtIOIOMMUEndpoint, next), + VMSTATE_BOOL_V(bypass, VirtIOIOMMUDomain, 2), VMSTATE_END_OF_LIST() } }; @@ -1186,7 +1215,7 @@ static const VMStateDescription vmstate_virtio_iommu_device = { .version_id = 2, .post_load = iommu_post_load, .fields = (VMStateField[]) { - VMSTATE_GTREE_DIRECT_KEY_V(domains, VirtIOIOMMU, 1, + VMSTATE_GTREE_DIRECT_KEY_V(domains, VirtIOIOMMU, 2, &vmstate_domain, VirtIOIOMMUDomain), VMSTATE_UINT8_V(config.bypass, VirtIOIOMMU, 2), VMSTATE_END_OF_LIST() From patchwork Mon Mar 7 10:02:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 548864 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp1558279mag; Mon, 7 Mar 2022 02:34:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjs0gcPg/aLtKbsqxuI6L0jtm023XnPwdMpAUCVynLeo9WJ6pjJVYp2Rt5fwu4L6Y5KMjX X-Received: by 2002:a05:620a:284d:b0:5ff:320d:c0a5 with SMTP id h13-20020a05620a284d00b005ff320dc0a5mr6342652qkp.681.1646649271033; Mon, 07 Mar 2022 02:34:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646649271; cv=none; d=google.com; s=arc-20160816; b=rLElOi+K2jVIBCrupOzMClcrJyXRLjpuDwm7ZS1asxC85zbE4/trpYm1+Q5S9IaQ2i AfMELHCyFJasJ2/TXfMrOfyHAHhOs8VUnvn7n712XHValGfJi9v85DFnn+wFk5+afEWQ HMN9G+hSypdg+5FSKL/QCvaKB0ZgGYPiS76dHqTWRw53zuelFFnqTtfnGf3VoWDBrCHC y0Z4aiNFrICsSfT1/Ww8bJgYRMovnbFs6XCZ5D7x1CboPOzDEcqSbIEfAcectS0SYWw6 Bi6HwnT4PtsHk8fab+hbdxpwfIB1hCX3hGPf+A+vRNq0TJNSk0s6Wf6WMx3uHkIuAEWq dUqA== 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:in-reply-to :mime-version:references:message-id:subject:to:from:date :dkim-signature; bh=wqPGtWFCVDPRGhVgRp/c/kDyoLIXiZZqdrhcBaAKsjU=; b=VYPADwqou8SM4Kw4fbKNfikBJ4v7yP5iIuuAoE/+7Tnjg/VugJDyScRWUhjxEdSv+Z KyQAwh9f4alY0AoCg7II6Ibu4Nmf4IEZ14taSpPgieH+LPUyJpxaYynuM1gaf3lkptP0 c8GCskLaKWhOd357hFD7KvQgOwBgy14uBGdatE7kwXd6NZsHvZAMYOssg2fJGcFg8UYe XYgXB6TVcdmDXtT2T6OAj9iOVhhMRsKgrjroC7xv1SpD2cQ+c0Y54bWE9bEq4R0BxRth PZQgrdCBXp89nI/957iAnB4rk7jeenyIwoRMdQkRIH8Gzolp3uyZ5Ig8chD4J0S/0g9g RYAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=bBLMJZQJ; 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 j26-20020ae9c21a000000b0062ce396f36esi4155690qkg.403.2022.03.07.02.34.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 02:34:31 -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=bBLMJZQJ; 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]:52220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRAhC-0000ZN-2q for patch@linaro.org; Mon, 07 Mar 2022 05:34:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRACq-0002El-Jo for qemu-devel@nongnu.org; Mon, 07 Mar 2022 05:03:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56929) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRACp-0002pn-29 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 05:03:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646647386; 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: in-reply-to:in-reply-to:references:references; bh=wqPGtWFCVDPRGhVgRp/c/kDyoLIXiZZqdrhcBaAKsjU=; b=bBLMJZQJA/JdPQJfOSpFsaZpAZVsW2DNYQpX4wLltDrOkSNI1EAVhU/DxJRJMThl6B93m8 /qgVkvvmTVNohw6xO0ce2AbO9YeqlVkr0nJl1rZ5PomMio2B1lH0iFAYQtRpok+87q/tCH SLdYFfP5U7/aZ2oa4qJP9pg/3rCzkds= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-CJHyleHVPpKkZh-qbs0pHw-1; Mon, 07 Mar 2022 05:02:27 -0500 X-MC-Unique: CJHyleHVPpKkZh-qbs0pHw-1 Received: by mail-ej1-f69.google.com with SMTP id go11-20020a1709070d8b00b006cf0d933739so6746603ejc.5 for ; Mon, 07 Mar 2022 02:02:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wqPGtWFCVDPRGhVgRp/c/kDyoLIXiZZqdrhcBaAKsjU=; b=QeOGZY6w2b/WJtVnrzczfn71IQgazR9mqxvIy9oaWB4EILJQCAv1oyBxLyM8umWXZn llUlrM0NFdXjZA7623T7PNfTDOnUPj+h3aI55mXCO7iyabfvp5tgacR1tbJOy+QBSr1K uUbILzlbOLYZfzkIsXwY70zrXcBqyNklbw3MhRV9o10sCuM4/rgFlAGhlLisdmLlW/xE E2Tdx8iqCtdPl5effk1dg8YRt/nMd2BArIkJ1H81t3Id8TkZ96lq7Y7vEpevE2mdIfZ5 +LQrM05dMS9hrqcstFOP/d0cbnq9lcZmvtfOGsKcZ/csLwV1K/JkTFG8Q2KUR7aXj0ob CMmg== X-Gm-Message-State: AOAM533g20vblaIY2Z5POzHBUCgMuNGWs0OvmvLNa/eX5ahXeQtyLPK6 2SZPrHI14B3TZcbdkYYmZhclOQv3jlv4nkUMZMcL2+oCO/ycEJ0L1DPV6/VSuJ4ZwdFqGcnGEwz 5zvUaWHobgmRWVnQuEaeBOfs5LKudB3shSYLNQPa2AuBr2GOcSDIlM5CLQw6k X-Received: by 2002:a05:6402:278e:b0:416:5064:b39b with SMTP id b14-20020a056402278e00b004165064b39bmr2441142ede.157.1646647345313; Mon, 07 Mar 2022 02:02:25 -0800 (PST) X-Received: by 2002:a05:6402:278e:b0:416:5064:b39b with SMTP id b14-20020a056402278e00b004165064b39bmr2441115ede.157.1646647345107; Mon, 07 Mar 2022 02:02:25 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id z16-20020a05640240d000b004165f6ce23bsm252852edb.24.2022.03.07.02.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 02:02:24 -0800 (PST) Date: Mon, 7 Mar 2022 05:02:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v2 20/47] tests/qtest/virtio-iommu-test: Check bypass config Message-ID: <20220307100058.449628-21-mst@redhat.com> References: <20220307100058.449628-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307100058.449628-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Jean-Philippe Brucker , Cornelia Huck , Eric Auger , Paolo Bonzini Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Jean-Philippe Brucker The bypass config field should be initialized to 1 by default. Reviewed-by: Eric Auger Signed-off-by: Jean-Philippe Brucker Message-Id: <20220214124356.872985-5-jean-philippe@linaro.org> Acked-by: Cornelia Huck Reviewed-by: Eric Auger Tested-by: Eric Auger Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Thomas Huth --- tests/qtest/virtio-iommu-test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/qtest/virtio-iommu-test.c b/tests/qtest/virtio-iommu-test.c index 47e68388a0..068e7a9e6c 100644 --- a/tests/qtest/virtio-iommu-test.c +++ b/tests/qtest/virtio-iommu-test.c @@ -31,11 +31,13 @@ static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc) uint64_t input_range_end = qvirtio_config_readq(dev, 16); uint32_t domain_range_start = qvirtio_config_readl(dev, 24); uint32_t domain_range_end = qvirtio_config_readl(dev, 28); + uint8_t bypass = qvirtio_config_readb(dev, 36); g_assert_cmpint(input_range_start, ==, 0); g_assert_cmphex(input_range_end, ==, UINT64_MAX); g_assert_cmpint(domain_range_start, ==, 0); g_assert_cmpint(domain_range_end, ==, UINT32_MAX); + g_assert_cmpint(bypass, ==, 1); } static int read_tail_status(struct virtio_iommu_req_tail *buffer)