diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 9d43f7b..4c9bce2 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1572,6 +1572,15 @@ int arch_vcpu_reset(struct vcpu *v) return 0; } + +int arch_vcpu_block(struct vcpu *v) { + if ( is_hvm_vcpu(v) ) { + return hvm_vcpu_block(v); + } else { + return 0; + } +} + long arch_do_vcpu_op( int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index a29c421..9ad1cfd 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4237,6 +4237,14 @@ void hvm_task_switch( hvm_unmap_entry(nptss_desc); } +int hvm_vcpu_block(struct vcpu *v) { + if ( hvm_funcs.vcpu_block ) { + return hvm_funcs.vcpu_block(v); + } else { + return 0; + } +} + #define HVMCOPY_from_guest (0u<<0) #define HVMCOPY_to_guest (1u<<0) #define HVMCOPY_no_fault (0u<<1) diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index 915f6d8..3926909 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -223,6 +223,8 @@ struct hvm_function_table { int (*altp2m_vcpu_emulate_vmfunc)(struct cpu_user_regs *regs); uint64_t (*scale_tsc)(const struct vcpu *v, uint64_t tsc); + + int (*vcpu_block) (const struct vcpu *v); }; extern struct hvm_function_table hvm_funcs; @@ -443,6 +445,8 @@ void hvm_task_switch( uint16_t tss_sel, enum hvm_task_switch_reason taskswitch_reason, int32_t errcode); +int hvm_vcpu_block(struct vcpu *v); + enum hvm_access_type { hvm_access_insn_fetch, hvm_access_none, @@ -580,12 +584,6 @@ const char *hvm_efer_valid(const struct vcpu *v, uint64_t value, signed int cr0_pg); unsigned long hvm_cr4_guest_reserved_bits(const struct vcpu *v, bool_t restore); -#define arch_vcpu_block(v) ({ \ - void (*func) (struct vcpu *) = (v)->domain->arch.hvm_domain.vmx.vcpu_block;\ - if ( func ) \ - func(v); \ -}) - #endif /* __ASM_X86_HVM_HVM_H__ */ /* diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index b47a3fe..89d2a5c 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -678,6 +678,11 @@ void startup_cpu_idle_loop(void); extern void (*pm_idle) (void); extern void (*dead_idle) (void); +/* + * Arch-specific hook to be called when the guest blocks (either in + * vcpu_block() or vcpu_poll). + */ +int arch_vcpu_block(struct vcpu *v); /* * Creates a continuation to resume the current hypercall. The caller should