Skip to content

Commit

Permalink
Remove segmentation fault handler
Browse files Browse the repository at this point in the history
Relic code used to use signal handlers in order to detect segmentation
faults.  This is not used anymore.

Fixes: 0c6cdfd ("Remove nx_fault_storage_address and related code")

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
  • Loading branch information
tuliom committed Aug 11, 2022
1 parent 5e43c54 commit bbf1eaf
Show file tree
Hide file tree
Showing 15 changed files with 0 additions and 125 deletions.
1 change: 0 additions & 1 deletion lib/gzip_vas.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#include <sys/ioctl.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <zlib.h>
#include "nx-gzip.h"
#include "crb.h"
Expand Down
1 change: 0 additions & 1 deletion lib/nx_zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include <sys/stat.h>
#include <endian.h>
#include <pthread.h>
#include <signal.h>
#include <dirent.h>
#include <syslog.h>
#include <limits.h>
Expand Down
1 change: 0 additions & 1 deletion lib/sw_zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include <sys/ioctl.h>
#include <endian.h>
#include <pthread.h>
#include <signal.h>
#include <zlib.h>
#include <dlfcn.h>
#include "nx_dbg.h"
Expand Down
1 change: 0 additions & 1 deletion samples/compdecomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
#include <sys/ioctl.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include "zlib.h"

/* Caller must free the allocated buffer
Expand Down
1 change: 0 additions & 1 deletion samples/compdecomp_th.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
#include <sys/ioctl.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <pthread.h>
#include "zlib.h"

Expand Down
18 changes: 0 additions & 18 deletions samples/gunzip_nx.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#include <sys/ioctl.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include "nxu.h"
#include "nx_dbg.h"
#include "nx_zlib.h"
Expand Down Expand Up @@ -85,15 +84,6 @@ const int line_sz = 1<<7;
const int window_max = 1<<15;
const int retry_max = 50;

void sigsegv_handler(int sig, siginfo_t *info, void *ctx)
{
fprintf(stderr, "%d: Got signal %d si_code %d, si_addr %p\n", getpid(),
sig, info->si_code, info->si_addr);

_nx_fault_storage_address = info->si_addr;
/* exit(0); */
}

__attribute__ ((unused))
static void nx_print_dde(nx_dde_t *ddep, const char *msg)
{
Expand Down Expand Up @@ -1198,21 +1188,13 @@ int decompress_file(int argc, char **argv, nx_devp_t devhandle)
int main(int argc, char **argv)
{
int rc;
struct sigaction act;
z_stream strm;
nx_streamp s;

strm.zalloc = (alloc_func) 0;
strm.zfree = (free_func) 0;
strm.opaque = (voidpf) 0;

act.sa_handler = 0;
act.sa_sigaction = sigsegv_handler;
act.sa_flags = SA_SIGINFO;
act.sa_restorer = 0;
sigemptyset(&act.sa_mask);
sigaction(SIGSEGV, &act, NULL);

if (nx_deflateInit(&strm, Z_DEFAULT_COMPRESSION) != Z_OK) {
fprintf(stderr, "Unable to init NX, errno %d\n", errno);
exit(-1);
Expand Down
18 changes: 0 additions & 18 deletions samples/gzip_nxdht.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
#include <sys/ioctl.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include "nxu.h"
#include "nx_dht.h"
#include "nx_dbg.h"
Expand Down Expand Up @@ -477,33 +476,16 @@ int compress_file(int argc, char **argv, nx_devp_t handle, void *dhthandle)
return 0;
}

void sigsegv_handler(int sig, siginfo_t *info, void *ctx)
{
fprintf(stderr, "%d: Got signal %d si_code %d, si_addr %p\n", getpid(),
sig, info->si_code, info->si_addr);

exit(-1);
nx_fault_storage_address = info->si_addr;
}

int main(int argc, char **argv)
{
int rc;
struct sigaction act;
z_stream strm;
nx_streamp s;

strm.zalloc = (alloc_func) 0;
strm.zfree = (free_func) 0;
strm.opaque = (voidpf) 0;

act.sa_handler = 0;
act.sa_sigaction = sigsegv_handler;
act.sa_flags = SA_SIGINFO;
act.sa_restorer = 0;
sigemptyset(&act.sa_mask);
sigaction(SIGSEGV, &act, NULL);

if (nx_deflateInit(&strm, Z_DEFAULT_COMPRESSION) != Z_OK) {
fprintf(stderr, "Unable to init NX, errno %d\n", errno);
exit(-1);
Expand Down
20 changes: 0 additions & 20 deletions samples/gzip_nxfht.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
#include <sys/ioctl.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <limits.h>
#include "nxu.h"
#include "nx_dbg.h"
Expand All @@ -78,8 +77,6 @@ struct _nx_time_dbg {
uint64_t fault;
} td;

void *nx_fault_storage_address;

#define SYSFS_GZIP_CAPS "/sys/devices/vio/ibm,compression-v1/nx_gzip_caps/"
static int nx_query_job_limits()
{
Expand Down Expand Up @@ -441,33 +438,16 @@ int compress_file(int argc, char **argv, nx_devp_t handle)
return 0;
}

void sigsegv_handler(int sig, siginfo_t *info, void *ctx)
{
fprintf(stderr, "%d: Got signal %d si_code %d, si_addr %p\n", getpid(),
sig, info->si_code, info->si_addr);

nx_fault_storage_address = info->si_addr;
}


int main(int argc, char **argv)
{
int rc;
struct sigaction act;
z_stream strm;
nx_streamp s;

strm.zalloc = (alloc_func) 0;
strm.zfree = (free_func) 0;
strm.opaque = (voidpf) 0;

act.sa_handler = 0;
act.sa_sigaction = sigsegv_handler;
act.sa_flags = SA_SIGINFO;
act.sa_restorer = 0;
sigemptyset(&act.sa_mask);
sigaction(SIGSEGV, &act, NULL);

if (nx_deflateInit(&strm, Z_DEFAULT_COMPRESSION) != Z_OK) {
fprintf(stderr, "Unable to init NX, errno %d\n", errno);
exit(-1);
Expand Down
29 changes: 0 additions & 29 deletions samples/nxlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
#include <sys/ioctl.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <stdarg.h>
#include "nxu.h"
#include "nx_dht.h"
Expand All @@ -84,10 +83,8 @@ typedef struct nxlite_handle_t {
#endif
#define NX_CHUNK_SZ (1<<18)

extern void *nx_fault_storage_address;
extern void *nx_function_begin(int function, int pri);
extern int nx_function_end(void *handle);
static void sigsegv_handler(int sig, siginfo_t *info, void *ctx);

static int compress_dht_sample(char *src, uint32_t srclen, char *dst,
uint32_t dstlen, int with_count,
Expand Down Expand Up @@ -449,7 +446,6 @@ void nxlite_end(void *nxhandle)
void *nxlite_begin()
{
int rc;
struct sigaction act;
nxlite_handle_t *h;

if (NULL == (h = malloc(sizeof(nxlite_handle_t)))) {
Expand All @@ -472,14 +468,6 @@ void *nxlite_begin()
return NULL;
}

/* use signals for catching CSB page faults */
act.sa_handler = 0;
act.sa_sigaction = sigsegv_handler;
act.sa_flags = SA_SIGINFO;
act.sa_restorer = 0;
sigemptyset(&act.sa_mask);
sigaction(SIGSEGV, &act, NULL);

return h;
}

Expand Down Expand Up @@ -692,15 +680,6 @@ static int nxlite_compress(char *dest, uint64_t *destLen,
return Z_OK;
}

static void sigsegv_handler(int sig, siginfo_t *info, void *ctx)
{
fprintf(stderr, "%d: Got signal %d si_code %d, si_addr %p\n", getpid(),
sig, info->si_code, info->si_addr);

nx_fault_storage_address = info->si_addr;
}


/*
Compresses the source buffer into the destination buffer. sourceLen
is the byte length of the source buffer. Upon entry, destLen is the
Expand Down Expand Up @@ -1448,16 +1427,8 @@ static int nxlite_uncompress(char *dest, uint64_t *destLen,
int main(int argc, char **argv)
{
int rc;
struct sigaction act;
void *handle;

act.sa_handler = 0;
act.sa_sigaction = sigsegv_handler;
act.sa_flags = SA_SIGINFO;
act.sa_restorer = 0;
sigemptyset(&act.sa_mask);
sigaction(SIGSEGV, &act, NULL);

handle = nx_function_begin( NX_FUNC_COMP_GZIP, 0);
if (!handle) {
fprintf( stderr, "Unable to init NX, errno %d\n", errno);
Expand Down
1 change: 0 additions & 1 deletion samples/openmultiple.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <sys/ioctl.h>
#include <endian.h>
#include <pthread.h>
#include <signal.h>
#include <dirent.h>

#include <sys/stat.h>
Expand Down
11 changes: 0 additions & 11 deletions samples/samples_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#define hwsync() asm volatile("sync" ::: "memory")

void *_nx_fault_storage_address;

static int _nx_wait_ticks(uint64_t accumulated_ticks)
{
uint64_t ts, te, mhz, us;
Expand Down Expand Up @@ -42,11 +40,6 @@ int _nx_wait_for_csb(nx_gzip_crb_cpb_t *cmdp)
if (t > (60 * onesecond)) /* 1 min */
break;

/* fault address from signal handler */
if (_nx_fault_storage_address) {
return -EAGAIN;
}

hwsync();
} while (getnn(cmdp->crb.csb, csb_v) == 0);

Expand Down Expand Up @@ -78,10 +71,6 @@ int _nxu_run_job(nx_gzip_crb_cpb_t *cmdp, nx_devp_t nxhandle)
ret = _nx_wait_for_csb( cmdp );

if (ret == -EAGAIN) {
volatile long x;
x = *(long *)_nx_fault_storage_address;
*(long *)_nx_fault_storage_address = x;
_nx_fault_storage_address = 0;
continue;
}
else
Expand Down
2 changes: 0 additions & 2 deletions samples/samples_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ typedef struct top_sym_t {

#define llns 0

extern void *_nx_fault_storage_address;

int _nxu_run_job(nx_gzip_crb_cpb_t *cmdp, void *handle);
int _nx_touch_pages(void *buf, long buf_len, long page_len, int wr);
int _nx_touch_pages_dde(nx_dde_t *ddep, long buf_sz, long page_sz, int wr);
Expand Down
16 changes: 0 additions & 16 deletions samples/simpleapi/gzip_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ __attribute__((constructor)) void nx_init(void)
nx_devices[ctr]->open_count = 0;
nx_devices[ctr]->chipId = ctr;
}

/* add a signal action */
sigact.sa_handler = 0;
sigact.sa_sigaction = sigsegv_handler;
sigact.sa_flags = SA_SIGINFO;
sigact.sa_restorer = 0;
sigemptyset(&sigact.sa_mask);
sigaction(SIGSEGV, &sigact, NULL);
}

__attribute__((destructor)) void nx_deinit(void)
Expand Down Expand Up @@ -254,14 +246,6 @@ int nx_append_dde(nx_dde_t *ddl, void *addr, uint32_t len)
return bytes;
}

void sigsegv_handler(int sig, siginfo_t *info, void *ctx)
{
fprintf(stderr, "%d: Got signal %d si_code %d, si_addr %p\n", getpid(),
sig, info->si_code, info->si_addr);
nx_fault_storage_address = info->si_addr;
// exit(0);
}

static void nx_print_dde(nx_dde_t *ddep, const char *msg)
{
uint32_t indirect_count;
Expand Down
4 changes: 0 additions & 4 deletions samples/simpleapi/gzip_simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <syscall.h>
#include <pthread.h>
#include "nx.h"
Expand All @@ -29,13 +28,10 @@ extern void *nx_function_begin(int function, int pri);
extern int nx_function_end(void *handle);

struct sigaction sigact;
void *nx_fault_storage_address;

void *nx_overflow_buffer;
p9_simple_handle_t *nx_devices[NX_MAX_DEVICES];

void sigsegv_handler(int sig, siginfo_t *info, void *ctx);

/*open the device*/
p9_simple_handle_t *p9open();

Expand Down
1 change: 0 additions & 1 deletion test/libnxz.abi
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
<typedef-decl name='__uint64_t' type-id='7359adad' id='8910171f'/>
<pointer-type-def type-id='48b5725f' size-in-bits='64' id='eaa32e2f'/>
<var-decl name='tb_freq' type-id='9c313c2d' visibility='default'/>
<var-decl name='nx_fault_storage_address' type-id='eaa32e2f' visibility='default'/>
</abi-instr>
<abi-instr address-size='64' path='nx_adler32.c' language='LANG_C11'>
<type-decl name='long int' size-in-bits='64' id='bd54fe1a'/>
Expand Down

0 comments on commit bbf1eaf

Please sign in to comment.