Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp64640ybp; Thu, 3 Oct 2019 10:13:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5u6j5MEMSM+O6gKMd0XZwIArkDAiuOqoWj05Ww1M4NzHdn60x1qSkGee1JKuSK0gVacgj X-Received: by 2002:a17:906:fc0c:: with SMTP id ov12mr8543731ejb.86.1570122821028; Thu, 03 Oct 2019 10:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570122821; cv=none; d=google.com; s=arc-20160816; b=XtgYd4OaTSR2xCHhcIrdFDM4T5kmGsqPZmNLloQVDE11sOXVJagfb66bOtRgLdA8Mw U0ggrO43RJAhxQBTutNt5HKjQqIwUF7PSMmqPmYq/ekimhTSOeupRqeUIz29QvvKU0h3 UBW03wsbju29YQYQaNWVIp3SuL+Rx9Vgqc1O1lr/7Ab1FUKZDLoR/wwTdB9FLfLbHE1z KYfRD5qKjHunYhLUv3UOWL9rNzq/KImBAVGjI7Y1jJZa/4kzZ1iHa4uzH8Hs/UTDGoI9 6fz3aZEzVUb3pYNOziV2MN5awhA8alCxgkGbbV1E0NHxe7VcOh3EA4slSnTGp/dSCAaH VFAw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dMzH94cJFQ5HhjtF0lC2+emO+TbjymVXRuR/ZfC2id4=; b=rswR/XSmjc/4YqsV4f0v9hwlgAS3aEqF3LL6PlyYBWPuyN6KJnza/KisfGAlJR948G Pq4bIaKwksX/Pc87eqY8ZYlVXzLWH7ZvtEBePpw7jeg0r7Ck/n89WU4wXksJr5Xqmc+M txSPHOk9ke2IbLy/rOrQ7YFs0Z1/984/whlnTgZUu+MHg1cS89af8XSNgzZZjVh1F+/J GhnnXxMrYBAprmH468N192InIfBmVAv129PiE5vzMXqHgkdJpae2GJmnx5bZ5rdQKZIk ZjCczzZTTNw/p9R/UOtru03IyEJhczBPLeE00S9w1MY+Cb4vSQXHNRF4eXYWRZGKyqXp OJbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0OwFmk8n; 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 z6si1805766edx.139.2019.10.03.10.13.16; Thu, 03 Oct 2019 10:13:41 -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; dkim=pass header.i=@kernel.org header.s=default header.b=0OwFmk8n; 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 S2393501AbfJCRLr (ORCPT + 99 others); Thu, 3 Oct 2019 13:11:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:37808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403803AbfJCQbI (ORCPT ); Thu, 3 Oct 2019 12:31:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 C588120865; Thu, 3 Oct 2019 16:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120268; bh=2et6kh5u9FLYVe88GeLbMKtsoeoF/CZr/Ah6IeVbid4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0OwFmk8nMoSBRRZMu6bJfnUxbir7MjHKAFtzbX5hCPx9IU0STzq1poqPD4e74Clsv jDen2+aWi4d7IMogItKV2f6kyL97fqI87alzNdJjQeNqqVHUD47bYHYsg4Z5mceRTV zszV/ck5DGwbmniF/dfBJUQylyV7ltqKZGNGogMo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , Dave Hansen , Ingo Molnar , Song Liu , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 5.2 157/313] x86/mm/pti: Do not invoke PTI functions when PTI is disabled Date: Thu, 3 Oct 2019 17:52:15 +0200 Message-Id: <20191003154548.392993969@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner [ Upstream commit 990784b57731192b7d90c8d4049e6318d81e887d ] When PTI is disabled at boot time either because the CPU is not affected or PTI has been disabled on the command line, the boot code still calls into pti_finalize() which then unconditionally invokes: pti_clone_entry_text() pti_clone_kernel_text() pti_clone_kernel_text() was called unconditionally before the 32bit support was added and 32bit added the call to pti_clone_entry_text(). The call has no side effects as cloning the page tables into the available second one, which was allocated for PTI does not create damage. But it does not make sense either and in case that this functionality would be extended later this might actually lead to hard to diagnose issues. Neither function should be called when PTI is runtime disabled. Make the invocation conditional. Signed-off-by: Thomas Gleixner Reviewed-by: Dave Hansen Acked-by: Ingo Molnar Acked-by: Song Liu Acked-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20190828143124.063353972@linutronix.de Signed-off-by: Sasha Levin --- arch/x86/mm/pti.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c index b196524759ec5..ba22b50f4eca2 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -666,6 +666,8 @@ void __init pti_init(void) */ void pti_finalize(void) { + if (!boot_cpu_has(X86_FEATURE_PTI)) + return; /* * We need to clone everything (again) that maps parts of the * kernel image. -- 2.20.1