Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp2665617rwb; Sat, 6 Aug 2022 03:58:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR7t8vCDE6ok5rROFvOByShbBdDxRih+ricbN9uN//w08HIFqzyh7sygVQgDdldqZmMlP4fu X-Received: by 2002:a05:6a00:787:b0:52d:47ca:e9fb with SMTP id g7-20020a056a00078700b0052d47cae9fbmr10650057pfu.39.1659783498551; Sat, 06 Aug 2022 03:58:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659783498; cv=none; d=google.com; s=arc-20160816; b=FwIhKr2inP/YlgLAWV2DFTA3QDROB2k4A3sB67cBN/Nn/LO46xHoD2ubxNzOpEOaAP p5U+AsBhJJzOMGdNUGNVOB+jTjGNmjIXB3y2ks8QbS12IpXJGnXgjyMmPEuFwI48uCRr lTlrl5OIRZrMLYEtZH0P0IxhjZo15PGAW/Xdq45+BTMWNMgV+bukLruqnRomWGr89Jl8 K8LNHr5QY3Rqbwgs3Wg7+wNO5Lkohfs4MARPXiI+xJwFYt8acPqm7MqQCPk6VgWd370F x8ytNZaKlb4Rvg45CFyT1EGcukxdRyBSbUD3Yjg3GNegx9BSwPL10dIrjmFAsH/S6WlC y1sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FVB8GBi8CPuWQGQ31lEj4KvoXOjnJ6pObTR9a5Q9woI=; b=duJWyxTX0VnqoHTOGAG3eh/6m3SXohQkggbnVZFQAq4cJdZmj2fxwoxg4CdxfGrNQG JvyeU6AjhrMdMSpBPZ+LWrAbx15k/K7rXJViT9xBfH0jjWQ6QODjjEcfHfOCaNjQoy6p SISVuh+L0FdlpDa5W4ftYTqb2en5jVsR56Z529E/vuWt/MxOmAN+W2SIl101dyNi19La jFlJT3dxs4btYfcYCM/SEmMCm7VAD6DsvlNlLx5Yt36CpLrVb78J4SIxLfGLrzhiHO/9 5bnsHTxeSNZsH4TISzRUZkjDDzHDjJWdbLUF03ZK+8JHylu8hoySKFR8WxMGm9nkxRDU Z0RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JdpefYoN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020a170902d54500b0016ed8f444edsi1355798plf.470.2022.08.06.03.58.03; Sat, 06 Aug 2022 03:58:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JdpefYoN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230096AbiHFKwe (ORCPT + 99 others); Sat, 6 Aug 2022 06:52:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229664AbiHFKwd (ORCPT ); Sat, 6 Aug 2022 06:52:33 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 61298102E for ; Sat, 6 Aug 2022 03:52:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659783151; 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=FVB8GBi8CPuWQGQ31lEj4KvoXOjnJ6pObTR9a5Q9woI=; b=JdpefYoNzdYIiD5XY+hsoBjhWOgl/njn0Fm8YxUiCskKdBVrM/6YktkfcIGzN7fKxsvyDY 9mCar8kxUeMiI8aXbAF14XNibChoDzFpHZWUvv6VBz45DHeqbULGp0U8Q+xMcHHB+QWMFp vj8LwqLgBOe4sOb06iTSDw6KaGILdE0= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-6-S4Tw3LJTN9GFit2OwKMAaw-1; Sat, 06 Aug 2022 06:52:28 -0400 X-MC-Unique: S4Tw3LJTN9GFit2OwKMAaw-1 Received: by mail-lj1-f198.google.com with SMTP id x26-20020a2e9dda000000b0025e608acc1dso1438190ljj.5 for ; Sat, 06 Aug 2022 03:52:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=FVB8GBi8CPuWQGQ31lEj4KvoXOjnJ6pObTR9a5Q9woI=; b=Ih4QNwyuYzfw4sq6rVK2evkwhp7ND5evDDA1IYTm3aZ3RVqqAP9803yXWyxhf5zCgX mgGGXdIEzPxD1yFkcGXMKU3I79OwRFeioYCtYVdnoUJmaoYCJRTb4Gpn7SQ4vu6yDW5F Ymdoh3rhwHvM0NLVTNV/c4UKDjomcD897lCwnVSM3Z8wqbBLpnj9Ew8sacOH4pTSF/y1 i4gCjaQTWh/ytXOdG8DxROm7BJvh3QGkh49xViFLNfAuIb1Xfw7e1IRmEaSlKSYS2kSD 5bcuVwmSU/gtEWQ0AWS58UVcyEHA/ak/GHye79x5s26LV5o4N+YQvWTibWd3W+uPXFik NcZQ== X-Gm-Message-State: ACgBeo1Ssa6S42OOc4zCh5U3xUgRHsQ5ytbJYuPSdxeXQ2KI5ENmkKvz p1LS/dK+TjQfUscwtAGSEcwz/MHXs+U+3EgAlwW5IJuoxkyRW2DtlFn7L2ajktvNTIvmxsRmJrv /PWqDlbJ2ohUnnDfiRAMF75j0Jn0iSsqRjh5k9hwW X-Received: by 2002:a2e:9d59:0:b0:25e:1eda:86f6 with SMTP id y25-20020a2e9d59000000b0025e1eda86f6mr3321016ljj.315.1659783146756; Sat, 06 Aug 2022 03:52:26 -0700 (PDT) X-Received: by 2002:a2e:9d59:0:b0:25e:1eda:86f6 with SMTP id y25-20020a2e9d59000000b0025e1eda86f6mr3321001ljj.315.1659783146571; Sat, 06 Aug 2022 03:52:26 -0700 (PDT) MIME-Version: 1.0 References: <20220805181105.GA29848@willie-the-truck> <20220806074828.zwzgn5gj47gjx5og@sgarzare-redhat> <20220806094239.GA30268@willie-the-truck> In-Reply-To: <20220806094239.GA30268@willie-the-truck> From: Stefan Hajnoczi Date: Sat, 6 Aug 2022 06:52:15 -0400 Message-ID: Subject: Re: IOTLB support for vhost/vsock breaks crosvm on Android To: Will Deacon Cc: Stefano Garzarella , mst@redhat.com, Stefan Hajnoczi , Jason Wang , torvalds@linux-foundation.org, ascull@google.com, maz@kernel.org, keirf@google.com, jiyong@google.com, kernel-team@android.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 6, 2022 at 5:50 AM Will Deacon wrote: > On Sat, Aug 06, 2022 at 09:48:28AM +0200, Stefano Garzarella wrote: > > On Fri, Aug 05, 2022 at 07:11:06PM +0100, Will Deacon wrote: > > If the VMM implements the translation feature, it is right in my opinion > > that it does not enable the feature for the vhost device. Otherwise, if it > > wants the vhost device to do the translation, enable the feature and send > > the IOTLB messages to set the translation. > > > > QEMU for example masks features when not required or supported. > > crosvm should negotiate only the features it supports. > > > > @Michael and @Jason can correct me, but if a vhost device negotiates > > VIRTIO_F_ACCESS_PLATFORM, then it expects the VMM to send IOTLB messages to > > set the translation. > > As above, the issue is that vhost now unconditionally advertises this in > VHOST_GET_FEATURES and so a VMM with no knowledge of IOTLB can end up > enabling it by accident. Unconditionally exposing all vhost feature bits to the guest is incorrect. The emulator must filter out only the feature bits that it supports. For example, see QEMU's vhost-net device's vhost feature bit allowlist: https://gitlab.com/qemu-project/qemu/-/blob/master/hw/net/vhost_net.c#L40 The reason why the emulator (crosvm/QEMU/etc) must filter out feature bits is that vhost devices are full VIRTIO devices. They are a subset of a VIRTIO device and the emulator is responsible for the rest of the device. Some features will require both vhost and emulator support. Therefore it is incorrect to expect the device to work correctly if the vhost feature bits are passed through to the guest. Stefan