All of lore.kernel.org
 help / color / mirror / Atom feed
From: Demi Marie Obenour <demi@invisiblethingslab.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
	"Jun Nakajima" <jun.nakajima@intel.com>,
	"Kevin Tian" <kevin.tian@intel.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Tim Deegan" <tim@xen.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v3 01/12] x86/mm: Avoid hard-coding PAT in get_page_from_l1e()
Date: Thu, 15 Dec 2022 11:00:48 -0500	[thread overview]
Message-ID: <Y5tEsuvxE4j0I86T@itl-email> (raw)
In-Reply-To: <a44afad2-4b63-a830-1ed9-2bd87e8aecde@suse.com>

[-- Attachment #1: Type: text/plain, Size: 2103 bytes --]

On Thu, Dec 15, 2022 at 09:46:41AM +0100, Jan Beulich wrote:
> 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

I think I understand your point now: this still assumes that the two
unused types are not UCM or WC, but this is not documented anywhere.  I
will move this to after the patch that introduces the X86_MT_* flags,
which will allow me to switch on (XEN_MSR_PAT >> pte_flags_to_cacheattr(l1f))
instead without having to change the code again in a subsequent patch.
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-12-15 16:01 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14 23:11 [PATCH v3 00/12] Make PAT handling less brittle Demi Marie Obenour
2022-12-14 23:11 ` [PATCH v3 01/12] x86/mm: Avoid hard-coding PAT in get_page_from_l1e() Demi Marie Obenour
2022-12-15  8:46   ` Jan Beulich
2022-12-15 16:00     ` Demi Marie Obenour [this message]
2022-12-14 23:11 ` [PATCH v3 02/12] p2m-pt: Avoid hard-coding Xen's PAT Demi Marie Obenour
2022-12-14 23:11 ` [PATCH v3 03/12] efi: Avoid hard-coding the various PAT constants Demi Marie Obenour
2022-12-14 23:11 ` [PATCH v3 04/12] x86: Add memory type constants Demi Marie Obenour
2022-12-15  8:49   ` Jan Beulich
2022-12-15 17:17     ` Andrew Cooper
2022-12-15 18:07       ` Demi Marie Obenour
2022-12-14 23:11 ` [PATCH v3 05/12] x86: Replace PAT_* with X86_MT_* Demi Marie Obenour
2022-12-14 23:11 ` [PATCH v3 06/12] x86: Replace MTRR_* constants with X86_MT_* constants Demi Marie Obenour
2022-12-15 16:19   ` Jan Beulich
2022-12-14 23:11 ` [PATCH v3 07/12] x86: Replace EPT_EMT_* constants with X86_MT_* Demi Marie Obenour
2022-12-14 23:11 ` [PATCH v3 08/12] x86: Remove MEMORY_NUM_TYPES and NO_HARDCODE_MEM_TYPE Demi Marie Obenour
2022-12-15 16:24   ` Jan Beulich
2022-12-14 23:11 ` [PATCH v3 09/12] x86: Derive XEN_MSR_PAT from its individual entries Demi Marie Obenour
2022-12-15 17:04   ` Jan Beulich
2022-12-14 23:12 ` [PATCH v3 10/12] x86/mm: make code robust to future PAT changes Demi Marie Obenour
2022-12-14 23:12 ` [PATCH v3 11/12] x86/mm: Reject invalid cacheability in PV guests by default Demi Marie Obenour
2022-12-14 23:12 ` [PATCH v3 12/12] x86: Use Linux's PAT Demi Marie Obenour

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y5tEsuvxE4j0I86T@itl-email \
    --to=demi@invisiblethingslab.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=marmarek@invisiblethingslab.com \
    --cc=roger.pau@citrix.com \
    --cc=tim@xen.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.