On Mon, Jun 17, 2019 at 04:51:58PM +0200, Peter Zijlstra wrote: > On Mon, Jun 17, 2019 at 05:43:28PM +0300, Kirill A. Shutemov wrote: > > On Mon, Jun 17, 2019 at 11:27:55AM +0200, Peter Zijlstra wrote: > > > > > > And yet I don't see anything in pageattr.c. > > > > > > > > You're right. I've hooked up the sync in the wrong place. > > > I think something like this should do (I'll fold it in after testing): > > > @@ -643,7 +641,7 @@ static int sync_direct_mapping_keyid(unsigned long keyid) > > * > > * The function is nop until MKTME is enabled. > > */ > > -int sync_direct_mapping(void) > > +int sync_direct_mapping(unsigned long start, unsigned long end) > > { > > int i, ret = 0; > > > > @@ -651,7 +649,7 @@ int sync_direct_mapping(void) > > return 0; > > > > for (i = 1; !ret && i <= mktme_nr_keyids; i++) > > - ret = sync_direct_mapping_keyid(i); > > + ret = sync_direct_mapping_keyid(i, start, end); > > > > flush_tlb_all(); > > > > diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c > > index 6a9a77a403c9..eafbe0d8c44f 100644 > > --- a/arch/x86/mm/pageattr.c > > +++ b/arch/x86/mm/pageattr.c > > @@ -347,6 +347,28 @@ static void cpa_flush(struct cpa_data *data, int cache) > > > > BUG_ON(irqs_disabled() && !early_boot_irqs_disabled); > > > > + if (mktme_enabled()) { > > + unsigned long start, end; > > + > > + start = *cpa->vaddr; > > + end = *cpa->vaddr + cpa->numpages * PAGE_SIZE; > > + > > + /* Sync all direct mapping for an array */ > > + if (cpa->flags & CPA_ARRAY) { > > + start = PAGE_OFFSET; > > + end = PAGE_OFFSET + direct_mapping_size; > > + } > > Understandable but sad, IIRC that's the most used interface (at least, > its the one the graphics people use). > > > + > > + /* > > + * Sync per-KeyID direct mappings with the canonical one > > + * (KeyID-0). > > + * > > + * sync_direct_mapping() does full TLB flush. > > + */ > > + sync_direct_mapping(start, end); > > + return; > > But it doesn't flush cache. So you can't return here. Thanks for catching this. if (!cache) return; should be fine. -- Kirill A. Shutemov