Re: [PATCH] arm64: uprobes: Optimize cache flushes for xol slot
From: Catalin Marinas
Date: Mon Sep 23 2024 - 12:04:13 EST
On Mon, Sep 23, 2024 at 08:18:57AM +0100, Will Deacon wrote:
> On Mon, Sep 23, 2024 at 09:57:14AM +0800, Liao, Chang wrote:
> > Unfortunately, the comparison assumes the D-cache and I-cache are already
> > in sync for the slot being copied. But this assumption is flawed if we start
> > with a page with some random bits and D-cache has not been sychronized with
> > I-cache. So, besides __GFP_ZERO, should we have a additional cache flush
> > after page allocation?
>
> No, I think Oleg's right. The initial cache maintenance will happen when the
> executable pte is installed.
For some reason I had kprobes in mind, did not realise that this page
ends up in user-space. So yes, we have cache maintenance when the pte is
set to point to this page. Subsequent changes will need cache
maintenance.
> However, we should use __GFP_ZERO anyway because I don't think it's a
> good idea to map an uninitialised page into userspace.
Oh, that's not good.
--
Catalin