From: Bruno Alvisio Date: Thu, 14 Dec 2017 00:30:10 +0000 (-0800) Subject: Save/Restore Support: Refactor trap_init() and setup vector callbacks X-Git-Tag: xen-RELEASE-4.14.0~24 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=29a343da9f9ec0723b74015234869a00df18db27;p=mini-os.git Save/Restore Support: Refactor trap_init() and setup vector callbacks Currently the setup of the IDT and the request to set the HVM vector callbacks are performed both in the trap_init function. As part of the post-suspend operation, the HVM vector callback needs to be setup again while the IDT does not. Thus, the trap_init function is split into two separate functions: trap_init (sets up IDT) and xen_callback_vector (sets the HVM vector callback). During the post-suspend operations the xen_callback_vector function will be invoked. Signed-off-by: Bruno Alvisio Reviewed-by: Samuel Thibault --- diff --git a/arch/x86/traps.c b/arch/x86/traps.c index aa17da3..a7388a5 100644 --- a/arch/x86/traps.c +++ b/arch/x86/traps.c @@ -389,6 +389,16 @@ static void setup_gate(unsigned int entry, void *addr, unsigned int dpl) #endif } +void xen_callback_vector(void) +{ + if (hvm_set_parameter(HVM_PARAM_CALLBACK_IRQ, + (2ULL << 56) | TRAP_xen_callback)) + { + xprintk("Request for Xen HVM callback vector failed\n"); + do_exit(); + } +} + void trap_init(void) { setup_gate(TRAP_divide_error, ÷_error, 0); @@ -415,12 +425,7 @@ void trap_init(void) gdt[GDTE_TSS] = (typeof(*gdt))INIT_GDTE((unsigned long)&tss, 0x67, 0x89); asm volatile ("ltr %w0" :: "rm" (GDTE_TSS * 8)); - if ( hvm_set_parameter(HVM_PARAM_CALLBACK_IRQ, - (2ULL << 56) | TRAP_xen_callback) ) - { - xprintk("Request for Xen HVM callback vector failed\n"); - do_exit(); - } + xen_callback_vector(); } void trap_fini(void) diff --git a/include/x86/os.h b/include/x86/os.h index fbc2eeb..d155914 100644 --- a/include/x86/os.h +++ b/include/x86/os.h @@ -67,6 +67,9 @@ extern shared_info_t *HYPERVISOR_shared_info; void trap_init(void); void trap_fini(void); +#ifndef CONFIG_PARAVIRT +void xen_callback_vector(void); +#endif void arch_fini(void);