Re: Is PTRACE_SINGLEBLOCK buggy?

2008-06-02 Thread Jan Kratochvil
On Mon, 02 Jun 2008 11:09:56 +0200, Renzo Davoli wrote:
> Jan Kratochvil has just sent me an E-mail saying that it seems to be 
> a kvm bug (or a bug caused by kvm).

KVM bug details at https://bugzilla.redhat.com/show_bug.cgi?id=437028 .

> He is right: using qemu/kqemu instead of kvm it does not panic.
> 
> Anyway I am puzzled. Using kvm the PTRACE_SINGLEBLOCK should have the
> same effect on 2.6.25.4 and 2.6.25.4+utrace.
> 2.6.25.4: ptrace_resume(kernel/ptrace.c)->user_enable_block_step
> 2.6.25.4+utrace: 
>  ptrace_common(kernel/ptrace.c) sets UTRACE_ACTION_BLOCKSTEP 
>  ->utrace_quiescent(kernel/utrace.c) tests UTRACE_ACTION_BLOCKSTEP 
>  ->user_enable_block_step
> I wonder where is the difference...

Just FYI on 2.6.25 I still get the crash,
  host: kernel: kvm: 19661: cpu0 unhandled wrmsr: 0x1d9 data 2
kernel-2.6.25.3-18.fc9.x86_64
kvm-65-7.fc9.x86_64
  guest: vanilla 2.6.25 x86_64
 Pid: 1945, comm: block-step Not tainted 2.6.25-0.101.rc4.git3.fc8 #1
 RIP: 0010:[]  [] 
__switch_to+0x218/0x2bc
 (the version number is for a RPM-built vanilla kernel)
(I did not find any ptrace patches in between 2.6.25 and 2.6.25.4.)


Regards,
Jan



Re: Is PTRACE_SINGLEBLOCK buggy?

2008-06-02 Thread Renzo Davoli
Jan Kratochvil has just sent me an E-mail saying that it seems to be 
a kvm bug (or a bug caused by kvm).

He is right: using qemu/kqemu instead of kvm it does not panic.

Anyway I am puzzled. Using kvm the PTRACE_SINGLEBLOCK should have the
same effect on 2.6.25.4 and 2.6.25.4+utrace.
2.6.25.4: ptrace_resume(kernel/ptrace.c)->user_enable_block_step
2.6.25.4+utrace: 
 ptrace_common(kernel/ptrace.c) sets UTRACE_ACTION_BLOCKSTEP 
 ->utrace_quiescent(kernel/utrace.c) tests UTRACE_ACTION_BLOCKSTEP 
 ->user_enable_block_step
I wonder where is the difference...

Anyway, let us wait for kvm people to fix it...

I want to thank Jan for his quick feedback.

renzo



Is PTRACE_SINGLEBLOCK buggy?

2008-06-02 Thread Renzo Davoli
Hi Roland, hi everybody,

I have finished teaching my spring term so I am back working on utrace.

I am porting my stuff about virtualquare kmview on the new version of
kernels.
I ran into something that seems to be a bug on PTRACE_SINGLEBLOCK.

The source code here enclosed says "OKAY" on a standard 2.6.25.4,
while it generates a kernel panic on a 2.6.25.4 +
http://people.redhat.com/roland/utrace/2.6-current/linux-2.6-utrace.patch.

Is this a bug? (I think so, no combination of syscall parms should
ever generate kernel panics ;)
Is this a known bug? (e.g. because PTRACE_SINGLEBLOCK is already a WIP
with utrace and you are already working on it...)

ciao
renzo

---
#include 
#include 
#include 
#include 
#include 

static int child(void *arg)
{
  if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0){
perror("ptrace traceme");
  }
  kill(getpid(), SIGSTOP);
  return 0;
}

int main()
{
  int pid, status, rv;
  static char stack[1024];

  if((pid = clone(child, &stack[1020], SIGCHLD, NULL)) < 0){
perror("clone");
return 0;
  }
  if((pid = waitpid(pid, &status, WUNTRACED)) < 0){
perror("Waiting for stop");
return 0;
  }
  ptrace(33, pid, 0, 0); /* PTRACE_SINGLEBLOCK */
  printf("OKAY\n");
  return 0;
}