Re: [PATCH 30/62] x86/head/64: Move early exception dispatch to C code

From: Andy Lutomirski
Date: Tue Feb 11 2020 - 17:45:01 EST


On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel <joro@xxxxxxxxxx> wrote:
>
> From: Joerg Roedel <jroedel@xxxxxxx>
>
> Move the assembly coded dispatch between page-faults and all other
> exceptions to C code to make it easier to maintain and extend.
>
> Signed-off-by: Joerg Roedel <jroedel@xxxxxxx>
> ---
> arch/x86/kernel/head64.c | 20 ++++++++++++++++++++
> arch/x86/kernel/head_64.S | 11 +----------
> 2 files changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
> index 7cdfb7113811..d83c62ebaa85 100644
> --- a/arch/x86/kernel/head64.c
> +++ b/arch/x86/kernel/head64.c
> @@ -36,6 +36,8 @@
> #include <asm/microcode.h>
> #include <asm/kasan.h>
> #include <asm/fixmap.h>
> +#include <asm/extable.h>
> +#include <asm/trap_defs.h>
>
> /*
> * Manage page tables very early on.
> @@ -377,6 +379,24 @@ int __init early_make_pgtable(unsigned long address)
> return __early_make_pgtable(address, pmd);
> }
>
> +void __init early_exception(struct pt_regs *regs, int trapnr)
> +{
> + unsigned long cr2;
> + int r;

How about int (or bool) handled; Or just if (!early_make_pgtable)
return; This would also be nicer if you inverted the return value so
that true means "I handled it".

--Andy