Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF9EDC433F5 for ; Fri, 11 Mar 2022 13:48:12 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.289042.490344 (Exim 4.92) (envelope-from ) id 1nSfcb-0001ot-5j; Fri, 11 Mar 2022 13:47:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 289042.490344; Fri, 11 Mar 2022 13:47:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nSfcb-0001om-2l; Fri, 11 Mar 2022 13:47:57 +0000 Received: by outflank-mailman (input) for mailman id 289042; Fri, 11 Mar 2022 13:47:55 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nSfcZ-0001oe-2r for xen-devel@lists.xen.org; Fri, 11 Mar 2022 13:47:55 +0000 Received: from sonic305-20.consmr.mail.gq1.yahoo.com (sonic305-20.consmr.mail.gq1.yahoo.com [98.137.64.83]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d6721d68-a141-11ec-8eba-a37418f5ba1a; Fri, 11 Mar 2022 14:47:51 +0100 (CET) Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.gq1.yahoo.com with HTTP; Fri, 11 Mar 2022 13:47:48 +0000 Received: by kubenode549.mail-prod1.omega.bf1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 9b8a9a8043f39f48f46947ac260309e3; Fri, 11 Mar 2022 13:47:44 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d6721d68-a141-11ec-8eba-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netscape.net; s=a2048; t=1647006468; bh=kWpHkZBAz6H+US7utCYqzMOteRtCtfOqLW3VfN4Z1yc=; h=Date:From:Subject:To:Cc:References:In-Reply-To:From:Subject:Reply-To; b=e+pMt9jgKgIgX/uH1AhIknz9+TSeedLCdtJ3VH1bCEpJuZAZlFUxfIOr2ikLyJAbmxZjVYPX6fGrN4KoVXAoxQkB02pLK4O82jScsGzOFMxb+RuWxb5EbvOorEY/uufzCGMnCxd+O+c9g19J3DXDI8c6sjufowrnCcr1o1ddCs7cvwayna/wejL+j2dD/QADkirUUpPvZrgqZRXIFiboXjVTA4BfrVboGbj4stCSw9hMfdrmDBxqWjZqbyoUQ28OIgt2V72fpv3IUSpt+duI8w8cqV+OEdpVFQOiDsRbRDdNSCQxAdm17R2Wt2vZrI+ytwXG91vn9dLjrKTlZPedkA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1647006468; bh=g2DpNCmSj0RDoYrNEkCgy0YSHOYA5n0qOPEZtw+asYN=; h=X-Sonic-MF:Date:From:Subject:To:From:Subject; b=ZRkud6mcLQ1xXbHR34ywjN8OeEzryQk2hlFUP1snrIGB02sJgu+htaRXxx5vfsh7A6dOx9/eshzZi2gqLtKvChAS5bf+/Yjqlrgxl6oUygMYXpu1gfcBrRVi+A9jsNvWTv3eF/KdmGC5/QKKmz05hNLB9Tx2f8FTP2gY8tDI7ppzRX+Cr3DuWIAahSNx3EhInCmiN96yZ+58L0dAOFkg8p91Vg6wQHN0WkneH5J/iITokPIhteMdQBboWTwRP34ledJuEeKbPozYKViPJ8UsFDFjW8WJ8JYow+xuv+zCODpao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mbmn3egMJXEtM5QXzGhEF6b70Yk1Z84FQ7FhJQcQeIa34rDUKdalTO8LWPQhvs uikG8DjQhP9zjSwpBQvfGzTyupUf0OUK0o6g9uIV72BmMA0N7Sib8ZwkoKJFgL5AEh.zibysq6gd AuqfNEcLFr4mg4St_RwCD2n0lK2obc5o7iHJ.FzS57DJCEm64CdHFYNvYvQV1q4jNeIzvOzuLizH Z47Y- X-Sonic-MF: Message-ID: Date: Fri, 11 Mar 2022 08:47:42 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 From: Chuck Zmudzinski Subject: Re: BUG: libxenlight fails to grant permission to access Intel IGD Opregion To: Jan Beulich Cc: xen-devel@lists.xen.org References: <4703b7f1-8d3c-5128-213c-e39f487e4cde.ref@netscape.net> <4703b7f1-8d3c-5128-213c-e39f487e4cde@netscape.net> <2e74415a-d0d4-321b-be2e-a14db297c51a@suse.com> Content-Language: en-US In-Reply-To: <2e74415a-d0d4-321b-be2e-a14db297c51a@suse.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailer: WebService/1.1.19878 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol On 3/11/2022 3:09 AM, Jan Beulich wrote: > On 11.03.2022 06:01, Chuck Zmudzinski wrote: >> Further research showed that these two pages at 0xcc490 are for the >> Intel IGD opregion, and because this memory is not permitted to be >> accessed by the domain, the passthrough of an Intel IGD to a Linux >> HVM domain fails, causing a crash of the Linux i915.ko kernel module >> in the HVM domain. My testing, which was on a desktop with a Haswell >> Intel CPU/IGD, confirmed that these two extra pages need to be >> permitted in order for passthrough of the Intel IGD to a Linux >> domain to work properly. >> >> I find that adding two pages is enough to fix the problem, but I >> have read in other places that the Opregion is actually three pages, >> and maybe newer revisions of the Intel IGD do need three pages instead >> of two. I am testing on a Haswell Intel chip, which is over 8 years old >> now. So the patch I propose adds two pages, but I am not sure if >> it should be three pages for newer Intel chips. >> >> The failure to map this memory with gfx_passthru enabled >> is therefore a bug, a regression that was introduced with the two >> aforementioned patches way back in 2014 when Xen 4.5 was under >> development. > Thanks for this analysis. It looks quite plausible (but the question > of 2 vs 3 pages of course needs resolving). > >> Once I developed a patch, I did more testing with the traditional >> Qemu device model and Debian's package of Xen-4.16 for Debian >> sid/unstable after I discovered where this bug first appeared in >> Xen 4.5-unstable back in 2014. In my testing, Windows HVM domains are >> not affected by this bug and they function properly, most likely >> because proprietary Intel graphics drivers for Windows are more >> forgiving than the Linux open source drivers for Intel graphics >> regarding the details of how Xen and Qemu configure the domain. >> >> This bug still exists in current supported versions of Xen >> because in Xen 4.16, passthrough of my Haswell Intel IGD to a Linux >> domain still fails with a crash of the i915 Linux kernel module in >> the Linux unprivileged domain when the traditional Qemu device model >> is used in dom0. The patch at the end of this message fixes it. >> >> I have not yet succeeded in reproducing this bug with the >> upstream device model because there is another bug in Qemu >> upstream that breaks passthrough of the Intel IGD to a Linux HVM >> domU, so for now, to reproduce it, please use the traditional device >> model. >> >> Also, as a starting point to reproduce the bug, first get Intel IGD >> passthrough to a Windows HVM domain using the Qemu traditional >> device model working on Xen 4.16. Then replace the Windows HVM domain >> with a Linux HVM domain, keeping everything else the same including >> the Qemu traditional device model. I tested using a Debian 11.2 >> (bullseye) HVM domain and Debian sid/unstable with Xen 4.16 and >> a build of the Qemu traditional device model from source as >> provided on xenbits.xen.org >> >> I am using a desktop computer and the xl toolstack and Xen as >> packaged by Debian, except that I added the traditional device >> model that Debian does not provide. >> >> If you need more info, please let me know. I am not subscribed to >> xen-devel so please cc me with your replies. >> >> Regards, >> >> Chuck >> >> Here is the patch that fixes the bug on Debian sid/Xen 4.16: > As to an actual patch for us to take - please see > docs/process/sending-patches.pandoc for the formal requirements. > (Note this was recently introduced, so you won't find it in the > 4.16 sources. But your patch wants to be against latest staging > anyway.) > > Jan > After resolving the question of two vs. three pages, I will follow the process for submitting a patch against the latest staging. Qubes OS has a patch that uses three pages, and the igd.c pci file in Qemu's hw/vfio directory also specifies three pages, but if two is enough, that seems to be safer. I haven't checked yet to see if there is an official specification from Intel. I will start by looking in the Linux kernel i915 driver code which might give a clue. Chuck