From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754597AbbCIPBG (ORCPT ); Mon, 9 Mar 2015 11:01:06 -0400 Received: from mail-qc0-f176.google.com ([209.85.216.176]:39335 "EHLO mail-qc0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754122AbbCIPBD (ORCPT ); Mon, 9 Mar 2015 11:01:03 -0400 MIME-Version: 1.0 In-Reply-To: References: <1425909943-14687-1-git-send-email-dvlasenk@redhat.com> From: Denys Vlasenko Date: Mon, 9 Mar 2015 16:00:42 +0100 Message-ID: Subject: Re: [PATCH] x86: entry_32.S: change ESPFIX test to not touch PT_OLDSS(%esp) To: Andy Lutomirski Cc: Denys Vlasenko , Linus Torvalds , Steven Rostedt , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Oleg Nesterov , Frederic Weisbecker , Alexei Starovoitov , Will Drewry , Kees Cook , X86 ML , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 9, 2015 at 3:18 PM, Andy Lutomirski wrote: > Do we actually need espfix on all returns to vm86 mode? No, the current code (and my new version) does *not* do espfix for vm86. It's not needed (apparently). >> + btl $X86_EFLAGS_VM_BIT,PT_EFLAGS(%esp) >> + jc restore_nocheck # VM set, not it > > This seems useless. In vm86 mode, espfix should work fine (even if > pointlessly), CS won't have the two low bits set, and SS won't > reference the LDT because it's not a selector at all. You seem to suggest we can drop VM flag test. If we do that, the tests for CS and SS will work on bogus data. I.e. they will semi-randomly rouse execution through espfix. Which will probably work correctly, but IIRC espfix does crazy stuff which is likely to be slow. What we definitely should do here is at least frame this check with "#ifdef CONFIG_VM86". > That being said, what ends up in the high bits of esp when we iret to > vm86 mode? I don't know. I guess it's time to write an actual vm86 testcase :)