[PATCH 2/3] x86-32: Simplify IOPL switch check

From: Brian Gerst
Date: Wed Jun 14 2017 - 08:46:43 EST


Remove the get_kernel_rpl() call from the test for switching IOPL. Instead
make set_iopl_mask() a no-op when Xen is running in supervisor mode.

Signed-off-by: Brian Gerst <brgerst@xxxxxxxxx>
---
arch/x86/kernel/process_32.c | 2 +-
arch/x86/xen/enlighten_pv.c | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index ffeae81..b2d1f7c 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -263,7 +263,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
* is running virtualized at a non-zero CPL, the popf will
* not restore flags, so it must be done in a separate step.
*/
- if (get_kernel_rpl() && unlikely(prev->iopl != next->iopl))
+ if (unlikely(prev->iopl != next->iopl))
set_iopl_mask(next->iopl);

/*
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index f33eef4..05257c0 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -1350,8 +1350,10 @@ asmlinkage __visible void __init xen_start_kernel(void)

#ifdef CONFIG_X86_32
pv_info.kernel_rpl = 1;
- if (xen_feature(XENFEAT_supervisor_mode_kernel))
+ if (xen_feature(XENFEAT_supervisor_mode_kernel)) {
pv_info.kernel_rpl = 0;
+ pv_cpu_ops.set_iopl_mask = paravirt_nop;
+ }
#else
pv_info.kernel_rpl = 0;
#endif
--
2.9.4