From patchwork Mon Oct 9 12:55:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Murzin X-Patchwork-Id: 9993003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0564360230 for ; Mon, 9 Oct 2017 13:05:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA786287B9 for ; Mon, 9 Oct 2017 13:05:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF044287D0; Mon, 9 Oct 2017 13:05:23 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 5C0E2287B9 for ; Mon, 9 Oct 2017 13:05:23 +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:References: In-Reply-To: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:List-Owner; bh=YInqwB3hDZwcJEV1XV1ZJQuHIzUzJlxSEGTd3axnFnA=; b=DyV7zVCK9LiWtHS3F3KaYRYsfK 4hhxlIjpbCQl5YWzeov1I9Z5kktokP2ukJl7VHUmnw3Msf+cebsfyjE8Wiohr9jkZ0F2J08mhm2Jl /ug9rF5+SaIvSubUA257XF4luW8PnTyrOIPIDqB3IRvZiHGCrt71MiG9ESTRnsKba5HTj1sIcrnht D4bGmE3VwqDiWiDNLLbPKG0rg3b3TL7K3FmSrrVNq1mUgYFas0SPid9wnhPpR2noAxYE/I84afW+x voHzBtgPabD2A3aw4SdSLMqdYceUX5f4IFHhs6yvvEsdX5V1+bKxgfPKIPDZAZ3fqyx8mkTwTUKF0 E1HIWmjQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e1XkH-00039r-3K; Mon, 09 Oct 2017 13:05:21 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e1XbQ-0006m3-0q for linux-arm-kernel@lists.infradead.org; Mon, 09 Oct 2017 12:56:15 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 59C2F15BF; Mon, 9 Oct 2017 05:55:55 -0700 (PDT) Received: from bc-a8-2-13.euhpc.arm.com. (bc-a8-2-13.euhpc.arm.com [10.6.11.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2889A3F578; Mon, 9 Oct 2017 05:55:54 -0700 (PDT) From: Vladimir Murzin To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] arm64: Introduce command line parameter to disable CNP Date: Mon, 9 Oct 2017 13:55:34 +0100 Message-Id: <1507553734-27854-4-git-send-email-vladimir.murzin@arm.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1507553734-27854-1-git-send-email-vladimir.murzin@arm.com> References: <1507553734-27854-1-git-send-email-vladimir.murzin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171009_055612_176343_69E38CDE X-CRM114-Status: UNSURE ( 9.38 ) X-CRM114-Notice: Please train this message. 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: mark.rutland@arm.com, catalin.marinas@arm.com, james.morse@arm.com, kbuild-all@01.org, marc.zyngier@arm.com 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 There are cases when activating of Common Not Private (CNP) feature might not be desirable; this patch allows to forcefully disable CNP even it is supported by hardware. Signed-off-by: Vladimir Murzin --- Documentation/admin-guide/kernel-parameters.txt | 4 ++++ arch/arm64/kernel/cpufeature.c | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0549662..3c1e45d 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2560,6 +2560,10 @@ noclflush [BUGS=X86] Don't use the CLFLUSH instruction + nocnp [ARM64] + Disable CNP (Common not Private translations) + even if it is supported by processor. + nodelayacct [KNL] Disable per-task delay accounting nodsp [SH] Disable hardware DSP at boot time. diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 8d098a1..724fd93 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -771,6 +771,24 @@ static bool has_no_hw_prefetch(const struct arm64_cpu_capabilities *entry, int _ MIDR_CPU_VAR_REV(1, MIDR_REVISION_MASK)); } +static bool nocnp; + +static int __init early_nocnp(char *p) +{ + nocnp = true; + return 0; +} +early_param("nocnp", early_nocnp); + +static bool has_useable_cnp(const struct arm64_cpu_capabilities *entry, int scope) +{ + if (!has_cpuid_feature(entry, scope)) + return false; + + return nocnp ? false : true; +} + + static bool runs_at_el2(const struct arm64_cpu_capabilities *entry, int __unused) { return is_kernel_in_hyp_mode(); @@ -905,7 +923,7 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .desc = "Common not Private translations", .capability = ARM64_HAS_CNP, .def_scope = SCOPE_SYSTEM, - .matches = has_cpuid_feature, + .matches = has_useable_cnp, .sys_reg = SYS_ID_AA64MMFR2_EL1, .sign = FTR_UNSIGNED, .field_pos = ID_AA64MMFR2_CNP_SHIFT,