From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753645AbbCQNve (ORCPT ); Tue, 17 Mar 2015 09:51:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44446 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752859AbbCQNvd (ORCPT ); Tue, 17 Mar 2015 09:51:33 -0400 Message-ID: <55083160.1010008@redhat.com> Date: Tue, 17 Mar 2015 14:51:28 +0100 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: Denys Vlasenko , 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 1/2] x86/asm/entry/64: Enable interrupts *after* we fetch PER_CPU_VAR(old_rsp) References: <1426599779-8010-1-git-send-email-dvlasenk@redhat.com> In-Reply-To: <1426599779-8010-1-git-send-email-dvlasenk@redhat.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 On 03/17/2015 02:42 PM, Denys Vlasenko wrote: > Without this change, it is still not possible to get rid of > PER_CPU_VAR(old_rsp) usage in switch_to: if preemption happens > while we did not fetch PER_CPU_VAR(old_rsp) and stored it in pt_regs->sp, > PER_CPU_VAR(old_rsp) gets corrupted by other task's user sp. > > Signed-off-by: Denys Vlasenko > CC: Linus Torvalds > CC: Steven Rostedt > CC: Ingo Molnar > CC: Borislav Petkov > CC: "H. Peter Anvin" > CC: Andy Lutomirski > CC: Oleg Nesterov > CC: Frederic Weisbecker > CC: Alexei Starovoitov > CC: Will Drewry > CC: Kees Cook > CC: x86@kernel.org > CC: linux-kernel@vger.kernel.org > --- > > Run-tested, including with PARAVIRT on. Well. The testing with PARAVIRT did work, however, I don't know why. > movq_cfi rax,ORIG_RAX > + /* > + * No need to follow this irqs off/on section - it's straight > + * and short: > + */ > + ENABLE_INTERRUPTS(CLBR_RAX) Here I wrongly assumed that now I can clobber rax, since it is saved in pt_regs->orig_ax now. Wrong. Code below still wants to use rax register directly. Looks like I was "lucky" and paravirt call happen to not change rax. I'll send a v2 patch without this ill-advised attempt of optimization. Sorry.