traps.c 16.8 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2 3
/*
 * Architecture-specific trap handling.
 *
David Mosberger's avatar
David Mosberger committed
4
 * Copyright (C) 1998-2002 Hewlett-Packard Co
Linus Torvalds's avatar
Linus Torvalds committed
5
 *	David Mosberger-Tang <davidm@hpl.hp.com>
Linus Torvalds's avatar
Linus Torvalds committed
6 7 8 9 10
 *
 * 05/12/00 grao <goutham.rao@intel.com> : added isr in siginfo for SIGFPE
 */

/*
Linus Torvalds's avatar
Linus Torvalds committed
11 12 13 14 15 16
 * fp_emulate() needs to be able to access and update all floating point registers.  Those
 * saved in pt_regs can be accessed through that structure, but those not saved, will be
 * accessed directly.  To make this work, we need to ensure that the compiler does not end
 * up using a preserved floating point register on its own.  The following achieves this
 * by declaring preserved registers that are not marked as "fixed" as global register
 * variables.
Linus Torvalds's avatar
Linus Torvalds committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
 */
register double f2 asm ("f2"); register double f3 asm ("f3");
register double f4 asm ("f4"); register double f5 asm ("f5");

register long f16 asm ("f16"); register long f17 asm ("f17");
register long f18 asm ("f18"); register long f19 asm ("f19");
register long f20 asm ("f20"); register long f21 asm ("f21");
register long f22 asm ("f22"); register long f23 asm ("f23");

register double f24 asm ("f24"); register double f25 asm ("f25");
register double f26 asm ("f26"); register double f27 asm ("f27");
register double f28 asm ("f28"); register double f29 asm ("f29");
register double f30 asm ("f30"); register double f31 asm ("f31");

#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sched.h>
David Mosberger's avatar
David Mosberger committed
35
#include <linux/tty.h>
Linus Torvalds's avatar
Linus Torvalds committed
36
#include <linux/vt_kern.h>		/* For unblank_screen() */
Linus Torvalds's avatar
Linus Torvalds committed
37

Linus Torvalds's avatar
Linus Torvalds committed
38
#include <asm/hardirq.h>
Linus Torvalds's avatar
Linus Torvalds committed
39 40 41 42 43 44
#include <asm/ia32.h>
#include <asm/processor.h>
#include <asm/uaccess.h>

#include <asm/fpswa.h>

Linus Torvalds's avatar
Linus Torvalds committed
45 46
extern spinlock_t timerlist_lock;

Linus Torvalds's avatar
Linus Torvalds committed
47 48 49 50 51
static fpswa_interface_t *fpswa_interface;

void __init
trap_init (void)
{
52 53 54
	int major = 0, minor = 0;

	if (ia64_boot_param->fpswa) {
Linus Torvalds's avatar
Linus Torvalds committed
55
		/* FPSWA fixup: make the interface pointer a kernel virtual address: */
Linus Torvalds's avatar
Linus Torvalds committed
56
		fpswa_interface = __va(ia64_boot_param->fpswa);
57 58
		major = fpswa_interface->revision >> 16;
		minor = fpswa_interface->revision & 0xffff;
59 60
	}
	printk("fpswa interface at %lx (rev %d.%d)\n", ia64_boot_param->fpswa, major, minor);
Linus Torvalds's avatar
Linus Torvalds committed
61 62
}

Linus Torvalds's avatar
Linus Torvalds committed
63 64 65 66
/*
 * Unlock any spinlocks which will prevent us from getting the message out (timerlist_lock
 * is acquired through the console unblank code)
 */
Linus Torvalds's avatar
Linus Torvalds committed
67
void
Linus Torvalds's avatar
Linus Torvalds committed
68
bust_spinlocks (int yes)
Linus Torvalds's avatar
Linus Torvalds committed
69
{
70 71
	int loglevel_save = console_loglevel;

Linus Torvalds's avatar
Linus Torvalds committed
72 73 74
	spin_lock_init(&timerlist_lock);
	if (yes) {
		oops_in_progress = 1;
75 76 77
		return;
	}

Linus Torvalds's avatar
Linus Torvalds committed
78
#ifdef CONFIG_VT
79
	unblank_screen();
Linus Torvalds's avatar
Linus Torvalds committed
80
#endif
81 82 83 84 85 86 87 88 89
	oops_in_progress = 0;
	/*
	 * OK, the message is on the console.  Now we call printk() without
	 * oops_in_progress set so that printk will give klogd a poke.  Hold onto
	 * your hats...
	 */
	console_loglevel = 15;		/* NMI oopser may have shut the console up */
	printk(" ");
	console_loglevel = loglevel_save;
Linus Torvalds's avatar
Linus Torvalds committed
90
}
Linus Torvalds's avatar
Linus Torvalds committed
91

Linus Torvalds's avatar
Linus Torvalds committed
92 93 94 95 96 97 98 99
void
die (const char *str, struct pt_regs *regs, long err)
{
	static struct {
		spinlock_t lock;
		int lock_owner;
		int lock_owner_depth;
	} die = {
100
		.lock =			SPIN_LOCK_UNLOCKED,
101 102
		.lock_owner =		-1,
		.lock_owner_depth =	0
Linus Torvalds's avatar
Linus Torvalds committed
103
	};
Linus Torvalds's avatar
Linus Torvalds committed
104

Linus Torvalds's avatar
Linus Torvalds committed
105 106 107 108 109 110
	if (die.lock_owner != smp_processor_id()) {
		console_verbose();
		spin_lock_irq(&die.lock);
		die.lock_owner = smp_processor_id();
		die.lock_owner_depth = 0;
		bust_spinlocks(1);
Linus Torvalds's avatar
Linus Torvalds committed
111
	}
Linus Torvalds's avatar
Linus Torvalds committed
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129

	if (++die.lock_owner_depth < 3) {
		printk("%s[%d]: %s %ld\n", current->comm, current->pid, str, err);
		show_regs(regs);
  	} else
		printk(KERN_ERR "Recursive die() failure, output suppressed\n");

	bust_spinlocks(0);
	die.lock_owner = -1;
	spin_unlock_irq(&die.lock);
  	do_exit(SIGSEGV);
}

void
die_if_kernel (char *str, struct pt_regs *regs, long err)
{
	if (!user_mode(regs))
		die(str, regs, err);
Linus Torvalds's avatar
Linus Torvalds committed
130 131 132 133 134 135 136 137 138 139 140
}

void
ia64_bad_break (unsigned long break_num, struct pt_regs *regs)
{
	siginfo_t siginfo;
	int sig, code;

	/* SIGILL, SIGFPE, SIGSEGV, and SIGBUS want these field initialized: */
	siginfo.si_addr = (void *) (regs->cr_iip + ia64_psr(regs)->ri);
	siginfo.si_imm = break_num;
David Mosberger's avatar
David Mosberger committed
141 142
	siginfo.si_flags = 0;		/* clear __ISR_VALID */
	siginfo.si_isr = 0;
Linus Torvalds's avatar
Linus Torvalds committed
143 144

	switch (break_num) {
145 146
	      case 0: /* unknown error (used by GCC for __builtin_abort()) */
		die_if_kernel("bad break", regs, break_num);
Linus Torvalds's avatar
Linus Torvalds committed
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
		sig = SIGILL; code = ILL_ILLOPC;
		break;

	      case 1: /* integer divide by zero */
		sig = SIGFPE; code = FPE_INTDIV;
		break;

	      case 2: /* integer overflow */
		sig = SIGFPE; code = FPE_INTOVF;
		break;

	      case 3: /* range check/bounds check */
		sig = SIGFPE; code = FPE_FLTSUB;
		break;

	      case 4: /* null pointer dereference */
		sig = SIGSEGV; code = SEGV_MAPERR;
		break;

	      case 5: /* misaligned data */
		sig = SIGSEGV; code = BUS_ADRALN;
		break;

	      case 6: /* decimal overflow */
		sig = SIGFPE; code = __FPE_DECOVF;
		break;

	      case 7: /* decimal divide by zero */
		sig = SIGFPE; code = __FPE_DECDIV;
		break;

	      case 8: /* packed decimal error */
		sig = SIGFPE; code = __FPE_DECERR;
		break;

	      case 9: /* invalid ASCII digit */
		sig = SIGFPE; code = __FPE_INVASC;
		break;

	      case 10: /* invalid decimal digit */
		sig = SIGFPE; code = __FPE_INVDEC;
		break;

	      case 11: /* paragraph stack overflow */
		sig = SIGSEGV; code = __SEGV_PSTKOVF;
		break;

194 195 196 197
	      case 0x3f000 ... 0x3ffff:	/* bundle-update in progress */
		sig = SIGILL; code = __ILL_BNDMOD;
		break;

Linus Torvalds's avatar
Linus Torvalds committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
	      default:
		if (break_num < 0x40000 || break_num > 0x100000)
			die_if_kernel("Bad break", regs, break_num);

		if (break_num < 0x80000) {
			sig = SIGILL; code = __ILL_BREAK;
		} else {
			sig = SIGTRAP; code = TRAP_BRKPT;
		}
	}
	siginfo.si_signo = sig;
	siginfo.si_errno = 0;
	siginfo.si_code = code;
	force_sig_info(sig, &siginfo, current);
}

/*
 * Unimplemented system calls.  This is called only for stuff that
 * we're supposed to implement but haven't done so yet.  Everything
 * else goes to sys_ni_syscall.
 */
asmlinkage long
ia64_ni_syscall (unsigned long arg0, unsigned long arg1, unsigned long arg2, unsigned long arg3,
		 unsigned long arg4, unsigned long arg5, unsigned long arg6, unsigned long arg7,
		 unsigned long stack)
{
	struct pt_regs *regs = (struct pt_regs *) &stack;

226 227
	printk("%s(%d): <sc%ld(%lx,%lx,%lx,%lx)>\n", current->comm, current->pid,
	       regs->r15, arg0, arg1, arg2, arg3);
Linus Torvalds's avatar
Linus Torvalds committed
228 229 230 231
	return -ENOSYS;
}

/*
Linus Torvalds's avatar
Linus Torvalds committed
232 233 234 235 236 237
 * disabled_fph_fault() is called when a user-level process attempts to access f32..f127
 * and it doesn't own the fp-high register partition.  When this happens, we save the
 * current fph partition in the task_struct of the fpu-owner (if necessary) and then load
 * the fp-high partition of the current task (if necessary).  Note that the kernel has
 * access to fph by the time we get here, as the IVT's "Disabled FP-Register" handler takes
 * care of clearing psr.dfh.
Linus Torvalds's avatar
Linus Torvalds committed
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
 */
static inline void
disabled_fph_fault (struct pt_regs *regs)
{
	struct ia64_psr *psr = ia64_psr(regs);

	/* first, grant user-level access to fph partition: */
	psr->dfh = 0;
#ifndef CONFIG_SMP
	{
		struct task_struct *fpu_owner = ia64_get_fpu_owner();

		if (fpu_owner == current)
			return;

		if (fpu_owner)
			ia64_flush_fph(fpu_owner);
	}
#endif /* !CONFIG_SMP */
257
	ia64_set_fpu_owner(current);
Linus Torvalds's avatar
Linus Torvalds committed
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
	if ((current->thread.flags & IA64_THREAD_FPH_VALID) != 0) {
		__ia64_load_fpu(current->thread.fph);
		psr->mfh = 0;
	} else {
		__ia64_init_fpu();
		/*
		 * Set mfh because the state in thread.fph does not match the state in
		 * the fph partition.
		 */
		psr->mfh = 1;
	}
}

static inline int
fp_emulate (int fp_fault, void *bundle, long *ipsr, long *fpsr, long *isr, long *pr, long *ifs,
	    struct pt_regs *regs)
{
Linus Torvalds's avatar
Linus Torvalds committed
275
	struct ia64_fpreg f6_11[6];
Linus Torvalds's avatar
Linus Torvalds committed
276 277 278 279 280 281 282 283 284
	fp_state_t fp_state;
	fpswa_ret_t ret;

	if (!fpswa_interface)
		return -1;

	memset(&fp_state, 0, sizeof(fp_state_t));

	/*
Linus Torvalds's avatar
Linus Torvalds committed
285
	 * compute fp_state.  only FP registers f6 - f11 are used by the
Linus Torvalds's avatar
Linus Torvalds committed
286 287 288
	 * kernel, so set those bits in the mask and set the low volatile
	 * pointer to point to these registers.
	 */
Linus Torvalds's avatar
Linus Torvalds committed
289 290 291 292 293 294
	fp_state.bitmask_low64 = 0xfc0;  /* bit6..bit11 */
	f6_11[0] = regs->f6; f6_11[1] = regs->f7;
	f6_11[2] = regs->f8; f6_11[3] = regs->f9;
	__asm__ ("stf.spill %0=f10%P0" : "=m"(f6_11[4]));
	__asm__ ("stf.spill %0=f11%P0" : "=m"(f6_11[5]));
	fp_state.fp_state_low_volatile = (fp_state_low_volatile_t *) f6_11;
Linus Torvalds's avatar
Linus Torvalds committed
295
	/*
Linus Torvalds's avatar
Linus Torvalds committed
296 297 298 299 300 301 302 303 304 305 306 307 308 309
	 * unsigned long (*EFI_FPSWA) (
	 *      unsigned long    trap_type,
	 *	void             *Bundle,
	 *	unsigned long    *pipsr,
	 *	unsigned long    *pfsr,
	 *	unsigned long    *pisr,
	 *	unsigned long    *ppreds,
	 *	unsigned long    *pifs,
	 *	void             *fp_state);
	 */
	ret = (*fpswa_interface->fpswa)((unsigned long) fp_fault, bundle,
					(unsigned long *) ipsr, (unsigned long *) fpsr,
					(unsigned long *) isr, (unsigned long *) pr,
					(unsigned long *) ifs, &fp_state);
Linus Torvalds's avatar
Linus Torvalds committed
310 311 312 313
	regs->f6 = f6_11[0]; regs->f7 = f6_11[1];
	regs->f8 = f6_11[2]; regs->f9 = f6_11[3];
	__asm__ ("ldf.fill f10=%0%P0" :: "m"(f6_11[4]));
	__asm__ ("ldf.fill f11=%0%P0" :: "m"(f6_11[5]));
Linus Torvalds's avatar
Linus Torvalds committed
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
	return ret.status;
}

/*
 * Handle floating-point assist faults and traps.
 */
static int
handle_fpu_swa (int fp_fault, struct pt_regs *regs, unsigned long isr)
{
	long exception, bundle[2];
	unsigned long fault_ip;
	struct siginfo siginfo;
	static int fpu_swa_count = 0;
	static unsigned long last_time;

	fault_ip = regs->cr_iip;
	if (!fp_fault && (ia64_psr(regs)->ri == 0))
		fault_ip -= 16;
	if (copy_from_user(bundle, (void *) fault_ip, sizeof(bundle)))
		return -1;

Linus Torvalds's avatar
Linus Torvalds committed
335
	if (jiffies - last_time > 5*HZ)
Linus Torvalds's avatar
Linus Torvalds committed
336
		fpu_swa_count = 0;
Linus Torvalds's avatar
Linus Torvalds committed
337
	if ((++fpu_swa_count < 5) && !(current->thread.flags & IA64_THREAD_FPEMU_NOPRINT)) {
Linus Torvalds's avatar
Linus Torvalds committed
338
		last_time = jiffies;
Linus Torvalds's avatar
Linus Torvalds committed
339
		printk(KERN_WARNING "%s(%d): floating-point assist fault at ip %016lx\n",
Linus Torvalds's avatar
Linus Torvalds committed
340 341
		       current->comm, current->pid, regs->cr_iip + ia64_psr(regs)->ri);
	}
Linus Torvalds's avatar
Linus Torvalds committed
342

Linus Torvalds's avatar
Linus Torvalds committed
343
	exception = fp_emulate(fp_fault, bundle, &regs->cr_ipsr, &regs->ar_fpsr, &isr, &regs->pr,
Linus Torvalds's avatar
Linus Torvalds committed
344
			       &regs->cr_ifs, regs);
Linus Torvalds's avatar
Linus Torvalds committed
345 346 347
	if (fp_fault) {
		if (exception == 0) {
			/* emulation was successful */
Linus Torvalds's avatar
Linus Torvalds committed
348
			ia64_increment_ip(regs);
Linus Torvalds's avatar
Linus Torvalds committed
349 350 351 352 353 354 355 356 357 358
		} else if (exception == -1) {
			printk("handle_fpu_swa: fp_emulate() returned -1\n");
			return -1;
		} else {
			/* is next instruction a trap? */
			if (exception & 2) {
				ia64_increment_ip(regs);
			}
			siginfo.si_signo = SIGFPE;
			siginfo.si_errno = 0;
Linus Torvalds's avatar
Linus Torvalds committed
359
			siginfo.si_code = __SI_FAULT;	/* default code */
Linus Torvalds's avatar
Linus Torvalds committed
360 361 362 363 364 365 366
			siginfo.si_addr = (void *) (regs->cr_iip + ia64_psr(regs)->ri);
			if (isr & 0x11) {
				siginfo.si_code = FPE_FLTINV;
			} else if (isr & 0x44) {
				siginfo.si_code = FPE_FLTDIV;
			}
			siginfo.si_isr = isr;
David Mosberger's avatar
David Mosberger committed
367 368
			siginfo.si_flags = __ISR_VALID;
			siginfo.si_imm = 0;
Linus Torvalds's avatar
Linus Torvalds committed
369 370 371 372 373 374 375 376 377 378
			force_sig_info(SIGFPE, &siginfo, current);
		}
	} else {
		if (exception == -1) {
			printk("handle_fpu_swa: fp_emulate() returned -1\n");
			return -1;
		} else if (exception != 0) {
			/* raise exception */
			siginfo.si_signo = SIGFPE;
			siginfo.si_errno = 0;
Linus Torvalds's avatar
Linus Torvalds committed
379
			siginfo.si_code = __SI_FAULT;	/* default code */
Linus Torvalds's avatar
Linus Torvalds committed
380 381 382 383 384 385 386 387 388
			siginfo.si_addr = (void *) (regs->cr_iip + ia64_psr(regs)->ri);
			if (isr & 0x880) {
				siginfo.si_code = FPE_FLTOVF;
			} else if (isr & 0x1100) {
				siginfo.si_code = FPE_FLTUND;
			} else if (isr & 0x2200) {
				siginfo.si_code = FPE_FLTRES;
			}
			siginfo.si_isr = isr;
David Mosberger's avatar
David Mosberger committed
389 390
			siginfo.si_flags = __ISR_VALID;
			siginfo.si_imm = 0;
Linus Torvalds's avatar
Linus Torvalds committed
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
			force_sig_info(SIGFPE, &siginfo, current);
		}
	}
	return 0;
}

struct illegal_op_return {
	unsigned long fkt, arg1, arg2, arg3;
};

struct illegal_op_return
ia64_illegal_op_fault (unsigned long ec, unsigned long arg1, unsigned long arg2,
		       unsigned long arg3, unsigned long arg4, unsigned long arg5,
		       unsigned long arg6, unsigned long arg7, unsigned long stack)
{
	struct pt_regs *regs = (struct pt_regs *) &stack;
	struct illegal_op_return rv;
	struct siginfo si;
	char buf[128];

Linus Torvalds's avatar
Linus Torvalds committed
411
#ifdef CONFIG_IA64_BRL_EMU
Linus Torvalds's avatar
Linus Torvalds committed
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
	{
		extern struct illegal_op_return ia64_emulate_brl (struct pt_regs *, unsigned long);

		rv = ia64_emulate_brl(regs, ec);
		if (rv.fkt != (unsigned long) -1)
			return rv;
	}
#endif

	sprintf(buf, "IA-64 Illegal operation fault");
	die_if_kernel(buf, regs, 0);

	memset(&si, 0, sizeof(si));
	si.si_signo = SIGILL;
	si.si_code = ILL_ILLOPC;
	si.si_addr = (void *) (regs->cr_iip + ia64_psr(regs)->ri);
	force_sig_info(SIGILL, &si, current);
	rv.fkt = 0;
	return rv;
}

void
ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
	    unsigned long iim, unsigned long itir, unsigned long arg5,
	    unsigned long arg6, unsigned long arg7, unsigned long stack)
{
	struct pt_regs *regs = (struct pt_regs *) &stack;
	unsigned long code, error = isr;
	struct siginfo siginfo;
	char buf[128];
442
	int result, sig;
Linus Torvalds's avatar
Linus Torvalds committed
443 444 445 446 447 448 449
	static const char *reason[] = {
		"IA-64 Illegal Operation fault",
		"IA-64 Privileged Operation fault",
		"IA-64 Privileged Register fault",
		"IA-64 Reserved Register/Field fault",
		"Disabled Instruction Set Transition fault",
		"Unknown fault 5", "Unknown fault 6", "Unknown fault 7", "Illegal Hazard fault",
Linus Torvalds's avatar
Linus Torvalds committed
450
		"Unknown fault 9", "Unknown fault 10", "Unknown fault 11", "Unknown fault 12",
Linus Torvalds's avatar
Linus Torvalds committed
451 452 453
		"Unknown fault 13", "Unknown fault 14", "Unknown fault 15"
	};

454 455 456 457 458 459 460
	if ((isr & IA64_ISR_NA) && ((isr & IA64_ISR_CODE_MASK) == IA64_ISR_CODE_LFETCH)) {
		/*
		 * This fault was due to lfetch.fault, set "ed" bit in the psr to cancel
		 * the lfetch.
		 */
		ia64_psr(regs)->ed = 1;
		return;
Linus Torvalds's avatar
Linus Torvalds committed
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
	}

	switch (vector) {
	      case 24: /* General Exception */
		code = (isr >> 4) & 0xf;
		sprintf(buf, "General Exception: %s%s", reason[code],
			(code == 3) ? ((isr & (1UL << 37))
				       ? " (RSE access)" : " (data access)") : "");
		if (code == 8) {
# ifdef CONFIG_IA64_PRINT_HAZARDS
			printk("%016lx:possible hazard, pr = %016lx\n", regs->cr_iip, regs->pr);
# endif
			return;
		}
		break;

	      case 25: /* Disabled FP-Register */
		if (isr & 2) {
			disabled_fph_fault(regs);
			return;
		}
		sprintf(buf, "Disabled FPL fault---not supposed to happen!");
		break;

	      case 26: /* NaT Consumption */
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
		if (user_mode(regs)) {
			if (((isr >> 4) & 0xf) == 2) {
				/* NaT page consumption */
				sig = SIGSEGV;
				code = SEGV_ACCERR;
			} else {
				/* register NaT consumption */
				sig = SIGILL;
				code = ILL_ILLOPN;
			}
			siginfo.si_signo = sig;
			siginfo.si_code = code;
			siginfo.si_errno = 0;
			siginfo.si_addr = (void *) (regs->cr_iip + ia64_psr(regs)->ri);
			siginfo.si_imm = vector;
			siginfo.si_flags = __ISR_VALID;
			siginfo.si_isr = isr;
			force_sig_info(sig, &siginfo, current);
			return;
505 506
		} else if (done_with_exception(regs))
			return;
507 508 509
		sprintf(buf, "NaT consumption");
		break;

Linus Torvalds's avatar
Linus Torvalds committed
510 511 512 513 514 515 516
	      case 31: /* Unsupported Data Reference */
		if (user_mode(regs)) {
			siginfo.si_signo = SIGILL;
			siginfo.si_code = ILL_ILLOPN;
			siginfo.si_errno = 0;
			siginfo.si_addr = (void *) (regs->cr_iip + ia64_psr(regs)->ri);
			siginfo.si_imm = vector;
David Mosberger's avatar
David Mosberger committed
517 518
			siginfo.si_flags = __ISR_VALID;
			siginfo.si_isr = isr;
Linus Torvalds's avatar
Linus Torvalds committed
519 520 521
			force_sig_info(SIGILL, &siginfo, current);
			return;
		}
522
		sprintf(buf, "Unsupported data reference");
Linus Torvalds's avatar
Linus Torvalds committed
523 524 525 526 527 528
		break;

	      case 29: /* Debug */
	      case 35: /* Taken Branch Trap */
	      case 36: /* Single Step Trap */
		switch (vector) {
Linus Torvalds's avatar
Linus Torvalds committed
529
		      case 29:
Linus Torvalds's avatar
Linus Torvalds committed
530 531 532 533 534 535 536 537 538
			siginfo.si_code = TRAP_HWBKPT;
#ifdef CONFIG_ITANIUM
			/*
			 * Erratum 10 (IFA may contain incorrect address) now has
			 * "NoFix" status.  There are no plans for fixing this.
			 */
			if (ia64_psr(regs)->is == 0)
			  ifa = regs->cr_iip;
#endif
Linus Torvalds's avatar
Linus Torvalds committed
539
			break;
540 541
		      case 35: siginfo.si_code = TRAP_BRANCH; ifa = 0; break;
		      case 36: siginfo.si_code = TRAP_TRACE; ifa = 0; break;
Linus Torvalds's avatar
Linus Torvalds committed
542 543 544
		}
		siginfo.si_signo = SIGTRAP;
		siginfo.si_errno = 0;
David Mosberger's avatar
David Mosberger committed
545 546
		siginfo.si_flags = 0;
		siginfo.si_isr = 0;
547
		siginfo.si_addr = (void *) ifa;
David Mosberger's avatar
David Mosberger committed
548
		siginfo.si_imm = 0;
Linus Torvalds's avatar
Linus Torvalds committed
549 550 551 552 553 554
		force_sig_info(SIGTRAP, &siginfo, current);
		return;

	      case 32: /* fp fault */
	      case 33: /* fp trap */
		result = handle_fpu_swa((vector == 32) ? 1 : 0, regs, isr);
Linus Torvalds's avatar
Linus Torvalds committed
555
		if ((result < 0) || (current->thread.flags & IA64_THREAD_FPEMU_SIGFPE)) {
Linus Torvalds's avatar
Linus Torvalds committed
556 557 558 559
			siginfo.si_signo = SIGFPE;
			siginfo.si_errno = 0;
			siginfo.si_code = FPE_FLTINV;
			siginfo.si_addr = (void *) (regs->cr_iip + ia64_psr(regs)->ri);
David Mosberger's avatar
David Mosberger committed
560 561 562
			siginfo.si_flags = __ISR_VALID;
			siginfo.si_isr = isr;
			siginfo.si_imm = 0;
Linus Torvalds's avatar
Linus Torvalds committed
563
			force_sig_info(SIGFPE, &siginfo, current);
Linus Torvalds's avatar
Linus Torvalds committed
564 565 566 567 568 569 570 571
		}
		return;

	      case 34:		/* Unimplemented Instruction Address Trap */
		if (user_mode(regs)) {
			siginfo.si_signo = SIGILL;
			siginfo.si_code = ILL_BADIADDR;
			siginfo.si_errno = 0;
David Mosberger's avatar
David Mosberger committed
572 573 574
			siginfo.si_flags = 0;
			siginfo.si_isr = 0;
			siginfo.si_imm = 0;
Linus Torvalds's avatar
Linus Torvalds committed
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
			siginfo.si_addr = (void *) (regs->cr_iip + ia64_psr(regs)->ri);
			force_sig_info(SIGILL, &siginfo, current);
			return;
		}
		sprintf(buf, "Unimplemented Instruction Address fault");
		break;

	      case 45:
#ifdef CONFIG_IA32_SUPPORT
		if (ia32_exception(regs, isr) == 0)
			return;
#endif
		printk("Unexpected IA-32 exception (Trap 45)\n");
		printk("  iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx\n", regs->cr_iip, ifa, isr);
		force_sig(SIGSEGV, current);
		break;

	      case 46:
Linus Torvalds's avatar
Linus Torvalds committed
593 594 595 596
#ifdef CONFIG_IA32_SUPPORT
		if (ia32_intercept(regs, isr) == 0)
			return;
#endif
Linus Torvalds's avatar
Linus Torvalds committed
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613
		printk("Unexpected IA-32 intercept trap (Trap 46)\n");
		printk("  iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx, iim - 0x%lx\n",
		       regs->cr_iip, ifa, isr, iim);
		force_sig(SIGSEGV, current);
		return;

	      case 47:
		sprintf(buf, "IA-32 Interruption Fault (int 0x%lx)", isr >> 16);
		break;

	      default:
		sprintf(buf, "Fault %lu", vector);
		break;
	}
	die_if_kernel(buf, regs, error);
	force_sig(SIGILL, current);
}