From: Zachary Amsden Date: Tue, 13 Feb 2007 12:26:21 +0000 (+0100) Subject: [PATCH] i386: iOPL handling for paravirt guests X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8b15114434998a78aa50f8559d69c7a400cff267;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [PATCH] i386: iOPL handling for paravirt guests I found a clever way to make the extra IOPL switching invisible to non-paravirt compiles - since kernel_rpl is statically defined to be zero there, and only non-zero rpl kernel have a problem restoring IOPL, as popf does not restore IOPL flags unless run at CPL-0. Signed-off-by: Zachary Amsden Signed-off-by: Andi Kleen Cc: Andi Kleen Cc: Jeremy Fitzhardinge Cc: Rusty Russell Cc: Chris Wright Signed-off-by: Andrew Morton --- diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c index cfae587bf7d2..05be77413351 100644 --- a/arch/i386/kernel/process.c +++ b/arch/i386/kernel/process.c @@ -669,6 +669,15 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas */ load_TLS(next, cpu); + /* + * Restore IOPL if needed. In normal use, the flags restore + * in the switch assembly will handle this. But if the kernel + * 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)) + set_iopl_mask(next->iopl); + /* * Now maybe handle debug registers and/or IO bitmaps */