From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BF94C433DB for ; Thu, 25 Feb 2021 17:14:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 79E0D64F13 for ; Thu, 25 Feb 2021 17:14:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79E0D64F13 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lFKDX-0002sA-Gz for qemu-devel@archiver.kernel.org; Thu, 25 Feb 2021 12:14:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lFKCx-0002R8-UP for qemu-devel@nongnu.org; Thu, 25 Feb 2021 12:13:47 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:33438) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lFKCw-0004Sb-3X for qemu-devel@nongnu.org; Thu, 25 Feb 2021 12:13:47 -0500 Received: by mail-wm1-x32a.google.com with SMTP id i7so5284130wmb.0 for ; Thu, 25 Feb 2021 09:13:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=fRFOcw1xhew8rNs0sF2Wu9Do743uZQ9iBCS3kg5ey/Q=; b=OQvd8eDZ0jsvhsHsqBdp4PsaAEEEA4KmsxefYLB10+TfHXUNH/0Qgt7h5GqS7XLAaV HfDPoVmNHEFEYaMjdkQm9LOkeK2rAxXrCqKBqHjH2WuA5FKixuqXqgQ004sOIrXDYuxJ Kn+WDBxHOlmvWaUPTMOfWqtIx1nm6fnJ09IrEdSbGRQ8qMqcdi+5BgSlvyUqPveGJtNx FP+UoDim+6N45+ENYX6ij6cAr2j01jW9FXDZ+0nGHo21xo6RV7y4NZER+XDL5ynV5WtG tMKpWtMlxiZhT1+ZuO4M6VIZg09tsJmDWPzPe9G2jIe0DrS37k3g7kjpRNXIxk2VPnr3 7H1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=fRFOcw1xhew8rNs0sF2Wu9Do743uZQ9iBCS3kg5ey/Q=; b=STFh9Qcwd42IX3Dd37fZzc7m8S56d7WFwx4JWDBwWgWO6bpAR2WmdEe8qRO1Gwb1PN 9/JWoE1d+0eM4b1wPLMbJ7PpzOqGTfFswqeR7/8NtYmk4vxPiKeW60aMn2NAUjUimc+d GOmENEDzyq+32jeH+UinIUY/vUVOPMHsK9rwXUNOo1uOCEs2D79xMeawDrnEYuduZ88E Eb9LxORMRglpZkGK4uhdVD0ignIDtNgFtRA3SMXAFvwBvo+vzorBxXC+DOX+WFSo85Yw yBKCzPjEd9NxAigK1CPQOEXRPCoYDjs6S6t4INnkm606/WpRMPHirxUTtpLn1o7O5F6l V63A== X-Gm-Message-State: AOAM532IJ9ZSNm6bEzDjVbNN4WAAHn6ZjxKsMaSkHu0L9LdCtGNp4Rwd Cwq0mvdUJHE7dhG3Gpv0iRVzNA== X-Google-Smtp-Source: ABdhPJzS42XDXwZThR8fnDomso690Xgug+YDGYfrdhVfXNgDGQZMOAWhxpv/TRIi8T9SSCIhsyHzxQ== X-Received: by 2002:a05:600c:214f:: with SMTP id v15mr4152821wml.62.1614273223822; Thu, 25 Feb 2021 09:13:43 -0800 (PST) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id n10sm9517563wrt.83.2021.02.25.09.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 09:13:43 -0800 (PST) Date: Thu, 25 Feb 2021 18:13:24 +0100 From: Jean-Philippe Brucker To: "Michael S. Tsirkin" Subject: Re: [PATCH] virtio-iommu: Default to bypass during boot Message-ID: References: <20210218105929.1433230-1-jean-philippe@linaro.org> <20210221064211-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210221064211-mutt-send-email-mst@kernel.org> Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=jean-philippe@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eric.auger@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Sun, Feb 21, 2021 at 06:45:18AM -0500, Michael S. Tsirkin wrote: > On Thu, Feb 18, 2021 at 11:59:30AM +0100, Jean-Philippe Brucker wrote: > > 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" option that lets users change > > this behavior. > > > > Signed-off-by: Jean-Philippe Brucker > > wouldn't this be a spec violation? > > > When the device is reset, endpoints are not attached to any domain. > > If the VIRTIO_IOMMU_F_BYPASS feature is negotiated, all accesses from > unattached endpoints are allowed and translated by the IOMMU using the > identity function. If the feature is not negotiated, any memory access > from an unattached endpoint fails. Upon attaching an endpoint in > bypass mode to a new domain, any memory access from the endpoint fails, > since the domain does not contain any mapping. Right, but the device behavior regarding BYPASS is specified as: If the driver does not accept the VIRTIO_IOMMU_F_BYPASS feature, the device SHOULD NOT let endpoints access the guest-physical address space. So I figured that the spec could be read as "before feature negotiation it's undefined whether the IOMMU is bypassed or not" and so a device implementation can choose either (previously discussed at [1]). But it's a stretch, we should clarify this. Also, the OS might want to know whether DMA was bypassing the IOMMU before the device is initialized. If there are strong security requirements, then boot-bypass means the system was vulnerable to DMA attacks during boot. So I'd like to add a new feature bit for this, VIRTIO_IOMMU_F_BOOT_BYPASS, that tells whether DMA bypasses the IOMMU before feature negotiation. It's only an indicator, accepting the feature doesn't change anything. I'll send the spec change shortly. Thanks, Jean [1] https://lore.kernel.org/qemu-devel/20200109104032.GA937123@myrica/ > Maybe it's not too late to change the spec here - want to try sending > a spec patch?