Commit 922eea2c authored by Jan Beulich's avatar Jan Beulich Committed by Thomas Gleixner

x86/xen/32: Simplify ring check in xen_iret_crit_fixup()

This can be had with two instead of six insns, by just checking the high
CS.RPL bit.

Also adjust the comment - there would be no #GP in the mentioned cases, as
there's no segment limit violation or alike. Instead there'd be #PF, but
that one reports the target EIP of said branch, not the address of the
branch insn itself.
Signed-off-by: default avatarJan Beulich <jbeulich@suse.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
Link: https://lkml.kernel.org/r/a5986837-01eb-7bf8-bf42-4d3084d6a1f5@suse.com
parent 29b810f5
...@@ -153,22 +153,15 @@ hyper_iret: ...@@ -153,22 +153,15 @@ hyper_iret:
* it's still on stack), we need to restore its value here. * it's still on stack), we need to restore its value here.
*/ */
ENTRY(xen_iret_crit_fixup) ENTRY(xen_iret_crit_fixup)
pushl %ecx
/* /*
* Paranoia: Make sure we're really coming from kernel space. * Paranoia: Make sure we're really coming from kernel space.
* One could imagine a case where userspace jumps into the * One could imagine a case where userspace jumps into the
* critical range address, but just before the CPU delivers a * critical range address, but just before the CPU delivers a
* GP, it decides to deliver an interrupt instead. Unlikely? * PF, it decides to deliver an interrupt instead. Unlikely?
* Definitely. Easy to avoid? Yes. The Intel documents * Definitely. Easy to avoid? Yes.
* explicitly say that the reported EIP for a bad jump is the
* jump instruction itself, not the destination, but some
* virtual environments get this wrong.
*/ */
movl 3*4(%esp), %ecx /* nested CS */ testb $2, 2*4(%esp) /* nested CS */
andl $SEGMENT_RPL_MASK, %ecx jnz 2f
cmpl $USER_RPL, %ecx
popl %ecx
je 2f
/* /*
* If eip is before iret_restore_end then stack * If eip is before iret_restore_end then stack
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment