From patchwork Thu Oct 21 13:45:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12575137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E200C433F5 for ; Thu, 21 Oct 2021 13:48:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C7783610A1 for ; Thu, 21 Oct 2021 13:48:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C7783610A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/yHstv8ERk8JXKYcEEeJ7w730PMpP6z1vNVSmagGyJw=; b=zvuFsqpB0dT3Mq GbKSsrOiev7GU2+qCBdr04kcWc4CQbqFgxiHHfRVlIIlZpYTgqNKblwylRpFYAw1fH1P9ZULGzjn2 g8jNBHDJqwzPIBzTPnVtYqNWiXScbvrVMXgf2YMEAxuG05Bwo2uxJdcailNwcOug5Pt2/AVXQMFl6 lBElXtDu7j1DW2MOBg0HAVg9RHy+dWJVV3xP5xxbt5RTMHuIX5fvI+LqV9L9feZ3dH+u6GPIL9kAh AvYqlicU5HrKRpfjsRAWVgpe9NZc5lGTz0A/Z+215EU+TmCZb8bqsvQD+tDrA4htDwnCjPfVOwwPN 7eXpJduQmDXsRiyRG+BQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdYOn-007gkB-Cv; Thu, 21 Oct 2021 13:46:25 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdYOH-007gZE-2v for linux-arm-kernel@lists.infradead.org; Thu, 21 Oct 2021 13:45:54 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d5so722398pfu.1 for ; Thu, 21 Oct 2021 06:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=koUrUpf8/lWFSVycc73OYER9/wNi0PLyGr7jK5BVrkE=; b=VjYlFYBFcBY4Xf9hmTEBkgkmnvg8mfNqcDq3fEUxO5+UegVAxYVvGBBJircBFhWdoe MUyXt116AIC80z9y4TuxxMXXx+dh3gDh3EIJOTPTSx/bPec2VyGePhDz9RvuX/qBV+3s 7G+1Xf/zPB3OXGgfAc+1j+rgDWbRtcDmTRmzzgW9lpIpt+DPemN9l+jLluJUoJDVig6X DUIL4TbY3lSiinMS43t7gW5dMkcj9LL/OS3+4dEJxar6iJr3EpGIO0INmN019BtEgdzD 0pYZyrcaSTOmiipMDJRFH58htob4krdZ8wd2GvDlN1+/PkUEl7KVtnQKWd9Z1mN22ea3 gqHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=koUrUpf8/lWFSVycc73OYER9/wNi0PLyGr7jK5BVrkE=; b=Weegda30kqGqq68rJ4qBJWUQWCa/1y/icxR0bTEkryxw6LEGt2k6LhakvzI1YeFWnK 1p5tFIUPYOpUxs11ua48KMU+8q1cdJiTWitM9CfS3NYARW8gbOSQnBVjFBzq16fSMFF5 1bOOuEvZEroP4yDmdeCzwhbN6YtrBBDt6PV3uCCVCrVoiNk5o4IYAphR5BUSqgXuUl88 yQWGlzeHHJOOJegPOtFsQPSZSM372Vh2bM5ycrP7TjuUIO3JBtnmGImwivyTZ5doTMaP CRhZ5CU+LR/liQk6sDiJDZwLMEqdQdjPN0V/NyDLzz9IhWAFubPdvstx735cvbd356/p LDaQ== X-Gm-Message-State: AOAM532Ee5hC9uzBIwY79s8NqSZuLXWVz6pqDdizaMyE8GW29UDjcZ7g uktUz0jbYLrvtSdfxISq8XFBVw== X-Google-Smtp-Source: ABdhPJwvgZgAy8cV8JcLrX7e83ZSIgNJ+0e7SgDaeSbYMx5rKqLga2ogThAEQvXS3l2rwnBM8gwfzA== X-Received: by 2002:a62:6d86:0:b0:448:152d:83a4 with SMTP id i128-20020a626d86000000b00448152d83a4mr5805089pfc.38.1634823951886; Thu, 21 Oct 2021 06:45:51 -0700 (PDT) Received: from localhost ([103.127.241.129]) by smtp.gmail.com with ESMTPSA id e12sm6021827pfl.67.2021.10.21.06.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 06:45:51 -0700 (PDT) From: Leo Yan To: Catalin Marinas , Will Deacon , Mark Rutland , Kees Cook , Ard Biesheuvel , Sami Tolvanen , Nicholas Piggin , James Morse , Marc Zyngier , Joey Gouly , Peter Collingbourne , Vincenzo Frascino , "Peter Zijlstra (Intel)" , Stephane Eranian , James Clark , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [RFCv1 3/4] arm64: Introduce functions for controlling PID tracing Date: Thu, 21 Oct 2021 21:45:29 +0800 Message-Id: <20211021134530.206216-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021134530.206216-1-leo.yan@linaro.org> References: <20211021134530.206216-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211021_064553_189441_BA5FB073 X-CRM114-Status: GOOD ( 11.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Introduce two functions contextidr_enable() and contextidr_disable(), which can be used by kernel modules to turn on or off PID tracing in contextidr register. Signed-off-by: Leo Yan --- arch/arm64/include/asm/mmu_context.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index e1f33616f83a..0c1669db19a1 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -37,6 +37,16 @@ static inline void contextidr_thread_switch(struct task_struct *next) isb(); } +static inline void contextidr_enable(void) +{ + static_branch_inc(&contextidr_in_use); +} + +static inline void contextidr_disable(void) +{ + static_branch_dec(&contextidr_in_use); +} + /* * Set TTBR0 to reserved_pg_dir. No translations will be possible via TTBR0. */