Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp948091ybl; Wed, 28 Aug 2019 07:35:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUqyXWPfn1fXNN0dTEVCzqnqemZJDcfTVWLa09mo8tsE2AAp7GB5hf4uDbdW68e/wt7JF7 X-Received: by 2002:a17:90a:8b98:: with SMTP id z24mr4587545pjn.77.1567002910490; Wed, 28 Aug 2019 07:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567002910; cv=none; d=google.com; s=arc-20160816; b=Mg1fhXy5a5NfHRY2Woyot8yjl/im8SoEqzQJGLGwlSrYAO4pTtYRrwXWais2BDdIlE b1rsEgF3qzvB5QIMhGnN3/e1g1y0OKM48hdr4+WI5mn1nBJdbfrejOi73/iNUMUMsd/t l3R+X8WWOXctE5WKguVU3/bfCraDnwND6FepQPv8uMRrS5CR+HAptdz8EWKnDvg3HrbD v06OQQcJJrIBfXFrcp33ZjboyQHs4dDuT7tBM6X1lFwpu0WHByGDPpxInE3iBciHoTAb yCctz3l1RPiQWOFNC7+B5RnEG9YY6bDc2lR3lOSRHLrSzn0FfMaR+PF16r88FctnJheL 0iyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id; bh=PR3WTuF7dpz6Dya+7TM2YCVaBuL/ff4TsN1dXwKpehQ=; b=PAAyHAokjXqo9fFJu5AoBS41V32O9YRXajI2FYpc0Je4Md8Cx1oGPurQ5EOUNBl7qo MlWpodjvutVUZtCqZhHH8cX8HkU9U+y/2kscWO5siDIR8NVFx963WESBq5oRClJEAspP OSHD+h7TxZA/gLyHmOgunjA+hnw80leeOTm+sMv10U5LyuQkdHR6q5LS/1Y1ZXVNZ5KJ WSZEvp1F83bELCTKZrRBJlgu+jLJKEwP0nkVrhcB4O2PQ9RE8rF2/0PGvGaLHobKHi0T 4ooKjCoMWWJkgqHPf0E8nbNiihIyXJilaeqIiWy5euSbAb8w0K3sqys9mJM1y5jIToS4 Lz9A== ARC-Authentication-Results: i=1; mx.google.com; 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 t185si2614404pfc.17.2019.08.28.07.34.54; Wed, 28 Aug 2019 07:35:10 -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; 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 S1726877AbfH1Obt (ORCPT + 99 others); Wed, 28 Aug 2019 10:31:49 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:47536 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbfH1Obm (ORCPT ); Wed, 28 Aug 2019 10:31:42 -0400 Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1i2yz6-00061y-MO; Wed, 28 Aug 2019 16:31:40 +0200 Message-Id: <20190828143124.063353972@linutronix.de> User-Agent: quilt/0.65 Date: Wed, 28 Aug 2019 16:24:47 +0200 From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Song Liu , Joerg Roedel , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Rik van Riel Subject: [patch 2/2] x86/mm/pti: Do not invoke PTI functions when PTI is disabled References: <20190828142445.454151604@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 issue. Neither function should be called when PTI is runtime disabled. Make the invocation conditional. Signed-off-by: Thomas Gleixner --- arch/x86/mm/pti.c | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -668,6 +668,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.