Re: [PATCH 1/4] x86/mm: Add a few comments

From: Peter Zijlstra
Date: Fri Nov 11 2022 - 06:51:07 EST


On Thu, Nov 10, 2022 at 07:02:31PM +0100, Peter Zijlstra wrote:

> > Do we need any of those alias passes at all for pure protection bit
> > changes? I thought we only did these because things like cacheability
> > bits have to be in sync due to machine checks etc?
> >
> > Or am I missing some case where writability matters too?
>
> I _think_, but I'm not actually sure, that it matters in exactly that
> case dhansen mentions, where we do a physical to virtual address
> translation and expect access to match whatever alias we originally came
> from.

That of course only covers the directmap; for giggles I did the below
patch on top of these and the testcase at hand boots and finishes just
fine...

So yeah, no sodding clue why we do that :/

diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index f275605892df..c63e6117221a 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -1656,7 +1676,7 @@ static int cpa_process_alias(struct cpa_data *cpa)
return ret;
}

-#ifdef CONFIG_X86_64
+#if 0 // def CONFIG_X86_64
/*
* If the primary call didn't touch the high mapping already
* and the physical address is inside the kernel map, we need