Linux Audio

Check our new training course

Loading...
v4.10.11
  1/*
  2 * unaligned.c: Unaligned load/store trap handling with special
  3 *              cases for the kernel to do them more quickly.
  4 *
  5 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  6 * Copyright (C) 1996 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  7 */
  8
  9
 10#include <linux/kernel.h>
 11#include <linux/sched.h>
 12#include <linux/mm.h>
 
 13#include <asm/ptrace.h>
 14#include <asm/processor.h>
 15#include <linux/uaccess.h>
 
 16#include <linux/smp.h>
 17#include <linux/perf_event.h>
 18
 19#include <asm/setup.h>
 20
 21#include "kernel.h"
 22
 23enum direction {
 24	load,    /* ld, ldd, ldh, ldsh */
 25	store,   /* st, std, sth, stsh */
 26	both,    /* Swap, ldstub, etc. */
 27	fpload,
 28	fpstore,
 29	invalid,
 30};
 31
 32static inline enum direction decode_direction(unsigned int insn)
 33{
 34	unsigned long tmp = (insn >> 21) & 1;
 35
 36	if(!tmp)
 37		return load;
 38	else {
 39		if(((insn>>19)&0x3f) == 15)
 40			return both;
 41		else
 42			return store;
 43	}
 44}
 45
 46/* 8 = double-word, 4 = word, 2 = half-word */
 47static inline int decode_access_size(unsigned int insn)
 48{
 49	insn = (insn >> 19) & 3;
 50
 51	if(!insn)
 52		return 4;
 53	else if(insn == 3)
 54		return 8;
 55	else if(insn == 2)
 56		return 2;
 57	else {
 58		printk("Impossible unaligned trap. insn=%08x\n", insn);
 59		die_if_kernel("Byte sized unaligned access?!?!", current->thread.kregs);
 60		return 4; /* just to keep gcc happy. */
 61	}
 62}
 63
 64/* 0x400000 = signed, 0 = unsigned */
 65static inline int decode_signedness(unsigned int insn)
 66{
 67	return (insn & 0x400000);
 68}
 69
 70static inline void maybe_flush_windows(unsigned int rs1, unsigned int rs2,
 71				       unsigned int rd)
 72{
 73	if(rs2 >= 16 || rs1 >= 16 || rd >= 16) {
 74		/* Wheee... */
 75		__asm__ __volatile__("save %sp, -0x40, %sp\n\t"
 76				     "save %sp, -0x40, %sp\n\t"
 77				     "save %sp, -0x40, %sp\n\t"
 78				     "save %sp, -0x40, %sp\n\t"
 79				     "save %sp, -0x40, %sp\n\t"
 80				     "save %sp, -0x40, %sp\n\t"
 81				     "save %sp, -0x40, %sp\n\t"
 82				     "restore; restore; restore; restore;\n\t"
 83				     "restore; restore; restore;\n\t");
 84	}
 85}
 86
 87static inline int sign_extend_imm13(int imm)
 88{
 89	return imm << 19 >> 19;
 90}
 91
 92static inline unsigned long fetch_reg(unsigned int reg, struct pt_regs *regs)
 93{
 94	struct reg_window32 *win;
 95
 96	if(reg < 16)
 97		return (!reg ? 0 : regs->u_regs[reg]);
 98
 99	/* Ho hum, the slightly complicated case. */
100	win = (struct reg_window32 *) regs->u_regs[UREG_FP];
101	return win->locals[reg - 16]; /* yes, I know what this does... */
102}
103
104static inline unsigned long safe_fetch_reg(unsigned int reg, struct pt_regs *regs)
105{
106	struct reg_window32 __user *win;
107	unsigned long ret;
108
109	if (reg < 16)
110		return (!reg ? 0 : regs->u_regs[reg]);
111
112	/* Ho hum, the slightly complicated case. */
113	win = (struct reg_window32 __user *) regs->u_regs[UREG_FP];
114
115	if ((unsigned long)win & 3)
116		return -1;
117
118	if (get_user(ret, &win->locals[reg - 16]))
119		return -1;
120
121	return ret;
122}
123
124static inline unsigned long *fetch_reg_addr(unsigned int reg, struct pt_regs *regs)
125{
126	struct reg_window32 *win;
127
128	if(reg < 16)
129		return &regs->u_regs[reg];
130	win = (struct reg_window32 *) regs->u_regs[UREG_FP];
131	return &win->locals[reg - 16];
132}
133
134static unsigned long compute_effective_address(struct pt_regs *regs,
135					       unsigned int insn)
136{
137	unsigned int rs1 = (insn >> 14) & 0x1f;
138	unsigned int rs2 = insn & 0x1f;
139	unsigned int rd = (insn >> 25) & 0x1f;
140
141	if(insn & 0x2000) {
142		maybe_flush_windows(rs1, 0, rd);
143		return (fetch_reg(rs1, regs) + sign_extend_imm13(insn));
144	} else {
145		maybe_flush_windows(rs1, rs2, rd);
146		return (fetch_reg(rs1, regs) + fetch_reg(rs2, regs));
147	}
148}
149
150unsigned long safe_compute_effective_address(struct pt_regs *regs,
151					     unsigned int insn)
152{
153	unsigned int rs1 = (insn >> 14) & 0x1f;
154	unsigned int rs2 = insn & 0x1f;
155	unsigned int rd = (insn >> 25) & 0x1f;
156
157	if(insn & 0x2000) {
158		maybe_flush_windows(rs1, 0, rd);
159		return (safe_fetch_reg(rs1, regs) + sign_extend_imm13(insn));
160	} else {
161		maybe_flush_windows(rs1, rs2, rd);
162		return (safe_fetch_reg(rs1, regs) + safe_fetch_reg(rs2, regs));
163	}
164}
165
166/* This is just to make gcc think panic does return... */
167static void unaligned_panic(char *str)
168{
169	panic("%s", str);
170}
171
172/* una_asm.S */
173extern int do_int_load(unsigned long *dest_reg, int size,
174		       unsigned long *saddr, int is_signed);
175extern int __do_int_store(unsigned long *dst_addr, int size,
176			  unsigned long *src_val);
177
178static int do_int_store(int reg_num, int size, unsigned long *dst_addr,
179			struct pt_regs *regs)
180{
181	unsigned long zero[2] = { 0, 0 };
182	unsigned long *src_val;
183
184	if (reg_num)
185		src_val = fetch_reg_addr(reg_num, regs);
186	else {
187		src_val = &zero[0];
188		if (size == 8)
189			zero[1] = fetch_reg(1, regs);
190	}
191	return __do_int_store(dst_addr, size, src_val);
192}
193
194extern void smp_capture(void);
195extern void smp_release(void);
196
197static inline void advance(struct pt_regs *regs)
198{
199	regs->pc   = regs->npc;
200	regs->npc += 4;
201}
202
203static inline int floating_point_load_or_store_p(unsigned int insn)
204{
205	return (insn >> 24) & 1;
206}
207
208static inline int ok_for_kernel(unsigned int insn)
209{
210	return !floating_point_load_or_store_p(insn);
211}
212
213static void kernel_mna_trap_fault(struct pt_regs *regs, unsigned int insn)
214{
215	unsigned long g2 = regs->u_regs [UREG_G2];
216	unsigned long fixup = search_extables_range(regs->pc, &g2);
217
218	if (!fixup) {
219		unsigned long address = compute_effective_address(regs, insn);
220        	if(address < PAGE_SIZE) {
221                	printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference in mna handler");
222        	} else
223                	printk(KERN_ALERT "Unable to handle kernel paging request in mna handler");
224	        printk(KERN_ALERT " at virtual address %08lx\n",address);
225		printk(KERN_ALERT "current->{mm,active_mm}->context = %08lx\n",
226			(current->mm ? current->mm->context :
227			current->active_mm->context));
228		printk(KERN_ALERT "current->{mm,active_mm}->pgd = %08lx\n",
229			(current->mm ? (unsigned long) current->mm->pgd :
230			(unsigned long) current->active_mm->pgd));
231	        die_if_kernel("Oops", regs);
232		/* Not reached */
233	}
234	regs->pc = fixup;
235	regs->npc = regs->pc + 4;
236	regs->u_regs [UREG_G2] = g2;
237}
238
239asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn)
240{
241	enum direction dir = decode_direction(insn);
242	int size = decode_access_size(insn);
243
244	if(!ok_for_kernel(insn) || dir == both) {
245		printk("Unsupported unaligned load/store trap for kernel at <%08lx>.\n",
246		       regs->pc);
247		unaligned_panic("Wheee. Kernel does fpu/atomic unaligned load/store.");
248	} else {
249		unsigned long addr = compute_effective_address(regs, insn);
250		int err;
251
252		perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr);
253		switch (dir) {
254		case load:
255			err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f),
256							 regs),
257					  size, (unsigned long *) addr,
258					  decode_signedness(insn));
259			break;
260
261		case store:
262			err = do_int_store(((insn>>25)&0x1f), size,
263					   (unsigned long *) addr, regs);
264			break;
265		default:
266			panic("Impossible kernel unaligned trap.");
267			/* Not reached... */
268		}
269		if (err)
270			kernel_mna_trap_fault(regs, insn);
271		else
272			advance(regs);
273	}
274}
275
276static inline int ok_for_user(struct pt_regs *regs, unsigned int insn,
277			      enum direction dir)
278{
279	unsigned int reg;
280	int check = (dir == load) ? VERIFY_READ : VERIFY_WRITE;
281	int size = ((insn >> 19) & 3) == 3 ? 8 : 4;
282
283	if ((regs->pc | regs->npc) & 3)
284		return 0;
285
286	/* Must access_ok() in all the necessary places. */
287#define WINREG_ADDR(regnum) \
288	((void __user *)(((unsigned long *)regs->u_regs[UREG_FP])+(regnum)))
289
290	reg = (insn >> 25) & 0x1f;
291	if (reg >= 16) {
292		if (!access_ok(check, WINREG_ADDR(reg - 16), size))
293			return -EFAULT;
294	}
295	reg = (insn >> 14) & 0x1f;
296	if (reg >= 16) {
297		if (!access_ok(check, WINREG_ADDR(reg - 16), size))
298			return -EFAULT;
299	}
300	if (!(insn & 0x2000)) {
301		reg = (insn & 0x1f);
302		if (reg >= 16) {
303			if (!access_ok(check, WINREG_ADDR(reg - 16), size))
304				return -EFAULT;
305		}
306	}
307#undef WINREG_ADDR
308	return 0;
309}
310
311static void user_mna_trap_fault(struct pt_regs *regs, unsigned int insn)
312{
313	siginfo_t info;
314
315	info.si_signo = SIGBUS;
316	info.si_errno = 0;
317	info.si_code = BUS_ADRALN;
318	info.si_addr = (void __user *)safe_compute_effective_address(regs, insn);
319	info.si_trapno = 0;
320	send_sig_info(SIGBUS, &info, current);
321}
322
323asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn)
324{
325	enum direction dir;
326
327	if(!(current->thread.flags & SPARC_FLAG_UNALIGNED) ||
328	   (((insn >> 30) & 3) != 3))
329		goto kill_user;
330	dir = decode_direction(insn);
331	if(!ok_for_user(regs, insn, dir)) {
332		goto kill_user;
333	} else {
334		int err, size = decode_access_size(insn);
335		unsigned long addr;
336
337		if(floating_point_load_or_store_p(insn)) {
338			printk("User FPU load/store unaligned unsupported.\n");
339			goto kill_user;
340		}
341
342		addr = compute_effective_address(regs, insn);
343		perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr);
344		switch(dir) {
345		case load:
346			err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f),
347							 regs),
348					  size, (unsigned long *) addr,
349					  decode_signedness(insn));
350			break;
351
352		case store:
353			err = do_int_store(((insn>>25)&0x1f), size,
354					   (unsigned long *) addr, regs);
355			break;
356
357		case both:
358			/*
359			 * This was supported in 2.4. However, we question
360			 * the value of SWAP instruction across word boundaries.
361			 */
362			printk("Unaligned SWAP unsupported.\n");
363			err = -EFAULT;
364			break;
365
366		default:
367			unaligned_panic("Impossible user unaligned trap.");
368			goto out;
369		}
370		if (err)
371			goto kill_user;
372		else
373			advance(regs);
374		goto out;
375	}
376
377kill_user:
378	user_mna_trap_fault(regs, insn);
379out:
380	;
381}
v3.1
  1/*
  2 * unaligned.c: Unaligned load/store trap handling with special
  3 *              cases for the kernel to do them more quickly.
  4 *
  5 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  6 * Copyright (C) 1996 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  7 */
  8
  9
 10#include <linux/kernel.h>
 11#include <linux/sched.h>
 12#include <linux/mm.h>
 13#include <linux/module.h>
 14#include <asm/ptrace.h>
 15#include <asm/processor.h>
 16#include <asm/system.h>
 17#include <asm/uaccess.h>
 18#include <linux/smp.h>
 19#include <linux/perf_event.h>
 20
 
 
 
 
 21enum direction {
 22	load,    /* ld, ldd, ldh, ldsh */
 23	store,   /* st, std, sth, stsh */
 24	both,    /* Swap, ldstub, etc. */
 25	fpload,
 26	fpstore,
 27	invalid,
 28};
 29
 30static inline enum direction decode_direction(unsigned int insn)
 31{
 32	unsigned long tmp = (insn >> 21) & 1;
 33
 34	if(!tmp)
 35		return load;
 36	else {
 37		if(((insn>>19)&0x3f) == 15)
 38			return both;
 39		else
 40			return store;
 41	}
 42}
 43
 44/* 8 = double-word, 4 = word, 2 = half-word */
 45static inline int decode_access_size(unsigned int insn)
 46{
 47	insn = (insn >> 19) & 3;
 48
 49	if(!insn)
 50		return 4;
 51	else if(insn == 3)
 52		return 8;
 53	else if(insn == 2)
 54		return 2;
 55	else {
 56		printk("Impossible unaligned trap. insn=%08x\n", insn);
 57		die_if_kernel("Byte sized unaligned access?!?!", current->thread.kregs);
 58		return 4; /* just to keep gcc happy. */
 59	}
 60}
 61
 62/* 0x400000 = signed, 0 = unsigned */
 63static inline int decode_signedness(unsigned int insn)
 64{
 65	return (insn & 0x400000);
 66}
 67
 68static inline void maybe_flush_windows(unsigned int rs1, unsigned int rs2,
 69				       unsigned int rd)
 70{
 71	if(rs2 >= 16 || rs1 >= 16 || rd >= 16) {
 72		/* Wheee... */
 73		__asm__ __volatile__("save %sp, -0x40, %sp\n\t"
 74				     "save %sp, -0x40, %sp\n\t"
 75				     "save %sp, -0x40, %sp\n\t"
 76				     "save %sp, -0x40, %sp\n\t"
 77				     "save %sp, -0x40, %sp\n\t"
 78				     "save %sp, -0x40, %sp\n\t"
 79				     "save %sp, -0x40, %sp\n\t"
 80				     "restore; restore; restore; restore;\n\t"
 81				     "restore; restore; restore;\n\t");
 82	}
 83}
 84
 85static inline int sign_extend_imm13(int imm)
 86{
 87	return imm << 19 >> 19;
 88}
 89
 90static inline unsigned long fetch_reg(unsigned int reg, struct pt_regs *regs)
 91{
 92	struct reg_window32 *win;
 93
 94	if(reg < 16)
 95		return (!reg ? 0 : regs->u_regs[reg]);
 96
 97	/* Ho hum, the slightly complicated case. */
 98	win = (struct reg_window32 *) regs->u_regs[UREG_FP];
 99	return win->locals[reg - 16]; /* yes, I know what this does... */
100}
101
102static inline unsigned long safe_fetch_reg(unsigned int reg, struct pt_regs *regs)
103{
104	struct reg_window32 __user *win;
105	unsigned long ret;
106
107	if (reg < 16)
108		return (!reg ? 0 : regs->u_regs[reg]);
109
110	/* Ho hum, the slightly complicated case. */
111	win = (struct reg_window32 __user *) regs->u_regs[UREG_FP];
112
113	if ((unsigned long)win & 3)
114		return -1;
115
116	if (get_user(ret, &win->locals[reg - 16]))
117		return -1;
118
119	return ret;
120}
121
122static inline unsigned long *fetch_reg_addr(unsigned int reg, struct pt_regs *regs)
123{
124	struct reg_window32 *win;
125
126	if(reg < 16)
127		return &regs->u_regs[reg];
128	win = (struct reg_window32 *) regs->u_regs[UREG_FP];
129	return &win->locals[reg - 16];
130}
131
132static unsigned long compute_effective_address(struct pt_regs *regs,
133					       unsigned int insn)
134{
135	unsigned int rs1 = (insn >> 14) & 0x1f;
136	unsigned int rs2 = insn & 0x1f;
137	unsigned int rd = (insn >> 25) & 0x1f;
138
139	if(insn & 0x2000) {
140		maybe_flush_windows(rs1, 0, rd);
141		return (fetch_reg(rs1, regs) + sign_extend_imm13(insn));
142	} else {
143		maybe_flush_windows(rs1, rs2, rd);
144		return (fetch_reg(rs1, regs) + fetch_reg(rs2, regs));
145	}
146}
147
148unsigned long safe_compute_effective_address(struct pt_regs *regs,
149					     unsigned int insn)
150{
151	unsigned int rs1 = (insn >> 14) & 0x1f;
152	unsigned int rs2 = insn & 0x1f;
153	unsigned int rd = (insn >> 25) & 0x1f;
154
155	if(insn & 0x2000) {
156		maybe_flush_windows(rs1, 0, rd);
157		return (safe_fetch_reg(rs1, regs) + sign_extend_imm13(insn));
158	} else {
159		maybe_flush_windows(rs1, rs2, rd);
160		return (safe_fetch_reg(rs1, regs) + safe_fetch_reg(rs2, regs));
161	}
162}
163
164/* This is just to make gcc think panic does return... */
165static void unaligned_panic(char *str)
166{
167	panic(str);
168}
169
170/* una_asm.S */
171extern int do_int_load(unsigned long *dest_reg, int size,
172		       unsigned long *saddr, int is_signed);
173extern int __do_int_store(unsigned long *dst_addr, int size,
174			  unsigned long *src_val);
175
176static int do_int_store(int reg_num, int size, unsigned long *dst_addr,
177			struct pt_regs *regs)
178{
179	unsigned long zero[2] = { 0, 0 };
180	unsigned long *src_val;
181
182	if (reg_num)
183		src_val = fetch_reg_addr(reg_num, regs);
184	else {
185		src_val = &zero[0];
186		if (size == 8)
187			zero[1] = fetch_reg(1, regs);
188	}
189	return __do_int_store(dst_addr, size, src_val);
190}
191
192extern void smp_capture(void);
193extern void smp_release(void);
194
195static inline void advance(struct pt_regs *regs)
196{
197	regs->pc   = regs->npc;
198	regs->npc += 4;
199}
200
201static inline int floating_point_load_or_store_p(unsigned int insn)
202{
203	return (insn >> 24) & 1;
204}
205
206static inline int ok_for_kernel(unsigned int insn)
207{
208	return !floating_point_load_or_store_p(insn);
209}
210
211static void kernel_mna_trap_fault(struct pt_regs *regs, unsigned int insn)
212{
213	unsigned long g2 = regs->u_regs [UREG_G2];
214	unsigned long fixup = search_extables_range(regs->pc, &g2);
215
216	if (!fixup) {
217		unsigned long address = compute_effective_address(regs, insn);
218        	if(address < PAGE_SIZE) {
219                	printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference in mna handler");
220        	} else
221                	printk(KERN_ALERT "Unable to handle kernel paging request in mna handler");
222	        printk(KERN_ALERT " at virtual address %08lx\n",address);
223		printk(KERN_ALERT "current->{mm,active_mm}->context = %08lx\n",
224			(current->mm ? current->mm->context :
225			current->active_mm->context));
226		printk(KERN_ALERT "current->{mm,active_mm}->pgd = %08lx\n",
227			(current->mm ? (unsigned long) current->mm->pgd :
228			(unsigned long) current->active_mm->pgd));
229	        die_if_kernel("Oops", regs);
230		/* Not reached */
231	}
232	regs->pc = fixup;
233	regs->npc = regs->pc + 4;
234	regs->u_regs [UREG_G2] = g2;
235}
236
237asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn)
238{
239	enum direction dir = decode_direction(insn);
240	int size = decode_access_size(insn);
241
242	if(!ok_for_kernel(insn) || dir == both) {
243		printk("Unsupported unaligned load/store trap for kernel at <%08lx>.\n",
244		       regs->pc);
245		unaligned_panic("Wheee. Kernel does fpu/atomic unaligned load/store.");
246	} else {
247		unsigned long addr = compute_effective_address(regs, insn);
248		int err;
249
250		perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr);
251		switch (dir) {
252		case load:
253			err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f),
254							 regs),
255					  size, (unsigned long *) addr,
256					  decode_signedness(insn));
257			break;
258
259		case store:
260			err = do_int_store(((insn>>25)&0x1f), size,
261					   (unsigned long *) addr, regs);
262			break;
263		default:
264			panic("Impossible kernel unaligned trap.");
265			/* Not reached... */
266		}
267		if (err)
268			kernel_mna_trap_fault(regs, insn);
269		else
270			advance(regs);
271	}
272}
273
274static inline int ok_for_user(struct pt_regs *regs, unsigned int insn,
275			      enum direction dir)
276{
277	unsigned int reg;
278	int check = (dir == load) ? VERIFY_READ : VERIFY_WRITE;
279	int size = ((insn >> 19) & 3) == 3 ? 8 : 4;
280
281	if ((regs->pc | regs->npc) & 3)
282		return 0;
283
284	/* Must access_ok() in all the necessary places. */
285#define WINREG_ADDR(regnum) \
286	((void __user *)(((unsigned long *)regs->u_regs[UREG_FP])+(regnum)))
287
288	reg = (insn >> 25) & 0x1f;
289	if (reg >= 16) {
290		if (!access_ok(check, WINREG_ADDR(reg - 16), size))
291			return -EFAULT;
292	}
293	reg = (insn >> 14) & 0x1f;
294	if (reg >= 16) {
295		if (!access_ok(check, WINREG_ADDR(reg - 16), size))
296			return -EFAULT;
297	}
298	if (!(insn & 0x2000)) {
299		reg = (insn & 0x1f);
300		if (reg >= 16) {
301			if (!access_ok(check, WINREG_ADDR(reg - 16), size))
302				return -EFAULT;
303		}
304	}
305#undef WINREG_ADDR
306	return 0;
307}
308
309static void user_mna_trap_fault(struct pt_regs *regs, unsigned int insn)
310{
311	siginfo_t info;
312
313	info.si_signo = SIGBUS;
314	info.si_errno = 0;
315	info.si_code = BUS_ADRALN;
316	info.si_addr = (void __user *)safe_compute_effective_address(regs, insn);
317	info.si_trapno = 0;
318	send_sig_info(SIGBUS, &info, current);
319}
320
321asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn)
322{
323	enum direction dir;
324
325	if(!(current->thread.flags & SPARC_FLAG_UNALIGNED) ||
326	   (((insn >> 30) & 3) != 3))
327		goto kill_user;
328	dir = decode_direction(insn);
329	if(!ok_for_user(regs, insn, dir)) {
330		goto kill_user;
331	} else {
332		int err, size = decode_access_size(insn);
333		unsigned long addr;
334
335		if(floating_point_load_or_store_p(insn)) {
336			printk("User FPU load/store unaligned unsupported.\n");
337			goto kill_user;
338		}
339
340		addr = compute_effective_address(regs, insn);
341		perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr);
342		switch(dir) {
343		case load:
344			err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f),
345							 regs),
346					  size, (unsigned long *) addr,
347					  decode_signedness(insn));
348			break;
349
350		case store:
351			err = do_int_store(((insn>>25)&0x1f), size,
352					   (unsigned long *) addr, regs);
353			break;
354
355		case both:
356			/*
357			 * This was supported in 2.4. However, we question
358			 * the value of SWAP instruction across word boundaries.
359			 */
360			printk("Unaligned SWAP unsupported.\n");
361			err = -EFAULT;
362			break;
363
364		default:
365			unaligned_panic("Impossible user unaligned trap.");
366			goto out;
367		}
368		if (err)
369			goto kill_user;
370		else
371			advance(regs);
372		goto out;
373	}
374
375kill_user:
376	user_mna_trap_fault(regs, insn);
377out:
378	;
379}