From nobody Thu Feb 23 16:50:57 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 4PMzYZ1pjtz3sCYs; Thu, 23 Feb 2023 16:50:58 +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 4PMzYZ13kXz3j2w; Thu, 23 Feb 2023 16:50:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677171058; 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=Jh5uNiGc9WPCsIpmsPrj9n/NqwxX3Tl+5vUJAQvROwk=; b=MahEB7cqqTogw9Sit1Ewz18DluOPSLpLlRYS8PrE+yr0GgqalR+mnqDxy8Vl2gXs3fetXw inGtuWzyzqDEhaS/5JYXS18e/wSmKXPpPvSpFEG60kTsAq8qbQ87NSY3ThR1By0X7dJ+LE xa0JR1iH+5vhuW5ttWiNwnhe5Ze1msojppPmk7nwrrIQ+ejOT83ydj8YZYdcxqEnS64eOZ MEpAvCnmg3Z4vNxswvePyN0W1modbHu6DiJgaYbwaQ1qIv8hOwJrJKYlyuBP5y02HBoPCv RFofmollKuK15fS90v/Cj/+IqvmF93wu4Z3fAotjrQIVkkM+rWz7FOh/FzgJIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677171058; 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=Jh5uNiGc9WPCsIpmsPrj9n/NqwxX3Tl+5vUJAQvROwk=; b=S/aEUHdg0lLaRwyMWUytqC1TboNLMUc+aP7eoXgRPisp1sCg9624zbQMW+j8sDuNQ+8FRu kXxRYSSm53OwG4ENxr84nNkFkU2e2AKfw9U5HIzMoRq02VL7JIuSJ/vMRHMQz++wlRwqk+ Lbr6QK1W1hlNs4lQ8nmSXGTVWm3kaYLl2zM8Fxfrf20xCJ4nTp3IQYYRJOKrfVuCmTdc4E tL9/erjTEebnR3sH0TLGLYp8qfqHuQOlVjAteuSHJVtd8rnojMUpsd2TiPqAZJqeGR5HnE 3oNpyBLMlr08OewFvqGOhFY01f88q/IcUp5gqEjbLPKeFJ5QPT4egwh6vTQ3QA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677171058; a=rsa-sha256; cv=none; b=Kb4gUuF+xMtbIbnp1aOA0zfXeHaJyfhKYiPPQNnac97XGKfMDRDFuFNU8lguFaQbcBYAtX csqEo97nZCxk36KluJBOpmmQeD01v81vbQYFpvEdyLWYntm3pKFaClPiO+ETlYtLKyZmwA CWBVQg04iBpUN13DK1mtTF+QwOq73+Y6Wf3tXRSInf5O0nfV6DHbCgsvkl8aGhVvCfo9w4 GN19iIuqH/7SBTWAw0AK1g6npa30YDHyNnU7LN5IgBr3+KYdHigx76ASfK5p3KwnP5Y/YQ 3u16cwcyY/ht6n2PdTjJIcBmGNlW5O3/NeCjd5US2HnFwrPfq32xFzLlldhxKw== 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 4PMzYZ06hNzpnS; Thu, 23 Feb 2023 16:50:58 +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 31NGovhH086449; Thu, 23 Feb 2023 16:50:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31NGovLI086448; Thu, 23 Feb 2023 16:50:57 GMT (envelope-from git) Date: Thu, 23 Feb 2023 16:50:57 GMT Message-Id: <202302231650.31NGovLI086448@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Kornel=20Dul=C4=99ba?= Subject: git: 4d2427f2c445 - main - arm: Unbreak debugging programs that use FP instructions 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: kd X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4d2427f2c4451babe1bad600ae02c8a7c66031fe Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kd: URL: https://cgit.FreeBSD.org/src/commit/?id=4d2427f2c4451babe1bad600ae02c8a7c66031fe commit 4d2427f2c4451babe1bad600ae02c8a7c66031fe Author: Kornel Dulęba AuthorDate: 2023-02-20 14:44:36 +0000 Commit: Kornel Dulęba CommitDate: 2023-02-23 16:50:26 +0000 arm: Unbreak debugging programs that use FP instructions Contrary to arm64, on armv7 get_vfpcontext/set_vfpcontext can be called from cpu_ptrace. This can be triggered when gdb hits a breakpoint in a userspace program. Relax td == currthread assertion to account for that situation. While here update an outdated comment in vfp_discard. Reported by: Mark Millard Tested by: Mark Millard Differential Revision: https://reviews.freebsd.org/D38696 --- sys/arm/arm/exec_machdep.c | 17 ++++++----------- sys/arm/arm/vfp.c | 2 -- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/sys/arm/arm/exec_machdep.c b/sys/arm/arm/exec_machdep.c index c14bd51146ef..96b382c9083f 100644 --- a/sys/arm/arm/exec_machdep.c +++ b/sys/arm/arm/exec_machdep.c @@ -100,19 +100,18 @@ get_vfpcontext(struct thread *td, mcontext_vfp_t *vfp) { struct pcb *pcb; - MPASS(td == curthread); + MPASS(td == curthread || TD_IS_SUSPENDED(td) || + P_SHOULDSTOP(td->td_proc)); pcb = td->td_pcb; - if ((pcb->pcb_fpflags & PCB_FP_STARTED) != 0) { + if ((pcb->pcb_fpflags & PCB_FP_STARTED) != 0 && td == curthread) { critical_enter(); vfp_store(&pcb->pcb_vfpstate, false); critical_exit(); } KASSERT(pcb->pcb_vfpsaved == &pcb->pcb_vfpstate, ("Called get_vfpcontext while the kernel is using the VFP")); - memcpy(vfp->mcv_reg, pcb->pcb_vfpstate.reg, - sizeof(vfp->mcv_reg)); - vfp->mcv_fpscr = pcb->pcb_vfpstate.fpscr; + memcpy(vfp, &pcb->pcb_vfpstate, sizeof(*vfp)); } /* @@ -123,19 +122,15 @@ set_vfpcontext(struct thread *td, mcontext_vfp_t *vfp) { struct pcb *pcb; - MPASS(td == curthread); - pcb = td->td_pcb; - if ((pcb->pcb_fpflags & PCB_FP_STARTED) != 0) { + if (td == curthread) { critical_enter(); vfp_discard(td); critical_exit(); } KASSERT(pcb->pcb_vfpsaved == &pcb->pcb_vfpstate, ("Called set_vfpcontext while the kernel is using the VFP")); - memcpy(pcb->pcb_vfpstate.reg, vfp->mcv_reg, - sizeof(pcb->pcb_vfpstate.reg)); - pcb->pcb_vfpstate.fpscr = vfp->mcv_fpscr; + memcpy(&pcb->pcb_vfpstate, vfp, sizeof(*vfp)); } #endif diff --git a/sys/arm/arm/vfp.c b/sys/arm/arm/vfp.c index 915d65c1b790..d51c4b6e0618 100644 --- a/sys/arm/arm/vfp.c +++ b/sys/arm/arm/vfp.c @@ -334,8 +334,6 @@ vfp_store(struct vfp_state *vfpsave, boolean_t disable_vfp) * The current thread is dying. If the state currently in the hardware belongs * to the current thread, set fpcurthread to NULL to indicate that the VFP * hardware state does not belong to any thread. If the VFP is on, turn it off. - * Called only from cpu_throw(), so we don't have to worry about a context - * switch here. */ void vfp_discard(struct thread *td)