Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2962793pxj; Mon, 17 May 2021 14:14:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1JNjHy5Wdtr8meriACNZXcKAfANfEoYNGUCcy9+Y6V2rb1eRHmUGb9zVTyWOx0PgZKHpK X-Received: by 2002:a17:907:2855:: with SMTP id el21mr1951617ejc.153.1621286083419; Mon, 17 May 2021 14:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621286083; cv=none; d=google.com; s=arc-20160816; b=nloBsbxsuZxgHSVD874zFIwGpRopL36GH9wqBFhu6k4dV52IesDXXundP7aSzmUIRi 0HcZh28cF6seIEL9Q9k4lfk2DhVd3zZOmN5SsS88eSXul7e5YEYBqy/xSvn2EJHNb9Mg P7yWzbGWdR35+GzTf8Jy2SirI/bXBiboQW4tcX59tJP4WXaFgiPRdUeqEhLW0Sl1mfNP ez+mcsLIgLVISyqxxtugrI0BisGvJ6smIl8rJUuzYN8c/MmDqtptcAjYCyIsa04kKs13 /bAt/VEGbprYtD8wg/f1xaeDUvaTN2Ys0JH/vMCouYBdC8wIKdn5lgGtbuFd2sMc44Xd X+4w== 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=O8donuLgy4oOk9oVzoQQjVG4cZlJ4ZG94eI2m5IXB7SMxbLbhUHKWVvy8fhB1J2/Jm Qy6Gaa7pY6R/jxZTKDas5HaTx3x0T2SO0c6GWUmqODpXV0j/DG20RD9rNHQkwrPLS06j L3ylbO/i6O586dJnM1deG60ooEMoRI1NqPUTeGsPSrMswKOCTxu75Gkw0LxF/Y1jz6hd qKUpSG27cAk6PEzSaLIVTjkIAMhZUH5+HVE7LDjJBDEhrRx/QyC2ikF9oHS7jOX6p2/S g/77BkZbv31oyQPGPtOBohUFN1mUaFJ6XXDHnPv1fjGPHeq11hXOnXPdx5XFeFkhVv/5 WQvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KhtN5QuF; 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 ce10si15734899edb.39.2021.05.17.14.14.19; Mon, 17 May 2021 14:14:43 -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=KhtN5QuF; 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 S238024AbhEQOJW (ORCPT + 99 others); Mon, 17 May 2021 10:09:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:58830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237837AbhEQOG7 (ORCPT ); Mon, 17 May 2021 10:06:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 303CA6134F; Mon, 17 May 2021 14:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260341; bh=IjQ16PaiznQ+DmnopLdAcuaE4WZWyIOLV2kE1mYF6KM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KhtN5QuFLBfyU9BJTLD65cGS4xaGpQ1HQa/3dI22+4rwQS4lu7A+5TV7foAZ3a+qc 0PUZEbyaA6P4CjVBLEhBCtOUZOGWGzWeq8C1giLNt/9XrHB7lxo8ZjGy8wKC4tnnU+ 51I8/pFymmC3auItmrVhaf9Jd2jbeB46/6wiGcSY= 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.12 038/363] selftests/powerpc: Fix L1D flushing tests for Power10 Date: Mon, 17 May 2021 15:58:24 +0200 Message-Id: <20210517140303.879831034@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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