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=-5.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable 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 136DEC10F29 for ; Tue, 17 Mar 2020 15:18:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDA7020724 for ; Tue, 17 Mar 2020 15:18:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uaG4cr4b"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="LUy+Ookc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDA7020724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OJUK9m4EFK+m+7oTv0TS7/tur13nc5hnWaEyYt4nmAs=; b=uaG4cr4bnARUkn 9eolM2QRyb9L1saqTWyo1ktJAX/2ZBa1YUcgFRQOTe8mGG9ULq8pAjGTIfUekGh9YxJt1P+zNCKrL lG+lgjfriNJ59c0U9glqPpm/AUMdg0nfBuCfR/FD165C6iRyrjKBuoEUkktgFM06ABduw2mZBi9KP 08GNCUrGPQc1+Txq5ZMnGWPiKbdfNjnFy0foohUHCUXnt02pnwheQBsLx3Q9BmbfWJbDcBEfvGAaP NHBqdJLkaINUEGmPDiP+hSyNm4gHvc8/YnalRwfV62dIvTV6Pi7ENQFT+3bqEKU/xxX02GQ+OOWRf IXl7IHd0WZR6AV+1occg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEDzF-0004Jw-Sa; Tue, 17 Mar 2020 15:18:33 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEDz1-0004AK-QY for linux-arm-kernel@lists.infradead.org; Tue, 17 Mar 2020 15:18:21 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (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 DD79C20714; Tue, 17 Mar 2020 15:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584458299; bh=kPqFh2OC+QYr6S9udTfHPUyXCCUZbCYYP+w4Ykyo5ac=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LUy+OokcgDni5hFal9vNvB6rC6CWzLecLAR9f1XopbpdGlLV9X07U3BWT4J1Jyptv +BJnDAuiik5lDTDZCkqpU0RGXJefbmywJuUAg/a8wyiePh7LnOVpvESitpBYCV7A+e 2DBa1Y8EAPamXkr2ZdZUIVFv/dQQwZOAdMfsZp2Y= Date: Tue, 17 Mar 2020 15:18:14 +0000 From: Will Deacon To: Mark Brown Subject: Re: [RFC PATCH] arm64: fix the missing ktpi= cmdline check in arm64_kernel_unmapped_at_el0() Message-ID: <20200317151813.GA16579@willie-the-truck> References: <20200317114708.109283-1-yaohongbo@huawei.com> <20200317121050.GH8831@lakrids.cambridge.arm.com> <20200317124323.GA16200@willie-the-truck> <20200317135719.GH3971@sirena.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200317135719.GH3971@sirena.org.uk> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200317_081819_952429_1A22F3E2 X-CRM114-Status: GOOD ( 22.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , catalin.marinas@arm.com, Hongbo Yao , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Mar 17, 2020 at 01:57:19PM +0000, Mark Brown wrote: > On Tue, Mar 17, 2020 at 12:43:24PM +0000, Will Deacon wrote: > > On Tue, Mar 17, 2020 at 12:10:51PM +0000, Mark Rutland wrote: > > > On Tue, Mar 17, 2020 at 07:47:08PM +0800, Hongbo Yao wrote: > > > > > Kpti cannot be disabled from the kernel cmdline after the commit > > > > 09e3c22a("arm64: Use a variable to store non-global mappings decision"). > > > > > Bring back the missing check of kpti= command-line option to fix the > > > > case where the SPE driver complains the missing "kpti-off" even it has > > > > already been set. > > > > > - return arm64_use_ng_mappings; > > > > + return arm64_use_ng_mappings && > > > > + cpus_have_const_cap(ARM64_UNMAP_KERNEL_AT_EL0); > > > > } > > > This probably isn't the right fix, since this will mean that early mappings > > will be global and we'll have to go through the painful page-table rewrite > > logic when the cap gets enabled for KASLR-enabled kernels. > > Aren't we looking for a rewrite from non-global to global here (disable > KPTI where we would otherwise have it), which we don't currently have > code for? What I mean is that cpus_have_const_cap() will be false initially, so we'll put down global mappings early on because PTE_MAYBE_NG will be 0, which means that we'll have to invoke the rewriting code if we then realise we want non-global mappings after the caps are finalised. > > Maybe a better bodge is something like: > > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > > index 0b6715625cf6..ad10f55b7bb9 100644 > > --- a/arch/arm64/kernel/cpufeature.c > > +++ b/arch/arm64/kernel/cpufeature.c > > @@ -1085,6 +1085,8 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, > > if (!__kpti_forced) { > > str = "KASLR"; > > __kpti_forced = 1; > > + } else if (__kpti_forced < 0) { > > + arm64_use_ng_mappings = false; > > } > > } > > That is probably a good idea but I think that runs too late to affect > the early mappings, they're done based on kaslr_requires_kpti() well > before we start secondaries. My first pass not having paged everything > back in yet is that there needs to be command line parsing in > kaslr_requires_kpti() but as things stand the command line isn't > actually ready then... Yeah, and I think you probably run into chicken and egg problems mapping the thing. With the change above, it's true that /some/ mappings will still be nG if you pass kpti=off, but I was hoping that didn't really matter :) What was the behaviour prior to your patch? If it used to work without any nG mappings, then I suppose we should try to restore that behaviour. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel