Skip to contentSkip to conversation

ix86: really make user_mode() work correctly for VM86 mode

PATCH In review Jan Beulich 4 participants 4 messages May 28, 2015 – May 29, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ix86: really make user_mode() work correctly for VM86 mode

While commit efa7045103 ("x86/asm/entry: Make user_mode() work correctly if regs came from VM86 mode") claims that "user_mode() is now identical to user_mode_vm()", this wasn't actually the case - no prior commit made it so.

Cc Andy Lutomirski <[email protected]>
---
 arch/x86/include/asm/ptrace.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/include/asm/ptrace.h +2 -1
@@ -107,7 +107,8 @@ static inline unsigned long regs_return_
 static inline int user_mode(struct pt_regs *regs)
 {
 #ifdef CONFIG_X86_32
-	return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
+	return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK))
+	       >= USER_RPL;
 #else
 	return !!(regs->cs & 3);
 #endif
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jan Beulich

While commit efa7045103 ("x86/asm/entry: Make user_mode() work correctly if regs came from VM86 mode") claims that "user_mode() is now identical to user_mode_vm()", this wasn't actually the case - no prior commit made it so.

That's embarrassing! I'm not sure how I screwed that up.

This is needed for x86/urgent. I'll see if I can write a simple test case, too. My old do_bounds test should be a good start.

--Andy

#2 lore raw
Quoted 8 lines · Andy Lutomirski
Quoted 5 lines · Jan Beulich

While commit efa7045103 ("x86/asm/entry: Make user_mode() work correctly if regs came from VM86 mode") claims that "user_mode() is now identical to user_mode_vm()", this wasn't actually the case - no prior commit made it so.

That's embarrassing! I'm not sure how I screwed that up.

I should have noticed it too :-/

In fact I remember that I wanted to double check it all because the algorithmic complexity of the new test looked suspiciously too simple on the 32-bit side (we _did_ have a legitimate reason to keep the API split originally) - but forgot about it.

Quoted 3 lines

This is needed for x86/urgent.

Yeah, queued it up.

Quoted 2 lines

[...] I'll see if I can write a simple test case, too. My old do_bounds test should be a good start.

That kind of test would be absolutely fantastic to have.

Thanks,

Ingo

#3 lore raw

[tip:x86/urgent] x86/asm/entry/32: Really make user_mode() work correctly for VM86 mode

In reply to Jan Beulich
x86/asm/entry/32: Really make user_mode() work correctly for VM86 mode
Commit-ID:  7ba554b5ac69e5f3edac9ce3233beb5acd480878
Gitweb:     http://git.kernel.org/tip/7ba554b5ac69e5f3edac9ce3233beb5acd480878
Author:     Jan Beulich <[email protected]>
AuthorDate: Thu, 28 May 2015 09:16:45 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 29 May 2015 09:46:40 +0200

x86/asm/entry/32: Really make user_mode() work correctly for VM86 mode

While commit efa7045103 ("x86/asm/entry: Make user_mode() work correctly if regs came from VM86 mode") claims that "user_mode() is now identical to user_mode_vm()", this wasn't actually the case - no prior commit made it so.

Cc Andy Lutomirski <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/include/asm/ptrace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/ptrace.h +1 -1
index 19507ff..5fabf13 100644
@@ -107,7 +107,7 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
 static inline int user_mode(struct pt_regs *regs)
 {
 #ifdef CONFIG_X86_32
-	return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
+	return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >= USER_RPL;
 #else
 	return !!(regs->cs & 3);
 #endif