From patchwork Tue Nov 13 15:29:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 10681011 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41B7A14D6 for ; Tue, 13 Nov 2018 15:29:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F66A2AD62 for ; Tue, 13 Nov 2018 15:29:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16DFA2AD69; Tue, 13 Nov 2018 15:29:33 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 12BB72AD62 for ; Tue, 13 Nov 2018 15:29:32 +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:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject: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=iEgnOuMm59Y9Ov2fwEkwp+Nm5ZB6WgEUbkYEeVAWiM8=; b=B4K 66nRjqreyQsqlW8aUCqma1qK9IQesPm0J4phoQvfsDAalF7mzGNxGj0ovqB9h8d0qOibRPV4r5m1V 42JBYzNL7feq8kU06wPrs/nOarjMeog0BYF1GsMtBhvJ+HNv+ZQGCWMCBEpXOLXwIjHgsfQy8UNx/ UdLJj5TZjvurkPINSUHGUR/kuDwhEN1Vr1vxaHGtPPd6a3ko6+VCZERbfg0LSpeEEroicj6vorDXl NKh2qgOoOAvJ4DJh0IiQ4NhxZtGBDc1CNgtWaxqiCzZgzbGXqhl1JspACebrKtYLTwMXLuD6Sxv0y nRFfQr5Ox+CaBQ+r30F7X3ugY0EbzOQ==; 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 1gMad3-0005W6-Fa; Tue, 13 Nov 2018 15:29:25 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMad1-0005Vw-Rm for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Nov 2018 15:29:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=yiFi9gss/LOF4rGdM6NQHkTaR6SYHIWHC7Yo2eufHns=; b=McTWqM+YD1S4rDhH2XKynpfw4 GrKeVkLgHdc5i0BE2OuQW3+gAtTtPSYxfhB1ym4L5cQAQ0qsfh/qpeftF2/ZpGM4OdNfUslcPJ6GE thrwIHXMlNK2kUw5UdkwYWaU2tYOnATCyvh/6y6ex7cGsQvu2JBXTaweLhwNodi0NBq9+jtEHExXR gjZ0dzx7EaiP3tT3OwwSaMlaksfND/pC+SNS7LLkLjatNi8yB/HlWXWEfJ0/baCXslQ65o7tnE37Q gv6O9dP7K1DtLQhiNbC9qu6an7DjaOh67MML8SSjDtNDF+QIhciZghmpTiNx8C//2DTQToeX5fmbp EoWKyNTDg==; Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMacz-00027m-3R for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 15:29:22 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9CAB9B0F4; Tue, 13 Nov 2018 15:29:10 +0000 (UTC) From: Alexander Graf To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] arm64: Make kpti command line options x86 compatible Date: Tue, 13 Nov 2018 16:29:06 +0100 Message-Id: <20181113152906.55802-1-agraf@suse.de> X-Mailer: git-send-email 2.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181113_152921_154153_39B309DD X-CRM114-Status: GOOD ( 16.83 ) 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: , Cc: Matthias Brugger , linux-doc@vger.kernel.org, Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Richard Brown 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 I've already stumbled over 2 cases where people got confused about how to disable kpti on AArch64. In both cases, they used existing x86_64 options and just applied that to an AArch64 system, expecting it to work. I think it makes a lot of sense to have compatible kernel command line parameters whenever we can have them be compatible. So this patch adds the pti= and no_pti kernel command line options, mapping them into the existing kpti= command line framework. It preserves the old syntax to maintain compatibility with older command lines. While at it, the patch also marks the respective options as dual-arch. Reported-by: Richard Brown Signed-off-by: Alexander Graf --- v1 -> v2: - Actually make it compile. Sorry for the sloppy v1. --- Documentation/admin-guide/kernel-parameters.txt | 6 +++--- arch/arm64/kernel/cpufeature.c | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 81d1d5a74728..4a1c6bcfcdb5 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3522,8 +3522,8 @@ pt. [PARIDE] See Documentation/blockdev/paride.txt. - pti= [X86_64] Control Page Table Isolation of user and - kernel address spaces. Disabling this feature + pti= [X86_64,ARM64] Control Page Table Isolation of user + and kernel address spaces. Disabling this feature removes hardening, but improves performance of system calls and interrupts. @@ -3534,7 +3534,7 @@ Not specifying this option is equivalent to pti=auto. - nopti [X86_64] + nopti [X86_64,ARM64] Equivalent to pti=off pty.legacy_count= diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index af50064dea51..a67b4b563a7c 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -978,13 +978,31 @@ static int __init parse_kpti(char *str) bool enabled; int ret = strtobool(str, &enabled); - if (ret) + if (ret) { + if (!strncmp(str, "auto", 4)) { + __kpti_forced = 0; + return 0; + } return ret; + } __kpti_forced = enabled ? 1 : -1; return 0; } early_param("kpti", parse_kpti); + +static int __init parse_pti(char *str) +{ + return parse_kpti(str); +} +early_param("pti", parse_pti); + +static int __init parse_no_pti(char *p) +{ + __kpti_forced = -1; + return 0; +} +early_param("nopti", parse_no_pti); #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ #ifdef CONFIG_ARM64_HW_AFDBM