Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5734645rwr; Mon, 24 Apr 2023 08:15:52 -0700 (PDT) X-Google-Smtp-Source: AKy350Z0IkUEKm/077xCFx0CgCTXH0rYvFSwhKs8CK2vCFTgclKp4Ka4HI8npunXPt7cRyBY4rEI X-Received: by 2002:a17:903:24d:b0:1a6:6fe3:df8d with SMTP id j13-20020a170903024d00b001a66fe3df8dmr18359616plh.8.1682349351677; Mon, 24 Apr 2023 08:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682349351; cv=none; d=google.com; s=arc-20160816; b=bD7JSFfGEfA+Fo7T4YkOIfl6+1g58tx/xF/03ZcsQ6iLtoVkFGmtl4Prfz4SpExrDc HgTowQrplrHsmXmkDmmTUruiSnt5OonWIj8M1YwzQG5KG8ew1NQoics0GfiwsOE7yWtu zha3lY+A0IYutxfTdVs7DbTziYsgWY/2Q23PY2BSGKpqedW8/FwjCA//3DTPpBW/j7Zw 8Gi4WCA0/tvp2iMwOZ5IN/k2pVbJY7U/ALot6cRjxhd1h/ZQ4vyxWvgOZqEE7CEV3URG RvYghisukY8IOZPPiLDboVavI0iOD179uUbbBcEWvMVHGNwH2I1x0mHoxAqMiyVBCeEA l1mw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=br2FvkkiVd9k+hHaNH9Pd3RjVFL01dwydgzwiLtpTq4=; b=S7JERzgOHlVKMSEuAPqVpkdX6/QNkroTgw6DLCTfGZIFckPKdXRi0lxPIX21Md6TK+ 3F0HxerMKZhlHHlam6UlGk322cqSGBZyids/1UU/6sUrnEtcL9W5Df/HO7YUc+DyyO7T ig9dh3SPgsoxQrhv2MGKmsmR8tYJ4XViJN0U07R3yudB3fP+xtnfbW9m7w7I4q6iqvsc GobCnT7cTE6tA3y+YQgYY7/hE7oRCOnHkXKrk+mZ367hkkiNqijK0Z+1JlPLcRrFhTk5 EujdrhNYE2LO8UO25zEZnQarSYqo7J+HSk2FyFZuvZQqN2mHkQDKPg/1/Sj3tQ/ruf6W HncA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@invisiblethingslab.com header.s=fm3 header.b=e15dlCFA; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=AusWtLUM; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r1-20020a170902be0100b0019f2506251dsi11131266pls.190.2023.04.24.08.15.34; Mon, 24 Apr 2023 08:15:51 -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=@invisiblethingslab.com header.s=fm3 header.b=e15dlCFA; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=AusWtLUM; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232010AbjDXPJo (ORCPT + 99 others); Mon, 24 Apr 2023 11:09:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230512AbjDXPJm (ORCPT ); Mon, 24 Apr 2023 11:09:42 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDC6710D3 for ; Mon, 24 Apr 2023 08:09:40 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 780645C014E; Mon, 24 Apr 2023 11:09:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 24 Apr 2023 11:09:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1682348978; x=1682435378; bh=br2FvkkiVd9k+hHaNH9Pd3RjVFL01dwydgz wiLtpTq4=; b=e15dlCFA9qXwho9DW72jqNpVUNwKx1eg6liq0FCXwo3fHxGLKGQ TiwiaGSRG2ZTsocxtXw4S8TlVpZ9ze0A3C6d1SV4f7Bsu9Pvp7Rs/48kbL5eR5Vl uhxZAUw2X+v3OPS0uX39GrsnD5hIOeCBVyo6f0uZz18f1KXQhvFPGXTr/aSZdObh emK7qOPGsDApkPtu/+hCTM9O2B4hdCWKKJ9F6R+9b9juGOlcDis6m0ZNGHdqN3VP xWllgEUOvvqEghlFcTy09VVNUgs92zQb2e18BVcTuAcrbu0MFqD+eW/Dxpsip+zv mKV2x63s5xu8nZEUDUFZXsHB507iegiaeXw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1682348978; x=1682435378; bh=br2FvkkiVd9k+ hHaNH9Pd3RjVFL01dwydgzwiLtpTq4=; b=AusWtLUMcsQDQwrShNinBYrilcsn9 Z44HTzvvbP6+cw3x+ZrU78ICS2gPJ1qH2QxSnRHdG9M6DPEflShaQ/675mw6GSfm RuWvORGfDsBG76cVNehHRwjiQr7+nlUK3oqJLoiLaxte34wesB1/z1mWdfst/iX8 +pJ6KpioLW5LD06dGXSsUZXQNcI1eiZrKFM+b+9QDb47DOnfSvzf2fis2ExJ6DKK mTkmSjKWsDyvrAAMVgSdJ5Yuhe467QQmXts6BVr5bE3MC95bLHxrqiZstjiNrog6 rOIkG6FgDDhLaUSzOE0u7SV0cT+6zcm+T2HoibMjiqbOOdD+0m5SwaE6A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfedutddgkeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtjeenucfhrhhomhepofgrrhgv khcuofgrrhgtiiihkhhofihskhhiqdfikphrvggtkhhiuceomhgrrhhmrghrvghksehinh hvihhsihgslhgvthhhihhnghhslhgrsgdrtghomheqnecuggftrfgrthhtvghrnhepvdeh fefgffefudegveetueegfeevvedvvedtleefgefftddufeejtdfhleeftdevnecuffhomh grihhnpehfrhgvvgguvghskhhtohhprdhorhhgnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvihhsihgslhgvth hhihhnghhslhgrsgdrtghomh X-ME-Proxy: Feedback-ID: i1568416f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 24 Apr 2023 11:09:35 -0400 (EDT) Date: Mon, 24 Apr 2023 17:09:31 +0200 From: Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= To: Janusz Krzysztofik Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andrew Morton , David Hildenbrand , Yu Zhao , Juergen Gross , linux-kernel@vger.kernel.org, Andi Shyti , Chris Wilson , Andrzej Hajda , Nirmoy Das , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: Re: [RFC PATCH] x86/mm: Fix PAT bit missing from page protection modify mask Message-ID: References: <20230424123524.17008-1-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="osZaiv/38K3nEkTW" Content-Disposition: inline In-Reply-To: <20230424123524.17008-1-janusz.krzysztofik@linux.intel.com> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,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 --osZaiv/38K3nEkTW Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Mon, 24 Apr 2023 17:09:31 +0200 From: Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= To: Janusz Krzysztofik Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andrew Morton , David Hildenbrand , Yu Zhao , Juergen Gross , linux-kernel@vger.kernel.org, Andi Shyti , Chris Wilson , Andrzej Hajda , Nirmoy Das , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: Re: [RFC PATCH] x86/mm: Fix PAT bit missing from page protection modify mask On Mon, Apr 24, 2023 at 02:35:24PM +0200, Janusz Krzysztofik wrote: > Visible glitches have been observed when running graphics applications on > Linux under Xen hypervisor. Those observations have been confirmed with > failures from kms_pwrite_crc Intel GPU test that verifies data coherency > of DRM frame buffer objects using hardware CRC checksums calculated by > display controllers, exposed to userspace via debugfs. Affected > processing paths have then been identified with new test variants that > mmap the objects using different methods and caching modes. >=20 > When running as a Xen PV guest, Linux uses Xen provided PAT configuration > which is different from its native one. In particular, Xen specific PTE > encoding of write-combining caching, likely used by graphics applications, > differs from the Linux default one found among statically defined minimal > set of supported modes. Since Xen defines PTE encoding of the WC mode as > _PAGE_PAT, it no longer belongs to the minimal set, depends on correct > handling of _PAGE_PAT bit, and can be mismatched with write-back caching. >=20 > When a user calls mmap() for a DRM buffer object, DRM device specific > .mmap file operation, called from mmap_region(), takes care of setting PTE > encoding bits in a vm_page_prot field of an associated virtual memory area > structure. Unfortunately, _PAGE_PAT bit is not preserved when the vma's > .vm_flags are then applied to .vm_page_prot via vm_set_page_prot(). Bits > to be preserved are determined with _PAGE_CHG_MASK symbol that doesn't > cover _PAGE_PAT. As a consequence, WB caching is requested instead of WC > when running under Xen (also, WP is silently changed to WT, and UC > downgraded to UC_MINUS). When running on bare metal, WC is not affected, > but WP and WT extra modes are unintentionally replaced with WC and UC, > respectively. >=20 > WP and WT modes, encoded with _PAGE_PAT bit set, were introduced by commit > 281d4078bec3 ("x86: Make page cache mode a real type"). Care was taken > to extend _PAGE_CACHE_MASK symbol with that additional bit, but that > symbol has never been used for identification of bits preserved when > applying page protection flags. Support for all cache modes under Xen, > including the problematic WC mode, was then introduced by commit > 47591df50512 ("xen: Support Xen pv-domains using PAT"). >=20 > Extend bitmask used by pgprot_modify() for selecting bits to be preserved > with _PAGE_PAT bit. However, since that bit can be reused as _PAGE_PSE, > and the _PAGE_CHG_MASK symbol, primarly used by pte_modify(), is likely > intentionally defined with that bit not set, keep that symbol unchanged. >=20 > Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/7648 > Fixes: 281d4078bec3 ("x86: Make page cache mode a real type") > Signed-off-by: Janusz Krzysztofik > Cc: stable@vger.kernel.org # v3.19+ I can confirm it fixes the issue, thanks! Tested-by: Marek Marczykowski-G=C3=B3recki --=20 Best Regards, Marek Marczykowski-G=C3=B3recki Invisible Things Lab --osZaiv/38K3nEkTW Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEyBAEBCAAdFiEEhrpukzGPukRmQqkK24/THMrX1ywFAmRGm6sACgkQ24/THMrX 1yzT0gf400BOXJvJeqI1javhvP81SDOZYUdV+Hbr92YK3/V923fZE3lL3vkMM0TQ TqbUZ0pvUaeds3y1dTt812XjjS/1AoT3tC+fj++bfX6LAYLuQWVO5P0gllFsb4bN ny3EG2Vz7YVYbFkVbWBZVhL1FgMJr176wvc0kNr1etE+PqeQjycOEK9y3lsr2gBi QuMreECQO49lJjzEViX0cC+OSQ8OaN460diENUnYrQf9b0Zp6OCWIWnGFjUuMO1W SB74scfbpDW3MvpGFjBT1vjLyTckriD/E4KvGDNETIf/nRrSa1PiVP98LHesAQwJ arBw1aNL48n2Xi10dhUmhhM+uQr3 =cWLA -----END PGP SIGNATURE----- --osZaiv/38K3nEkTW--