From nobody Fri May 13 17:42:47 2022 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 DCD941AE50AA; Fri, 13 May 2022 17:42:47 +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 4L0GFM5XxGz4S20; Fri, 13 May 2022 17:42:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652463767; 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=BYaDqSZ+8WZz84tQ+3SdbN4JAbnSH1FYJLm1YO07+rA=; b=wjXIon/2ugHM4zSje2tLm1vr2Nw+9EA8bqzx8fXvn7Qa117WM2R2Y4Ux6Ba1bzHBrq+jSw mDxkCficfZmwj53Q8WftiITQkm/xNkpUePdWlO8ZeQTLD/vV0F23Yr+EVrgV7VrWtvYEnK WnqR304TJhR4nEH02Vn8j8gtdUrc+bFkrIg+qFGIUZ7HQAUC3v4hsO3uVCetF4hwnr72Dg Zk4xJycKYU6BeKdf64qBTG8SetCHK9gSlSeFz7SF2ICVDd9MJZhIjw+OO5ZntYYzkh7wOW 4BYUFx4o94H0o5AS4eB28jO0gUzxIkJW5JOpU3T2d7ZllPdjBvABU0Uz6CGowg== 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 9E19926F6D; Fri, 13 May 2022 17:42:47 +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 24DHglT7055524; Fri, 13 May 2022 17:42:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24DHglVT055523; Fri, 13 May 2022 17:42:47 GMT (envelope-from git) Date: Fri, 13 May 2022 17:42:47 GMT Message-Id: <202205131742.24DHglVT055523@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: c0e2ddd1a44e - stable/13 - aarch64: Fix get_fpcontext32() to work on non-curthread. 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c0e2ddd1a44e4d81e1512e547f97759305618aa9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652463767; 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=BYaDqSZ+8WZz84tQ+3SdbN4JAbnSH1FYJLm1YO07+rA=; b=T+rvfGrPid9KpeJEPlG/01HKxCZh+FUc/31+46iBChNQ1lZPw/kYI0vzeizg9YfVu/+78m n2gdmC8q4JBpwGD7sASmR8AHPBVTmRQTSvlaccG6MGAKhcgYwMToQ1nmydx5KB668+lB0y Zrm3aDxKeBc0O2bNXiNfSR7DDQLVoGo7aQl1OWTfk8A2aEbvxyJ3JS0MRN2NqyCMlnnPHT t0cDrGMnSpQ5AJa4K37fAKc/SXHNEmhi9rth9yyeFn1OfiWisu21QoCMJplUdq0UxsJoj3 e968V+/c8q3SUDgxfHziPHa0LWXJxFN+jKn8BR/2dIJiLNQh8db34V7RBh4WsQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652463767; a=rsa-sha256; cv=none; b=ixPdOLJZr2hMKw6CTLMEL9wuzfYgLslSJLakSz+jdJCK/IgEuJtoG/HPVkfHalFeVAQvjT MSZpTJYaWLY1iigdqIufLMdMRQFGkU80U9cFos1wnUg3yXZknfcHPwntwOpQM0+kKOYeW4 lytZfFTnzjuBOTuKN9n4So5iKzp1//rx4dckdEpAhQNPL2hK1MRCOIv72TvkHpN/Q/FUL6 Cau054EAoa7o2x0HTSs93l7odmZrIdtK4NsnR24JphWgi12H4k9vTr/cL+iqhad+7LBVym KKCeKmmL/L4VgX29WjnVWqHGjzTLIiJ6TNXk3H7glh79zgRe+TWA6/iUSZnyKA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c0e2ddd1a44e4d81e1512e547f97759305618aa9 commit c0e2ddd1a44e4d81e1512e547f97759305618aa9 Author: John Baldwin AuthorDate: 2022-03-23 20:33:06 +0000 Commit: John Baldwin CommitDate: 2022-05-12 22:57:15 +0000 aarch64: Fix get_fpcontext32() to work on non-curthread. Similar to fill_fpregs(), only invoke vfp_save_state() for curthread. While here, zero the buffer if FP hasn't been started to avoid leaking kernel stack memory. Reviewed by: andrew, markj Sponsored by: University of Cambridge, Google, Inc. Differential Revision: https://reviews.freebsd.org/D34525 (cherry picked from commit a47fd6929fe2008e28e3e697e449fb0904258d04) --- sys/arm64/arm64/freebsd32_machdep.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/sys/arm64/arm64/freebsd32_machdep.c b/sys/arm64/arm64/freebsd32_machdep.c index 9d7b5effac0c..f9b847d8b658 100644 --- a/sys/arm64/arm64/freebsd32_machdep.c +++ b/sys/arm64/arm64/freebsd32_machdep.c @@ -126,29 +126,33 @@ freebsd32_sysarch(struct thread *td, struct freebsd32_sysarch_args *uap) static void get_fpcontext32(struct thread *td, mcontext32_vfp_t *mcp) { - struct pcb *curpcb; + struct pcb *pcb; int i; - critical_enter(); - curpcb = curthread->td_pcb; + KASSERT(td == curthread || TD_IS_SUSPENDED(td) || + P_SHOULDSTOP(td->td_proc), + ("not suspended thread %p", td)); + + memset(mcp, 0, sizeof(*mcp)); + pcb = td->td_pcb; - if ((curpcb->pcb_fpflags & PCB_FP_STARTED) != 0) { + if ((pcb->pcb_fpflags & PCB_FP_STARTED) != 0) { /* * If we have just been running VFP instructions we will * need to save the state to memcpy it below. */ - vfp_save_state(td, curpcb); + if (td == curthread) + vfp_save_state(td, pcb); - KASSERT(curpcb->pcb_fpusaved == &curpcb->pcb_fpustate, - ("Called get_fpcontext while the kernel is using the VFP")); - KASSERT((curpcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0, - ("Non-userspace FPU flags set in get_fpcontext")); + KASSERT(pcb->pcb_fpusaved == &pcb->pcb_fpustate, + ("Called get_fpcontext32 while the kernel is using the VFP")); + KASSERT((pcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0, + ("Non-userspace FPU flags set in get_fpcontext32")); for (i = 0; i < 32; i++) - mcp->mcv_reg[i] = (uint64_t)curpcb->pcb_fpustate.vfp_regs[i]; - mcp->mcv_fpscr = VFP_FPSCR_FROM_SRCR(curpcb->pcb_fpustate.vfp_fpcr, - curpcb->pcb_fpustate.vfp_fpsr); + mcp->mcv_reg[i] = (uint64_t)pcb->pcb_fpustate.vfp_regs[i]; + mcp->mcv_fpscr = VFP_FPSCR_FROM_SRCR(pcb->pcb_fpustate.vfp_fpcr, + pcb->pcb_fpustate.vfp_fpsr); } - critical_exit(); } static void