All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Brook <paul@codesourcery.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Armv5 target
Date: Wed, 2 Feb 2005 15:47:24 +0000	[thread overview]
Message-ID: <200502021547.24944.paul@codesourcery.com> (raw)
In-Reply-To: <20050202120109.GB17294@xi.wantstofly.org>

[-- Attachment #1: Type: text/plain, Size: 1225 bytes --]

On Wednesday 02 February 2005 12:01, Lennert Buytenhek wrote:
> On Wed, Feb 02, 2005 at 01:26:37AM +0000, Paul Brook wrote:
> > > > +    /* XXX: locking issue */
> > > > +    if (is_write && page_unprotect(address, pc, puc)) {
> > > > +        return 1;
> > > > +    }
> > > >      /* XXX: do more */
> > > >      return 0;
> > > >  }
> > >
> > > Sort of. Self-modifying code (e.g. stack trampolines) are still broken,
> > > and the patch above should work.
> > >
> > > However I just tested it and it doesn't seem to work any more. It seems
> > > that the SEGV handler is being passed an address of 0, rather than the
> > > actual faulting location.
> > >
> > > This may be a host kernel/libc bug.
> >
> > I just tried on a few different machines, and this is a host kernel bug
> > specific to one particular kernel (custom 2.6.9).
>
> Do you have some example code that demonstrates this?

I've attached two programs. segv-test.c tests for the kernel bug. nest_test.c 
tests stack trampolines, which exposes the bug then run inside qemu-user.

Note that the proper fix for arm is to remove the ||1 hack on the 
TARGET_HAS_SMC tests in exec.c. Comments indicate this hack is to work around 
bugs in the PPC emulation.

Paul

[-- Attachment #2: segv_test.c --]
[-- Type: text/x-csrc, Size: 845 bytes --]

/* Test that gatching SIGSEGV gives the correct fault address.  */
#include <stdio.h>
#include <signal.h>
#include <sys/mman.h>
#include <stdio.h>

void * volatile p = NULL;
void * volatile block;

void foo(int n, siginfo_t *info, void *data)
{
  p = info->si_addr;
  printf ("%p\n", block);
  mprotect(block, sizeof(int), PROT_READ | PROT_WRITE);
}

int main()
{
  struct sigaction sa;

  p = &sa;
  memset (&sa, 0, sizeof(sa));
  sa.sa_sigaction = foo;
  sa.sa_flags = SA_SIGINFO;
  sigaction (SIGSEGV, &sa, NULL);
  block = mmap(NULL, sizeof(int), PROT_READ, MAP_SHARED|MAP_ANONYMOUS, 0, 0);
  if (block == MAP_FAILED)
    {
      printf ("mmap failed\n");
      return 1;
    }
  *(volatile int *) block = 42;
  sleep(1);
  if (p != block)
    printf ("FAIL: expected %p, got %p\n",  block, p);
  else
    printf ("OK\n");
  
  return 0;
}


[-- Attachment #3: nest_test.c --]
[-- Type: text/x-csrc, Size: 273 bytes --]

/* Test stack trampolines (nested functions).  */
/* Should print "Hello nested world". */
#include <stdio.h>

void bar(void (*)())
{
  f();
}
int main()
{
  void f()
    {
      printf ("nested ");
    }
  printf ("Hello ");
  bar(f);
  printf ("world\n");
  return 0;
}


  reply	other threads:[~2005-02-02 16:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-31 20:19 [Qemu-devel] Armv5 target Paul Brook
2005-01-31 22:44 ` Lennert Buytenhek
2005-01-31 23:13   ` Paul Brook
2005-02-02  1:26     ` Paul Brook
2005-02-02 12:01       ` Lennert Buytenhek
2005-02-02 15:47         ` Paul Brook [this message]
2005-02-02 18:18           ` Ulrich Hecht
2005-02-02 19:17             ` Paul Brook
2005-02-03 14:08               ` Ulrich Hecht
2005-02-03 15:43                 ` Paul Brook
2005-02-03  9:59           ` Sylvain Petreolle
2005-02-03 11:25             ` Ulrich Hecht

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=200502021547.24944.paul@codesourcery.com \
    --to=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.