From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751897AbdLBPSo (ORCPT ); Sat, 2 Dec 2017 10:18:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53154 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751749AbdLBPSn (ORCPT ); Sat, 2 Dec 2017 10:18:43 -0500 Date: Sat, 2 Dec 2017 09:18:40 -0600 From: Josh Poimboeuf To: Andy Lutomirski Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , Brian Gerst , David Laight , Kees Cook , Peter Zijlstra Subject: Re: [PATCH 4/6] Unsuck "x86/entry/64: Create a percpu SYSCALL entry trampoline" Message-ID: <20171202151840.7qeuvg6nxoqmat6a@treble> References: <8000c2851af491df898d232ecb7500857e2716ea.1512109321.git.luto@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <8000c2851af491df898d232ecb7500857e2716ea.1512109321.git.luto@kernel.org> User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Sat, 02 Dec 2017 15:18:43 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 30, 2017 at 10:29:44PM -0800, Andy Lutomirski wrote: > diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S > index caf74a1bb3de..28f4e7553c26 100644 > --- a/arch/x86/entry/entry_64.S > +++ b/arch/x86/entry/entry_64.S > @@ -180,14 +180,24 @@ ENTRY(entry_SYSCALL_64_trampoline) > > /* > * x86 lacks a near absolute jump, and we can't jump to the real > - * entry text with a relative jump, so we fake it using retq. > + * entry text with a relative jump. We could push the target > + * address and then use retq, but this destroys the pipeline on > + * many CPUs (wasting over 20 cycles on Sandy Bridge). Instead, > + * spill RDI and restore it in a second-stage trampoline. > */ > - pushq $entry_SYSCALL_64_after_hwframe > - retq > + pushq %rdi > + movq $entry_SYSCALL_64_stage2, %rdi > + jmp *%rdi > END(entry_SYSCALL_64_trampoline) > > .popsection > > +ENTRY(entry_SYSCALL_64_stage2) > + UNWIND_HINT_EMPTY > + popq %rdi > + jmp entry_SYSCALL_64_after_hwframe > +END(entry_SYSCALL_64_stage2) > + > ENTRY(entry_SYSCALL_64) > UNWIND_HINT_EMPTY > /* Another crazy idea: call 1f 1: movq $entry_SYSCALL_64_after_hwframe, (%rsp) ret Does that fix the regression? -- Josh