Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp253988pxj; Tue, 18 May 2021 02:34:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLZuiYWqA9YK3DgEJ41PMthv3YLGZh2Rh8J3+/BAdrbM324EOTEpVMIr1kJ3kULI0Ey8HD X-Received: by 2002:a50:fe8e:: with SMTP id d14mr5853888edt.97.1621330448036; Tue, 18 May 2021 02:34:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621330448; cv=none; d=google.com; s=arc-20160816; b=RGDlNIgNMDyKwKgmdlcnjhUXJM1jJWvV+Uu+HZEAGM9tncAa7Mc+4baxgBhVq9CKnG 2z6oIx7oYB8p8/vU6hpv4g+ybGFVW3AaTclVhf2mU5MYyv5bj8ThFUnxPYZme/YUHOEp F3PYVKzC+7s/tN6txd71oPtDHdQFradzF3mV9qRjJO1wvcuJS77nJlBrw4Sh9WrB4cyF cHvnVvbGQMIibHvLdOVCzSQrS8KFbP6I5G28WvT3FUQfvv7SuO1C1dwgaJzrRLWq5U9t 7YL0uBynrqK20UIRNu7YHf59cgdOKBNw69bNhZVVceNIv0MoN6cbDLS9M1b3vWoZMQBy nWYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RwQXu7wS1TVeJK2tnY4KdtV4TOzrLWcD05Xg8IFDm4o=; b=pgvowvot/EPOlQI5YaBNoIp9CtuCvSKNbwh75JJKNc8ZOjkZP4xKmOmjoQT/2Z6slB oeaxfJSBUO573KOn3xlmgMHqlDhzekJNqi61F16hFwR64lR/5ykH17ELhc4Le+U4c82c LZxvZzzJK6eoO+mIi2/1ojctgmUmfRVornNqnVbT89/pfSEKG9Z/3odlRNZmpldWMMGb INDdPwuXCLAnvXKDRuz7ASEcIxg0KXm01NZ3UXAihZHXzGphhHEsGCtr7Yszx+f1rBLj qLVd6VQsUkg32eM4kAZf5rBcCtyICte2ljT92vdMReEJ40sCsNgarMarLx3JlwBuWGLb 6jOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i2ri3lGn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o6si20875979edi.480.2021.05.18.02.33.44; Tue, 18 May 2021 02:34:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i2ri3lGn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240414AbhEQPHY (ORCPT + 99 others); Mon, 17 May 2021 11:07:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:58730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241488AbhEQO6A (ORCPT ); Mon, 17 May 2021 10:58:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A7BBE619AE; Mon, 17 May 2021 14:25:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261550; bh=IjQ16PaiznQ+DmnopLdAcuaE4WZWyIOLV2kE1mYF6KM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i2ri3lGnvKVJDGhr0aMSu207HlhOQJH+DFcMBzlLiymxD5kiZ1fHl7dFnDozuYfq2 9xASu21KjU5309AMpHB+cFtnGaSJ4j/RbjhLHloPF1FpoLkbWJRTlXNz68Kgzq2Ds5 TP2QUGDaLV5izegv/pFbFS7bAWcLTSbN+sKvMpxw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Russell Currey , Daniel Axtens , Michael Ellerman , Sasha Levin Subject: [PATCH 5.10 032/289] selftests/powerpc: Fix L1D flushing tests for Power10 Date: Mon, 17 May 2021 15:59:17 +0200 Message-Id: <20210517140306.274717721@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Russell Currey [ Upstream commit 3a72c94ebfb1f171eba0715998010678a09ec796 ] The rfi_flush and entry_flush selftests work by using the PM_LD_MISS_L1 perf event to count L1D misses. The value of this event has changed over time: - Power7 uses 0x400f0 - Power8 and Power9 use both 0x400f0 and 0x3e054 - Power10 uses only 0x3e054 Rather than relying on raw values, configure perf to count L1D read misses in the most explicit way available. This fixes the selftests to work on systems without 0x400f0 as PM_LD_MISS_L1, and should change no behaviour for systems that the tests already worked on. The only potential downside is that referring to a specific perf event requires PMU support implemented in the kernel for that platform. Signed-off-by: Russell Currey Acked-by: Daniel Axtens Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20210223070227.2916871-1-ruscur@russell.cc Signed-off-by: Sasha Levin --- tools/testing/selftests/powerpc/security/entry_flush.c | 2 +- tools/testing/selftests/powerpc/security/flush_utils.h | 4 ++++ tools/testing/selftests/powerpc/security/rfi_flush.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/powerpc/security/entry_flush.c b/tools/testing/selftests/powerpc/security/entry_flush.c index 78cf914fa321..68ce377b205e 100644 --- a/tools/testing/selftests/powerpc/security/entry_flush.c +++ b/tools/testing/selftests/powerpc/security/entry_flush.c @@ -53,7 +53,7 @@ int entry_flush_test(void) entry_flush = entry_flush_orig; - fd = perf_event_open_counter(PERF_TYPE_RAW, /* L1d miss */ 0x400f0, -1); + fd = perf_event_open_counter(PERF_TYPE_HW_CACHE, PERF_L1D_READ_MISS_CONFIG, -1); FAIL_IF(fd < 0); p = (char *)memalign(zero_size, CACHELINE_SIZE); diff --git a/tools/testing/selftests/powerpc/security/flush_utils.h b/tools/testing/selftests/powerpc/security/flush_utils.h index 07a5eb301466..7a3d60292916 100644 --- a/tools/testing/selftests/powerpc/security/flush_utils.h +++ b/tools/testing/selftests/powerpc/security/flush_utils.h @@ -9,6 +9,10 @@ #define CACHELINE_SIZE 128 +#define PERF_L1D_READ_MISS_CONFIG ((PERF_COUNT_HW_CACHE_L1D) | \ + (PERF_COUNT_HW_CACHE_OP_READ << 8) | \ + (PERF_COUNT_HW_CACHE_RESULT_MISS << 16)) + void syscall_loop(char *p, unsigned long iterations, unsigned long zero_size); diff --git a/tools/testing/selftests/powerpc/security/rfi_flush.c b/tools/testing/selftests/powerpc/security/rfi_flush.c index 7565fd786640..f73484a6470f 100644 --- a/tools/testing/selftests/powerpc/security/rfi_flush.c +++ b/tools/testing/selftests/powerpc/security/rfi_flush.c @@ -54,7 +54,7 @@ int rfi_flush_test(void) rfi_flush = rfi_flush_orig; - fd = perf_event_open_counter(PERF_TYPE_RAW, /* L1d miss */ 0x400f0, -1); + fd = perf_event_open_counter(PERF_TYPE_HW_CACHE, PERF_L1D_READ_MISS_CONFIG, -1); FAIL_IF(fd < 0); p = (char *)memalign(zero_size, CACHELINE_SIZE); -- 2.30.2