NetBSD Problem Report #54185

From mgorny@pomiocikbsd.local  Thu May  9 16:47:47 2019
Return-Path: <mgorny@pomiocikbsd.local>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 14A837A172
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  9 May 2019 16:47:47 +0000 (UTC)
Message-Id: <20190509051037.2C82744B8B0@pomiocikbsd.local>
Date: Thu,  9 May 2019 07:10:37 +0200 (CEST)
From: mgorny@NetBSD.org
Reply-To: mgorny@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: PT_{G,S}ETXMMREGS not implemented in compat32
X-Send-Pr-Version: 3.95

>Number:         54185
>Category:       port-amd64
>Synopsis:       PT_{G,S}ETXMMREGS ptrace() requests are not implemented in compat32 on amd64
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-amd64-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 09 16:50:00 +0000 2019
>Originator:     Michał Górny
>Release:        NetBSD 8.99.37
>Organization:
NetBSD
>Environment:
System: NetBSD pomiocikbsd.local 8.99.37 NetBSD 8.99.37 (GENERIC) #0: Fri May 3 22:06:59 CEST 2019 root@pomiocikbsd.local:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
It seems that the PT_GETXMMREGS and PT_SETXMMREGS ptrace() requests
are not implemented in compat32 of amd64 kernel.  When trying to run
a test I've written for i386, I get the following failure:

failed: /usr/src/tests/lib/libc/sys/t_ptrace_x86_wait.h:2438:
ptrace(PT_GETXMMREGS, child, &fpr, 0) != -1: Not supported

With PT_GETFPREGS correctly emulating i386 API, this makes it
impossible to query XMM registers of a 32-bit program via ptrace
(unless I'm mistaken).

>How-To-Repeat:
cat > test.c <<EOF

#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#undef _NDEBUG
#include <assert.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main()
{
	char out[512];
	int ret;
	int pid;
	int st;

	pid = fork();
	assert(pid != -1);
	if (pid == 0)
	{
		assert(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
		raise(SIGSTOP);
		_exit(0);
	}

	assert(wait(&st) == pid);

	ret = ptrace(PT_GETXMMREGS, pid, out, 0);
	if (ret == -1)
		perror("ptrace(PT_GETXMMREGS) failed");

	return 0;
}

EOF

cc -m32 test.c
./a.out

>Fix:
FTR, I don't consider this very important since I'll be working
on adding full xsave support via a new ptrace() request.  When done,
it will probably render using i386-specific PT_GETXMMREGS unnecessary.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.