Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1265411ybl; Wed, 28 Aug 2019 12:01:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiCXFgE99baGkuPtQyhvIMRw55TYyqjTMp26EVzbF29d9d3Ke3sXwn+NQOjfjaa8aveG/M X-Received: by 2002:a63:d301:: with SMTP id b1mr4677502pgg.379.1567018890729; Wed, 28 Aug 2019 12:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567018890; cv=none; d=google.com; s=arc-20160816; b=k1CJ5fiLTWBIN7QqRrKoAS2vEgnHJOst9HEEbZe8Hnftl4VwZfxUtS4PhJb779k/61 Yr6OTTd+PeN49mhF4/n9m0sD+rCLlAJrhHapYg5FR1xufmGlx3MmfkYslh4EeAGdgUQC IidixtOS6b1nqdFEyKvi8H3QziWekeUb/xa03FpDMgJZ0TyAdbjVXOK1nkXjMivq7/+m 0cZuvMAer5PAkkMBIY3Ng8Es89ney03j3mrv+qgRVMFZrzo09yeWIWxmuI/XqG5cg7nb D3RUcFOUK9rXPDuk4vGby9b95wXZbsHijtbcPn3hUoiSXuz8Kl2VFXX0WnjjdEJGPZvX Icfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=XdmZGtARKaGVNuVdqzkRt4PkpnK4Z78+t/Gev6u8314=; b=X7HDmc1Zjh1o6LaVRVz4MOnrI7JOm8eUbUZXPtQW7eeayq03in2kN453vD16zTn0es CeVRTP3pg1QhoJd2F3ve678TGbHJvOc9tv21RAoersk3Gt1sCqPxImGwvTZqMMMjQjeh 6PESlSYVl9F6W969B8q8tJN5pzXpi293MuxernN4UFkrJ+vHtmfuemGXTt5IaHIY+yCw KOhSW8rKp6Sc20gp9MsCMWADNzEae8MkqlSlvYPy8hJmMWtTo7Y0qlflfCa2tKGfrGuO O91Ymjgr4QPrphIyjUhoiFewPhGYj0Dv6+t81kxXaKGbyOy+3u87SrktXCDJz4J+TzrN E+5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=vMDIknOd; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d124si33341pfd.180.2019.08.28.12.01.15; Wed, 28 Aug 2019 12:01:30 -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=fail header.i=@gmail.com header.s=20161025 header.b=vMDIknOd; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726773AbfH1TAN (ORCPT + 99 others); Wed, 28 Aug 2019 15:00:13 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34098 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726591AbfH1TAM (ORCPT ); Wed, 28 Aug 2019 15:00:12 -0400 Received: by mail-wr1-f67.google.com with SMTP id s18so908060wrn.1 for ; Wed, 28 Aug 2019 12:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XdmZGtARKaGVNuVdqzkRt4PkpnK4Z78+t/Gev6u8314=; b=vMDIknOd3KU31BE32YSHpbz9+A5hrcOZVyHfTqAiKzu9/UyfQce91Z5AZoxMqqBpTD TKbvW77HDp3a99FsSHf/tRz8FAus0pIyEopJDg65kjIctNoNiTT37jBbsllN1wDjJCwU VAwZWpd7F/1X9KFxvgoji0Gkk9ExGqrZAGsn4nnTP/aVl7QM036yMSfJ6i0dJRvjR5xg qdGinJXrlDZTn/33e4BYvTC2nQMqvHNYMk9DFhh59fhHDkM+djpElM0zluj9XxXXMgBB k3FbdqL6KL0TOOx4ekhcSoLLjT9KOeIhimArzrfqKL4E00mo4XY0itvBdRy+rPdfUzvF iPgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=XdmZGtARKaGVNuVdqzkRt4PkpnK4Z78+t/Gev6u8314=; b=q5v+SSMyAXYp+nv2MoL8+RvjnC9UQJatY7F/LfMZTWwRCOZ2Zahj5hnZ3IU7lweIFk gEb0oeVHqXs+E6S6lwfppKUSflXbfwoN8zznuZDDmpCahCV3iuGy6c9/UxcSEFZMz89m bTB4NGHdssWvGeuma7Jz+WtWkUmWQuvziN2twLhAAoEb8uW3+opC9JaAxLHGlmVFLlUs 4HqxinsstI2A/Y+0ZRkKh9Ba9gb5j9ILnudBIhsFwRGcLIqOM7q11E+mQQobhf53sy1n 9TPaneji9CHunH+KSMplw0D4QtPhbjvRL0KA9y+Z+aDtw4dIC38ti5ZC1CL5ebao76ao v2Dg== X-Gm-Message-State: APjAAAU7MK3o31lZag9m5wpD/4gSP9Xf64mrG1eL95B5Pt13l1veX0Fx 9M/NZ6yvOk4s9FjlXaF5zmY= X-Received: by 2002:a5d:45cb:: with SMTP id b11mr6851468wrs.117.1567018810735; Wed, 28 Aug 2019 12:00:10 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id k9sm25658wrq.15.2019.08.28.12.00.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 12:00:08 -0700 (PDT) Date: Wed, 28 Aug 2019 21:00:06 +0200 From: Ingo Molnar To: Thomas Gleixner Cc: LKML , x86@kernel.org, Song Liu , Joerg Roedel , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Rik van Riel Subject: Re: [patch 2/2] x86/mm/pti: Do not invoke PTI functions when PTI is disabled Message-ID: <20190828190006.GB77809@gmail.com> References: <20190828142445.454151604@linutronix.de> <20190828143124.063353972@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190828143124.063353972@linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Thomas Gleixner wrote: > 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. s/issue/issues > 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. Acked-by: Ingo Molnar Thanks, Ingo