* [PATCH V2] x86/xsaves: get_xsave_addr, check xsave header and support uncompressed format
@ 2015-12-18 15:03 Huaitong Han
2015-12-18 15:13 ` Andrew Cooper
0 siblings, 1 reply; 2+ messages in thread
From: Huaitong Han @ 2015-12-18 15:03 UTC (permalink / raw)
To: jbeulich, andrew.cooper3, keir; +Cc: Huaitong Han, shuai.ruan, xen-devel
The check needs to be against the xsave header in the area, rather than Xen's
maximum xfeature_mask. A guest might easily have a smaller xcr0 than the
maximum Xen is willing to allow, causing the pointer below to be bogus.
The get_xsave_addr() is modified to support uncompressed xstate areas.
Signed-off-by: Huaitong Han <huaitong.han@intel.com>
---
xen/arch/x86/xstate.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c
index b65da38..4e87ab3 100644
--- a/xen/arch/x86/xstate.c
+++ b/xen/arch/x86/xstate.c
@@ -146,12 +146,15 @@ static void __init setup_xstate_comp(void)
}
}
-static void *get_xsave_addr(void *xsave, unsigned int xfeature_idx)
+static void *get_xsave_addr(struct xsave_struct *xsave,
+ unsigned int xfeature_idx)
{
- if ( !((1ul << xfeature_idx) & xfeature_mask) )
+ if ( !((1ul << xfeature_idx) & xsave->xsave_hdr.xstate_bv) )
return NULL;
- return xsave + xstate_comp_offsets[xfeature_idx];
+ return (void *)xsave + (xsave_area_compressed(xsave)
+ ? xstate_comp_offsets
+ : xstate_offsets)[xfeature_idx];
}
void expand_xsave_states(struct vcpu *v, void *dest, unsigned int size)
--
2.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH V2] x86/xsaves: get_xsave_addr, check xsave header and support uncompressed format
2015-12-18 15:03 [PATCH V2] x86/xsaves: get_xsave_addr, check xsave header and support uncompressed format Huaitong Han
@ 2015-12-18 15:13 ` Andrew Cooper
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2015-12-18 15:13 UTC (permalink / raw)
To: Huaitong Han, jbeulich, keir; +Cc: shuai.ruan, xen-devel
On 18/12/15 15:03, Huaitong Han wrote:
> The check needs to be against the xsave header in the area, rather than Xen's
> maximum xfeature_mask. A guest might easily have a smaller xcr0 than the
> maximum Xen is willing to allow, causing the pointer below to be bogus.
>
> The get_xsave_addr() is modified to support uncompressed xstate areas.
>
> Signed-off-by: Huaitong Han <huaitong.han@intel.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-18 15:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-18 15:03 [PATCH V2] x86/xsaves: get_xsave_addr, check xsave header and support uncompressed format Huaitong Han
2015-12-18 15:13 ` Andrew Cooper
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.