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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 26CB1C43334 for ; Thu, 16 Jun 2022 12:37:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=mkRHp964rsvda6bGKXWByZ8lOaNnFX6u63+FodfM6TE=; b=ZwMIsQHztapFE1 sPUMbTzxVIa51TF9E3MwwMSQ8whdsighZwWXCY/jYl7mrG7/a3gw6YrqaTc71qmY9IkXHMAkC1sAO lIGj9jZI9e3NUCvMnu4O2OqQYH4loeYPS59JQayO6EPsGSFZsfMeTboCfjcoU/y8FAsOozhlQJLTB OHcc7dr253lHMf22pwK8vKVT5V1FjKZAs1FBQgonuTihC+z/HsgzgRYBudEM81GV8DGVmiAF/68hZ UjJMA2mToAYgGus7eQLOAT+VogwxfbGQezjAaNZdPaJ6swi0bkvdP6jxixqzW15EiOvz/1M6SanIZ g6ak5XSHcQKPlEEdHokQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1ojS-002JAt-CG; Thu, 16 Jun 2022 12:36:18 +0000 Received: from out199-16.us.a.mail.aliyun.com ([47.90.199.16]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1ojO-002J9M-05 for linux-arm-kernel@lists.infradead.org; Thu, 16 Jun 2022 12:36:16 +0000 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=liusong@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0VGaLZ.H_1655382938; Received: from localhost(mailfrom:liusong@linux.alibaba.com fp:SMTPD_---0VGaLZ.H_1655382938) by smtp.aliyun-inc.com; Thu, 16 Jun 2022 20:36:02 +0800 From: Liu Song To: catalin.marinas@arm.com, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] arm64: cpufeature: make sure cpu_mitigations_off then kpti off Date: Thu, 16 Jun 2022 20:35:38 +0800 Message-Id: <1655382938-126283-1-git-send-email-liusong@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220616_053614_338039_626A5584 X-CRM114-Status: GOOD ( 10.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Liu Song If kaslr is enabled, kpti cannot be turned off even if "mitigations=off", adjust the code order to ensure that kpti is off when "mitigations=off". Signed-off-by: Liu Song --- arch/arm64/kernel/cpufeature.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 42ea2bd..27d4850 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1616,6 +1616,11 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, __kpti_forced = -1; } + if (cpu_mitigations_off() && !__kpti_forced) { + str = "mitigations=off"; + __kpti_forced = -1; + } + /* Useful for KASLR robustness */ if (kaslr_requires_kpti()) { if (!__kpti_forced) { @@ -1624,11 +1629,6 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, } } - if (cpu_mitigations_off() && !__kpti_forced) { - str = "mitigations=off"; - __kpti_forced = -1; - } - if (!IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0)) { pr_info_once("kernel page table isolation disabled by kernel configuration\n"); return false; -- 1.8.3.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel