From: Jan Beulich Date: Tue, 9 Feb 2016 12:22:13 +0000 (+0100) Subject: x86/nHVM: avoid NULL deref during INVLPG intercept handling X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=86c59615f4e7f38df24182f20d9dbdec3299c514;p=people%2Fliuw%2Flibxenctrl-split%2Fxen.git x86/nHVM: avoid NULL deref during INVLPG intercept handling When intercepting (or emulating) L1 guest INVLPG, the nested P2M pointer may be (is?) NULL, and hence there's no point in calling p2m_flush(). In fact doing so would cause a dereference of that NULL pointer at least in the ASSERT() right at the beginning of the function. While so far nothing supports hap_invlpg() being reachable from the INVLPG intercept paths (only INVLPG insn emulation would lead there), and hence the code in question (added by dd6de3ab99 ["Implement Nested-on-Nested"]) appears to be dead, this seems to be the change which can be agreed on as an immediate fix. Ideally, however, the problematic code would go away altogether. See thread at lists.xenproject.org/archives/html/xen-devel/2016-01/msg03762.html. Reported-by: 刘令 Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper Acked-by: George Dunlap --- diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index ee87825a39..f173539549 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -687,7 +687,8 @@ static bool_t hap_invlpg(struct vcpu *v, unsigned long va) * Must perform the flush right now or an other vcpu may * use it when we use the next VMRUN emulation, otherwise. */ - p2m_flush(v, vcpu_nestedhvm(v).nv_p2m); + if ( vcpu_nestedhvm(v).nv_p2m ) + p2m_flush(v, vcpu_nestedhvm(v).nv_p2m); return 1; }