From nobody Thu Mar 23 19:02:48 2023 X-Original-To: dev-commits-src-all@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 4PjF8m52xmz41gnc; Thu, 23 Mar 2023 19:02: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 4PjF8m4YHBz3pQh; Thu, 23 Mar 2023 19:02:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679598168; 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=COFY3xL4UpT2kPeafiTY0WxiT+9XDHkDZpMXnmASB/U=; b=eBlfkBE4PFTyH/BrnGRIwQfGm6i5wlNZ2DjlX7IForqihjh6Mrbu+aiPdDlsMs/5pQmy1j FZO4Ddjk4u83lwz0tK2Gd3EI6aOr8HHvFsiNsLMpgBcd8YreZ3uwuR3z2zp+vJQHnXH1yV tzoQ6CvxP2YHtHk17MezU7r1tUbd6pzARPVMZk6q58tPNjYYTLPFcIxxKGgBbb+IICARtH SejO4ufnIPrd7iaNrphBhzeHkXsL+nMNjKMjjWRejBHz9/MrpOLndBNtd8JzMGaQdljCa/ eug3JeJekZQkC1tEfsZCNiWtQIFFdsT/nqYcNMUol67DWruojLosbsKJ/2zEdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679598168; 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=COFY3xL4UpT2kPeafiTY0WxiT+9XDHkDZpMXnmASB/U=; b=NbATiRW9q0h3sQNf6xM1NSNnFME3tHAyvActd2fIqRlCwfYzCngLmw/a4UlhDKrxqfytGP LygRiPkbGId7AJASkj2PyU+FeSnooxQF9LFSX1HAQI4hlp1pnbV3mSkq38UuEdNL60Fmh8 wY5MCawMTuNj/RiVmqEqpvrirHX1f78xkODmT1sEgm85IHTEs4YvQ0yRgChaISRNP9UIpd kMleV1MpEVYU7ob8fmNNg2wkS13EyhJrOguZJ8mclp6cjRS1XB4IYjNqZI8+8cKRFKSpwQ 3TRQ3FPvwQVIsza0AWcLS8jSQxB6DKXBzccy82THi+OzcTyyPZTOXmBELAKTtA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679598168; a=rsa-sha256; cv=none; b=n4EYrPtOBj0tTiEGsfWZleD5X7s+nKY512koDW1/Rg7kGOqFxBYbp5hyKzfyQSyWyJSKjH B/dfslF25uZssHDKuzKiNZe3DJZp2dsEc0bD9xIEq6DktJyXhruUZmSygcZNw3wNxdtyx6 Mx79qFicvhiTY5657mx6RpbZLTgAVNDXiqYlV+030/yUmZimxiTG3yLQJLea/YGh5KgJNE kGxYpb97F69zmMfreprBg9PvyjR+SnOij/UFGwaFStbY+RCbjL6t17GdOZVS6JqR1Bvs9v Z/Yoe+iu3WQnG7v9SZaUxVzWYMZHMWL66iOiuO7zfBqcHBLObrDQnUzLOuSB5Q== 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 4PjF8m3FytznXG; Thu, 23 Mar 2023 19:02: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 32NJ2mdf039347; Thu, 23 Mar 2023 19:02:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32NJ2mS3039346; Thu, 23 Mar 2023 19:02:48 GMT (envelope-from git) Date: Thu, 23 Mar 2023 19:02:48 GMT Message-Id: <202303231902.32NJ2mS3039346@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 4a06b28a15ad - main - Add compat support for struct reg on arm64 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4a06b28a15ad2e33cc2b8c16ce2b946a517d758a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=4a06b28a15ad2e33cc2b8c16ce2b946a517d758a commit 4a06b28a15ad2e33cc2b8c16ce2b946a517d758a Author: Andrew Turner AuthorDate: 2023-03-20 17:38:39 +0000 Commit: Andrew Turner CommitDate: 2023-03-23 18:56:26 +0000 Add compat support for struct reg on arm64 The size of the spsr field in struct reg has changed. Mask the bits that userspace doesn't know about out as they may be invalid. While here add a comment why we don't need compat support in set_regs. Sponsored by: Arm Ltd --- sys/arm64/arm64/exec_machdep.c | 29 ++++++++++++++++++++++++++++- sys/sys/param.h | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/sys/arm64/arm64/exec_machdep.c b/sys/arm64/arm64/exec_machdep.c index 7ead30a05663..a51ff3aeca86 100644 --- a/sys/arm64/arm64/exec_machdep.c +++ b/sys/arm64/arm64/exec_machdep.c @@ -125,6 +125,13 @@ set_regs(struct thread *td, struct reg *regs) #endif { frame->tf_elr = regs->elr; + /* + * frame->tf_spsr and regs->spsr on FreeBSD 13 was 32-bit + * where from 14 they are 64 bit. As PSR_SETTABLE_64 clears + * the upper 32 bits no compatibility handling is needed, + * however if this is ever not the case we will need to add + * these, similar to how it is done in set_mcontext. + */ frame->tf_spsr &= ~PSR_SETTABLE_64; frame->tf_spsr |= regs->spsr & PSR_SETTABLE_64; /* Enable single stepping if userspace asked fot it */ @@ -456,10 +463,22 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret) int set_mcontext(struct thread *td, mcontext_t *mcp) { +#define PSR_13_MASK 0xfffffffful struct trapframe *tf = td->td_frame; uint64_t spsr; spsr = mcp->mc_gpregs.gp_spsr; +#ifdef COMPAT_FREEBSD13 + if (td->td_proc->p_osrel < P_OSREL_ARM64_SPSR) { + /* + * Before FreeBSD 14 gp_spsr was 32 bit. The size of mc_gpregs + * was identical because of padding so mask of the upper bits + * that may be invalid on earlier releases. + */ + spsr &= PSR_13_MASK; + } +#endif + if ((spsr & PSR_M_MASK) != PSR_M_EL0t || (spsr & PSR_AARCH32) != 0 || (spsr & PSR_DAIF) != (td->td_frame->tf_spsr & PSR_DAIF)) @@ -470,7 +489,14 @@ set_mcontext(struct thread *td, mcontext_t *mcp) tf->tf_sp = mcp->mc_gpregs.gp_sp; tf->tf_lr = mcp->mc_gpregs.gp_lr; tf->tf_elr = mcp->mc_gpregs.gp_elr; - tf->tf_spsr = mcp->mc_gpregs.gp_spsr; +#ifdef COMPAT_FREEBSD13 + if (td->td_proc->p_osrel < P_OSREL_ARM64_SPSR) { + /* Keep the upper 32 bits of spsr on older releases */ + tf->tf_spsr &= ~PSR_13_MASK; + tf->tf_spsr |= spsr; + } else +#endif + tf->tf_spsr = spsr; if ((tf->tf_spsr & PSR_SS) != 0) { td->td_pcb->pcb_flags |= PCB_SINGLE_STEP; @@ -481,6 +507,7 @@ set_mcontext(struct thread *td, mcontext_t *mcp) set_fpcontext(td, mcp); return (0); +#undef PSR_13_MASK } static void diff --git a/sys/sys/param.h b/sys/sys/param.h index a613dbf7f2b1..d3bdca7c42e7 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -108,6 +108,7 @@ #define P_OSREL_CK_INODE 1300005 #define P_OSREL_POWERPC_NEW_AUX_ARGS 1300070 #define P_OSREL_TIDPID 1400079 +#define P_OSREL_ARM64_SPSR 1400084 #define P_OSREL_MAJOR(x) ((x) / 100000) #endif