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 72039C43219 for ; Tue, 30 Apr 2019 11:19:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 452FA21707 for ; Tue, 30 Apr 2019 11:19:21 +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="AflxWRnR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727770AbfD3LTU (ORCPT ); Tue, 30 Apr 2019 07:19:20 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:55220 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726648AbfD3LTS (ORCPT ); Tue, 30 Apr 2019 07:19:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=L6RbtbALsHZdEB1dBgFqPR0csu0ISaHiL/UV6U5cQuY=; b=AflxWRnRKui1Arz8Gz8hqwfhh hSyqQce0AL36oM5bSHSDDxAPOC8yZA3631xf2pNjInQQ+Un7XTJd4TFbRvjYkKdS3Cu0PFCRV6e+Q Y5TK909VdvuD3W/E6upJEwVk8emMg+3FounrP4GB2EoELK7eMWRUArlQDxgsVSw9ze+j8UVAk6+Yh T4zq2UaKM1xNBten2qYt3fKJYCCViKMEc6VmjxIQLPpEfv51twOcnPtNNjvhWz5ewQBFWXLA/A3d+ agzaOR9Yg6Ev9i/pHuyzq+Rq5k5T/zTbmaF1WvwmdS9DvY5cvsNYqrVnrbOLTQnjYFJ4I3pMttUFz 3zN9KWVBw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLQme-00086p-P4; Tue, 30 Apr 2019 11:18:48 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 7A84129B1115A; Tue, 30 Apr 2019 13:18:46 +0200 (CEST) Date: Tue, 30 Apr 2019 13:18:46 +0200 From: Peter Zijlstra To: Linus Torvalds Cc: Andy Lutomirski , Steven Rostedt , 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: [PATCH 3/4] x86/ftrace: make ftrace_int3_handler() not to skip fops invocation Message-ID: <20190430111846.GS2623@hirez.programming.kicks-ass.net> References: <20190427100639.15074-1-nstange@suse.de> <20190427100639.15074-4-nstange@suse.de> <20190427102657.GF2623@hirez.programming.kicks-ass.net> <20190428133826.3e142cfd@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 Mon, Apr 29, 2019 at 03:06:30PM -0700, Linus Torvalds wrote: > On Mon, Apr 29, 2019 at 11:57 AM Andy Lutomirski wrote: > > > > > > Otherwise you could never trust the whole sti shadow thing - and it very much is part of the architecture. > > > > Is this documented somewhere? > > Btw, if you really don't trust the sti shadow despite it going all the > way back to the 8086, then you could instead make the irqoff code do > > push %gs:bp_call_return > push %gs:bp_call_target > sti > ret This variant cures the RETPOLINE complaint; due to there not actually being an indirect jump anymore. And it cures the sibling call complaint, but trades it for "return with modified stack frame". Something like so is clean: +extern asmlinkage void emulate_call_irqon(void); +extern asmlinkage void emulate_call_irqoff(void); + +asm( + ".text\n" + ".global emulate_call_irqoff\n" + ".type emulate_call_irqoff, @function\n" + "emulate_call_irqoff:\n\t" + "push %gs:bp_call_return\n\t" + "push %gs:bp_call_target\n\t" + "sti\n\t" + "ret\n" + ".size emulate_call_irqoff, .-emulate_call_irqoff\n" + + ".global emulate_call_irqon\n" + ".type emulate_call_irqon, @function\n" + "emulate_call_irqon:\n\t" + "push %gs:bp_call_return\n\t" + "push %gs:bp_call_target\n\t" + "ret\n" + ".size emulate_call_irqon, .-emulate_call_irqon\n" + ".previous\n"); + +STACK_FRAME_NON_STANDARD(emulate_call_irqoff); +STACK_FRAME_NON_STANDARD(emulate_call_irqon);