[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 01/12] x86/mm: Avoid hard-coding PAT in get_page_from_l1e()


  • To: Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 15 Dec 2022 09:46:41 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YaeD9LfcGhrBYh4I7awl+lPjYMNEbiEqWekCrFBz2zk=; b=kcG1u0kUxTB6kQgo3SPVhUKN7C47qsyGiFioGgxTk3LeTfb1VO/WRBKaM96ACAMdMsAnDyHdQhF1XAGFbNw+IgPalrYJOZkX5HOPAmj73UrWvyXteVE6PmwjFfFXcj7C0+hWSxIPfVzemUCow8hbJ5ZmYN4XXe2b6el29TZaFXTJUiK/l/CvZA0jQVn3SGeDSk+RuhdyoC8Hat1K22hFHLU1SSUPH3/USEJ2K5Zb6WIsu4ljKr1z8jLfQcc2J4KxExg3fb7dn/LAgZJFJEaWAcBCwPe6yVpigByS4t6Oju/sR6jIK6JIXp82RFl9PcAjhFgZqtvkqGMbg+JXtTvmVQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iiJIqPw3HklVsbWubzx6o/FW0S/Ls75iNsN3NtmBSluFObgETCPYCGdTuNw16TrYdqrL4ORoSCaiBlgqYQc5Xg/x0TUUkYsLN8epCaSjAdRc8bpm1MdS7yfFxSwDLLgdTxgxcYu8lXosapFQLcJfrMh3mm/tqOTyaudwe6jPtZbuLr18jU2JpmE/C5sWCRU/xsW7OYptu1fco4j0fJ5mhof8NByHdcHOc82ainQ0RTPro6OUYps9DOYxZyf3dR31ewWJiAC6BEGWiKZfvZUytkaWllLpcbbKNOF1jdeQl3oFXscricCM6UnBw2aqow9xkWsBPef0NVnwB6Pw9zv4Mg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Tim Deegan <tim@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 15 Dec 2022 08:46:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 15.12.2022 00:11, Demi Marie Obenour wrote:
> get_page_from_l1e() relied on Xen's choice of PAT, which is brittle in
> the face of future PAT changes.  Use the proper _PAGE_* constants
> instead.  Also, treat the two unused cases as if they are cacheable, as
> future changes may make them cacheable.

This still does not cover ...

> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -959,14 +959,19 @@ get_page_from_l1e(
>              flip = _PAGE_RW;
>          }
>  
> +        /* Force cacheable memtypes to UC */
>          switch ( l1f & PAGE_CACHE_ATTRS )
>          {
> -        case 0: /* WB */
> -            flip |= _PAGE_PWT | _PAGE_PCD;
> +        case _PAGE_UC:
> +        case _PAGE_UCM:
> +        case _PAGE_WC:
> +            /* not cached */
>              break;
> -        case _PAGE_PWT: /* WT */
> -        case _PAGE_PWT | _PAGE_PAT: /* WP */
> -            flip |= _PAGE_PCD | (l1f & _PAGE_PAT);
> +        case _PAGE_WB:
> +        case _PAGE_WT:
> +        case _PAGE_WP:
> +        default:
> +            flip |= (l1f & PAGE_CACHE_ATTRS) ^ _PAGE_UC;
>              break;

... the three cases here assuming certain properties wrt the flipping of
_PAGE_UC. As said before - going from one kind of assumption to another
_may_ be a good thing to do, but needs justifying as actually being an
improvement. Alternatively such assumptions could be checked by suitable
BUILD_BUG_ON(), which then at the same serve as documentation thereof.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.