From patchwork Tue Aug 27 13:08:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13779541 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6AED0C5472F for ; Tue, 27 Aug 2024 13:11:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7KqRcAFW8nUzDZ1FEN66jGQtx4LYaSNAvAG+5szB8q0=; b=fmkmwIJ3umPDI9H3l2kmJiujA+ 31kv0ZXnNd/JZ9FcGSxYQQEtEld/ifOV81JdW3LjL+oSC/2CHFvkMwSX7o6Ly6TQVxDt/2eWKzhce nnr6kA7ArzLsh09wm2rgMfigo2t+i0IPP4AgjbDbf9eSEncHq28g4ur/sYfTw9ac1BBeC4g31UhSU lIJVPQw7XOD+nElVJnkIxAEGWdZOoWo2GyP/fMbYboMxIIXhQj/x1a+0PFQ0U+sGglWB+vQ+SfauE F/LX10LYb/3mrNkxh6aslVlfeMRY35PUAc8TDl1ZcZF33EyZNwDeuqOujvb1s4BATMobzYxG5wZ6x N/ZsMAcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sivyO-0000000BOMG-1UKv; Tue, 27 Aug 2024 13:11:00 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sivw2-0000000BNiS-3f76 for linux-arm-kernel@lists.infradead.org; Tue, 27 Aug 2024 13:08:37 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-371ba7e46easo3226290f8f.0 for ; Tue, 27 Aug 2024 06:08:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724764113; x=1725368913; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7KqRcAFW8nUzDZ1FEN66jGQtx4LYaSNAvAG+5szB8q0=; b=SCymQIyzIa6E9syeI+IVQl91N1T3x20JZnCr6HEZ9uk/F16bB4MgPg+GzbAyF+UEpc UL53KrNvZD1GyO+/CY71440dqY+fXVTza4BlTvQ5dVhTq6d6995A2voEY3UE2MNOfWzL jnCNtPMeJZF4vI3qUs1dWmCbWuNK4UBpeRK23ovIm5dBqY30+3/NHDhbIMTqKuR3SkYL nt236quOrR8oUE/T3BvSaVGPWfiTNFMHJStrPQykw/uZtKCg2NvnPV2ENMVOLS+fgTFw a1CjSF+JNCvCrkiYqWn57hIIta74MPwDInRBgJEFSERU6yzk+WI2XY1U9JaOw6GVA8Ez X/9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724764113; x=1725368913; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7KqRcAFW8nUzDZ1FEN66jGQtx4LYaSNAvAG+5szB8q0=; b=vhDV56qwfc3te3Hb9MaZnZagv3GEzmqjY8+hDPYvuWt8YrvWfaGFuUbEdmI2uc9j27 8fe2mGDOC8ESY5wN3zGht3WTvkiZWUoHgGllvu/ww8NU+b6k/c7zyYjV+Qten3y99Vh+ dDL7R3XlaiaGxpNkx2gtk/JzH01qhIta6lgfcFRT1pfGItiFxUfUrRD4dw619MrnqynP GN7iltA+WdWaRhdcBs+4afnTS26a05AZFcOu3m0iYhsApFUCqd1t8B8jPltKiPnB7Qhx 85/tFU1PffkId12X3FdVzJiaMzozFa+MLHIRmk+i+JNKPKFRohzKABcuqQzJmLsrEDJ2 Khtg== X-Forwarded-Encrypted: i=1; AJvYcCVLr7mGIysJZVXKPR7pZWzpT18080H2sRUCmN4ERpzapT6kDJwitMj/SFLdkL8UL63lgmNkhsT89ldxTSfpy719@lists.infradead.org X-Gm-Message-State: AOJu0Yw9qcNmN8pN6EUT+De/tgBKUNoADYDy6uJE1XLTFljPp/YcwXy+ bj9k9Cn/GHKapVXDMHe1Fxk4TcY4jpIMuFM4cUVH9gYCWITIOvWFlOA8fRwZWQk= X-Google-Smtp-Source: AGHT+IFlcKOK92s/UxJ1kIhXDpRFVT9AfPK9EVRV4+49EEVGWs+1h7/ccWiUMy3fn1r+RZMCd6eVbg== X-Received: by 2002:adf:a351:0:b0:371:7e46:68cb with SMTP id ffacd0b85a97d-373118c6b95mr7484089f8f.50.1724764112624; Tue, 27 Aug 2024 06:08:32 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3730813c1e3sm13012590f8f.35.2024.08.27.06.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 06:08:32 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 380E35F9FF; Tue, 27 Aug 2024 14:08:30 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, maz@kernel.org, arnd@linaro.org, =?utf-8?q?Alex_Ben?= =?utf-8?q?n=C3=A9e?= Subject: [PATCH 3/3] ampere/arm64: instrument the altra workarounds Date: Tue, 27 Aug 2024 14:08:29 +0100 Message-Id: <20240827130829.43632-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240827130829.43632-1-alex.bennee@linaro.org> References: <20240827130829.43632-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240827_060834_957809_6B0ACD10 X-CRM114-Status: GOOD ( 19.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is mostly a debugging aid to measure the impact of workarounds. Signed-off-by: Alex Bennée --- arch/arm64/include/asm/pgtable.h | 2 ++ arch/arm64/mm/fault.c | 9 +++-- arch/arm64/mm/ioremap.c | 11 ++++++ include/trace/events/altra_fixup.h | 57 ++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 include/trace/events/altra_fixup.h diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index f4603924390eb..26812b7fc6d93 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -679,6 +679,7 @@ static inline bool pud_table(pud_t pud) { return true; } #ifdef CONFIG_ALTRA_ERRATUM_82288 extern bool __read_mostly have_altra_erratum_82288; +void do_trace_altra_mkspecial(pte_t pte); #endif static inline pte_t pte_mkspecial(pte_t pte) @@ -692,6 +693,7 @@ static inline pte_t pte_mkspecial(pte_t pte) (phys >= 0x200000000000 && phys < 0x400000000000) || (phys >= 0x600000000000 && phys < 0x800000000000))) { pte = __pte(__phys_to_pte_val(phys) | pgprot_val(pgprot_device(prot))); + do_trace_altra_mkspecial(pte); } #endif diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 744e7b1664b1c..6cb3c600cc56a 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -45,6 +45,8 @@ #include #include +#include + struct fault_info { /* fault handler, return 0 on successful handling */ int (*fn)(unsigned long far, unsigned long esr, @@ -1376,6 +1378,8 @@ static int fixup_alignment(unsigned long addr, unsigned int esr, u32 insn; int res; + trace_altra_fixup_alignment(addr, esr); + if (user_mode(regs)) { __le32 insn_le; @@ -1414,8 +1418,9 @@ static int do_alignment_fault(unsigned long far, unsigned long esr, struct pt_regs *regs) { #ifdef CONFIG_ALTRA_ERRATUM_82288 - if (!fixup_alignment(far, esr, regs)) - return 0; + if (!fixup_alignment(far, esr, regs)) { + return 0; + } #endif if (IS_ENABLED(CONFIG_COMPAT_ALIGNMENT_FIXUPS) && compat_user_mode(regs)) diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c index 8965766181359..d38d903d8a063 100644 --- a/arch/arm64/mm/ioremap.c +++ b/arch/arm64/mm/ioremap.c @@ -5,9 +5,19 @@ #ifdef CONFIG_ALTRA_ERRATUM_82288 +#define CREATE_TRACE_POINTS +#include + bool have_altra_erratum_82288 __read_mostly; EXPORT_SYMBOL(have_altra_erratum_82288); +void do_trace_altra_mkspecial(pte_t pte) +{ + trace_altra_mkspecial(pte); +} +EXPORT_SYMBOL(do_trace_altra_mkspecial); +EXPORT_TRACEPOINT_SYMBOL(altra_mkspecial); + static bool is_altra_pci(phys_addr_t phys_addr, size_t size) { phys_addr_t end = phys_addr + size; @@ -25,6 +35,7 @@ pgprot_t ioremap_map_prot(phys_addr_t phys_addr, size_t size, #ifdef CONFIG_ALTRA_ERRATUM_82288 if (unlikely(have_altra_erratum_82288 && is_altra_pci(phys_addr, size))) { prot = pgprot_device(prot); + trace_altra_ioremap_prot(prot); } #endif return prot; diff --git a/include/trace/events/altra_fixup.h b/include/trace/events/altra_fixup.h new file mode 100644 index 0000000000000..73115740c5d84 --- /dev/null +++ b/include/trace/events/altra_fixup.h @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM altra_fixup + +#if !defined(_ALTERA_FIXUP_H_) || defined(TRACE_HEADER_MULTI_READ) +#define _ALTRA_FIXUP_H_ + +#include +#include + +#ifdef CONFIG_ALTRA_ERRATUM_82288 + +TRACE_EVENT(altra_fixup_alignment, + TP_PROTO(unsigned long far, unsigned long esr), + TP_ARGS(far, esr), + TP_STRUCT__entry( + __field(unsigned long, far) + __field(unsigned long, esr) + ), + TP_fast_assign( + __entry->far = far; + __entry->esr = esr; + ), + TP_printk("far=0x%016lx esr=0x%016lx", + __entry->far, __entry->esr) +); + +TRACE_EVENT(altra_mkspecial, + TP_PROTO(pte_t pte), + TP_ARGS(pte), + TP_STRUCT__entry( + __field(pteval_t, pte) + ), + TP_fast_assign( + __entry->pte = pte_val(pte); + ), + TP_printk("pte=0x%016llx", __entry->pte) +); + +TRACE_EVENT(altra_ioremap_prot, + TP_PROTO(pgprot_t prot), + TP_ARGS(prot), + TP_STRUCT__entry( + __field(pteval_t, pte) + ), + TP_fast_assign( + __entry->pte = pgprot_val(prot); + ), + TP_printk("prot=0x%016llx", __entry->pte) +); + +#endif /* CONFIG_ALTRA_ERRATUM_82288 */ + +#endif /* _ALTRA_FIXUP_H_ */ + +/* This part must be outside protection */ +#include