Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp4512023lfc; Mon, 6 Jun 2022 11:04:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZAHxzpVeaTzek3eu/ZH+IbGV9XOCXysrV3OBekKHtSvUt6at7RvOAv2L+4wMYjjtjLPrY X-Received: by 2002:a17:90b:4f8f:b0:1e8:4846:d868 with SMTP id qe15-20020a17090b4f8f00b001e84846d868mr17107554pjb.70.1654538694467; Mon, 06 Jun 2022 11:04:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654538694; cv=none; d=google.com; s=arc-20160816; b=wRKZT8e+GpVUhEjvkv1QaM2mvRfekiXSgA9vbZWbYfKaT7W5hQ1Asy6tvfARH4phsp bWVjGh1sX75hp+QBbtcaUuZc6jNT2jYt6GDgo/kJTuU/ulcMQgq8VQJSky1btEVhNy0M D6/fbIY+fRRgc9DyvGpqm9ut3YADUXPGo8RXVXUhoGjY/rFb/f6bOX7VoYPRc6hcDpm5 +1BI1+CURmtze3+V3W+PJDr8qt8nCjFGA3wCcEIts/cm49RHTSe7haxSEX0IY9COiNjG 2MkP5faVbFFD0u0IMTYnQqtDPKTVFkNKkM1GLtxT+Qg4QM/T1TtcT5TvRl5AzjttyJ5a sJmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=iA2aAWueYemnyJQ4dmqeSAUKTpTcIZlRBOZbhOhKWRA=; b=sAdecAio+l7LETx8FO4F8qhxEXpN2GYJ7p0w0Hbdp0FRw212LIeZyHQM7qV2DNqn6p +PR3Yhq0Hz0NfBJimGxYgiRIfD/1VLMAm1UWDFhpmhz7yeFL029P/cmPAlNDCg6RD5w8 +rEVTJhOfQjbJEWOCLXrv+/25MWQ9Qeh4W8yF3NoY5EUC0NP5KOigdRktn8MCJSPJHCy 4utXx1hGFFu9zflUasuEYNqjyr8Vsio8qdfvcj/C16XaRvD0lZ6EPn5o2Zf+3QJpOq1E NzPJY5qKZjXqLYKN2D/50wWVKU6tr4Z0/CqLkph8I90HpDm6ZaX95TsdnSEZ53NQqUY3 SvJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ITqIJgUf; 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 j20-20020a63fc14000000b003f60333a5dcsi20269169pgi.560.2022.06.06.11.04.39; Mon, 06 Jun 2022 11:04:54 -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=ITqIJgUf; 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 S230226AbiFFRxg (ORCPT + 99 others); Mon, 6 Jun 2022 13:53:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbiFFRxf (ORCPT ); Mon, 6 Jun 2022 13:53:35 -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 608FC1451FB for ; Mon, 6 Jun 2022 10:53:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654538013; 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=iA2aAWueYemnyJQ4dmqeSAUKTpTcIZlRBOZbhOhKWRA=; b=ITqIJgUfpbiRw0AYeozE/cX4AsG2Lq/0THVQBxU4JwXk3NMx8OBM+UZbiJTkw/BzbvG4DM 8+mOE8SYEvRmlZS6sumsI7QAB4KExmxVneaW6pEQV/b8f+4SuI3L5rFiy8WSEsoUrmkbn8 AoYdnqNpVyYdNSj7v4F7I3N7Hnve9RQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-wQ4XU06yNX2snpDddsb96g-1; Mon, 06 Jun 2022 13:53:30 -0400 X-MC-Unique: wQ4XU06yNX2snpDddsb96g-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C32573979680; Mon, 6 Jun 2022 17:53:29 +0000 (UTC) Received: from [172.30.41.16] (unknown [10.22.35.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 139F840336E; Mon, 6 Jun 2022 17:53:29 +0000 (UTC) Subject: [PATCH 2/2] vfio/pci: Remove console drivers From: Alex Williamson To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@linux.ie, daniel@ffwll.ch Cc: Laszlo Ersek , Laszlo Ersek , Gerd Hoffmann , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Date: Mon, 06 Jun 2022 11:53:28 -0600 Message-ID: <165453800875.3592816.12944011921352366695.stgit@omen> In-Reply-To: <165453797543.3592816.6381793341352595461.stgit@omen> References: <165453797543.3592816.6381793341352595461.stgit@omen> User-Agent: StGit/1.5.dev2+g9ce680a52bd9 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Spam-Status: No, score=-3.3 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=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 Console drivers can create conflicts with PCI resources resulting in userspace getting mmap failures to memory BARs. This is especially evident when trying to re-use the system primary console for userspace drivers. Attempt to remove all nature of conflicting drivers as part of our VGA initialization. Reported-by: Laszlo Ersek Tested-by: Laszlo Ersek Suggested-by: Gerd Hoffmann Signed-off-by: Alex Williamson --- drivers/vfio/pci/vfio_pci_core.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index a0d69ddaf90d..e0cbcbc2aee1 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,8 @@ #include +#include + #define DRIVER_AUTHOR "Alex Williamson " #define DRIVER_DESC "core driver for VFIO based PCI devices" @@ -1793,6 +1796,20 @@ static int vfio_pci_vga_init(struct vfio_pci_core_device *vdev) if (!vfio_pci_is_vga(pdev)) return 0; +#if IS_REACHABLE(CONFIG_DRM) + drm_aperture_detach_platform_drivers(pdev); +#endif + +#if IS_REACHABLE(CONFIG_FB) + ret = remove_conflicting_pci_framebuffers(pdev, vdev->vdev.ops->name); + if (ret) + return ret; +#endif + + ret = vga_remove_vgacon(pdev); + if (ret) + return ret; + ret = vga_client_register(pdev, vfio_pci_set_decode); if (ret) return ret;