mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: TAKADA Yoshihito <takada@mbf.nifty.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] ptrace GET/SET FPXREGS broken
Date: Mon, 30 Jun 2008 13:44:45 +0900 (JST)	[thread overview]
Message-ID: <20080630.134445.193700135.takada@mbf.nifty.com> (raw)

[-- Attachment #1: Type: Text/Plain, Size: 247 bytes --]

Hi
When I update kernel 2.6.25 from 2.6.24, gdb does not work.
On 2.6.25, ptrace(PTRACE_GETFPXREGS, ...) returns ENODEV.
But 2.6.24 kernel's ptrace() returns EIO.
It is issue of compatibility.
I attached test program as pt.c and patch for fix it.

[-- Attachment #2: pt.c --]
[-- Type: Text/Plain, Size: 1077 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <sys/ptrace.h>
#include <sys/types.h>


struct user_fxsr_struct {
	unsigned short	cwd;
	unsigned short	swd;
	unsigned short	twd;
	unsigned short	fop;
	long	fip;
	long	fcs;
	long	foo;
	long	fos;
	long	mxcsr;
	long	reserved;
	long	st_space[32];	/* 8*16 bytes for each FP-reg = 128 bytes */
	long	xmm_space[32];	/* 8*16 bytes for each XMM-reg = 128 bytes */
	long	padding[56];
};

int main(void)
{
  pid_t pid;

  pid = fork();

  switch(pid){
  case -1:/*  error */
    break;
  case 0:/*  child */
    child();
    break;
  default:
    parent(pid);
    break;
  }
  return 0;
}

int child(void)
{
  ptrace(PTRACE_TRACEME);
  kill(getpid(), SIGSTOP);
  sleep(10);
  return 0;
}
int parent(pid_t pid)
{
  int ret;
  struct user_fxsr_struct fpxregs;

  ret = ptrace(PTRACE_GETFPXREGS, pid, 0, &fpxregs);
  if(ret < 0){
    printf("%d: %s.\n", errno, strerror(errno));
  }
  kill(pid, SIGCONT);
  wait(pid);
  return 0;
}

/* in the kerel, at kernel/i387.c get_fpxregs() */

[-- Attachment #3: fxsr.patch --]
[-- Type: Text/Plain, Size: 417 bytes --]

--- a/arch/x86/kernel/i387.c	2008-04-17 11:49:44.000000000 +0900
+++ b/arch/x86/kernel/i387.c	2008-06-30 13:22:57.000000000 +0900
@@ -130,7 +130,7 @@
 		void *kbuf, void __user *ubuf)
 {
 	if (!cpu_has_fxsr)
-		return -ENODEV;
+		return -EIO;
 
 	init_fpu(target);
 
@@ -145,7 +145,7 @@
 	int ret;
 
 	if (!cpu_has_fxsr)
-		return -ENODEV;
+		return -EIO;
 
 	init_fpu(target);
 	set_stopped_child_used_math(target);

             reply	other threads:[~2008-06-30  4:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-30  4:44 TAKADA Yoshihito [this message]
2008-06-30 12:18 ` Ingo Molnar
2008-06-30 21:02 ` [PATCH] x86 ptrace: fix PTRACE_GETFPXREGS error Roland McGrath
2008-07-01  9:02   ` Ingo Molnar
2008-07-01  9:32     ` Roland McGrath
2008-07-01 10:11       ` Ingo Molnar
2008-07-01 14:34         ` [stable] " Greg KH
2008-07-01 14:46           ` Ingo Molnar
2008-07-01 15:02             ` Greg KH
2008-07-03  2:37     ` TAKADA Yoshihito
2008-07-03  1:58   ` TAKADA Yoshihito
2008-07-03  3:00     ` Roland McGrath
2008-06-30 21:02 ` [PATCH] ptrace GET/SET FPXREGS broken Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080630.134445.193700135.takada@mbf.nifty.com \
    --to=takada@mbf.nifty.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®