Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752884AbbFNPVe (ORCPT ); Sun, 14 Jun 2015 11:21:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37702 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751938AbbFNPVX (ORCPT ); Sun, 14 Jun 2015 11:21:23 -0400 Message-ID: <557D9BEE.8010902@redhat.com> Date: Sun, 14 Jun 2015 17:21:18 +0200 From: Denys Vlasenko User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Ingo Molnar CC: Linus Torvalds , Steven Rostedt , Borislav Petkov , "H. Peter Anvin" , Andy Lutomirski , Oleg Nesterov , Frederic Weisbecker , Alexei Starovoitov , Will Drewry , Kees Cook , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/5] x86/asm/entry/32: Replace RESTORE_RSI_RDI[_RDX] with open-coded 32-bit reads References: <1433876051-26604-1-git-send-email-dvlasenk@redhat.com> <1433876051-26604-4-git-send-email-dvlasenk@redhat.com> <20150614084059.GA24562@gmail.com> In-Reply-To: <20150614084059.GA24562@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1477 Lines: 49 On 06/14/2015 10:40 AM, Ingo Molnar wrote: > > * Denys Vlasenko wrote: > >> +8b 74 24 68 mov 0x68(%rsp),%esi >> +8b 7c 24 70 mov 0x70(%rsp),%edi >> +8b 54 24 60 mov 0x60(%rsp),%edx > > Btw., could you (in another patch) order the restoration properly, by pt_regs > memory order, where possible? Will do. > So this: > >> + movl RSI(%rsp), %esi >> + movl RDI(%rsp), %edi >> + movl RDX(%rsp), %edx >> movl RIP(%rsp), %ecx >> movl EFLAGS(%rsp), %r11d > > would become: > > movl RDX(%rsp), %edx > movl RSI(%rsp), %esi > movl RDI(%rsp), %edi > movl RIP(%rsp), %ecx > movl EFLAGS(%rsp), %r11d > > ... or so. Actually, ecx and r11 need to be loaded first. They are not so much "restored" as "prepared for SYSRET insn". Every cycle lost in loading these delays SYSRET. Other loads can be reordered by CPU past SYSRET. > In fact I'd suggest we structure movl based restoration precisely after the field > order in the structure, and comment on cases where we depart from what's in > pt_regs - to make it all easier to verify. Makes sense. I'm sending a two-patch series which (1) open-codes RESTORE_RSI_RDI and (2) sprinkles comments in this area. -- 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/