From patchwork Mon Mar 7 22:45:07 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: 548888 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp2102040mag; Mon, 7 Mar 2022 14:49:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzc5iKa71sAI0WTSlIjJlvB0WzhWRjvb5ht4ZBYOPtirh1oe6Rr8XDQeBlvHnYDCxqT4D5f X-Received: by 2002:a25:254:0:b0:629:6709:2cc6 with SMTP id 81-20020a250254000000b0062967092cc6mr3032420ybc.357.1646693340713; Mon, 07 Mar 2022 14:49:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646693340; cv=none; d=google.com; s=arc-20160816; b=fWT/PcbXZIaY4464GSOJ2ry+00hmxNpfNYhBlqu6o2VlgqFFPWoSVBJGgRYgvO68cs dfyJG9+ynAk5MbKkxdBuEO76G49VHzcP55RGqcsQejD2yyEZnFVo0zJLXbq1ooPJxHnj +YWe85sbbmEpz+uFG84rsZUwtMIdquI9kEx2U+FfUrvyE6CZhuE2h2to5Oy6Cs9WQ5Nt c+MzpMrQSasi5bTEOs7tIaXtlb0Y2fie8A2TP4PEGZFVmpPYSh5k0I7oMH6msKzolzrK PuYEcXrs0qgZMBZhZx7Y5Wly84au1EJkaA3+uqjYIOp13kmsdUprXBK7OF22txv7NB56 o/0w== 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=Z1Q+0RxjFSNNcavQ2F26xpGILIiEWXOIIExsZguOmKe+DyTCrIoP/K7GfF3Ln6CBn3 5Zz+QAiZDDX8/yry8holDDgW9fzoyQlpw/GWc04Gd3ZAsfxB7gagOQvhiN+fkQL/JJXi FZnZJx2tTMoxvwNfOpv1J6pbwY+TtvwEduNWxF2dgsdOt4wt4HbWTCYjSl4CkxvqHp8J YygO/VKkVGecsZQaGK+ZhyOm16CCggQSC0qhB1g762Zv5HBHz5Pg8HinUQwFmJ0QrGNs PEXIykvIYhOtTBUcNSoeTHyDM6b2AYK70sYLrf/+Sa9Vxb5Aey76jjLTcEpUMNqepwcy rr0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=KxK7m0sH; 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 130-20020a810388000000b002d5e27f81d2si8991931ywd.253.2022.03.07.14.49.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 14:49:00 -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=KxK7m0sH; 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]:55692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMA0-0003MS-66 for patch@linaro.org; Mon, 07 Mar 2022 17:49:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6N-0006CI-Nh for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6L-0005PV-Jt for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693113; 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=KxK7m0sHzgx+Dfdtb2GxY1IzlxTJmXrXEPNuRGdZaOk98a5YTmzhjbmjylK2VFBER/D4dL y4YI9jK0gquCzvbQ3ZrIYS/F1q27OlauL9wCmb96Bd1PnDkPwYX2bVAEAObo7x075TSwFY HUgh7jpWwupK21hiVFduevaHUIB4Zpw= 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-568-EIIbyrLmP5a4LmUl9cmj_Q-1; Mon, 07 Mar 2022 17:45:12 -0500 X-MC-Unique: EIIbyrLmP5a4LmUl9cmj_Q-1 Received: by mail-wm1-f69.google.com with SMTP id v67-20020a1cac46000000b00383e71bb26fso5575322wme.1 for ; Mon, 07 Mar 2022 14:45:11 -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=4WyF5/URl6ei1ij4nE/it6FwtTrCZP42W0es4B45cj1UlBz+Wk4j6dt8iIaT1bQwhN siMKcE9UwatgMcqrUuHPXli7tmGGvnKUZB6Axvgg9sbBPjfa7KjT2yOMFL6iAgwJSMaZ dcv00mMveOi+ayuXJeWYaUpbdbQNWuAu2XANAb8R7SwYnfbRgK2K9Yu2DKnF4lDFtnr6 3wJr1Xbs+1g/18ArWVGxOL3+/atijdeYAKqvKoHxVteGkXvQpy8NEY/eH5m0sPCNFa4J paGkVBLgQMK3PGZytPWVcGH6l6pl7ZCfqvk0sOkzKZST9ggkL0lfAsns7rvFFHlMZ7yw esaA== X-Gm-Message-State: AOAM532Xa3Po4y37bfYYZgCuL8IUXHwFDZh5ObSJYmYQ8xFfwFiyRLMc nZoRpvJqu6Q7Ok2Zvn1oxlcteMP3ZGZIup8PpQOHml/89Bq/ycrHcnf7jDY+ldAp+Oasb8vXieq tz47H3kAznriLx1hQ7eoM3EARYFmZ8ciwve2ws8HE+GToXcgimHYOfaRPxQ1s X-Received: by 2002:a05:6000:1a86:b0:1f0:3437:86af with SMTP id f6-20020a0560001a8600b001f0343786afmr9910249wry.700.1646693110725; Mon, 07 Mar 2022 14:45:10 -0800 (PST) X-Received: by 2002:a05:6000:1a86:b0:1f0:3437:86af with SMTP id f6-20020a0560001a8600b001f0343786afmr9910237wry.700.1646693110459; Mon, 07 Mar 2022 14:45:10 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id r5-20020a5d4945000000b001f06372fa9fsm18755313wrs.54.2022.03.07.14.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:09 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:07 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 12/47] hw/vhost-user-i2c: Add support for VIRTIO_I2C_F_ZERO_LENGTH_REQUEST Message-ID: <20220307224357.682101-13-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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 22:45:28 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: 548890 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp2106272mag; Mon, 7 Mar 2022 14:56:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJycYY5qM5zgiNjpp7BWVZxuk/1HeZ9SnSkUywymj1fCN2bx/dnQ7Fk7P2JUh3nNEwSHXuV7 X-Received: by 2002:a25:e697:0:b0:629:1f4a:5a3c with SMTP id d145-20020a25e697000000b006291f4a5a3cmr8290953ybh.228.1646693768134; Mon, 07 Mar 2022 14:56:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646693768; cv=none; d=google.com; s=arc-20160816; b=l16l8k2B9G+0AfMf5Ia4x2CsvjlD1gGbqjxhNbK9QXSMJdWakXIxJJ7UUkDn79KjnB 7BE2gJe0FcXkJsSGHfRkLExbqrcUkucDGKhh3HTcSMs50HUpZL7zx/Gl6BQMXejWVpRr C4qBceOf1uwidzUcbSokCORLPpB6L9Lgya495/MLTBRQ43qTMALbfr+2GL5Vz3sQDrzl b3LwchRrOLWCahZbsPvG3NnIhJGwmaFxz+vRThLaCUXD4KNNybh9oYbUzK9ftHnMB/OE rs/oTH948wF0KbDz/zRrJlqTFLZqowmQ9cLwq8aAn/Bnj/P+UgXp/aIaQpytTI56P7le 85WQ== 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=IPaSM9YIHIh57SX2liUakQD7AmGqJ25SCwXgXvzdycNDw9rBc+Mik5IwNToAX7Uhjz 2jKQ3MdOQn0FM9HVVWJE+0MvJTs+nF6m3rRtDw9RJFLkfViHseGPwmsVzLNvaXALhPb7 wR7QQNHHHhlWzz+uKp9pY9i19kZWR3WXn95oTnWlH32uos9CQPneEFywZGUwP9mgZvvH 8NW6cYxeGBzUJAD4QAlEsWLql2ELHk7eRUPBUxf/2tuLTdiye8YU20JpRpqBOC3lbTFS w2vAwcyhRHWL+6yGgN5fK5WBYiXi9/f4rsQsB2kmFhoEnd112O3CpxMCYQlHN6cMdbAl xuYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=PHEodkJF; 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 g6-20020a81fc06000000b002dbdf337f8fsi9729109ywi.299.2022.03.07.14.56.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 14:56:08 -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=PHEodkJF; 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]:51632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMGt-0002qt-HL for patch@linaro.org; Mon, 07 Mar 2022 17:56:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6k-00076J-Bt for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6i-0005Xa-B6 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693135; 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=PHEodkJFHUVcKkbh77ssYiQF5unxWrJSaeo28rjnNuTJouKZa+/ccoDW7ZSN4G8K+74CM2 2sT8MbLbXHPk4oVt3czfYu0dGyRS2DMeVRg0acFFwqEe002DqfQ886VweOk7eCTTlhdjrk vhd6Mjpy/6R3t9AY8u8yP7A86ZtVcDc= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-eGwxXZ40M1CsmrTfptjHIw-1; Mon, 07 Mar 2022 17:45:32 -0500 X-MC-Unique: eGwxXZ40M1CsmrTfptjHIw-1 Received: by mail-wm1-f71.google.com with SMTP id c19-20020a05600c0ad300b00385bb3db625so257195wmr.4 for ; Mon, 07 Mar 2022 14:45:32 -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=HvQl1gGfNkzq6lg8fZ2Xg3ov1GjPSm8UZk+fluw/63HQlwsvnz4u0eMTZWGvdn4RU3 Dw7WIu4Xy9AXCophsjclJgqJyQtJfoXGUrKkZAKeZHJ2ZyHkhC4dY7tNGiNdZ3su0kre H33+3c6vNkzRFVCr/Um8CFfb8dunTz7atC1wqjIlg8zL/2Uy8Kzu4b/rGF/8OnnplJnP io5wpYCxbcW1wGgEAWIymVgK8uvajp8U/p5Foz5qScYcn5zLfxHfaG/ufiBk9bJnRJoh KoxczCack8oXMMWfGabTzRb2wCm/jwLAuu+nkGGiXkpp/3fT63e6UIGcM7wAoVUFisYy J9rg== X-Gm-Message-State: AOAM530Gl6hD56LtojWSF5nGYZFccdhP6sRFr9sBm29EMT/v7Bez2PNz pt6NOrHheNjbEgd6GaceVfrd2lx64nSyBVvAAkSKumiw/VW09EgoGZY5f1AJ9hLwPK+489eY8R0 s29/nvina5Pk7UHtI+XaOV4cq+LbpRHld6te5+QNdlEF1NhE10DAJ0ZMeYtuD X-Received: by 2002:a1c:7708:0:b0:381:f18b:29ca with SMTP id t8-20020a1c7708000000b00381f18b29camr978279wmi.140.1646693131274; Mon, 07 Mar 2022 14:45:31 -0800 (PST) X-Received: by 2002:a1c:7708:0:b0:381:f18b:29ca with SMTP id t8-20020a1c7708000000b00381f18b29camr978263wmi.140.1646693130966; Mon, 07 Mar 2022 14:45:30 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id l18-20020adfe592000000b001f064ae9830sm10674827wrm.37.2022.03.07.14.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:30 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 18/47] virtio-iommu: Default to bypass during boot Message-ID: <20220307224357.682101-19-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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 22:45:31 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: 548889 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp2105452mag; Mon, 7 Mar 2022 14:54:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4Gq58kv8YtCdOHACXOt8+sSxS9AsOTAK793Lo9x5JFrrsRZhUqc9ir70+Vsuhvbnf3Tp9 X-Received: by 2002:a81:d34d:0:b0:2dc:558:962f with SMTP id d13-20020a81d34d000000b002dc0558962fmr10458478ywl.390.1646693673016; Mon, 07 Mar 2022 14:54:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646693673; cv=none; d=google.com; s=arc-20160816; b=gT4DB9pHPMrngTS7nv3cCEenlUXlQCH+Z53QdGL6coTQc/qHzKFJy0KWLmYBveEKmX ASHNYXLgSaAOH8iM/JThzPA5YeSQtpfoT4mUarDZlYd2UKNbLFjxkqvUDbkQQDDiqey8 e5uWLvcc4j1oeY/puTybs36IdZSVDSnRc71I6L/bpmUrwU/cKLtsyk4SP9BBA7T1oz0D cH9WqdyqPt234Pa6tGqYEnY7L7vw+EsTMDjy5RgVoB8Q9jlGG+Gls81UKnxHYVtXeUgn a35aTAqckNt0LNikWCRz5Rr10RYeKv0KqV3UtwXXjBwlYm/J7lT+i1Mw72Dg6nyWWn71 RGyw== 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=p69um4sHGZjKFd45sXeYMgvYUU+5DuGWef+FIsMRH/nx/TGwGGKHICVKi3EGgHuyAj owFkfBfA+iFmq8EmQbYzrtHubXq4pqgSy71UeqvUgzr30OIBV6ZWNexNC1d1Zg/CT4q1 65OGtNvGPyxnrbhcGYsl8fet/nLU8xpnVgT92TJJta/5us2/yrRtUOPzG8o7JivOStQE 1rtmhx6JRtWsw3+GQeG/W3kr0J5AI3CCMe37QW8UBnzZSdamzku1BQIXXESl/4fWeC5E 74BCG4CmYJLwbMM7gwghTAW7KukBlCrCATOk8ntwyYcgGHJl7sUu3OO2MTbbp7mxXYjG 7HXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=WxpzfPzQ; 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 f5-20020a811f05000000b002dbdebaf365si11313318ywf.141.2022.03.07.14.54.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 14:54:33 -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=WxpzfPzQ; 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]:44318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMFM-0006Lf-FX for patch@linaro.org; Mon, 07 Mar 2022 17:54:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6l-00079F-2g for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44676) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6j-0005YV-9M for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693136; 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=WxpzfPzQjEbz9apgDruyOL9GWCDmpZdL7H9PaafI3fQ48Qh/s7HHGzGx4O64+6XJPGM40x R32bd3zWBOkg1E91dodPZQ0H/nQxpybi1i8nwHBkuYVEc7nfyGmUfl3D61J/ljrZ1ekoNY Ih5wqKFKLBL9Q/2PHKxsgG86it65nYE= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-235-l1HbBBJnOg6Yju-nFZEx0w-1; Mon, 07 Mar 2022 17:45:35 -0500 X-MC-Unique: l1HbBBJnOg6Yju-nFZEx0w-1 Received: by mail-wm1-f72.google.com with SMTP id c19-20020a05600c0ad300b00385bb3db625so257254wmr.4 for ; Mon, 07 Mar 2022 14:45:35 -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=h/l2NiIIsykCM9BKDDo10gp0pyGQeVB/GRD71RbCSRaVjQWtuSeJfSnwaoGzX9QFUf qSyefeLUunxpZmD1zEWLVAa9wRXSgUNMdpot1g4NRekFYpHyrwWgbITOkwhPj5Y9tT2i 7ujn9WvZ2fpdVxR1r2hHH9l3SwagvDLXbI//0QZfzezxuhWb90MICjtsr598ira5mpfL BvdkrD8rpDmzJuKPt/8Vz4v1xp3nOpvrMwHgqtW+dOdz4QzM4vWHXfzZCDnzUAEZVDsu qv6c+pYqRv5LMlZo+utPiSr42s1mYCYoBYZV/bdJobRI1PR4xVPWEnA5khSAB6sQrKLc DQYw== X-Gm-Message-State: AOAM533HYfkxqre7Zcyg4/+RtnlmrjljwcAd7UJ7tnoK/E20drykpYN2 lMsz6UWe8hYnl1mmYkCfDn9BuP6tI3JCFfo93IRH64re2FOGKdbrW4YiKNllCcdlaEm6D6bwJ40 Wf9BD0CC2quwz7ra/6aL7eGakSGfWc5crsboAJtMiiKbfw4zVa4cjgjB+boyJ X-Received: by 2002:a05:6000:1549:b0:1f1:e566:eb87 with SMTP id 9-20020a056000154900b001f1e566eb87mr8224936wry.87.1646693134260; Mon, 07 Mar 2022 14:45:34 -0800 (PST) X-Received: by 2002:a05:6000:1549:b0:1f1:e566:eb87 with SMTP id 9-20020a056000154900b001f1e566eb87mr8224922wry.87.1646693133943; Mon, 07 Mar 2022 14:45:33 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id r188-20020a1c2bc5000000b00387c81c32e7sm555903wmr.8.2022.03.07.14.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:33 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:31 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 19/47] virtio-iommu: Support bypass domain Message-ID: <20220307224357.682101-20-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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 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 22:45:34 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: 548891 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp2107660mag; Mon, 7 Mar 2022 14:58:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuptf38KsFJEOS88CY+IcbA6FpoNt762+cUuDmEAc0lmA45cvFEbRSiJt7nsTadza2MqDw X-Received: by 2002:a25:fe10:0:b0:625:262f:e792 with SMTP id k16-20020a25fe10000000b00625262fe792mr9551175ybe.365.1646693926423; Mon, 07 Mar 2022 14:58:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646693926; cv=none; d=google.com; s=arc-20160816; b=VxvlrLfeLSVOxv30ExYdJ37NrwtLAjOCV0AmXZqo3IpzLiLoDAziIeyD/V3aCDnxt1 rrEPNZ31611/m7MrVYKYLoFjkmm/XtYUgQZTCyDchFNLvOCITJtfy+Nrd3yKEROQh5aW rL50rGuk9jKvcerj00XHPvzBmE9+CFnrSF5DTY6d7u+JTuPpZjyva7HFUlu65pyevp1c aryryn/vSGBZksMET5Lg4wQSCK8smsbbZ8b7X2mhND46GEgm5M0ztP1wYW1z1CCyQbQ3 F/vnQJI0CsZNbiblfXBtveVAitEIiiJwIydASuDSLUqDY77rXOvYN7KK1EV3eTxppnU/ gR1Q== 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=EcUh2wqZBfpCzvsGxZXC/gR4iwgSRa1/qrinft1kpVmztA5HWQ69Ftg2UNrwu0RXAO PKCJK/iz4j2xoIU9GFCTyDfyvClh3OPiVs8pNHxehLdY01cDlUN3p3vTi0p0bsiNb2V2 5AbDgiGv6Ltn91EOx6PW/+Khx3YZWwYCSagh3YhSzICigZ+EUatNoTyn5wTBKXXRXOcC ttVgQlrfC6xRl85XbhxwtHiBfz16YW3JgfnzngnmiAZMvSuAIA7niI6xFyuY7XuFoo/g N0qqrF+luLFRp+5JUJWW1YlFkAmWdAbnMkz96kQpW7cEXEqr9BFGAGJGPlDZogUP8aNo P5ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=GwcAekG9; 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 j13-20020a05690212cd00b0062886a4a681si10401074ybu.229.2022.03.07.14.58.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 14:58:46 -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=GwcAekG9; 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]:60232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMJR-0000IG-Vj for patch@linaro.org; Mon, 07 Mar 2022 17:58:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6p-0007Ec-Af for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53604) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6n-0005bI-PH for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693141; 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=GwcAekG9HLfY32Wtd0wvLq1CQcKs0snT95Nh61YGsllvrKbtOOtGPPwJqsl3XV3MlHjRee 68y/RFE4TgXsT5eF/TixMcbH6JzNCIW4NCXwSMUep+MQfvXnCrira/J6RALQA3fCn0QR55 ks+QyDVeGIAC3qidAm+Aeo6EYtstRpM= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-ipo7KVlTN8uZpgxaQ-SDmw-1; Mon, 07 Mar 2022 17:45:40 -0500 X-MC-Unique: ipo7KVlTN8uZpgxaQ-SDmw-1 Received: by mail-wm1-f72.google.com with SMTP id 3-20020a05600c230300b00384e15ceae4so248442wmo.7 for ; Mon, 07 Mar 2022 14:45:40 -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=bGcgPVlKELak4n9ozXwaxtdCVQpXMlw7CCwgqO46pLWk0gza9+TnQHOtm0Scrzygaf bRBO7Rb93HTnxQU88OswcowAEjabTYa0Z01nOmrn1gXGcuTOTpMY4mS8BsB0Pjq6I3Fv vnzAUQxAVsOflaxxPfn1cNoFrmK9rZnaipAGyH+clXCcs2OnTM+fmHvxqCS834iqCGSz kYyi9y9ubtdi0H2wpdYXBeJtthYeMWkuDNZG6PAm9QYCJx1TxOQrA0qJY3TUrFBnwRBe KIoNPegbkIhqUxmvrYabqLZiaMm80VLLKkSINoVjBb/nftOA9eNoVLLdU0fkvP+d7U8I 8PrQ== X-Gm-Message-State: AOAM5307I+2pk6FjbpW9cdKorj2c69DiAuK5BXZcMbSn9XfeofSKV4Zj 6FbQiUO4J0CRSX/7cG89aQ640H13yFz0ERPKtJeLKbuWkJbMys0c+huHs6jyWvZAXNWS204rUcB nkzzzx1ydz2hPo/6Nu/qA11C2kjj3gwCySPbEuTJBXQjYwfPezYZO2tUylsdX X-Received: by 2002:a5d:548b:0:b0:1ed:e0b2:188c with SMTP id h11-20020a5d548b000000b001ede0b2188cmr9615834wrv.122.1646693138614; Mon, 07 Mar 2022 14:45:38 -0800 (PST) X-Received: by 2002:a5d:548b:0:b0:1ed:e0b2:188c with SMTP id h11-20020a5d548b000000b001ede0b2188cmr9615818wrv.122.1646693138279; Mon, 07 Mar 2022 14:45:38 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id p16-20020adff210000000b001f062b80091sm11230268wro.34.2022.03.07.14.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:37 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:34 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 20/47] tests/qtest/virtio-iommu-test: Check bypass config Message-ID: <20220307224357.682101-21-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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)