Borislav Petkov
2020-Aug-31 09:45 UTC
[PATCH v6 42/76] x86/sev-es: Setup early #VC handler
On Mon, Aug 24, 2020 at 10:54:37AM +0200, Joerg Roedel wrote:> +#ifdef CONFIG_AMD_MEM_ENCRYPT > +static void set_early_idt_handler(gate_desc *idt, int n, void *handler) > +{ > + struct idt_data data; > + gate_desc desc; > + > + init_idt_data(&data, n, handler); > + idt_init_desc(&desc, &data); > + native_write_idt_entry(idt, n, &desc); > +} > +#endif > + > +static struct desc_ptr early_idt_descr __initdata = { > + .size = IDT_TABLE_SIZE - 1, > + .address = 0 /* Needs physical address of idt_table - initialized at runtime. */, > +}; > + > +void __init early_idt_setup(unsigned long physbase) > +{ > + void __maybe_unused *handler; > + gate_desc *idt; > + > + idt = fixup_pointer(idt_table, physbase); > + > +#ifdef CONFIG_AMD_MEM_ENCRYPT > + /* VMM Communication Exception */ > + handler = fixup_pointer(vc_no_ghcb, physbase); > + set_early_idt_handler(idt, X86_TRAP_VC, handler);This function is used only once AFAICT - you might just as well add its three-lined body here and save yourself the function definition and ifdeffery above...> +#endif > + > + /* Initialize IDT descriptor and load IDT */ > + early_idt_descr.address = (unsigned long)idt; > + native_load_idt(&early_idt_descr); > +} > -- > 2.28.0 >-- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette
On Mon, Aug 31, 2020 at 11:45:41AM +0200, Borislav Petkov wrote:> On Mon, Aug 24, 2020 at 10:54:37AM +0200, Joerg Roedel wrote: > > +#ifdef CONFIG_AMD_MEM_ENCRYPT > > + /* VMM Communication Exception */ > > + handler = fixup_pointer(vc_no_ghcb, physbase); > > + set_early_idt_handler(idt, X86_TRAP_VC, handler); > > This function is used only once AFAICT - you might just as well add its > three-lined body here and save yourself the function definition and > ifdeffery above...True, but having a separate function might be handy when support for #VE and #HV is developed. Those might also need to setup their early handlers here, no? Regards, Joerg
Borislav Petkov
2020-Sep-01 13:35 UTC
[PATCH v6 42/76] x86/sev-es: Setup early #VC handler
On Tue, Sep 01, 2020 at 02:59:22PM +0200, Joerg Roedel wrote:> True, but having a separate function might be handy when support for #VE > and #HV is developed. Those might also need to setup their early > handlers here, no?Ok. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette
Apparently Analagous Threads
- [PATCH v6 42/76] x86/sev-es: Setup early #VC handler
- [PATCH v6 42/76] x86/sev-es: Setup early #VC handler
- [PATCH v6 42/76] x86/sev-es: Setup early #VC handler
- [PATCH v7 39/72] x86/sev-es: Setup early #VC handler
- [PATCH v7 40/72] x86/sev-es: Setup GHCB based boot #VC handler