Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2279344imm; Thu, 21 Jun 2018 09:52:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJaxrst5AABpLDfiUBF60uC/zgGvkpjm16NAUscJuO3SQHEG8+CWdf8JwTt5hlfRofoB+1C X-Received: by 2002:a63:9246:: with SMTP id s6-v6mr6369427pgn.35.1529599958278; Thu, 21 Jun 2018 09:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529599958; cv=none; d=google.com; s=arc-20160816; b=pECnFSGkyY1eSKLP3J3gNaqPSLKbCP4FUsfvxpKNm4xESMKMuvlkq+MBpb5yZEUOj7 IURF+cSlcMlZO4MGC20PX8UYMefbzGJJesDe3c40XYmiKjs6Z7b4x37mDUYW06e3Tsm8 Ufhzs3dTz6IbNgGfT+WLb+TgW6YssUhwVPv86OfWZp+4w4n+BYjpJmwoDamaj42hre4X B3SSIOpOcZWPH2EiAhHm7VwrehnAxSUr+yFh/sxHrbmT+dgkjWxt5Ml1TXGnyHAm5+3O BJKDkKfYRshn5s1BMFssXAW+yuSUUMjzC0jfWTTVmMKlXoDvg2KtsATCkgEkt9+53Ezn lFYg== 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 :arc-authentication-results; bh=Occ8Rlm0hmeMl2X3/eGHOWDpppG1taYK586GV1L4HNk=; b=KOZnm6wkbdM2y/DpvQ46FEKyP8v4N+ryv1Ba9qpmXM5RIgEL/kK9zwaaeODw+calbv HH0Yz2bl1xc3BS9PQwRglwvC8/wniE1aEJMS0M0H1e1Dd/I98BwXteFzlKnIfwEGpncG A/+69qxkpceTrnWtyyvlD1PR3WC21XamVqv7piQjv07KJpI6nlluMdiIdjUKADv5erYt cP77+V1mV1iW8nv82Ctc1Pfb1TVPFuX7VSvxG3rykMZsKEnev/S9s3ENMWg2t/lbRcnP bgkt57jrdvhNjBWPlB+1tZ4au3d063OTd/TqsNWAsoNZcBva87hVWyUwAVDk0HDlBaUg 8Y7w== 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 60-v6si5198448pla.376.2018.06.21.09.52.21; Thu, 21 Jun 2018 09:52:38 -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; 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 S933520AbeFUQu3 (ORCPT + 99 others); Thu, 21 Jun 2018 12:50:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:60542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933429AbeFUQu2 (ORCPT ); Thu, 21 Jun 2018 12:50:28 -0400 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 4412E21708; Thu, 21 Jun 2018 16:50:27 +0000 (UTC) Date: Thu, 21 Jun 2018 12:50:25 -0400 From: Steven Rostedt To: LKML , linux-arm-kernel@lists.infradead.org, Russell King - ARM Linux Cc: Stefan Agner , abelvesa@linux.com, Abhishek Sagar , Ingo Molnar Subject: Re: [PATCH] ARM: ftrace: Only set kernel memory back to read-only after boot Message-ID: <20180621125025.25b70bb9@gandalf.local.home> In-Reply-To: <20180621124710.453ee0ae@gandalf.local.home> References: <20180621124710.453ee0ae@gandalf.local.home> 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 Thu, 21 Jun 2018 12:47:10 -0400 Steven Rostedt wrote: > From: Steven Rostedt (VMware) > > Dynamic ftrace requires modifying the code segments that are usually > set to read-only. To do this, a per arch function is called both before > and after the ftrace modifications are performed. The "before" function > will set kernel code text to read-write to allow for ftrace to make the > modifications, and the "after" function will set the kernel code text > back to "read-only" to keep the kernel code text protected. > > The issue happens when dynamic ftrace is tested at boot up. The test is > done before the kernel code text has been set to read-only. But the > "before" and "after" calls are still performed. The "after" call will > change the kernel code text to read-only prematurely, and other boot > code that expects this code to be read-write will fail. > > The solution is to add a variable that is set when the kernel code text > is expected to be converted to read-only, and make the ftrace "before" > and "after" calls do nothing if that variable is not yet set. This is > similar to the x86 solution from commit 162396309745 ("ftrace, x86: > make kernel text writable only for conversions"). > > Reported-by: Stefan Agner > Tested-by: Stefan Agner > Link: http://lkml.kernel.org/r/20180620212906.24b7b66e@vmware.local.home > Signed-off-by: Steven Rostedt (VMware) > --- Perhaps I should have Cc'd stable too? -- Steve