Re: [kernel-hardening] [PATCH v5 03/32] x86/cpa: In populate_pgd, don't set the pgd entry until it's populated

From: Ingo Molnar
Date: Fri Jul 22 2016 - 16:11:16 EST



* Andy Lutomirski <luto@xxxxxxxxxxxxxx> wrote:

> This garbage (as evidenced by my bug and my failed attempt to fix it)
> only works if you never have a low-level page table that isn't linked
> into a higher-level page table, and it mostly requires you to do
> everything exactly the way it was originally done so all the horrible
> inline helpers don't get confused.
>
> And AFAICT all of this was done to manually unroll a loop, and I bet
> it never sped anything up measurably even on 386 or PPro.
>
> Whenever some vendor releases a 5 level page table CPU, can we
> *please* clean this up first? We should have a type that points to a
> table, a different type that points to an entry (or maybe not have
> pointers to entries at all), and the levels should be referred to by
> *number*. When you need to traverse all the way down, you write a
> *loop* instead of four bloody helper functions, some of which are
> incomprehensibly no-ops on some kernels. And if this means that, on
> Intel, we have a silly branch in the inner loop because the bottom
> level entry format is special, who cares?
> </rant>

I'd welcome (and help out!) any effort to clean it up gradually.

Thanks,

Ingo