Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751348AbbGBPdf (ORCPT ); Thu, 2 Jul 2015 11:33:35 -0400 Received: from mail-lb0-f176.google.com ([209.85.217.176]:36359 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751685AbbGBPd1 (ORCPT ); Thu, 2 Jul 2015 11:33:27 -0400 MIME-Version: 1.0 In-Reply-To: <20150702102520.GE4001@pd.tnic> References: <88b8446ce3af6822db02b5f983b8740f8365e9b4.1435602481.git.luto@kernel.org> <20150702102520.GE4001@pd.tnic> From: Andy Lutomirski Date: Thu, 2 Jul 2015 08:33:05 -0700 Message-ID: Subject: Re: [PATCH v4 10/17] x86/entry/64: Really create an error-entry-from-usermode code path To: Borislav Petkov Cc: Andy Lutomirski , X86 ML , "linux-kernel@vger.kernel.org" , =?UTF-8?B?RnLDqWTDqXJpYyBXZWlzYmVja2Vy?= , Rik van Riel , Oleg Nesterov , Denys Vlasenko , Kees Cook , Brian Gerst , Paul McKenney Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2241 Lines: 65 On Thu, Jul 2, 2015 at 3:25 AM, Borislav Petkov wrote: > On Mon, Jun 29, 2015 at 12:33:42PM -0700, Andy Lutomirski wrote: >> In 539f51136500 ("x86/asm/entry/64: Disentangle error_entry/exit >> gsbase/ebx/usermode code"), I arranged the code slightly wrong -- >> IRET faults would skip the code path that was intended to execute on >> all error entries from user mode. Fix it up. >> >> This does not fix a bug, but we'll need it, and it slightly shrinks >> the code. >> >> Signed-off-by: Andy Lutomirski >> --- >> arch/x86/entry/entry_64.S | 12 ++++++++---- >> 1 file changed, 8 insertions(+), 4 deletions(-) >> >> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S >> index 141a5d49dddc..cd9cbc62159c 100644 >> --- a/arch/x86/entry/entry_64.S >> +++ b/arch/x86/entry/entry_64.S >> @@ -1145,9 +1145,14 @@ ENTRY(error_entry) >> testb $3, CS+8(%rsp) >> jz error_kernelspace >> >> - /* We entered from user mode */ >> +error_entry_from_usermode_swapgs: >> + /* >> + * We entered from user mode or we're pretending to have entered >> + * from user mode due to an IRET fault. >> + */ >> SWAPGS >> >> +error_entry_from_usermode_after_swapgs: >> error_entry_done: > > Why the second label? "Migrate error and interrupt exit work to C" puts code between those labels. I could squash the patches together to make it less mysterious. > > Also, please make all those labels local by prefixing them with .L > because they appear unnecesasrily in objdump output as global symbols. Will do. > > $ objdump -d vmlinux | grep -E "^[0-9a-f]+ <(error_entry_\w*|error_kernelspace|bstep_iret|error_bad_iret)" > ffffffff8167a4a8 : > ffffffff8167a4ab : > ffffffff8167a4b1 : > ffffffff8167a4e0 : > ffffffff8167a4e8 : > > Oh, and shorter please :) > I'll try to think of a good shorter name. No promises :) --Andy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/