Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp706722pxb; Fri, 8 Jan 2021 16:32:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwO6HlUA4iZY9HDg8knUWCv4L77OnGqVooNZwAxMeeY1hXc6sKMc1k9NS6Ox9XyRX01oYdB X-Received: by 2002:a17:906:d209:: with SMTP id w9mr4147644ejz.211.1610152376565; Fri, 08 Jan 2021 16:32:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610152376; cv=none; d=google.com; s=arc-20160816; b=cGL21gyL3hV2lmqvRozKINwa1c4cEp0/HMyTiZRGPDL8sjd/+smLqIjaAAS7xjoNOr FDckbrZXcIe7+3kc/Oltz+xm/W/vjaErXxPBHQltCRJpG8U/VY/B3o5PS/f4nSdwMCjy 5JGrp36gIVMwKGqfCwITu8KEpM23PhkMRpjDWc0FR8PzTZUNU8t4v9SIUge2iOFT+Gqg txpl6UfEsHr5pz4pIDxnhel3xAAQsrSpckhoMh19Kzfwo/EOGDfmUhdogWkswvjtlWe4 yKL7waSx2riULjNBqL8+lTNF6oBa8M1cpM1/+YTubaoWczTJ2ednDxOptl7KUr5V+qvY PQEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dmarc-filter:sender:dkim-signature; bh=xy5glqBJuubC1mKDX0iVSGthVCjNQpvfd4mP/Wv3hJ4=; b=n4ZJNnA8NkPNcDgDqBdOxwkoTkxFEonD7sRGOcLUTPL+J173Gtrq8fit4jnOhCWm4g GlxWoh0YrZ7M1WF8y1revKrx2JoixbR08pZJ/lU77LHnNAF/s7XlgaZw8TTIUbr5LIdN n2+yP3XmF3ALhlIol64+JeTA8UvDFW6EAYYCLBU7ucbrGw8SzENHaWVdgJrwN3k43jas AszoBS9Zx0v/C815+jP7ckkkMq2IxehqSepQWBQ2478a4Vzojcb01RD9kVzzkZJfk+Yk vu9BTiKCVZlw/6Sg0F0Z2pVTEXghvUsVY6WgSkaHpXiu6o2EGS9VcEqUgTauZjiZrDjh kzeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=aFIbKny9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x11si4104602ejb.241.2021.01.08.16.32.33; Fri, 08 Jan 2021 16:32:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=aFIbKny9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726456AbhAIAap (ORCPT + 99 others); Fri, 8 Jan 2021 19:30:45 -0500 Received: from m43-15.mailgun.net ([69.72.43.15]:42438 "EHLO m43-15.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726429AbhAIAao (ORCPT ); Fri, 8 Jan 2021 19:30:44 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1610152221; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=xy5glqBJuubC1mKDX0iVSGthVCjNQpvfd4mP/Wv3hJ4=; b=aFIbKny9mEuvAbq0ODo33wP4thJ2mpih3JN142H6BdvYVC98OrJTf7bhIBxhWqFqH9QjDfqK CF5w6gyX4bqBmYrqyPtTW4BX1cPBMxpZALs/ttuP4srQ1+prZrzuF5Pn53+YZk3HYNU0lOyk AKt96sB0kLcKW1/12IPfm2QTQck= X-Mailgun-Sending-Ip: 69.72.43.15 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n04.prod.us-east-1.postgun.com with SMTP id 5ff8f8f6c88af06107c030e9 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sat, 09 Jan 2021 00:29:42 GMT Sender: sramana=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 6733BC43461; Sat, 9 Jan 2021 00:29:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from sramana-linux1.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sramana) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8C2E8C433CA; Sat, 9 Jan 2021 00:29:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8C2E8C433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=sramana@codeaurora.org From: Srinivas Ramana To: catalin.marinas@arm.com, will@kernel.org, pajay@qti.qualcomm.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-msm@vger.kernel.org, Srinivas Ramana , Prasad Sodagudi Subject: [PATCH 1/3] arm64: Defer enabling pointer authentication on boot core Date: Fri, 8 Jan 2021 16:29:21 -0800 Message-Id: <1610152163-16554-2-git-send-email-sramana@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1610152163-16554-1-git-send-email-sramana@codeaurora.org> References: <1610152163-16554-1-git-send-email-sramana@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Defer enabling pointer authentication on boot core until after its required to be enabled by cpufeature framework. This will help in controlling the feature dynamically with a boot parameter. Signed-off-by: Ajay Patil Signed-off-by: Prasad Sodagudi Signed-off-by: Srinivas Ramana --- arch/arm64/include/asm/pointer_auth.h | 10 ++++++++++ arch/arm64/include/asm/stackprotector.h | 1 + arch/arm64/kernel/head.S | 4 ---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/pointer_auth.h b/arch/arm64/include/asm/pointer_auth.h index c6b4f0603024..b112a11e9302 100644 --- a/arch/arm64/include/asm/pointer_auth.h +++ b/arch/arm64/include/asm/pointer_auth.h @@ -76,6 +76,15 @@ static inline unsigned long ptrauth_strip_insn_pac(unsigned long ptr) return ptrauth_clear_pac(ptr); } +static __always_inline void ptrauth_enable(void) +{ + if (!system_supports_address_auth()) + return; + sysreg_clear_set(sctlr_el1, 0, (SCTLR_ELx_ENIA | SCTLR_ELx_ENIB | + SCTLR_ELx_ENDA | SCTLR_ELx_ENDB)); + isb(); +} + #define ptrauth_thread_init_user(tsk) \ ptrauth_keys_init_user(&(tsk)->thread.keys_user) #define ptrauth_thread_init_kernel(tsk) \ @@ -84,6 +93,7 @@ static inline unsigned long ptrauth_strip_insn_pac(unsigned long ptr) ptrauth_keys_switch_kernel(&(tsk)->thread.keys_kernel) #else /* CONFIG_ARM64_PTR_AUTH */ +#define ptrauth_enable() #define ptrauth_prctl_reset_keys(tsk, arg) (-EINVAL) #define ptrauth_strip_insn_pac(lr) (lr) #define ptrauth_thread_init_user(tsk) diff --git a/arch/arm64/include/asm/stackprotector.h b/arch/arm64/include/asm/stackprotector.h index 7263e0bac680..33f1bb453150 100644 --- a/arch/arm64/include/asm/stackprotector.h +++ b/arch/arm64/include/asm/stackprotector.h @@ -41,6 +41,7 @@ static __always_inline void boot_init_stack_canary(void) #endif ptrauth_thread_init_kernel(current); ptrauth_thread_switch_kernel(current); + ptrauth_enable(); } #endif /* _ASM_STACKPROTECTOR_H */ diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index a0dc987724ed..83d3929e0e8b 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -404,10 +404,6 @@ SYM_FUNC_START_LOCAL(__primary_switched) adr_l x5, init_task msr sp_el0, x5 // Save thread_info -#ifdef CONFIG_ARM64_PTR_AUTH - __ptrauth_keys_init_cpu x5, x6, x7, x8 -#endif - adr_l x8, vectors // load VBAR_EL1 with virtual msr vbar_el1, x8 // vector table address isb -- 2.7.4