git: aa17908bc7af - main - amd64/pt.c: Align ToPA table to page size

From: Bojan Novković <bnovkov_at_FreeBSD.org>
Date: Tue, 17 Nov 2026 17:44:42 UTC
The branch main has been updated by bnovkov:

URL: https://cgit.FreeBSD.org/src/commit/?id=aa17908bc7af30de38f8ff37ce90c26d1b17d175

commit aa17908bc7af30de38f8ff37ce90c26d1b17d175
Author:     Bojan Novković <bnovkov@FreeBSD.org>
AuthorDate: 2026-11-07 12:44:55 +0000
Commit:     Bojan Novković <bnovkov@FreeBSD.org>
CommitDate: 2026-11-17 17:41:07 +0000

    amd64/pt.c: Align ToPA table to page size
    
    The Intel SDM states that the ToPA table must by 4k-aligned, and any
    alignment issues will cause an operational error and disable tracing.
    
    The default buffer size prevented this from happening, but a smaller
    buffer size could hit this issue. Fix this by explicitly allocating
    the ToPA table with malloc_aligned.
    
    Fixes:  310162ea218a
---
 sys/amd64/pt/pt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/amd64/pt/pt.c b/sys/amd64/pt/pt.c
index 6b2296de049c..20db2447fa43 100644
--- a/sys/amd64/pt/pt.c
+++ b/sys/amd64/pt/pt.c
@@ -311,7 +311,7 @@ pt_topa_prepare(struct pt_ctx *ctx, struct hwt_vm *vm)
 
 	KASSERT(buf->topa_hw == NULL,
 	    ("%s: ToPA info already exists", __func__));
-	buf->topa_hw = mallocarray(vm->npages + 1, sizeof(uint64_t), M_PT,
+	buf->topa_hw = malloc_aligned((vm->npages + 1) * sizeof(uint64_t), PAGE_SIZE, M_PT,
 	    M_ZERO | M_WAITOK);
 	dprintf("%s: ToPA virt addr %p\n", __func__, buf->topa_hw);
 	buf->size = vm->npages * PAGE_SIZE;