From nobody Thu Jan 20 10:13:24 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 37EF919656F4; Thu, 20 Jan 2022 10:13:25 +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 4Jfdd05Zmrz4W3M; Thu, 20 Jan 2022 10:13:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642673604; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IFP8sodB2ldmdSRu0coRyeQKxEntWCc4AhOLI/A9O+k=; b=w6fuQ2qLXrzNoW1B7N7etsubntAGDEM08+lZ+8YHYvZYe6BXGlkwESm1YU+r7JhMKVMDYf qG6rSOc9szFECruwo2xbBA11vbH2xFcDUcKCAgELq9Le2wrmaxxPo6ye57wQb2NTNwP0ny LkgA19++f38RzETC/pcJe+VztaR4Z/BHW+qcmEr5WeL+OC5e1v9Nk0e0kQJ+9Qwz/jhYHB vMc70d4v+nVi3K97P8U7OqbUnlK+QrSg1rG00k4+trf4Tun9Utyof9cv2iXYFfTptzq9VG ev0rY0edbde0e66VCo26FL6B+dOlNZsBT+X12qsNP4bBExoxwcdZ0FOR/qD5iQ== 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 5AD30264ED; Thu, 20 Jan 2022 10:13:24 +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 20KADOcM004834; Thu, 20 Jan 2022 10:13:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20KADOam004833; Thu, 20 Jan 2022 10:13:24 GMT (envelope-from git) Date: Thu, 20 Jan 2022 10:13:24 GMT Message-Id: <202201201013.20KADOam004833@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michal Meloun Subject: git: 79631b49eeda - stable/13 - arm: Fix handling of undefined instruction aborts in THUMB2 mode. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mmel X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 79631b49eeda47d90f6ceba9ad574e6625f1f2f1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642673604; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IFP8sodB2ldmdSRu0coRyeQKxEntWCc4AhOLI/A9O+k=; b=Xya1Xfp5qtrr/SGtazocjDDRj3dOCIORh/H6Nv44DGtylHDGGmT6xno/qkgMjx++U9KdKO OTib6yw4EQUFhSEvMO/pmWCIqkQ98pEnUV4KmVbDKYXZMzwySHCuki12lkQyPbEqAymxQn 3IgfKPWsY9wLfBNMlUL1Vh3aJ6iv5nGxIl3K+LeVxauJmCi6H73BS81tyTgZHUPNyvyuAL rrMoCAdftbGrowgJVkcUk9ATf1GOSpx88IxPQFrtV5jSLdh1wd8mILLlEIfA2GMyf9Fizi FMGNHx84jpRsydLDllD4DFE4q7thTaT7nv9p/l8DQypkKu4pONsRF0u7gGalAA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642673604; a=rsa-sha256; cv=none; b=BZkXyoLIkMJrCx1/peWFD/NRXsoXlVS0TXkJ8IJoafsCmI+iDtOtii/o5kSK4cy6+x8byi DxVjMLCxsH8TcN5YlUCTKKvYVNSljTT610x0zN5+1qBRWDn4EWtpCRj41/fiJHwZatDzEh IJF+ah6GtLX2H78XBz7RJQ/nNwrWhlqjhppBYEZnn53AEVq/KlcQsia6Ow7j22k9+zjJGg Axy9Y3/TesNNQZZewc7CqvbFOEO8sDOC9l0jpguO/Lkin/75RJUILt0b/3sdOZX1Nw5O8G Td7zKPu2Y/m5M8Q5yPurPU+8MLOR0dLKnSTQsAQhvbGQ57qqR1nh0dy4mfBgRA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mmel: URL: https://cgit.FreeBSD.org/src/commit/?id=79631b49eeda47d90f6ceba9ad574e6625f1f2f1 commit 79631b49eeda47d90f6ceba9ad574e6625f1f2f1 Author: Michal Meloun AuthorDate: 2021-10-17 17:36:33 +0000 Commit: Michal Meloun CommitDate: 2022-01-20 10:12:36 +0000 arm: Fix handling of undefined instruction aborts in THUMB2 mode. Correctly recognize NEON/SIMD and VFP instructions in THUMB2 mode and pass these to the appropriate handler. Note that it is not necessary to filter all undefined instruction variant or register combinations, this is a job for given handler. Reported by: Robert Clausecker PR: 259187 MFC after: 2 weks (cherry picked from commit a670e1c13a522df4fb8c63bb023b88b1d65de797) --- sys/arm/arm/undefined.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/sys/arm/arm/undefined.c b/sys/arm/arm/undefined.c index ef9e72c89163..1fff398394fd 100644 --- a/sys/arm/arm/undefined.c +++ b/sys/arm/arm/undefined.c @@ -90,13 +90,25 @@ __FBSDID("$FreeBSD$"); #define ARM_COPROC_INSN(insn) (((insn) & (1 << 27)) != 0) #define ARM_VFP_INSN(insn) ((((insn) & 0xfe000000) == 0xf2000000) || \ - (((insn) & 0xff100000) == 0xf4000000)) + (((insn) & 0xff100000) == 0xf4000000)) #define ARM_COPROC(insn) (((insn) >> 8) & 0xf) -#define THUMB_32BIT_INSN(insn) ((insn) >= 0xe800) +#define THUMB_32BIT_INSN(insn) ((((insn) & 0xe000) == 0xe000) && \ + (((insn) & 0x1800) != 0)) +/* + * Coprocessor, Advanced SIMD, and + * Floating-point instructions on page A6-251 + * OP1 == 01 OR 11 + * OP2 == 1xxxxxx + */ #define THUMB_COPROC_INSN(insn) (((insn) & (3 << 26)) == (3 << 26)) -#define THUMB_COPROC_UNDEFINED(insn) (((insn) & 0x3e << 20) == 0) -#define THUMB_VFP_INSN(insn) (((insn) & (3 << 24)) == (3 << 24)) +/* + * Advanced SIMD element or structure + * load/store instructions on page A7-275 + * OP1 == 11 + * OP2 == 001xxx0 +*/ +#define THUMB_VFP_INSN(insn) (((insn) & (0x1F1 << 20)) == (0x190 << 20)) #define THUMB_COPROC(insn) (((insn) >> 8) & 0xf) #define COPROC_VFP 10 @@ -278,18 +290,13 @@ undefinedinstruction(struct trapframe *frame) fault_instruction <<= 16; fault_instruction |= *(uint16_t *)(fault_pc + 2); - /* - * Is it a Coprocessor, Advanced SIMD, or - * Floating-point instruction. - */ - if (THUMB_COPROC_INSN(fault_instruction)) { - if (THUMB_COPROC_UNDEFINED(fault_instruction)) { - /* undefined insn */ - } else if (THUMB_VFP_INSN(fault_instruction)) - coprocessor = COPROC_VFP; - else - coprocessor = - THUMB_COPROC(fault_instruction); + /* Coprocessor, Advanced SIMD and Floating-point */ + if (THUMB_COPROC_INSN(fault_instruction)) + coprocessor = THUMB_COPROC(fault_instruction); + else { + /* Advanced SIMD load/store */ + if (THUMB_VFP_INSN(fault_instruction)) + coprocessor = COPROC_VFP; /* SIMD */ } } #else