From: Shuai Ruan Date: Thu, 7 Apr 2016 22:04:13 +0000 (+0200) Subject: x86/xsaves: fix two miscellaneous issues X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~1346 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6b5e0bc7e4ff9e6a8124357d1318259f1cf78b46;p=xen.git x86/xsaves: fix two miscellaneous issues 1. get_xsave_addr() will only be called when xsave_area_compressed(xsave) is true. So drop the conditional expression. 2. expand_xsave_states() will memset the area when get NULL from get_xsave_addr(). Reported-by: Jan Beulich Signed-off-by: Shuai Ruan Reviewed-by: Jan Beulich --- diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c index 8c652bc238..047ac74fa7 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -164,12 +164,9 @@ static void *get_xsave_addr(struct xsave_struct *xsave, const uint16_t *comp_offsets, unsigned int xfeature_idx) { - if ( !((1ul << xfeature_idx) & xsave->xsave_hdr.xstate_bv) ) - return NULL; - - return (void *)xsave + (xsave_area_compressed(xsave) ? - comp_offsets[xfeature_idx] : - xstate_offsets[xfeature_idx]); + ASSERT(xsave_area_compressed(xsave)); + return (1ul << xfeature_idx) & xsave->xsave_hdr.xstate_bv ? + (void *)xsave + comp_offsets[xfeature_idx] : NULL; } void expand_xsave_states(struct vcpu *v, void *dest, unsigned int size) @@ -211,6 +208,8 @@ void expand_xsave_states(struct vcpu *v, void *dest, unsigned int size) ASSERT((xstate_offsets[index] + xstate_sizes[index]) <= size); memcpy(dest + xstate_offsets[index], src, xstate_sizes[index]); } + else + memset(dest + xstate_offsets[index], 0, xstate_sizes[index]); valid &= ~feature; }