1*b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */ 2d670bd4fSSam Ravnborg/* una_asm.S: Kernel unaligned trap assembler helpers. 3d670bd4fSSam Ravnborg * 4d670bd4fSSam Ravnborg * Copyright (C) 1996,2005,2008 David S. Miller (davem@davemloft.net) 5d670bd4fSSam Ravnborg * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 6d670bd4fSSam Ravnborg */ 7d670bd4fSSam Ravnborg 8d670bd4fSSam Ravnborg#include <linux/errno.h> 9d670bd4fSSam Ravnborg 10d670bd4fSSam Ravnborg .text 11d670bd4fSSam Ravnborg 12d670bd4fSSam Ravnborgretl_efault: 13d670bd4fSSam Ravnborg retl 14d670bd4fSSam Ravnborg mov -EFAULT, %o0 15d670bd4fSSam Ravnborg 16d670bd4fSSam Ravnborg /* int __do_int_store(unsigned long *dst_addr, int size, 17d670bd4fSSam Ravnborg * unsigned long *src_val) 18d670bd4fSSam Ravnborg * 19d670bd4fSSam Ravnborg * %o0 = dest_addr 20d670bd4fSSam Ravnborg * %o1 = size 21d670bd4fSSam Ravnborg * %o2 = src_val 22d670bd4fSSam Ravnborg * 23d670bd4fSSam Ravnborg * Return '0' on success, -EFAULT on failure. 24d670bd4fSSam Ravnborg */ 25d670bd4fSSam Ravnborg .globl __do_int_store 26d670bd4fSSam Ravnborg__do_int_store: 27d670bd4fSSam Ravnborg ld [%o2], %g1 282492218cSDaniel Hellstrom cmp %o1, 2 29d670bd4fSSam Ravnborg be 2f 302492218cSDaniel Hellstrom cmp %o1, 4 31d670bd4fSSam Ravnborg be 1f 32d670bd4fSSam Ravnborg srl %g1, 24, %g2 33d670bd4fSSam Ravnborg srl %g1, 16, %g7 34d670bd4fSSam Ravnborg4: stb %g2, [%o0] 35d670bd4fSSam Ravnborg srl %g1, 8, %g2 36d670bd4fSSam Ravnborg5: stb %g7, [%o0 + 1] 37d670bd4fSSam Ravnborg ld [%o2 + 4], %g7 38d670bd4fSSam Ravnborg6: stb %g2, [%o0 + 2] 39d670bd4fSSam Ravnborg srl %g7, 24, %g2 40d670bd4fSSam Ravnborg7: stb %g1, [%o0 + 3] 41d670bd4fSSam Ravnborg srl %g7, 16, %g1 42d670bd4fSSam Ravnborg8: stb %g2, [%o0 + 4] 43d670bd4fSSam Ravnborg srl %g7, 8, %g2 44d670bd4fSSam Ravnborg9: stb %g1, [%o0 + 5] 45d670bd4fSSam Ravnborg10: stb %g2, [%o0 + 6] 46d670bd4fSSam Ravnborg b 0f 47d670bd4fSSam Ravnborg11: stb %g7, [%o0 + 7] 48d670bd4fSSam Ravnborg1: srl %g1, 16, %g7 49d670bd4fSSam Ravnborg12: stb %g2, [%o0] 50d670bd4fSSam Ravnborg srl %g1, 8, %g2 51d670bd4fSSam Ravnborg13: stb %g7, [%o0 + 1] 52d670bd4fSSam Ravnborg14: stb %g2, [%o0 + 2] 53d670bd4fSSam Ravnborg b 0f 54d670bd4fSSam Ravnborg15: stb %g1, [%o0 + 3] 55d670bd4fSSam Ravnborg2: srl %g1, 8, %g2 56d670bd4fSSam Ravnborg16: stb %g2, [%o0] 57d670bd4fSSam Ravnborg17: stb %g1, [%o0 + 1] 58d670bd4fSSam Ravnborg0: retl 59d670bd4fSSam Ravnborg mov 0, %o0 60d670bd4fSSam Ravnborg 61d670bd4fSSam Ravnborg .section __ex_table,#alloc 62d670bd4fSSam Ravnborg .word 4b, retl_efault 63d670bd4fSSam Ravnborg .word 5b, retl_efault 64d670bd4fSSam Ravnborg .word 6b, retl_efault 65d670bd4fSSam Ravnborg .word 7b, retl_efault 66d670bd4fSSam Ravnborg .word 8b, retl_efault 67d670bd4fSSam Ravnborg .word 9b, retl_efault 68d670bd4fSSam Ravnborg .word 10b, retl_efault 69d670bd4fSSam Ravnborg .word 11b, retl_efault 70d670bd4fSSam Ravnborg .word 12b, retl_efault 71d670bd4fSSam Ravnborg .word 13b, retl_efault 72d670bd4fSSam Ravnborg .word 14b, retl_efault 73d670bd4fSSam Ravnborg .word 15b, retl_efault 74d670bd4fSSam Ravnborg .word 16b, retl_efault 75d670bd4fSSam Ravnborg .word 17b, retl_efault 76d670bd4fSSam Ravnborg .previous 77d670bd4fSSam Ravnborg 78d670bd4fSSam Ravnborg /* int do_int_load(unsigned long *dest_reg, int size, 79d670bd4fSSam Ravnborg * unsigned long *saddr, int is_signed) 80d670bd4fSSam Ravnborg * 81d670bd4fSSam Ravnborg * %o0 = dest_reg 82d670bd4fSSam Ravnborg * %o1 = size 83d670bd4fSSam Ravnborg * %o2 = saddr 84d670bd4fSSam Ravnborg * %o3 = is_signed 85d670bd4fSSam Ravnborg * 86d670bd4fSSam Ravnborg * Return '0' on success, -EFAULT on failure. 87d670bd4fSSam Ravnborg */ 88d670bd4fSSam Ravnborg .globl do_int_load 89d670bd4fSSam Ravnborgdo_int_load: 90d670bd4fSSam Ravnborg cmp %o1, 8 91d670bd4fSSam Ravnborg be 9f 92d670bd4fSSam Ravnborg cmp %o1, 4 93d670bd4fSSam Ravnborg be 6f 94d670bd4fSSam Ravnborg4: ldub [%o2], %g1 95d670bd4fSSam Ravnborg5: ldub [%o2 + 1], %g2 96d670bd4fSSam Ravnborg sll %g1, 8, %g1 97d670bd4fSSam Ravnborg tst %o3 98d670bd4fSSam Ravnborg be 3f 99d670bd4fSSam Ravnborg or %g1, %g2, %g1 100d670bd4fSSam Ravnborg sll %g1, 16, %g1 101d670bd4fSSam Ravnborg sra %g1, 16, %g1 102d670bd4fSSam Ravnborg3: b 0f 103d670bd4fSSam Ravnborg st %g1, [%o0] 104d670bd4fSSam Ravnborg6: ldub [%o2 + 1], %g2 105d670bd4fSSam Ravnborg sll %g1, 24, %g1 106d670bd4fSSam Ravnborg7: ldub [%o2 + 2], %g7 107d670bd4fSSam Ravnborg sll %g2, 16, %g2 108d670bd4fSSam Ravnborg8: ldub [%o2 + 3], %g3 109d670bd4fSSam Ravnborg sll %g7, 8, %g7 110d670bd4fSSam Ravnborg or %g3, %g2, %g3 111d670bd4fSSam Ravnborg or %g7, %g3, %g7 112d670bd4fSSam Ravnborg or %g1, %g7, %g1 113d670bd4fSSam Ravnborg b 0f 114d670bd4fSSam Ravnborg st %g1, [%o0] 115d670bd4fSSam Ravnborg9: ldub [%o2], %g1 116d670bd4fSSam Ravnborg10: ldub [%o2 + 1], %g2 117d670bd4fSSam Ravnborg sll %g1, 24, %g1 118d670bd4fSSam Ravnborg11: ldub [%o2 + 2], %g7 119d670bd4fSSam Ravnborg sll %g2, 16, %g2 120d670bd4fSSam Ravnborg12: ldub [%o2 + 3], %g3 121d670bd4fSSam Ravnborg sll %g7, 8, %g7 122d670bd4fSSam Ravnborg or %g1, %g2, %g1 123d670bd4fSSam Ravnborg or %g7, %g3, %g7 124d670bd4fSSam Ravnborg or %g1, %g7, %g7 125d670bd4fSSam Ravnborg13: ldub [%o2 + 4], %g1 126d670bd4fSSam Ravnborg st %g7, [%o0] 127d670bd4fSSam Ravnborg14: ldub [%o2 + 5], %g2 128d670bd4fSSam Ravnborg sll %g1, 24, %g1 129d670bd4fSSam Ravnborg15: ldub [%o2 + 6], %g7 130d670bd4fSSam Ravnborg sll %g2, 16, %g2 131d670bd4fSSam Ravnborg16: ldub [%o2 + 7], %g3 132d670bd4fSSam Ravnborg sll %g7, 8, %g7 133d670bd4fSSam Ravnborg or %g1, %g2, %g1 134d670bd4fSSam Ravnborg or %g7, %g3, %g7 135d670bd4fSSam Ravnborg or %g1, %g7, %g7 136d670bd4fSSam Ravnborg st %g7, [%o0 + 4] 137d670bd4fSSam Ravnborg0: retl 138d670bd4fSSam Ravnborg mov 0, %o0 139d670bd4fSSam Ravnborg 140d670bd4fSSam Ravnborg .section __ex_table,#alloc 141d670bd4fSSam Ravnborg .word 4b, retl_efault 142d670bd4fSSam Ravnborg .word 5b, retl_efault 143d670bd4fSSam Ravnborg .word 6b, retl_efault 144d670bd4fSSam Ravnborg .word 7b, retl_efault 145d670bd4fSSam Ravnborg .word 8b, retl_efault 146d670bd4fSSam Ravnborg .word 9b, retl_efault 147d670bd4fSSam Ravnborg .word 10b, retl_efault 148d670bd4fSSam Ravnborg .word 11b, retl_efault 149d670bd4fSSam Ravnborg .word 12b, retl_efault 150d670bd4fSSam Ravnborg .word 13b, retl_efault 151d670bd4fSSam Ravnborg .word 14b, retl_efault 152d670bd4fSSam Ravnborg .word 15b, retl_efault 153d670bd4fSSam Ravnborg .word 16b, retl_efault 154d670bd4fSSam Ravnborg .previous 155