From mboxrd@z Thu Jan 1 00:00:00 1970 From: peterz at infradead.org (Peter Zijlstra) Date: Wed, 1 May 2019 21:17:16 +0200 Subject: [RFC][PATCH v3] ftrace/x86_64: Emulate call function while updating in breakpoint handler In-Reply-To: References: <20190501113238.0ab3f9dd@gandalf.local.home> <20190501145200.6c095d7f@oasis.local.home> Message-ID: <20190501191716.GV7905@worktop.programming.kicks-ass.net> On Wed, May 01, 2019 at 11:59:05AM -0700, Linus Torvalds wrote: > On Wed, May 1, 2019 at 11:52 AM Steven Rostedt wrote: > > > > I got Peter's patch working. Here it is. What do you think? > > I can tell from just looking at it for five seconds that at least the > 32-bit case is buggy. > > You can't look at CS(%rsp) without first also checking that you're not > coming from vm86 mode. Something like so then? Index: linux-2.6/arch/x86/entry/entry_32.S =================================================================== --- linux-2.6.orig/arch/x86/entry/entry_32.S +++ linux-2.6/arch/x86/entry/entry_32.S @@ -1479,6 +1479,10 @@ ENTRY(int3) ASM_CLAC pushl $-1 # mark this as an int +#ifdef CONFIG_VM86 + testl $X86_EFLAGS_VM, PT_EFLAGS(%esp) + jnz .Lfrom_usermode_no_gap +#endif testl $SEGMENT_RPL_MASK, PT_CS(%esp) jnz .Lfrom_usermode_no_gap .rept 6 From mboxrd@z Thu Jan 1 00:00:00 1970 From: peterz@infradead.org (Peter Zijlstra) Date: Wed, 1 May 2019 21:17:16 +0200 Subject: [RFC][PATCH v3] ftrace/x86_64: Emulate call function while updating in breakpoint handler In-Reply-To: References: <20190501113238.0ab3f9dd@gandalf.local.home> <20190501145200.6c095d7f@oasis.local.home> Message-ID: <20190501191716.GV7905@worktop.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" Message-ID: <20190501191716.Tcs-hUE4QEtbkTjHqvhdIrCHu0VKTHbBRNPA_lNXFSc@z> On Wed, May 01, 2019@11:59:05AM -0700, Linus Torvalds wrote: > On Wed, May 1, 2019@11:52 AM Steven Rostedt wrote: > > > > I got Peter's patch working. Here it is. What do you think? > > I can tell from just looking at it for five seconds that at least the > 32-bit case is buggy. > > You can't look at CS(%rsp) without first also checking that you're not > coming from vm86 mode. Something like so then? Index: linux-2.6/arch/x86/entry/entry_32.S =================================================================== --- linux-2.6.orig/arch/x86/entry/entry_32.S +++ linux-2.6/arch/x86/entry/entry_32.S @@ -1479,6 +1479,10 @@ ENTRY(int3) ASM_CLAC pushl $-1 # mark this as an int +#ifdef CONFIG_VM86 + testl $X86_EFLAGS_VM, PT_EFLAGS(%esp) + jnz .Lfrom_usermode_no_gap +#endif testl $SEGMENT_RPL_MASK, PT_CS(%esp) jnz .Lfrom_usermode_no_gap .rept 6 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C148C43219 for ; Wed, 1 May 2019 19:17:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D2B72085A for ; Wed, 1 May 2019 19:17:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="KQvdmwVH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726242AbfEATRk (ORCPT ); Wed, 1 May 2019 15:17:40 -0400 Received: from merlin.infradead.org ([205.233.59.134]:47770 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726079AbfEATRj (ORCPT ); Wed, 1 May 2019 15:17:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+gSyYjZ0CwmIbD+YmCAZE4zrdyoc/i5bD93o1EN4L80=; b=KQvdmwVHilv+bxpOq/seGyHad tQ0SRr3bxpB90tmiYqSJbtSkK6pqddKpXZ32ibe4RtPDFQ2g8jMkIpQV754ck4ah1VA1rZ9z3DY2U uvgb0Bkdcwsju6e6K0LYl3JH1BG/Xko4HfwxSiTuN3BonXUK9EwUad4jUwgh3j+Pkd33LK3/W+EGe RoM2/reFIFUPLuwfvs7O84VXvqJW9WfI6fnQzWaRVKKrSuii+0UMuDZZDkCt/zgEGeXPrcJ6orE3r UOu8jRm7W6lvVtD+x8blkVRWdK7RR8SnXIC2wRiR/S8ytsB712yA4Yk8sH/3J6KCmqCqluHZdVmYz J0dcN5JUA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLujG-0002tD-T7; Wed, 01 May 2019 19:17:19 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 1A283984EB4; Wed, 1 May 2019 21:17:16 +0200 (CEST) Date: Wed, 1 May 2019 21:17:16 +0200 From: Peter Zijlstra To: Linus Torvalds Cc: Steven Rostedt , Andy Lutomirski , Nicolai Stange , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , the arch/x86 maintainers , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Shuah Khan , Konrad Rzeszutek Wilk , Tim Chen , Sebastian Andrzej Siewior , Mimi Zohar , Juergen Gross , Nick Desaulniers , Nayna Jain , Masahiro Yamada , Joerg Roedel , Linux List Kernel Mailing , live-patching@vger.kernel.org, "open list:KERNEL SELFTEST FRAMEWORK" Subject: Re: [RFC][PATCH v3] ftrace/x86_64: Emulate call function while updating in breakpoint handler Message-ID: <20190501191716.GV7905@worktop.programming.kicks-ass.net> References: <20190501113238.0ab3f9dd@gandalf.local.home> <20190501145200.6c095d7f@oasis.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 01, 2019 at 11:59:05AM -0700, Linus Torvalds wrote: > On Wed, May 1, 2019 at 11:52 AM Steven Rostedt wrote: > > > > I got Peter's patch working. Here it is. What do you think? > > I can tell from just looking at it for five seconds that at least the > 32-bit case is buggy. > > You can't look at CS(%rsp) without first also checking that you're not > coming from vm86 mode. Something like so then? Index: linux-2.6/arch/x86/entry/entry_32.S =================================================================== --- linux-2.6.orig/arch/x86/entry/entry_32.S +++ linux-2.6/arch/x86/entry/entry_32.S @@ -1479,6 +1479,10 @@ ENTRY(int3) ASM_CLAC pushl $-1 # mark this as an int +#ifdef CONFIG_VM86 + testl $X86_EFLAGS_VM, PT_EFLAGS(%esp) + jnz .Lfrom_usermode_no_gap +#endif testl $SEGMENT_RPL_MASK, PT_CS(%esp) jnz .Lfrom_usermode_no_gap .rept 6