public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Matt Chapman <matthewc@cse.unsw.edu.au>
To: linux-ia64@vger.kernel.org
Subject: Re: [Linux-ia64] sigaltstack and RBS
Date: Sun, 09 Feb 2003 07:58:06 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590709805827@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-105590709805824@msgid-missing>

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

Here's a small test program.

Matt


[-- Attachment #2: test.c --]
[-- Type: text/plain, Size: 971 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/mman.h>
#include <asm/page.h>

#define RBS_BASE	(void *)0x60000fff80000000UL
#define RBS_SIZE	PAGE_SIZE

static void
mprotect_rbs(int flags)
{
	mprotect(RBS_BASE, RBS_SIZE, flags);
}

static void
SIGSEGV_handler(int sig, siginfo_t *info, void *uc)
{
#if 1
	abort();
#endif
	mprotect_rbs(PROT_READ|PROT_WRITE);
}

int
main(void)
{
	struct sigaction sa;
	stack_t newstack;
	static unsigned long stack[SIGSTKSZ/sizeof(unsigned long)] __attribute__((aligned(PAGE_SIZE))) /* paranoia */;

	newstack.ss_sp = stack;
	newstack.ss_flags = 0;
	newstack.ss_size = sizeof(stack);
	if (sigaltstack(&newstack, NULL) == -1)
	{
		perror("sigaltstack");
		return 1;
	}

	sigemptyset(&sa.sa_mask);
	sa.sa_flags = SA_ONSTACK | SA_SIGINFO;
	sa.sa_sigaction = SIGSEGV_handler;
	if (sigaction(SIGSEGV, &sa, NULL) == -1)
	{
		perror("sigaction");
		return 1;
	}

	mprotect_rbs(0);
	printf("Still alive!\n");
	return 0;
}

  parent reply	other threads:[~2003-02-09  7:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-09  5:19 [Linux-ia64] sigaltstack and RBS Matt Chapman
2003-02-09  5:27 ` David Mosberger
2003-02-09  5:47 ` Matt Chapman
2003-02-09  7:58 ` Matt Chapman [this message]
2003-02-09  8:48 ` David Mosberger
2003-02-09 10:55 ` Matt Chapman
2003-02-09 18:22 ` David Mosberger
2003-02-11  3:06 ` David Mosberger
2003-02-11  7:26 ` Matt Chapman
2003-02-11 19:11 ` David Mosberger
2003-03-07 23:35 ` Bjorn Helgaas

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=marc-linux-ia64-105590709805827@msgid-missing \
    --to=matthewc@cse.unsw.edu.au \
    --cc=linux-ia64@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