Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753902AbdDDKls (ORCPT ); Tue, 4 Apr 2017 06:41:48 -0400 Received: from mail-sn1nam01on0052.outbound.protection.outlook.com ([104.47.32.52]:53724 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753576AbdDDKlU (ORCPT ); Tue, 4 Apr 2017 06:41:20 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=cavium.com; From: Ganapatrao Kulkarni To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Will.Deacon@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com, marc.zyngier@arm.com, jnair@caviumnetworks.com, gpkulkarni@gmail.com Subject: [PATCH] arm64: perf: Count EL2 events if either of kernel and hyp are not excluded Date: Tue, 4 Apr 2017 16:10:55 +0530 Message-Id: <1491302455-5939-1-git-send-email-ganapatrao.kulkarni@cavium.com> X-Mailer: git-send-email 1.8.1.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [12.108.191.226] X-ClientProxiedBy: CY4PR2201CA0008.namprd22.prod.outlook.com (10.171.208.146) To BN3PR0701MB1687.namprd07.prod.outlook.com (10.163.39.153) X-MS-Office365-Filtering-Correlation-Id: 1dc1aaa5-affd-4c14-2aef-08d47b47206a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BN3PR0701MB1687; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1687;3:2VvGlf4575DStOGQ8sNY8fryBl+7ws1c4Sxjch3EIIC1akdG6funVLMkgSEQNxV4nxxSCjmMOYVZc6u/rkw9EqK3v09Y+0MImmCKrSNjYGZosO2N+kuQdRLqWST2KSG6PpKFCaYRw8xJxNigDkEQBYBYHYKP2dnP8ukGYVF4aLCm/ktlGSzWxKx1Gg6083vaHGE4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cK4+23aQpMYKi8+FXvJNFM9aRyMM1bjlYo7Bv/ZZju/8a7nGfMznOksUIuXiqhEiKpsvUI8xIO4VVYil5YqGYaubFJnJsXaKMphp8PqdEz0kGQCZmA4s8FxBd86SPcSHBtcbzxbrm6/Fv5q0JwgumIyxt9BSoZ98LUZdp/6nSNx3nYhmxFcZr67NOjmmFOs43HES4/wjF3UQXM/cQbargFc6c1a3wtWUblB5mbcvGr9ELuEbof9jilHz+LWwsIbPZs2UbCafaO/jNjmP6DfFn1NHniugg8Bv9dpbbpUSlHQqsNpYV1pt7tjb7bUH+KS5IfKSOaSQU X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(278428928389397); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(20161123555025)(20161123564025)(20161123562025)(6072148);SRVR:BN3PR0701MB1687;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1687; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1687;4:SRCLcBLvzoB8kb/p0nIeYVOHv36JJK2NLgPhNSV7xWaQTbChJia7ncahu3TZGQ5xoTXKcd0eELnszrQRNzCYdsZEi0IEYtKIKf3zNJUgNYHE2AQ3+2PgngTSDeAhyVpfOC/WDsdXvyxi7U33zsDcTEfuN1fzYZpdm4oT+sQts0DtY6Ir5MDFfLwqQz9splV7na1fQkcKOOqqQCqnFt1gmRYVTuKBh1iL5iQo8QVOsS84Ir8TVBGMFUSAOX/RxhL0BrXkoDvUYb9q5Hm8s7RezTCjtVLj1kIt5WbvvokLHjN6KyWYYBP6vZjHepCCS9LJ8f44GpPIM6DV8eZnlQLUpl2UY6aTkP/k2c+Wvm6ThT0tHCwq3Vtg0prZJRto8K+lIyMymA/sr8NgFM3UG2xyv9xlxrBCR3QGNy0kofgLP7LJqiGtaAYigi0URSnvhO2BiEeM0PtaeJ/zj3tm4leCy66n18l67DSqVQOLcJPtaSa2Dg1nM0v0e3Ls4fy93wAiupVII+ADMCvjR6g3m9J9jh1VHOj4I7N13qiV+BrYfcjkCmEFiVBK1KLC12wq3PcEmR+aDUrb/uUxRIPXnysHBWwAyg6Apq3JRyPgbhiO4ujCQ51tWK16YtMMJWVLA4tOOoxJ7ilyWQ9DGstmRlNfRXcs0xwaUNDgRS11F1x4YDzOCV8M+SBZshM7MU9q9mqsbrfuhBPClz+Pd6l8YT10DTxYu2P9X5h70FEbv+xtDFHkL3hiswo8DfTu/djiwhRd X-Forefront-PRVS: 0267E514F9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39410400002)(39850400002)(39400400002)(39450400003)(39840400002)(2906002)(50986999)(81166006)(38730400002)(50466002)(6116002)(3846002)(50226002)(4720700003)(42186005)(5660300001)(6512007)(5003940100001)(8676002)(6666003)(86362001)(33646002)(305945005)(7736002)(66066001)(189998001)(36756003)(53936002)(4326008)(25786009)(6506006)(6486002)(47776003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR0701MB1687;H:mypc.cavium.com.com;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1687;23:7lLBveJCcjGods6FUoIe5w9OjCvptbx7SVEz8CJo31Uegp2IF4j/P3x2IEyB+rTtWECPAV+qnr+j+62hY6TbmvKTxjgWqtnr52T0nBrNNu2KsfRUjsnxjSdSgNRqyclCX0dTII6G4k4tvrBK/Q00Rj7BtsZx3IS92yaIDrAuaubdizVXkmjDw39Aa21g/gINzOJq0sA97YXwEblfBuWPCgAe24Qgw9OHzbe/viiYSjoXbgkUVJnxf87rmYwzN4adM5Y3/C0Ts6nJpMBTdCu2MPHnKC+P3ihfDqknEe18kiaSBBf52PKvLzihy+KjSBUnoDGWLDYzCGYtBGbvSLBo78RAdUOd03J25LtRHE4pgEpTnbZaOTmGUNv11HspGSDFXtau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/xMnDkUU8MEDOW+6f+vkwCFdJ2PP6/1UG/lDaIzukg6dOMWuNsCK+VdyJLjO1QfgiR2Z/ApAmI/u/A==;24:JR4X8NcuF+rPKxlKALtt8AgoJNVd0ayzxVbQVdIp/bBAQHzILXMgbeET8oSpx4khsF1wEu1n88+Ko4DAi3guSHu19yRhwJuC7+c94REh1Wc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN3PR0701MB1687;7:g0AVwdJSVbtQKBMdRGA//6ODCYzF3u/H/HjENUEclhn6yhbcIBRlgCevMxuMGonX4g3qhmaG1KK+0HVnENACv/6TjIuhmAwdQpYpqJo4+uIqWcl4ldUwnGliOOXnmdO45tL8BnBZ77Om+cMdNPx4vIIv8Tb9vZjmXmsqSPzdqgoRbUnDiSg211vPyqR2h2wFNPQx9HX7OJfoY694D9B8aUwndL9N8HkrfwsyiwulqwbknFi0YuTgL49kQF776QsBzxpFrmztvbF4VfqwqT004VzXjyfHHuVnIZRrUN+V/eMYVl0kOHhJ/ktefjP643BkqBh+fsJJGWn0ZcDUKMMZew== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2017 10:41:14.2972 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1687 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1672 Lines: 47 commit d98ecda (arm64: perf: Count EL2 events if the kernel is running in HYP) is returning error for perf syscall with mixed attribute set for exclude_kernel and exlude_hv. This change is breaking some applications (observed with hhvm) when ran with VHE enabled. Adding change to enable EL2 event counting, if either of or both of exclude_kernel and exlude_hv are not set. Signed-off-by: Ganapatrao Kulkarni --- arch/arm64/kernel/perf_event.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index daf95919..ea5848a 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -871,15 +871,20 @@ static int armv8pmu_set_event_filter(struct hw_perf_event *event, if (attr->exclude_idle) return -EPERM; - if (is_kernel_in_hyp_mode() && - attr->exclude_kernel != attr->exclude_hv) - return -EINVAL; + if (is_kernel_in_hyp_mode()) { + /* include EL2 events, if either of not excluded */ + if ((attr->exclude_kernel != attr->exclude_hv) || + !attr->exclude_kernel || + !attr->exclude_hv) + config_base |= ARMV8_PMU_INCLUDE_EL2; + } else { + if (attr->exclude_kernel) + config_base |= ARMV8_PMU_EXCLUDE_EL1; + if (!attr->exclude_hv) + config_base |= ARMV8_PMU_INCLUDE_EL2; + } if (attr->exclude_user) config_base |= ARMV8_PMU_EXCLUDE_EL0; - if (!is_kernel_in_hyp_mode() && attr->exclude_kernel) - config_base |= ARMV8_PMU_EXCLUDE_EL1; - if (!attr->exclude_hv) - config_base |= ARMV8_PMU_INCLUDE_EL2; /* * Install the filter into config_base as this is used to -- 1.8.1.4