Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4779287yba; Tue, 30 Apr 2019 04:21:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6D5JcKuZ+qpw1WzQD2F2dWFyYckWowcVQQjnTkGtRnjgHkSRkW87sl7P4EHbT9bMuY7N/ X-Received: by 2002:a62:e117:: with SMTP id q23mr8976088pfh.60.1556623315013; Tue, 30 Apr 2019 04:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556623315; cv=none; d=google.com; s=arc-20160816; b=cXaGOXf6qtm6idVLQcGfQ5JB8lH0Ko36FJynB+cUh4menCWqHkCuRaNgZNkbu0c2/Q xbRf+qcP7Nn94sah0onww8JA/nKkNf74TAwb7VY4m0CL1lChjEteQHPtPUbmKopGxVyB s512/o7hJb1DOjYIA95v3G6L69ioLZsMOl7Ar/boqkHaiJNQBBCJ1weQSKU70rlkIjsj Hn7dBBSYJD5CaYdqDUEMybQ2WPbwQDlID+JhUufIZwL9JIbOCaS1slAOudhZ/Ec+aNTz TYt/aiy6tC8R7unfd/n9i02sIs/cIx8qyjpEzwnzp7x4iM3AdZ55i03arqUcswFA55X9 5FHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=L6RbtbALsHZdEB1dBgFqPR0csu0ISaHiL/UV6U5cQuY=; b=F+n8kMJdOAA86qWA8H7O837P6mMNGlQjU9x76wk3EuhiPQ4ANz5sSdaOH1c2O0tPKj gHxp22SnhAAOBviWWxO09y1jeJBZVVsthf/IPlt2qePnsy4moGHjd5EDbk3j6N/XZp8C zLh9rCuUiKdpIL4HjR4BRRKmS3gVJ7jeEYcE1dVdWnNrpsGv25aS2W/3+zLDpgunKWgK rJQSB29wSYat7qEhs3oEgAPt8CZ6R5XAOFVwnsjwH4Wqd5O8raG7KzCycvmzOfcKT1aJ qoYXfL7v8sADgb9EF1Z2HDdUvgzfES3FbCUfrs0NYmAcgrfslIwyPYcB2MFlrmnKi5mo I+6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=AflxWRnR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o14si17070624pgj.241.2019.04.30.04.21.38; Tue, 30 Apr 2019 04:21:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=AflxWRnR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727727AbfD3LTU (ORCPT + 99 others); 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);