From owner-svn-src-head@freebsd.org  Thu Sep 14 15:03:45 2017
Return-Path: <owner-svn-src-head@freebsd.org>
Delivered-To: svn-src-head@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 612D6E1DE70;
 Thu, 14 Sep 2017 15:03:45 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from repo.freebsd.org (repo.freebsd.org
 [IPv6:2610:1c1:1:6068::e6a:0])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id 3B9CC77BAA;
 Thu, 14 Sep 2017 15:03:45 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v8EF3ikC061745;
 Thu, 14 Sep 2017 15:03:44 GMT (envelope-from jhb@FreeBSD.org)
Received: (from jhb@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id v8EF3irB061741;
 Thu, 14 Sep 2017 15:03:44 GMT (envelope-from jhb@FreeBSD.org)
Message-Id: <201709141503.v8EF3irB061741@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org
 using -f
From: John Baldwin <jhb@FreeBSD.org>
Date: Thu, 14 Sep 2017 15:03:44 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r323582 - in head: lib/libc/sys sys/arm/arm
 sys/arm/include sys/conf
X-SVN-Group: head
X-SVN-Commit-Author: jhb
X-SVN-Commit-Paths: in head: lib/libc/sys sys/arm/arm sys/arm/include sys/conf
X-SVN-Commit-Revision: 323582
X-SVN-Commit-Repository: base
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
 <svn-src-head.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head/>
List-Post: <mailto:svn-src-head@freebsd.org>
List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 14 Sep 2017 15:03:45 -0000

Author: jhb
Date: Thu Sep 14 15:03:43 2017
New Revision: 323582
URL: https://svnweb.freebsd.org/changeset/base/323582

Log:
  Add ptrace operations to fetch and store VFP registers.
  
  Reviewed by:	mmel, kib
  MFC after:	1 month
  Differential Revision:	https://reviews.freebsd.org/D12294

Added:
  head/sys/arm/arm/ptrace_machdep.c   (contents, props changed)
Modified:
  head/lib/libc/sys/ptrace.2
  head/sys/arm/include/ptrace.h
  head/sys/conf/files.arm

Modified: head/lib/libc/sys/ptrace.2
==============================================================================
--- head/lib/libc/sys/ptrace.2	Thu Sep 14 14:36:56 2017	(r323581)
+++ head/lib/libc/sys/ptrace.2	Thu Sep 14 15:03:43 2017	(r323582)
@@ -2,7 +2,7 @@
 .\"	$NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $
 .\"
 .\" This file is in the public domain.
-.Dd June 11, 2017
+.Dd September 14, 2017
 .Dt PTRACE 2
 .Os
 .Sh NAME
@@ -762,6 +762,28 @@ The
 .Fa data
 argument is ignored.
 .El
+.Sh ARM MACHINE-SPECIFIC REQUESTS
+.Bl -tag -width "Dv PT_SETVFPREGS"
+.It Dv PT_GETVFPREGS
+Return the thread's
+.Dv VFP
+machine state in the buffer pointed to by
+.Fa addr .
+.Pp
+The
+.Fa data
+argument is ignored.
+.It Dv PT_SETVFPREGS
+Set the thread's
+.Dv VFP
+machine state from the buffer pointed to by
+.Fa addr .
+.Pp
+The
+.Fa data
+argument is ignored.
+.El
+.Pp
 .Sh x86 MACHINE-SPECIFIC REQUESTS
 .Bl -tag -width "Dv PT_GETXSTATE_INFO"
 .It Dv PT_GETXMMREGS

Added: head/sys/arm/arm/ptrace_machdep.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm/arm/ptrace_machdep.c	Thu Sep 14 15:03:43 2017	(r323582)
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2017 John Baldwin <jhb@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/proc.h>
+#include <sys/ptrace.h>
+#ifdef VFP
+#include <machine/vfp.h>
+#endif
+
+int
+cpu_ptrace(struct thread *td, int req, void *addr, int data)
+{
+#ifdef VFP
+	mcontext_vfp_t vfp;
+#endif
+	int error;
+
+	switch (req) {
+#ifdef VFP
+	case PT_GETVFPREGS:
+		get_vfpcontext(td, &vfp);
+		error = copyout(&vfp, addr, sizeof(vfp));
+		break;
+	case PT_SETVFPREGS:
+		error = copyin(addr, &vfp, sizeof(vfp));
+		if (error == 0)
+			set_vfpcontext(td, &vfp);
+		break;
+#endif
+	default:
+		error = EINVAL;
+	}
+
+	return (error);
+}

Modified: head/sys/arm/include/ptrace.h
==============================================================================
--- head/sys/arm/include/ptrace.h	Thu Sep 14 14:36:56 2017	(r323581)
+++ head/sys/arm/include/ptrace.h	Thu Sep 14 15:03:43 2017	(r323582)
@@ -4,5 +4,20 @@
 #ifndef _MACHINE_PTRACE_H_
 #define _MACHINE_PTRACE_H_
 
+#define	__HAVE_PTRACE_MACHDEP
+
+/*
+ * Must match mcontext_vfp_t.  Note that mcontext_vfp_t does not
+ * include explicit padding.
+ */
+struct vfpreg {
+	__uint64_t	vfp_reg[32];
+	__uint32_t	vfp_scr;
+	__uint32_t	vfp_pad0;
+};
+
+#define	PT_GETVFPREGS	(PT_FIRSTMACH + 0)
+#define	PT_SETVFPREGS	(PT_FIRSTMACH + 1)
+
 #endif /* !_MACHINE_PTRACE_H */
 

Modified: head/sys/conf/files.arm
==============================================================================
--- head/sys/conf/files.arm	Thu Sep 14 14:36:56 2017	(r323581)
+++ head/sys/conf/files.arm	Thu Sep 14 15:03:43 2017	(r323582)
@@ -88,6 +88,7 @@ arm/arm/platform_pl310_if.m	optional	platform pl310
 arm/arm/pmap-v4.c		optional	!armv6
 arm/arm/pmap-v6.c		optional	armv6
 arm/arm/pmu.c			optional	pmu | fdt hwpmc
+arm/arm/ptrace_machdep.c	standard
 arm/arm/sc_machdep.c		optional	sc
 arm/arm/setcpsr.S		standard
 arm/arm/setstack.s		standard