From patchwork Tue Nov 13 15:20:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 150977 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4527551ljp; Tue, 13 Nov 2018 07:20:53 -0800 (PST) X-Google-Smtp-Source: AJdET5fW4D2rHpYTkevz0bcqh3NNDO/bvig2+0rCVyFTewoSuHX3gI/VpmUnsE1dg9CbOG9tCJ2B X-Received: by 2002:aa7:818a:: with SMTP id g10-v6mr5538756pfi.153.1542122453647; Tue, 13 Nov 2018 07:20:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542122453; cv=none; d=google.com; s=arc-20160816; b=pmViFdPdA3mmzjLCTcq+PUPQRcilcle8PdAsu4mG22R8yF/RZIXNZeCXYlE8iEOmIG Aj2bYNwin52fVCH4W0EyJHSOt2NEuvro2MY2lxAHozmy8bwkpiZnHi69QI/Kp8smCUyj +3aUGuRr2f70KwPTwC6H/oLLToCi39By3eCaQ6BCjmFnySdTKQBTHYIfx5pBfD+i0rz5 PeTFWKiMPz0GCew2PlSxd9XFtPsc/SMCf8g4gBV1T84q6MWzPPbq948PbYWl8Wpv2sB4 u/KF3ML/rHbOWa0ZyoNYzmtjHu9V7oCKRlW1i+Ng5x/UmwsrnUf2K0c2+GAY6yURvmkG f7Fg== 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=mdUuw75ZKExAhDl45o1VFXv/8InptxNic/avhUlc054=; b=pIscpbaI5Sn1Ztdy+q63gDpDJMXmCknh3pD5H5T1z/Elsd5uY3lVEY867g+OullkKW AkxpuGDBqLppqmNIphMpcqlv6OLP20WWoVq5szC4EUyKBtKU7fMoCpjRQ8RZB1GOS5ZS wGV3SV4GK01W2ph5EGTfx2TZQgY/O+DGbh9FefB1RJoxHdtDviVVDiMO3LGn9Nbad9J+ 4Ck2zj4JH37KMzxG0iO/jMsUkLwMe7Htmkco4jOB9j5Uc0bMRSAxc6HmrbwuQl1PmcfB ukN3o212QQG3FcLAqgJbtnqtLMds1MTECiTC8ISCAAZKhYo86Y3fPKjgUGNSQCG3pWzy yuYw== 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 h6si2252300plk.231.2018.11.13.07.20.53; Tue, 13 Nov 2018 07:20:53 -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 S2387763AbeKNBT0 (ORCPT + 32 others); Tue, 13 Nov 2018 20:19:26 -0500 Received: from mx2.suse.de ([195.135.220.15]:53006 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732000AbeKNBT0 (ORCPT ); Tue, 13 Nov 2018 20:19:26 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9DDE1B141; Tue, 13 Nov 2018 15:20:49 +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] arm64: Make kpti command line options x86 compatible Date: Tue, 13 Nov 2018 16:20:46 +0100 Message-Id: <20181113152046.22389-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 --- Documentation/admin-guide/kernel-parameters.txt | 6 +++--- arch/arm64/kernel/cpufeature.c | 15 ++++++++++++++- 2 files changed, 17 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..12bb3b0470dd 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -978,13 +978,26 @@ 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); +early_param("pti", parse_kpti); + +static int __init handle_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