From owner-dev-commits-src-all@freebsd.org Wed Sep 22 23:05:48 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6F655674016; Wed, 22 Sep 2021 23:05:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HFDRc2Smvz3ltH; Wed, 22 Sep 2021 23:05:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 341681FFD8; Wed, 22 Sep 2021 23:05:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18MN5mhm013140; Wed, 22 Sep 2021 23:05:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18MN5mxe013139; Wed, 22 Sep 2021 23:05:48 GMT (envelope-from git) Date: Wed, 22 Sep 2021 23:05:48 GMT Message-Id: <202109222305.18MN5mxe013139@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Houchard Subject: git: ebbc3140ca0d - main - truss: Decode correctly 64bits arguments on 32bits arm. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cognet X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ebbc3140ca0d7eee154f7a67ccdae7d3d88d13fd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Sep 2021 23:05:48 -0000 The branch main has been updated by cognet: URL: https://cgit.FreeBSD.org/src/commit/?id=ebbc3140ca0d7eee154f7a67ccdae7d3d88d13fd commit ebbc3140ca0d7eee154f7a67ccdae7d3d88d13fd Author: Olivier Houchard AuthorDate: 2021-09-22 22:45:42 +0000 Commit: Olivier Houchard CommitDate: 2021-09-22 23:04:16 +0000 truss: Decode correctly 64bits arguments on 32bits arm. When decoding 32bits arm syscall, make sure we account for the padding when decoding 64bits args. Do it too when using a 64bits truss on a 32bits binary. MFC After: 1 week PR: 256199 --- usr.bin/truss/syscalls.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index f7657f30b583..9cd53e71cc9b 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -792,11 +792,14 @@ print_mask_arg32(bool (*decoder)(FILE *, uint32_t, uint32_t *), FILE *fp, * decoding arguments. */ static void -quad_fixup(struct syscall_decode *sc) +quad_fixup(struct procabi *abi, struct syscall_decode *sc) { int offset, prev; u_int i; +#ifndef __aarch64__ + (void)abi; +#endif offset = 0; prev = -1; for (i = 0; i < sc->nargs; i++) { @@ -810,17 +813,20 @@ quad_fixup(struct syscall_decode *sc) switch (sc->args[i].type & ARG_MASK) { case Quad: case QuadHex: -#ifdef __powerpc__ +#if defined(__powerpc__) || defined(__arm__) || defined(__aarch64__) /* - * 64-bit arguments on 32-bit powerpc must be + * 64-bit arguments on 32-bit powerpc and arm must be * 64-bit aligned. If the current offset is * not aligned, the calling convention inserts * a 32-bit pad argument that should be skipped. */ - if (sc->args[i].offset % 2 == 1) { - sc->args[i].offset++; - offset++; - } +#ifdef __aarch64__ + if (abi->pointer_size == sizeof(uint32_t)) +#endif + if (sc->args[i].offset % 2 == 1) { + sc->args[i].offset++; + offset++; + } #endif offset++; default: @@ -854,7 +860,7 @@ add_syscall(struct procabi *abi, u_int number, struct syscall *sc) * procabi instead. */ if (abi->pointer_size == 4) - quad_fixup(&sc->decode); + quad_fixup(abi, &sc->decode); if (number < nitems(abi->syscalls)) { assert(abi->syscalls[number] == NULL);