From: Feng Wu Date: Fri, 3 Mar 2017 10:57:30 +0000 (+0100) Subject: VMX: permanently assign PI hook vmx_pi_switch_to() X-Git-Tag: 4.9.0-rc1~349 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7c00de17562e28f01e188c6a2c240ebc21b9d4b7;p=xen.git VMX: permanently assign PI hook vmx_pi_switch_to() PI hook vmx_pi_switch_to() is needed even after any previously assigned device is detached from the domain. Since 'SN' bit is also used to control the CPU side PI and we change the state of SN bit in vmx_pi_switch_to() and vmx_pi_switch_from(), then evaluate this bit in vmx_deliver_posted_intr() when trying to deliver the interrupt in posted way via software. The problem is if we deassign the hooks while the vCPU is runnable in the runqueue with 'SN' set, all the furture notificaton event will be suppressed. This patch makes the hook permanently assigned. Signed-off-by: Feng Wu Signed-off-by: Chao Gao Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Jan Beulich ). Acked-by: Kevin Tian --- diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index b3d274bcf8..e9f75d71c8 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -259,9 +259,22 @@ void vmx_pi_hooks_deassign(struct domain *d) ASSERT(d->arch.hvm_domain.pi_ops.vcpu_block); + /* + * Note that we don't set 'd->arch.hvm_domain.pi_ops.switch_to' to NULL + * here. If we deassign the hooks while the vCPU is runnable in the + * runqueue with 'SN' set, all the future notification event will be + * suppressed since vmx_deliver_posted_intr() also use 'SN' bit + * as the suppression flag. Preserving the 'switch_to' hook function can + * clear the 'SN' bit when the vCPU becomes running next time. After + * that, No matter which status(runnable, running or block) the vCPU is in, + * the 'SN' bit will keep clear for the 'switch_from' hook function that set + * the 'SN' bit has been removed. At that time, the 'switch_to' hook function + * is also useless. Considering the function doesn't do harm to the whole + * system, leave it here until we find a clean solution to deassign the + * 'switch_to' hook function. + */ d->arch.hvm_domain.pi_ops.vcpu_block = NULL; d->arch.hvm_domain.pi_ops.switch_from = NULL; - d->arch.hvm_domain.pi_ops.switch_to = NULL; d->arch.hvm_domain.pi_ops.do_resume = NULL; }