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.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,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 D8359C48BD7 for ; Thu, 27 Jun 2019 10:13:54 +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 B047A2085A for ; Thu, 27 Jun 2019 10:13:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="a4df9fhI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B047A2085A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com 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=QEIkvArIZ3oNQ/eTFz8ca30IAw4LNMzFpBhsd5sQr+Q=; b=a4df9fhI3QAm0Q Mcj1OinfJf17zRyrzcxqBCvr6AKbheN8pOummix1gJM3J5p422nnlXKXCc47tk+WGAsp4/OuDYhDH 8H9FlC+uXZgEGV/f9LBeYMnIQTRRWPVwwNUIuXlIyDk4FtqCuezgUSfMiJUoIZliTWZQxSHdj1ZzZ E9MhwfRI1McL/uNL/G6Y4jMN2JXZLnY6Q8cePUDNGcTCa5qSHttPe3QHUehqI8ZuWy09D5MNX36bp 1xYu44j3UZvrmbgvOcYBNTFvPgXfbSCQkSXefLlG3mKhGEfasGyB5Vz9iZwm8V3sM5iXlL7+W96I2 rfZN2pPiKWHuMjb2nDDw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hgRPW-0006ou-W0; Thu, 27 Jun 2019 10:13:46 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hgRPT-0006o2-FX for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2019 10:13:44 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9386F2B; Thu, 27 Jun 2019 03:13:42 -0700 (PDT) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 075D23F718; Thu, 27 Jun 2019 03:13:41 -0700 (PDT) Date: Thu, 27 Jun 2019 11:13:39 +0100 From: Catalin Marinas To: Will Deacon Subject: Re: [PATCH] arm64: Add support for E0PD Message-ID: <20190627101339.GA9894@arrakis.emea.arm.com> References: <20190626144535.27680-1-broonie@kernel.org> <20190626150403.dekq5l5rpmgzknfr@willie-the-truck> <20190626160622.GA5379@sirena.org.uk> <20190626165102.GE29672@arrakis.emea.arm.com> <20190627092529.a2hdttgitnile3h6@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190627092529.a2hdttgitnile3h6@willie-the-truck> 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-20190627_031343_605369_97618F3D X-CRM114-Status: GOOD ( 33.24 ) 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 Brown , 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 Thu, Jun 27, 2019 at 10:25:30AM +0100, Will Deacon wrote: > On Wed, Jun 26, 2019 at 05:51:03PM +0100, Catalin Marinas wrote: > > On Wed, Jun 26, 2019 at 05:06:22PM +0100, Mark Brown wrote: > > > On Wed, Jun 26, 2019 at 04:04:04PM +0100, Will Deacon wrote: > > > > I think you're missing one small thing here: all v8.5 CPUs will have > > > > hardware mitigations for meltdown as advertised in the ID registers. > > > > However, we still force KPTI on for those CPUs if KASLR is enabled to avoid > > > > it being trivially bypassed by looking at fault timings. As you point out, > > > > there are two issues with that: (1) the performance impact of KPTI and (2) > > > > the incompatibility with statistical profiling. It is these issues which > > > > E0PD attempts to address, so whilst I'm ok with enabling it unconditionally > > > > as you propose, we should go one step further and avoid enabling KPTI on > > > > CPUs with E0PD even if KASLR is enabled. > > > > > > I agree, I'm currently working on a patch which will disable KPTI by > > > default if we've enabled E0PD - it's a bit of a faff due to how early we > > > decide if we're going to use KPTI so it probably needs to be a separate > > > patch anyway. > > > > Could we not wire up this check in unmap_kernel_at_el0()? We can look at > > this as a more efficient KPTI handled by the hardware. > > CPUs with this feature will already return false from unmap_kernel_at_el0(), > but I suppose the kaslr check could be augmented not to force kpti if E0PD > is supported. Something similar would need to be added to > arm64_kernel_use_ng_mappings(), so adding a kaslr_needs_kpti() helper might > be a good idea. unmap_kernel_at_el0() currently forces kpti on if kaslr is enabled. That's why I suggested placing al the checking logic in this function and enabling E0PD via kpti_install_ng_mappings(). Anyway, it may be simpler if we do it as per Mark's patch here and enable E0PD where available with a separate cpufeature entry while also checking for the corresponding CPUID in unmap_kernel_at_el0() (and return false if E0PD is present). > > > > We probably also need to consider the unfortunate situations where E0PD > > > > is not supported by all of the CPUs in the system. > > > > > > Yes, I've marked it as ARM64_CPUCAP_SYSTEM_FEATURE so it should be safe > > > unless all the CPUs that don't support it are late CPUs (in which case > > > it'd stop them booting) but it's not ideal as it means we won't use it > > > at on mixed systems. I did debate marking it as _WEAK so that we'd > > > enable it on the CPUs that can use it but I worried that that'd be > > > potentially misleading with regard to the level of hardening if the > > > kernel said it was turning on E0PD. > > > > I think this will become problematic in combination with disabling kpti. > > If we decide early that it is meltdown-safe (unmap_kernel_at_el0() > > returning false) because the boot CPU supports E0PD, any subsequent CPU > > not having E0PD and hence requiring unmap_kernel_at_el0() will not boot. > > That's fine by me as long as we have a Kconfig option to disable E0PD > > and allow mixed CPU features on some custom SoCs. > > No, I think that's a regression over the current behaviour where we do boot > on mixed SoCs like this. What we don't allow is late onlining of CPUs that > are affected if none of the initial CPUs were affected, but that's only an > issue with "maxcpus=" so it's not a big deal (you can just as easily pass > "kpti=on" at the same time). Ah, I misread the feature type. Then unmap_kernel_at_el0() returning false if E0PD is present would not be a problem for normally booting secondary CPUs, only for late ones. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel