From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC875C43381 for ; Mon, 25 Mar 2019 12:37:16 +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 8C0722085A for ; Mon, 25 Mar 2019 12:37:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WckMTzdO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C0722085A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wFNNWN7ShDaLbkxIWgjkRJP8RLobNc2yOOdeuS4HQl8=; b=WckMTzdOTtXTCd YHl3ANqeKcSlEpmlAEeJS97pLcOmYY6eCX8rhMQRxMuZTDC2AgYLvRECMBmC7B8blBPEUrXq+VzEx NtwixDk+qk5sk1c/uULu4XOCqaeIdk8mM1GoRKpsvL16SIm+Gqo/lhw0sxs9+Y4C5mN3pVHK40bPU ARpNGbM+28rg9SUeSlllhHEJueb/wCQ/PgmJP/SfDB9OireKUP1WubmmmDKgyUnWfNvrIOIEKtHSz Z2GmCm+9NFAPjSjQeVQRLKOXX9rXO2/JjM6sGZGwuviTPxhahsXN1t5uHY+3fg5r9iOQT3ME3/C0R iLyJmFlZVNHWEt3XjpDA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8Oql-0001Cd-NR; Mon, 25 Mar 2019 12:37:11 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8Oqi-0001B5-6y for linux-arm-kernel@lists.infradead.org; Mon, 25 Mar 2019 12:37:10 +0000 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 36CBBC8C605997C2D4CF; Mon, 25 Mar 2019 20:36:58 +0800 (CST) Received: from [127.0.0.1] (10.184.212.80) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.408.0; Mon, 25 Mar 2019 20:36:52 +0800 Subject: Re: [PATCH v2 1/9] arm64: perf: avoid PMXEV* indirection To: Julien Thierry , References: <1553271844-49003-1-git-send-email-julien.thierry@arm.com> <1553271844-49003-2-git-send-email-julien.thierry@arm.com> From: "liwei (GF)" Message-ID: <8da46a99-d28f-884c-dbc9-4a90a82abd2d@huawei.com> Date: Mon, 25 Mar 2019 20:36:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <1553271844-49003-2-git-send-email-julien.thierry@arm.com> X-Originating-IP: [10.184.212.80] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190325_053708_421104_EABA3EBD X-CRM114-Status: GOOD ( 10.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, peterz@infradead.org, Catalin Marinas , will.deacon@arm.com, acme@kernel.org, alexander.shishkin@linux.intel.com, mingo@redhat.com, libin 00196512 , guohanjun 00470146 , namhyung@kernel.org, jolsa@redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Calling the ARMV8_IDX_TO_COUNTER() is missed before accessing these counters. It will access the wrong counters and may even cause undefinstr exception. I think we need add it as armv8pmu_select_counter() do before. Signed-off-by: Wei Li --- arch/arm64/kernel/perf_event.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index c6fe36f5a9f5..42fe7109468f 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -599,7 +599,9 @@ static inline int armv8pmu_counter_has_overflowed(u32 pmnc, int idx) static inline u32 armv8pmu_read_evcntr(int idx) { - return read_pmevcntrn(idx); + u32 counter = ARMV8_IDX_TO_COUNTER(idx); + + return read_pmevcntrn(counter); } static inline u64 armv8pmu_read_hw_counter(struct perf_event *event) @@ -633,7 +635,9 @@ static inline u64 armv8pmu_read_counter(struct perf_event *event) static inline void armv8pmu_write_evcntr(int idx, u32 value) { - write_pmevcntrn(idx, value); + u32 counter = ARMV8_IDX_TO_COUNTER(idx); + + write_pmevcntrn(counter, value); } static inline void armv8pmu_write_hw_counter(struct perf_event *event, @@ -674,8 +678,10 @@ static inline void armv8pmu_write_counter(struct perf_event *event, u64 value) static inline void armv8pmu_write_evtype(int idx, u32 val) { + u32 counter = ARMV8_IDX_TO_COUNTER(idx); + val &= ARMV8_PMU_EVTYPE_MASK; - write_pmevtypern(idx, val); + write_pmevtypern(counter, val); } static inline void armv8pmu_write_event_type(struct perf_event *event) -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel