Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1003714imu; Fri, 4 Jan 2019 11:06:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN66WCmNWR5RJh+D5oJtqRTbFwzg1cH0sUylNyxCR1XmonIBRyGDFY3BotPYPVxQRH1YFDTv X-Received: by 2002:a62:34c6:: with SMTP id b189mr54795673pfa.229.1546628762555; Fri, 04 Jan 2019 11:06:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546628762; cv=none; d=google.com; s=arc-20160816; b=hj3vgPGaxLlQzUuh4JcX17SVfcWTMdx1O5Wjb5Bwi5YfZj4YUZs91z1zhtCbA5ersa upae5Cr7lM+n4msnlS5YzsBIWaffXeY0+Rs58BFfWRr+Nzkom079rLi7woesFycWA9UZ IyffbKfROokrfsXkNQ06Loe1GLWfucQi+KickSz9aE0zdq2KLF+lXdtWEch6PehuwBRr ENjjb4QAP2rfrBCCdFaoooctkCi/g/v2Gbb+sk9HDq9tNrZ792pxxniZzYH9ktF/oCDD VH27x5uPBJYSqB2hv4lKyyeVoQMNjY0RlSIwhMIAT+0eKThsIrjWprVLw2cJ+5+DARzz bSsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=5l5G19uSEgB3dvxK0i+P1+D/wz9jryMRZbh86J5zwq4=; b=PmTphyIsd45AqTe3RoKP7je3s/3uqf1OZYEvsGLOcznihfgRVQrmC6pSisExUIYWDL 8Y8adnzjUvphAWbhBm2hNJoMHpaRgU2/3lZuXGkYAIhQ/ohczqz+uJfJPGZx9vo4+Dy/ tFD//NR+nlA3uz0ivrfRjrk50aPCHC6fI1ZZY4PNsZvQ7Jjw4sPBfScaujD274CDoybD oATVP83ilMhpJHA+5fF+Wuy/Das7EveKTJzC2SAhvQwKt9F+j1WzqXXH+IBYywP/NCIC HhQ2YHJD/n+JPS3LlyJC8gjFI5j1wQJsC8wgnVKZx69KHOITgQahfIYYlbuHqTwGo57K dm6g== ARC-Authentication-Results: i=1; mx.google.com; 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 k25si18897305pfe.10.2019.01.04.11.05.47; Fri, 04 Jan 2019 11:06:02 -0800 (PST) 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; 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 S1728000AbfADSGw (ORCPT + 99 others); Fri, 4 Jan 2019 13:06:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:44966 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725958AbfADSGw (ORCPT ); Fri, 4 Jan 2019 13:06:52 -0500 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4D612218D3; Fri, 4 Jan 2019 18:06:50 +0000 (UTC) Date: Fri, 4 Jan 2019 13:06:48 -0500 From: Steven Rostedt To: Mark Rutland Cc: Torsten Duwe , Will Deacon , Catalin Marinas , Julien Thierry , Josh Poimboeuf , Ingo Molnar , Ard Biesheuvel , Arnd Bergmann , AKASHI Takahiro , Amit Daniel Kachhap , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org Subject: Re: [PATCH v6] arm64: implement ftrace with regs Message-ID: <20190104130648.02657f3f@gandalf.local.home> In-Reply-To: <20190104175017.GA7157@lakrids.cambridge.arm.com> References: <20190104141053.360F768D93@newverein.lst.de> <20190104175017.GA7157@lakrids.cambridge.arm.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 4 Jan 2019 17:50:18 +0000 Mark Rutland wrote: > At Linux Plumbers, I had a conversation with Steve Rostedt, and we came > to the conclusion that (withut heavyweight synchronization) patching two > NOPs at runtime isn't safe, since a CPU might have executed the first > NOP as a NOP before another CPU patches both instructions. So a CPU > might execute: > > NOP > BL ftrace_regs_caller > > ... rather than the expected: > > MOV X9, X30 > BL ftrace_regs_caller > > ... and therefore X9 contains some UNKNOWN value, rather than the > original LR value. > > I wonder if we could solve that by patching the kernel at build-time, to > add the MOV X9, X30 in place of the first NOP. If we were to do that, we > could also update the addresses to pooint at the second NOP, simplifying > the changes to the runtime code. You can also patch it at boot up when there's only one CPU running, and interrupts are disabled. -- Steve