Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5972836ybv; Wed, 12 Feb 2020 03:46:23 -0800 (PST) X-Google-Smtp-Source: APXvYqxbSvqZUXa8bZ+O+dFjlIw06TC+AHCplFaoBuY02ilUKYTJyh3GOsyHi/RReYodGmBzUlGF X-Received: by 2002:a05:6830:1188:: with SMTP id u8mr8966742otq.274.1581507983047; Wed, 12 Feb 2020 03:46:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581507983; cv=none; d=google.com; s=arc-20160816; b=QYYh1aoWzfUSFjUtLpMyjYnpGL5SBcOpOLVxeqv606VpTHy2E6htnvfK5dbpA8zehw gjg7WfvBcaKndZW3rrqwkA/AyD1su4czk2kp7qO0k+kfOSTEVEz/EzQhcUGMLwU082y+ cflfXw2DrpzkoJtPmkRmX6L62+Qi9g/yJrBVn07xHBzkOsQbtScumrpoIxoS73bh3gLN ZEQawV2OqSO/BN/1VIH1kaIUW5iGCe8KB4YZ+58LrMRmvejmSFnD73UdL9buTsaScIyP Lj6q6OJSbPcLqoY0qPgM8EPLIoi+50pDKxSw/mQcX1sxcNEPXUXEKDQZ64Vrk//7ow3t qoOQ== 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=GhZKb9sTYJN4ttEyXBkZ7gSQkkfRBl4xLRZ0SlE41tM=; b=n4lhvhjFAMp6dxWHBXka4I2aGkmOS8nPUBCYEwV/IriLdr/vDP2lXxWdojXfINMtlw I7telxyIgpnD+3dKgdQxGRtw7YkjVr7v/1ppLui5w/m6VblZJMzBvQhXZ12gYC2eTjf2 bb8jXDFMz1niqx91fe7vfmqxsbC1lgGjDi5ahUkYOa2a0MMACJiPvwF43dd1AXPLSNco PlFBskLqktWwQf3D1IlMHqlhyw4r91DTFWNjev6MV3R1aEsUdms29lDNo4fr9kLG5ZS4 BygIzS35w2seLe36R6M055vxgtO+b/Ovb7qYqeXgzyDq6qdGuVQuLVLjw3JZ90BgFQ88 yPEw== 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 y23si77355oti.65.2020.02.12.03.46.11; Wed, 12 Feb 2020 03:46:23 -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 S1728375AbgBLLpE (ORCPT + 99 others); Wed, 12 Feb 2020 06:45:04 -0500 Received: from foss.arm.com ([217.140.110.172]:59914 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728085AbgBLLpD (ORCPT ); Wed, 12 Feb 2020 06:45:03 -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 0C93730E; Wed, 12 Feb 2020 03:45:03 -0800 (PST) Received: from [10.1.197.1] (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E2F583F68F; Wed, 12 Feb 2020 03:45:00 -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, sudeep.holla@arm.com, lukasz.luba@arm.com, valentin.schneider@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: Suzuki Kuruppassery Poulose Message-ID: Date: Wed, 12 Feb 2020 11:44:59 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <20200211184542.29585-3-ionela.voinescu@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed 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: Suzuki K Poulose