Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp9755867rwl; Wed, 11 Jan 2023 09:31:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXtg3OuUD/dQzU6eP5qLemgwkqUQfdBAxVcEm6w/0LOSohh9FYQfniqv2FuVRg1AsMFm8yUv X-Received: by 2002:a17:902:d2cf:b0:192:90e7:41d5 with SMTP id n15-20020a170902d2cf00b0019290e741d5mr76098998plc.52.1673458265892; Wed, 11 Jan 2023 09:31:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673458265; cv=none; d=google.com; s=arc-20160816; b=cyVO7JVkIgtetDQ1ebciJVyU9Olgz5ghxw5uZmF9XZNmzEnrL03KKslXP/dw/WaExO miNWcx09wj0CbKx5wcyusf+4GVC9tbVkMpRNjUbvtokREtKQ5SEILj1tiTvg6vUMcD9L wKQuapO7P0gWv6VND6W+S+WYT6M2Tij48EGLozQDG3+Dt774JqjWTnQcINA+eU57S86B SAZGRIlmUgvieuK25o7BYe4o67EFd+Tk3Ze1/W/lX0eT5PWMO6+vFTsWIcW4zW2NXjUN Ac4MmS+2E+hzPaqVoJmyVPavX7KTjXF2CK/OxqSame4UOH0xt0tEvYis8cQULLr8vJlT o6qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:to :from:date:dkim-signature; bh=7xoqM2b4yU5Wgrth55wL+NVhuuSQRsysOAOffMfb2Zs=; b=Ie4KnOrxtAr2BTWqLYMiw5/nIIH/ThxOMfGYowsm2oOgnUOoA7WgXMcDNL2xwtW1Ms BCx6nqRoWGOlvFFX4E2A/GuIUALpP/+6eRLXos+CYYNowweTyRmYiEeR7+uyXvPbGklM v6KBX/sXw8ZL2HjForMTE/C9m30eJ6sZfs5VVwb3ufrvMLWhwbqkd2CD+BwlfCAarAY6 CPmP6dE+FsHzEaiWFZUBKjx5JQm+ne1bHVh1YfffJUNByGQOMm09YxtE39+msfs0gea3 7T2UzxYnfeVlMhv03gdZ052kkdFdWsjSXprqQH+X9PNReztgaMkMy68OVrsXvBCvqwHQ ac4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=UTHw9GP4; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n16-20020a170902d2d000b0019274931758si15861499plc.577.2023.01.11.09.30.58; Wed, 11 Jan 2023 09:31:05 -0800 (PST) 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=@google.com header.s=20210112 header.b=UTHw9GP4; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234117AbjAKRNj (ORCPT + 53 others); Wed, 11 Jan 2023 12:13:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234415AbjAKRN2 (ORCPT ); Wed, 11 Jan 2023 12:13:28 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E775F2AFA for ; Wed, 11 Jan 2023 09:13:27 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id z9-20020a17090a468900b00226b6e7aeeaso17947970pjf.1 for ; Wed, 11 Jan 2023 09:13:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=7xoqM2b4yU5Wgrth55wL+NVhuuSQRsysOAOffMfb2Zs=; b=UTHw9GP46gMj4w7BoWTjll73gGs6xDrYov0a9OBFb+A+fCEnj/lNlk/PdejnbXURqO Bjaa3RzcOfRgNZwW4y4wEquG1PiGvWa+mDFtnWW0uykLypatPgx5G7+4SERoq1k+dvQG xFFX2kzEYRvqMO5becq4T5XslALlZk0R4OFnPNGloW7hFS7+kr3EIBznbqo0ZIAm8A1H +p3Zp0frWYwjCW7td3rratlrAVtlk1S+6jOhrJ+M/+CWMO1tC4v7PVqrV9Thc4XztjhF 1CE9QPZeiFYhJRLTxvImYXddOrBCNoD718EF13VjvKDTA1rmkfHp64GNv01N55tZjVL5 n6Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7xoqM2b4yU5Wgrth55wL+NVhuuSQRsysOAOffMfb2Zs=; b=kN2nxolD+HZCRvdQFQDwcZj3l+QCYN58GMBJsHpU8U6N+TCirS8tB5b5vNCtBi6RNS I9YgCC83WnLfrHg00H5Je2m+t4KrKv4VtXUICsUL19WEDZiVwg/Yh3rVVOwNStdDI0WU TWj3AO90fAD3t9ZKbZiBlxo32eYefYYUnsxk2dnxI0eC7WkSbmco5gVYEShclaeTDr7P d3wO6s/cSpMvCGXPnzsuRjuVcl/wpIxnYAkA5gbSojJR1Lg4eisrJ/aNxP+XjkCRzCzy lKYRYiIlH+WWnWGZjutKKFWQ64Djd+ZSE/XwCx6BCc4sT0937pTSnEG7VhhXbKv/AVcz aErA== X-Gm-Message-State: AFqh2krsJNxLew3orcdm5ur5GG7CMjisEbjk+RsMLyEYBuT2fhjbqUep bIZIzqYvym7T1R7Ejc3XoM2x5A== X-Received: by 2002:a17:90a:9503:b0:227:679:17df with SMTP id t3-20020a17090a950300b00227067917dfmr499019pjo.0.1673457207330; Wed, 11 Jan 2023 09:13:27 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id e13-20020a63e00d000000b00485cbedd34bsm8852733pgh.89.2023.01.11.09.13.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 09:13:26 -0800 (PST) Date: Wed, 11 Jan 2023 17:13:23 +0000 From: Sean Christopherson To: Christian =?iso-8859-1?Q?K=F6nig?= , Dmitry Osipenko , David Airlie , Huang Rui , Trigger Huang , Gert Wollny , Antonio Caggiano , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Osipenko , kvm@vger.kernel.org, kernel@collabora.com, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v1] drm/ttm: Refcount allocated tail pages Message-ID: References: <20220815095423.11131-1-dmitry.osipenko@collabora.com> <8230a356-be38-f228-4a8e-95124e8e8db6@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 Tue, Sep 06, 2022, Daniel Vetter wrote: > On Tue, Sep 06, 2022 at 10:01:47PM +0200, Daniel Vetter wrote: > > On Mon, Aug 15, 2022 at 12:05:19PM +0200, Christian K?nig wrote: > > > Am 15.08.22 um 11:54 schrieb Dmitry Osipenko: > > > > Higher order pages allocated using alloc_pages() aren't refcounted and they > > > > need to be refcounted, otherwise it's impossible to map them by KVM. This > > > > patch sets the refcount of the tail pages and fixes the KVM memory mapping > > > > faults. > > > > > > > > Without this change guest virgl driver can't map host buffers into guest > > > > and can't provide OpenGL 4.5 profile support to the guest. The host > > > > mappings are also needed for enabling the Venus driver using host GPU > > > > drivers that are utilizing TTM. > > > > > > > > Based on a patch proposed by Trigger Huang. > > > > > > Well I can't count how often I have repeated this: This is an absolutely > > > clear NAK! > > > > > > TTM pages are not reference counted in the first place and because of this > > > giving them to virgl is illegal. > > > > > > Please immediately stop this completely broken approach. We have discussed > > > this multiple times now. > > > > Yeah we need to get this stuff closed for real by tagging them all with > > VM_IO or VM_PFNMAP asap. > > For a bit more context: Anything mapping a bo should be VM_SPECIAL. And I > think we should add the checks to the gem and dma-buf mmap functions to > validate for that, and fix all the fallout. > > Otherwise this dragon keeps resurrecting ... > > VM_SPECIAL _will_ block get_user_pages, which will block everyone from > even trying to refcount this stuff. FWIW, IIUC that won't change the KVM story. KVM acquires the PFN for these pages via follow_pte(), not by gup(). Details are in a different strand of this thread[*]. If TTM pages aren't tied into mmu_notifiers, then I believe the only solution is to not allow them to be mapped into user page tables. If they are tied into mmu_notifiers, then this is fully a KVM limitation that we are (slowly) resolving. [*] https://lore.kernel.org/all/Y77sQZI0IfFVx7Jo@google.com