From patchwork Thu May 31 17:08:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Langsdorf X-Patchwork-Id: 10441393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1357A603B5 for ; Thu, 31 May 2018 17:09:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06C0728F4E for ; Thu, 31 May 2018 17:09:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EECC828F81; Thu, 31 May 2018 17:09:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9127F28F4E for ; Thu, 31 May 2018 17:09:23 +0000 (UTC) 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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yd+6o1WXkUH9ykS1TO3TBoWU+0GjbGHyWksdkvpQaZ8=; b=IyVmA9qU+NXh1I AzuBx4kQEtE/C3JJoTSDt8w88oEwaHxZ6IjmDDbTuJXddnn/pF/+zZr6PZAjdCdcH7Zu8cH7TfMiZ 7ho6JPnVXBvvvxziSMmcsoT5I53uDkjetnJSZopprU8Q1iXRJNjYCDfP9MwVbfOuGkFzlP9j5GsYZ tiFkZMUKAmK5yTE1MXBvD0Xpo4i8ZEwcagEVBjPkl+lKEHf207cuFiSAqEl9eSy6oblbFH/z4RaK4 AVcIT1mm0y6IZL6hIpE5haWin8oRUyP5bGEQDlq5SZa0tXSeIv6tTSSIRoXXUYNeafd5XxUUbbo/f mhi8D15Vb0Ma0w6cMaGA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fOR4Z-0005v0-GC; Thu, 31 May 2018 17:09:11 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fOR4B-0005gz-Vk for linux-arm-kernel@lists.infradead.org; Thu, 31 May 2018 17:08:49 +0000 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8B5458A41 for ; Thu, 31 May 2018 17:08:36 +0000 (UTC) Received: from redhatnow.redhat.com (ovpn-116-158.phx2.redhat.com [10.3.116.158]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A4931001947 for ; Thu, 31 May 2018 17:08:36 +0000 (UTC) From: Mark Langsdorf To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 2/2] arm64: cpufeature: always log KPTI setting on boot Date: Thu, 31 May 2018 12:08:32 -0500 Message-Id: <20180531170832.14263-3-mlangsdo@redhat.com> In-Reply-To: <20180531170832.14263-1-mlangsdo@redhat.com> References: <20180531170832.14263-1-mlangsdo@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 31 May 2018 17:08:36 +0000 (UTC) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180531_100848_055142_F47513CB X-CRM114-Status: GOOD ( 17.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Always log KPTI setting at boot time, whether or not KPTI was forced by a kernel parameter. Signed-off-by: Mark Langsdorf --- arch/arm64/kernel/cpufeature.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 7c5d8712..2bfbbe4 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -860,6 +860,7 @@ static bool has_cache_dic(const struct arm64_cpu_capabilities *entry, #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 static int __kpti_forced; /* 0: not forced, >0: forced on, <0: forced off */ +static bool __pti_enabled; static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, int scope) @@ -884,21 +885,26 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, /* Forced? */ if (__kpti_forced) { + __pti_enabled = __kpti_forced > 0; pr_info_once("kernel page table isolation forced %s by %s\n", - __kpti_forced > 0 ? "ON" : "OFF", str); - return __kpti_forced > 0; - } - - /* Useful for KASLR robustness */ - if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) - return true; + __pti_enabled ? "ON" : "OFF", str); + } else { + str = "default"; + /* Useful for KASLR robustness */ + if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) + __pti_enabled = true; + /* Don't force KPTI for CPUs that are not vulnerable */ + else if (is_midr_in_range_list(read_cpuid_id(), kpti_safe_list)) + __pti_enabled = false; + /* Defer to CPU feature registers */ + else + __pti_enabled = !has_cpuid_feature(entry, scope); - /* Don't force KPTI for CPUs that are not vulnerable */ - if (is_midr_in_range_list(read_cpuid_id(), kpti_safe_list)) - return false; + pr_info_once("kernel page table isolation %s by %s\n", + __pti_enabled ? "ON" : "OFF", str); + } - /* Defer to CPU feature registers */ - return !has_cpuid_feature(entry, scope); + return __pti_enabled; } static void