From patchwork Fri Mar 4 13:38:52 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: 548120 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp45856mag; Fri, 4 Mar 2022 06:06:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzS/TrXiHHqlP6ST7jsK6NTn6J9BEQwLaR9Iijz4WPGBPSlg5ScAYdJJAdtGikIL56QpkW0 X-Received: by 2002:a05:6122:549:b0:330:288:f36d with SMTP id y9-20020a056122054900b003300288f36dmr17093934vko.28.1646402775952; Fri, 04 Mar 2022 06:06:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646402775; cv=none; d=google.com; s=arc-20160816; b=wDKNXiZog3IYlq4Uj4rvFag5rozrML4bc828xTz/YEX8e4G0Yp02fpRoNZaGApiEpB zOupH9vZyQQNmUeEjbcojGRW8JMb8LhjsYT+14rBzXJIRxIlqIgH3x4QVB4HJMDF9fwT UGWBqzjYZcTITaLqqia0DFaklEhQx6H2r13HTxe2aq5EZLu7claqHqC5E0k+zH2XP6sv Nb9Moa0q7mkfI6aKnjLLAs2XCrmvHFrrIVnWZhhqlg5mKM8cP7k1qQlU5KBskoltndg0 hZOFyUX2sm8n2Q2Vf7Pz0HC73c3rqsdogEC9kiyBRu+oGjWWcO7bqwOVmhudqWyKzqET XPaA== 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=MqUd3LQ4Uc3oOWFaw6T4x/aFzUyuVm/cVR8+ngoajND5XX7NHrV6I2Izu7F+YKkx1k x4ZjvEeHP1aRSkOIocYpeu06PkM4OIWAYXVQrZ95xvnV0fmETtg+VJt0p55KlBqrU4rY Rfxct+xF8jIWcECBL5HiMHwRFtU0alMIOnukrNgf2GkdqcQX/zpJ6l2FNnoRZEk49Elx 4BfH/mAQvkRIcM+89oSJSyIOXU1I9NaSV11TbzrOj0F8xQhQvew3OZYcIx2h7ni/8bYZ faA0mjRNiDBPVFTQ+K3hJuVfC2eaHUvSOG+YfHbw4IRXwTud5oxdjR4d8I+FwFyU+/70 WXOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=CNAeKk+t; 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 x15-20020a67df8f000000b0031bf1889a06si359298vsk.350.2022.03.04.06.06.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Mar 2022 06:06:15 -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=CNAeKk+t; 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]:56806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8ZT-0000ko-Di for patch@linaro.org; Fri, 04 Mar 2022 09:06:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89B-0000VH-OH for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26831) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89A-0000Uw-9K for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401143; 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=CNAeKk+teapYSwQqCFbPfWFXPhqPfVL27dJr6E6q7I6VQmpvzcV35W5+9hix6YoH6uBy3+ TBGkIgR46xq6QGiDS0/f6GZpDrCPy0xfNKMJa/wjh09OHc+udUUHTAQZVqjpvG4MHrIvT4 lr9qDxjOWlzYNl9GHKKsnupthooheM4= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-311-AmOPkJl3MW2DIABbqANX3Q-1; Fri, 04 Mar 2022 08:39:03 -0500 X-MC-Unique: AmOPkJl3MW2DIABbqANX3Q-1 Received: by mail-wr1-f69.google.com with SMTP id h11-20020a5d430b000000b001f01a35a86fso3366577wrq.4 for ; Fri, 04 Mar 2022 05:39:02 -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=Cm5bwOWU6WxTXIr/CosAdbJYtE/MmEvoWeMX8BVew6o/bGKkO7bx68fRfBxQkbCIOW Hm5vtYYIDXgDJf+m/7s/zjG5UjyI6L/DhJlJzTPQvDBT6uG50zEuONmo09ghk2iEH/z7 DATTocsHjCExt46PmGL9nAsZsjMdA85haFKVA9H8T6i4vdTN/AKBIcqP83CpSwERwqBM 72eIAc+FJY5ioWuAK3sC9rc+WwT5zTw7WWKsVv4kQBmU7J8qUhE2QxEFSHC7noQhjzWw f7042Z+taiSQl1s4U3hYd3rrhxiwhnEpXenZT22+MP/HYdX3CPYwR9g2FYwwbZZqC1C4 e/DQ== X-Gm-Message-State: AOAM531S58VX8scoogTjOwRsTwTloi98hkHR4TH9X6nG8z3ASFmJgiwX AsVEGFsV+qoSWfRbFnznwk2XF6d1km/ifAgmf9HS8+B85PxhqNdH7Cnsm8/SfgToauLQ1BuUpdN 50RJM3d4j2SzxmQZ+0cah4OzEQUu0fWnaMDHVcP7JdKejPNIR83P8+5EmufN+ X-Received: by 2002:a05:600c:4982:b0:380:e458:dbd9 with SMTP id h2-20020a05600c498200b00380e458dbd9mr7732761wmp.49.1646401141385; Fri, 04 Mar 2022 05:39:01 -0800 (PST) X-Received: by 2002:a05:600c:4982:b0:380:e458:dbd9 with SMTP id h2-20020a05600c498200b00380e458dbd9mr7732742wmp.49.1646401141080; Fri, 04 Mar 2022 05:39:01 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id a3-20020a7bc1c3000000b00380e493660esm11183768wmj.42.2022.03.04.05.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:38:55 -0800 (PST) Date: Fri, 4 Mar 2022 08:38:52 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 12/45] hw/vhost-user-i2c: Add support for VIRTIO_I2C_F_ZERO_LENGTH_REQUEST Message-ID: <20220304133556.233983-13-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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_LOW=-0.7, 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 Fri Mar 4 13:40:06 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: 548123 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp62077mag; Fri, 4 Mar 2022 06:24:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZplq08FGJ498M4Tt3bsCg3JuU+Is1OlhjuvvAKcrLE+kz0kXkf2Kh9QELdrvlxwcE1pT1 X-Received: by 2002:a25:9909:0:b0:624:57e:d919 with SMTP id z9-20020a259909000000b00624057ed919mr40263556ybn.494.1646403856609; Fri, 04 Mar 2022 06:24:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646403856; cv=none; d=google.com; s=arc-20160816; b=fvHBn2Rfu+k3EYm75BufRWrfEBJiGRP8B80OIM9p5GJmHy+TUoVCHkSfQSubcOFCCP NA3MXhz9ieyAhKSiffFAdJK7/EGAXpSFOhjiqHDNiQ7zBy6zwDykDfcHlH3XFwVb901Y gNGGy2k9aWRTk66JlvmFuqQ4j49c9oOMFCHe6w8tC4vZ6phAYGd9iuDmUFta0J7f6qPe 1yKcI0sanWs5axiC+JnxeSlc4lPc3gsV/WD3r0CdyrXkX5tVx+iuY7qrM8r2DL7WGKj2 MaDme+DY9EA/kdMdsfyRsj7Yt6AqRzIxdnpbAMjjVK4vmvPc6WlG9z/aSVhVadn6qLCJ YvdA== 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=gUBc0VTNmpR7s3vJfDLOJApgNKXbQ2XZ2YTZdTN4TUHu36P85anmnZG7G3FuN/vHCq Ty5A3wl8b6zB7w629LlWub5hIh9rc5r0EbabvFO9LqL59z+7K475xJzXWIhq6m5uXTNh ++E9pGJhwTOeDCIFPuWgaOc6it+FTI84uyIGkDWxsYlCfugb3kWW6kelsgX6kXqyoq/T LMGsR6JRFMIe8S+H/ejHqLDoJFWYO5gN+7WD3ybOq9Y17zBMQl+UqEcpReHSQ/T+TTwD 68w25GPNBQZJUEntHU7/iMbRqBCplyym0Ahe/Iy732lxPfWedECfG7mYbCsPpp1NjmcH JKqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=cdkRmmXZ; 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 r126-20020a812b84000000b002d035ccfb6fsi4378655ywr.531.2022.03.04.06.24.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Mar 2022 06:24:16 -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=cdkRmmXZ; 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]:51216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8qt-0002K4-Ov for patch@linaro.org; Fri, 04 Mar 2022 09:24:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AM-0002gs-6C for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54513) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AK-0000q4-6g for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401215; 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=cdkRmmXZoiocBO1anX8gvgYmCYrBHNIY11o9ZzwHpLPdDzpSilG0EHiWh7SGOZQrzzx0Jx cwmS/+UJ3qKSmslbxMGKfd35oxUGZ41WxQBVRL+2sF4BKK/8v5ruU0irqyJAaC3JW7vG7J IQc6xEoM1pqGPWsAjKRRj42CjiF49F8= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-267-99UM-9KNPlulnWpbKaaZPg-1; Fri, 04 Mar 2022 08:40:14 -0500 X-MC-Unique: 99UM-9KNPlulnWpbKaaZPg-1 Received: by mail-wr1-f72.google.com with SMTP id ay18-20020a5d6f12000000b001efe36eb038so3401233wrb.17 for ; Fri, 04 Mar 2022 05:40:14 -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=NaFbOazMTht9q5omsue66tL5j8iaGrURDAxbSkswOsVWSd8G6oun17xt1XbuejSPnb EJ7ERxOoNAZfZ/0UwyDkc/ycfn1c8P4m3ciBOjKdwLb4vLqQmkRNHHsK2YfXGEW5WxHh 6v8wqedeJgFOm5JXjOyezya5v9SHS6wbnd4FghOJkCf9x3tXqOdi+IyAhZBt7bf0Mm/u +Jm6xlnPR4calyHlb8PSnsZE0braLvRPAhv9LR7fYeYv4hJQwIg40xmU/HNKCiwiGFxR xYOXb3chEi1MqXFZPM5Gmz2U74qN6MxExg5qO+jD5pmd13DtAGhsWQFZT56N7ryzSRsV sHtg== X-Gm-Message-State: AOAM533zuT/pKPngm3HupkpXhHYvhB3QuyjxNzkF4GTp+zgW88qw09P0 qtKzphJJhQWbm9BBtiR1qrlUyh9CgLpiEWMD4q08C0UhUwK2pobBtI7houo7N626kjMCfgd0PHN J634DFwyKTqu0PpW/0YP8XStYQcRFeXY8eJbCwG1F45+oHqg8QZ4gSK5KH2CC X-Received: by 2002:a5d:6f0f:0:b0:1ef:f983:3887 with SMTP id ay15-20020a5d6f0f000000b001eff9833887mr15137664wrb.526.1646401212614; Fri, 04 Mar 2022 05:40:12 -0800 (PST) X-Received: by 2002:a5d:6f0f:0:b0:1ef:f983:3887 with SMTP id ay15-20020a5d6f0f000000b001eff9833887mr15137648wrb.526.1646401212342; Fri, 04 Mar 2022 05:40:12 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id u4-20020adfdb84000000b001e8d8ac5394sm5134678wri.110.2022.03.04.05.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:40:09 -0800 (PST) Date: Fri, 4 Mar 2022 08:40:06 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 22/45] virtio-iommu: Default to bypass during boot Message-ID: <20220304133556.233983-23-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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_LOW=-0.7, 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 Fri Mar 4 13:40:12 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: 548121 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp56189mag; Fri, 4 Mar 2022 06:17:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8epk8BdZCss2CkimrhkgcwydFV4dtt/PLBMBOlUipv4RlZBQSTiWxrgp+sC8jf7QAD11n X-Received: by 2002:a25:a1e4:0:b0:620:f638:3eeb with SMTP id a91-20020a25a1e4000000b00620f6383eebmr39690837ybi.392.1646403439402; Fri, 04 Mar 2022 06:17:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646403439; cv=none; d=google.com; s=arc-20160816; b=HyJSNvi7w1r0+gryCHvvFglW1jcdXxANmet9U+1xx5vtC8SGTYtFStlbPxsjQuxfLH Vrj1T+mC8+vu76W7TwGQihz42Jea9yrMhK4l3KXtCq90cLRPK/9WlTqS/heRW0hyfFuR 6qlBrrKXFGOujvu75HBWKZWoOz75MemMJjkt9nQDyYyQPeEgn5PBdF2MaPj3jbbtxOVK 1717mfjo6mXQQfm7UxaLcEEpAq5Ux3Q8Rr/CYMsZymcC/SwGCtI+jAQfVS9sD+/1WQaz h40zaWIgxop8AqXd6Xl4uNam/2E7ZschYxmGyMhqaKVTI/1Aw064DFdUkN9KRH7QW7PD Je1w== 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=CRJnRcAxmwN9TEmhWhLY+ybdywBEDIsF8lIMEs6GhHzGpGWTV6O0Y2xLQ+17Ut7YFB 8pZDrwdMaEMtvaRF2qTG4DT0Tqt+2MserJZqMBOexhRcx7tkv8IceOpwJCFkG+ng0sdD 8n/O12y5bCSW/wKzItoPql6pm4wNqNV5yi+PIzPookK2sXh48WWtkORBC9DZSubG8nVr B2oT8YAdcXfXHoQnVxRPcXxCAFzz/6Z8cnc3381Px56P5lpTf7SHKC5tME+1vlDZIDDP +aSOqhYr8ZSZC1kQ76afSKdavH01r35+Mj2/6T5wlxXogHV8SJzqMkA+TJ2y31rCQ/d0 BZ5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=EavHM9Ty; 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 y12-20020a5b09cc000000b0062469b3d5c4si4162550ybq.75.2022.03.04.06.17.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Mar 2022 06:17:19 -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=EavHM9Ty; 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]:59180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8kA-0005B2-OM for patch@linaro.org; Fri, 04 Mar 2022 09:17:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AQ-0002lD-77 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39965) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AO-0000rO-EC for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401219; 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=EavHM9Ty3hdmkRuT8a6z5d6mxPhD4GdrY0l3543qJiD6cAHUb8tQfnGGMVyr4YCoaHAJdr HWiCQOQ+nN71QvDma7/ZyVCo5HRLrbvLe/gWCUKUus5ucHh7f/FCYWDEIFZEKASsu+Bu61 GxwbGCwYLszipWV3STRT5rBx0+XKLy0= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-ySDVolVUOjKLng1n6Faycg-1; Fri, 04 Mar 2022 08:40:19 -0500 X-MC-Unique: ySDVolVUOjKLng1n6Faycg-1 Received: by mail-wm1-f69.google.com with SMTP id o207-20020a1ca5d8000000b0038977354e75so803002wme.1 for ; Fri, 04 Mar 2022 05:40:18 -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=5scSBoKAeWx2/XRbAXUOhokxq+x1ztDVu8AtrERf3ED1Hj2VhOtozIMwLiq5P2wXCY BoVUsJwvsT6znBPBJUBYX85m6m4u3GilDIzkAcqiUDfN4lpuK/9RmL4OBn+Gh3DrBVRx 5pMXi0HgPMsMa0ADKLMCicBaLOM06Jrw/0QbybmqhFBLZ4vrrdxiQCzts4rD5VfFK5EF RwNppKgLiQDfd10ZzFmgU2dsYVuGgI7UJT1JOseAhTEdrFgYjtiWgJwS6bbh7OmfbO/c Qa8PiBwp9rRlWhMRLhFvi3Ybm3YR5WXRlY6D6Vnh8FmnwqkJGnB8hK2YXFjW4fjWvPou RdLw== X-Gm-Message-State: AOAM5333Xi/SYEPMreJydR6hYYs4rIXwdDzUtSftvGvHwpUb876NHn/V RNsBTwvQGcwMYjQLvZwj/67ew57M6iNFX6+YgCMGq9PD6NoOltYM+nJZsRxkbeLNAWq0dFHeJQz z2Y33WRLUnTyiPa5T7OlGuk9Cl5N4f8wp8UDngn+Ld0UaI2EoILKE2o+dqrlG X-Received: by 2002:adf:dcc2:0:b0:1f0:4c38:d6be with SMTP id x2-20020adfdcc2000000b001f04c38d6bemr6312408wrm.79.1646401217217; Fri, 04 Mar 2022 05:40:17 -0800 (PST) X-Received: by 2002:adf:dcc2:0:b0:1f0:4c38:d6be with SMTP id x2-20020adfdcc2000000b001f04c38d6bemr6312387wrm.79.1646401216913; Fri, 04 Mar 2022 05:40:16 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id r1-20020a5d4941000000b001ed89dcacbbsm4598790wrs.23.2022.03.04.05.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:40:15 -0800 (PST) Date: Fri, 4 Mar 2022 08:40:12 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 23/45] virtio-iommu: Support bypass domain Message-ID: <20220304133556.233983-24-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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_LOW=-0.7, 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 Fri Mar 4 13:40:17 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: 548122 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp59524mag; Fri, 4 Mar 2022 06:20:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBw9ggHt1Io2yr6lSCkYrg7R8yaNSgMa3oInfkuucnFfXRuzxgXXfKvV5KCW9GWLq5vFnk X-Received: by 2002:a5b:a0d:0:b0:622:6203:ab21 with SMTP id k13-20020a5b0a0d000000b006226203ab21mr37433490ybq.502.1646403657066; Fri, 04 Mar 2022 06:20:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646403657; cv=none; d=google.com; s=arc-20160816; b=yxZ+PfEcaoWzomGztmSRSv1Mb8x22DLl7Uhkxl03/yMTOt25oEk8GSaxsn4pyA0lPr OHoCklNwKBmSmowa3zniurzu43lpv/YPN47XlPzcNtwe8A2KreUf8iWrznFfcVHziUkW ZDY64P/3+64Z4KAR8OaphVndb9jYFKTXmru/2tRM56cYyOQh6fDZ4TJ2biNQqgEPkFCH iK05SKEIDrIxCN4OQb2zwVgAZgs1nfmYxoyfmv9qknuIMNEoyJhQNJX97Rt4Ux6kyKeD TheUacZouiMsXNclLY3WrJjHFXlnPvjundyvwv0zK1FCf24xUtxvrPZQPcpTUEdurULC 8h0Q== 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=lupzRnVR6Lhk2DJVCvNZ1Yg/wFWAIKdhtXVvb2Rya4kg8xgv98fIcHCJ7LZV8PBBPy w656JkVr503g+hb5AGJM08lLgt5Iivkr+p393z5yf3jY4kepylITIX6iX2geRaEiVY+c DLbb/W1DOjL/7RxsxKMRDJEiEUzGzOyFpPUcgiaWB9vY77aQ59bBC/tdlWsbZra94ggh syIb71aN6NSCQquViQ0FGZiGTYSJWCGta5HpeP8I/id9HqqgoDqC73R9ZUJNfxmmj7ui VhH87nDsYgZs8jx9DFAmIS0Ng8Y+1NFHOtTEohZn8gIFs6IyiJOYeB/ApLdwIXER3LuW dZDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=JT+J2VJZ; 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 q128-20020a818086000000b002d695489be8si4415586ywf.457.2022.03.04.06.20.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Mar 2022 06:20:57 -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=JT+J2VJZ; 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]:39508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8ng-0002n3-Fj for patch@linaro.org; Fri, 04 Mar 2022 09:20:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AX-0002sm-S6 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49751) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AW-0000vj-9F for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401227; 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=JT+J2VJZxIsYuaooEigUjycdSWnbOwMzOF57Pdx2da1ZzjWu2Ue6+9pWSfXGXeTUuVe6wy sHl6qyd80vVmTN1d+8nSvx9jwevhv6w4oFbzkpJ8LwA8nIbZj6nS5zVKQaKOGzBBV/Y4Pi ij+JZ50QXzl7aLySRaw41zAfk7E0r10= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-424-bGopWifKNZKn-Inm9pKhqQ-1; Fri, 04 Mar 2022 08:40:26 -0500 X-MC-Unique: bGopWifKNZKn-Inm9pKhqQ-1 Received: by mail-wr1-f70.google.com with SMTP id z16-20020adff1d0000000b001ef7dc78b23so3371545wro.12 for ; Fri, 04 Mar 2022 05:40: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=ibd19zB4/iwjnc2HGl2i/LnqULBA39VtdNJPO4cJeeuUyC0oQ/Oh7WSVMCWEp2kWQB H0ad/Q2LUZd46UpG83OycLzuebv7UTKHWpJlEN25OyAnb6mjmJIBgqKApFIKiSOHHWAh jqZrrYLrp5cGUGt2Fi33psUYQLl/JcvjAXT+OBzvxZsX//zS4iIyKW4MI9MON+NY6jh1 OwwefgiiVKM4Vv8DH6qCY674G2FMMSVbcNeJ3FpgqrH1K3Vq6hET6rhwslP8o1IM/vm3 EIfz6VflsHOJLjNQpZfgXn4vHtg2ZD+M3RyNq46X7BoVFIVga25VMU9zJAOD2sq5sd9Y ylbQ== X-Gm-Message-State: AOAM533MUouvc08ezDH+RAf4CTGVCt8H5fW9KMsBe0+Gk5ukQnlyFWpj e0iRZP00HZ02xuIwH9sxdEfK6Bab7/6K1jjvTF9Jadw0IdOFSzMu4gF9M6miC8K0SjedwT+q2xA 6kyDnG0No13rJZLlREH/4enJOG/HBXznfijxB2Yoto8Kv8AV2zNL+yhCjiGRq X-Received: by 2002:a5d:6d8e:0:b0:1f0:3594:c3e with SMTP id l14-20020a5d6d8e000000b001f035940c3emr9401239wrs.44.1646401225238; Fri, 04 Mar 2022 05:40:25 -0800 (PST) X-Received: by 2002:a5d:6d8e:0:b0:1f0:3594:c3e with SMTP id l14-20020a5d6d8e000000b001f035940c3emr9401219wrs.44.1646401225013; Fri, 04 Mar 2022 05:40:25 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id s17-20020adfbc11000000b001f023d197b8sm4614847wrg.68.2022.03.04.05.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:40:20 -0800 (PST) Date: Fri, 4 Mar 2022 08:40:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 24/45] tests/qtest/virtio-iommu-test: Check bypass config Message-ID: <20220304133556.233983-25-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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_LOW=-0.7, 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)