lkml.org 
[lkml]   [2019]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC PATCH 1/2] x86: Don't let pgprot_modify() change the page encryption bit
From
Date
Hi Thomas,

Thanks for the second batch of patches! These look much improved on all
fronts.

On 9/5/19 3:35 AM, Thomas Hellström (VMware) wrote:
> -/* mprotect needs to preserve PAT bits when updating vm_page_prot */
> +/*
> + * mprotect needs to preserve PAT and encryption bits when updating
> + * vm_page_prot
> + */
> #define pgprot_modify pgprot_modify
> static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
> {
> - pgprotval_t preservebits = pgprot_val(oldprot) & _PAGE_CHG_MASK;
> - pgprotval_t addbits = pgprot_val(newprot);
> + pgprotval_t preservebits = pgprot_val(oldprot) &
> + (_PAGE_CHG_MASK | sme_me_mask);
> + pgprotval_t addbits = pgprot_val(newprot) & ~sme_me_mask;
> return __pgprot(preservebits | addbits);
> }

_PAGE_CHG_MASK is claiming similar functionality about preserving bits
when changing PTEs:

> /*
> * Set of bits not changed in pte_modify. The pte's
> * protection key is treated like _PAGE_RW, for
> * instance, and is *not* included in this mask since
> * pte_modify() does modify it.
> */
> #define _PAGE_CHG_MASK (PTE_PFN_MASK | _PAGE_PCD | _PAGE_PWT | \
> _PAGE_SPECIAL | _PAGE_ACCESSED | _PAGE_DIRTY | \
> _PAGE_SOFT_DIRTY | _PAGE_DEVMAP)

This makes me wonder if we should be including sme_me_mask in
_PAGE_CHG_MASK (logically).

\
 
 \ /
  Last update: 2019-09-05 16:16    [W:0.073 / U:16.592 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site