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: 150978 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4536567ljp; Tue, 13 Nov 2018 07:29:24 -0800 (PST) X-Google-Smtp-Source: AJdET5cXBL1ZRrNG2A4C/QxK6ipq2aGLFqx55EXZY9QfKdM2NbmcOZlm957QSIt0iGG4nYrKuaWk X-Received: by 2002:a17:902:6113:: with SMTP id t19mr2301212plj.248.1542122963952; Tue, 13 Nov 2018 07:29:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542122963; cv=none; d=google.com; s=arc-20160816; b=XsRxOSK73h/6l5UNIbB7j2aAgwykJQKG3YyMJml2dXlHhP5Qiuh+PO0cdR6acqUtjf 5+MXSY/AzbWp0rSCTuuTnbMFS1MJJthHprVmb7kIXWqSZMv2rQ5z4nbgPXzGkwI7Idv0 tqFg7tye8yTuCs7Z0jT5Qo1XCauERKByIcV/WBIdS+nNeGQ6Syz1lT3Lc6Z47fQ/I8Qi n/Oof3ljUug4Qs0e3vJFfw9G06jGrmYxoNYkYZP0jUe7WmqafD3phsAdO0drqEf0TN36 Uv9fGzWN4YYJDvD6AEjfFKjmOw8sLf8XBQZas0j9zC1EGpWb9LR3u1ox7aXZ0lEbSiBn kNRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=yiFi9gss/LOF4rGdM6NQHkTaR6SYHIWHC7Yo2eufHns=; b=Pxm0dlIAGElMLwzurnXA1aFh9s4KfatGWtq8O1jahqs9R6W7Z0aHBbD1KCkxKNbjWY k5HzF35qQ9j7Ng1NLK6FKzOxnN7xVGb32bEWk9UrXspEABVk9Xbjjbvhakefq9jS61JQ OkupIOzf2A+R0FLHLCBcFBq07h4KDmCh0sYnEkd8fKJ0Nu/tH49TMtLyCfjz5/6g252I B7zsNax5CkQmlwFK0l8hEJUqAa5zODdzlCEZzQI4wuT2tclm5blRe6RnLBspFJDb93a6 qK9kFUenkwzmKNsNAChLtIoE7zdNySIJvQZu5mGfCgIs6job2trgfyQIWILifwIyfWQ5 9hIw== 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 l184si19305342pgd.523.2018.11.13.07.29.14; Tue, 13 Nov 2018 07:29:23 -0800 (PST) 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 S2387883AbeKNB1s (ORCPT + 32 others); Tue, 13 Nov 2018 20:27:48 -0500 Received: from mx2.suse.de ([195.135.220.15]:55148 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731422AbeKNB1s (ORCPT ); Tue, 13 Nov 2018 20:27:48 -0500 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 Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Catalin Marinas , Will Deacon , Richard Brown , Matthias Brugger 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.12.3 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