Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6189544ybv; Wed, 12 Feb 2020 07:36:36 -0800 (PST) X-Google-Smtp-Source: APXvYqyyQyxkgTpLYBOSFIKCe+enEbAff6X2id108UsLlj1T13NQ1pGg6wNL4reE2fFZImHbn1qm X-Received: by 2002:a9d:12a2:: with SMTP id g31mr2837403otg.283.1581521796440; Wed, 12 Feb 2020 07:36:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581521796; cv=none; d=google.com; s=arc-20160816; b=mV9fxn48Kr8mYXDQyDKPqF3jngaJBAeqrYabU360Nlo1or+oqUr+0N0wvRPrkKfANm oltb9ADatnrYRtB/UUNXdXakFR2KnoZOSnZFgxcIhMw+lm3G0NA/KOQTEFR8/RG+Sh0j YSVpWOJh5ew4eJDSpy8ulkATcAvelZfhOC2ZF4iKSyT1I/OgcndUUkzR+ychs3xpZSZu rkx+0orugrElGNbSOFT1n6fCYZKl2Ew8MZreJLrcF9g/5yvDLkNJcOtQcR52mY+cDSLo BLE2Lp7MglYYpoWXpbtBmOA84bsfjFng2cEkWlVCQ1zia06feiO/USTDBNZX1C0PxzIx g3Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=mNEcB9F61xK7JRBnmWm61MdHEV1S921YJj8U4630jh0=; b=GKHIiZfMLJZAQdi3sUOWGlRS/duHDUH1Gl85yprptM4zrddoAS6KgweyzxK/kiRRFl htVDtkDntT0/ITynrBf5W2xTyZz3Z8tHFCqmQVUtGJHHMi5XHAxRS4wXvbk7etUG1sTO a4SQ3zdTCgjN7SxvMrzRda1rRHWEfTr3cQhjKG0fdIQ1bBeU61WsbHxdSvMre9CWO0zs U6Fl+RfdVXrwmpNpWUMLR2J7HXGivtOr+v6CkHn9yYuMYicrstiuVVQIlN1uWeIX2PqZ sWQDSUsjlPQm5UvVYHKG81DIELQLkmshfj2vYshHeUljW23j92RVrz2iGKp6zN3MLfHN 3onA== 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 x25si3473138oie.261.2020.02.12.07.36.22; Wed, 12 Feb 2020 07:36:36 -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 S1728098AbgBLPgR (ORCPT + 99 others); Wed, 12 Feb 2020 10:36:17 -0500 Received: from foss.arm.com ([217.140.110.172]:34146 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727026AbgBLPgR (ORCPT ); Wed, 12 Feb 2020 10:36:17 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1FBF5328; Wed, 12 Feb 2020 07:36:16 -0800 (PST) Received: from [10.1.194.46] (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B7A873F68F; Wed, 12 Feb 2020 07:36:13 -0800 (PST) Subject: Re: [PATCH v3 2/7] arm64: trap to EL1 accesses to AMU counters from EL0 To: Ionela Voinescu , catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, maz@kernel.org, suzuki.poulose@arm.com, sudeep.holla@arm.com, lukasz.luba@arm.com, rjw@rjwysocki.net Cc: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, viresh.kumar@linaro.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Steve Capper References: <20200211184542.29585-1-ionela.voinescu@arm.com> <20200211184542.29585-3-ionela.voinescu@arm.com> From: Valentin Schneider Message-ID: <17a791d0-89ec-9b1e-ff36-502cbf51ab17@arm.com> Date: Wed, 12 Feb 2020 15:36:12 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200211184542.29585-3-ionela.voinescu@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/02/2020 18:45, Ionela Voinescu wrote: > The activity monitors extension is an optional extension introduced > by the ARMv8.4 CPU architecture. In order to access the activity > monitors counters safely, if desired, the kernel should detect the > presence of the extension through the feature register, and mediate > the access. > > Therefore, disable direct accesses to activity monitors counters > from EL0 (userspace) and trap them to EL1 (kernel). > > To be noted that the ARM64_AMU_EXTN kernel config and the disable_amu > kernel parameter do not have an effect on this code. Given that the > amuserenr_el0 resets to an UNKNOWN value, setting the trap of EL0 > accesses to EL1 is always attempted for safety and security > considerations. Therefore firmware should still ensure accesses to > AMU registers are not trapped in EL2/EL3 as this code cannot be > bypassed if the CPU implements the Activity Monitors Unit. > > Signed-off-by: Ionela Voinescu > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Mark Rutland > Cc: Steve Capper Reviewed-by: Valentin Schneider