opnsense-src/sys/mips/mips
Adrian Chadd 5687a376df [mips] fix up the assembly generation of unaligned exception loads
I noticed that unaligned accesses were returning garbage values.

Give test data like this:

char testdata[] = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf1, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x5a };

Iterating through uint32_t space 1 byte at a time should
look like this:

freebsd-carambola2:/mnt# ./test
Hello, world!
offset 0 pointer 0x410b00 value 0x12345678 0x12345678
offset 1 pointer 0x410b01 value 0x3456789a 0x3456789a
offset 2 pointer 0x410b02 value 0x56789abc 0x56789abc
offset 3 pointer 0x410b03 value 0x789abcde 0x789abcde
offset 4 pointer 0x410b04 value 0x9abcdef1 0x9abcdef1
offset 5 pointer 0x410b05 value 0xbcdef123 0xbcdef123
offset 6 pointer 0x410b06 value 0xdef12345 0xdef12345
offset 7 pointer 0x410b07 value 0xf1234567 0xf1234567

.. but to begin with it looked like this:

offset 0 value 0x12345678
offset 1 value 0x00410a9a
offset 2 value 0x00419abc
offset 3 value 0x009abcde
offset 4 value 0x9abcdef1
offset 5 value 0x00410a23
offset 6 value 0x00412345
offset 7 value 0x00234567

The amusing reason? The compiler is generating the lwr/lwl incorrectly.
Here's an example after I tried to replace the two macros with a single
invocation and offset, rather than having the compiler compile in addiu
to s3 - but the bug is the same:

1044: 8a620003 lwl v0,0(s3)
1048: 9a730000 lwr s3,3(s3)

.. which is just totally trashy and wrong.

This explicitly tells the compiler to treat the output as being read
and written to, which is what lwl/lwr does with the destination
register.

I think a subsequent commit should unify these macros to skip an addiu,
but that can be a later commit.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D25040
2020-05-29 00:05:43 +00:00
..
autoconf.c sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
bcopy.S Make memmove an alias for memcpy 2018-05-24 21:11:24 +00:00
bus_space_generic.c Remove support for the now very old SiByte MIPS platform. It's not 2018-12-19 22:54:03 +00:00
busdma_machdep.c Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
cache.c sys/mips: further adoption of SPDX licensing ID tags. 2017-11-27 15:07:26 +00:00
cache_mipsNN.c sys/mips: further adoption of SPDX licensing ID tags. 2017-11-27 15:07:26 +00:00
cpu.c Print CPU informtion later in boot. 2020-05-20 21:16:54 +00:00
db_disasm.c spdx: initial adoption of licensing ID tags. 2017-11-18 14:26:50 +00:00
db_interface.c Remove mips MD atomic_load_64 and atomic_store_64. 2017-12-22 23:27:03 +00:00
db_trace.c sys/mips: further adoption of SPDX licensing ID tags. 2017-11-27 15:07:26 +00:00
dump_machdep.c sys/mips: further adoption of SPDX licensing ID tags. 2017-11-27 15:07:26 +00:00
elf_machdep.c [PowerPC][Book-E] Fix missing load base in elf_cpu_parse_dynamic(). 2020-03-18 02:58:18 +00:00
elf_trampoline.c Delete unneeded #include <sys/inflate.h> from sys/mips. 2019-05-23 05:17:18 +00:00
exception.S Rename assym.s to assym.inc 2018-03-20 17:58:51 +00:00
fp.S Rename assym.s to assym.inc 2018-03-20 17:58:51 +00:00
freebsd32_machdep.c Merge freebsd32_exec_setregs() into exec_setregs() on MIPS. 2020-05-20 19:51:39 +00:00
gdb_machdep.c sys/mips: further adoption of SPDX licensing ID tags. 2017-11-27 15:07:26 +00:00
genassym.c sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
in_cksum.c spdx: initial adoption of licensing ID tags. 2017-11-18 14:26:50 +00:00
inckern.S
intr_machdep.c follow-up to r336635, update TAILQ to CK_SLIST for ie_handlers 2018-07-23 15:36:55 +00:00
libkern_machdep.c sys/mips: further adoption of SPDX licensing ID tags. 2017-11-27 15:07:26 +00:00
locore.S Rename assym.s to assym.inc 2018-03-20 17:58:51 +00:00
machdep.c Print CPU informtion later in boot. 2020-05-20 21:16:54 +00:00
mem.c sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
minidump_machdep.c Display the approximate space needed when a minidump fails due to lack 2019-06-30 03:14:04 +00:00
mips_pic.c bhnd(4): implement MIPS and PCI(e) interrupt support 2017-11-21 23:15:20 +00:00
mp_machdep.c Eliminate kmem_malloc()'s unused arena parameter. (The arena parameter 2018-08-21 16:43:46 +00:00
mpboot.S Rename assym.s to assym.inc 2018-03-20 17:58:51 +00:00
nexus.c Preemptively map MIPS INTRNG interrupts on non-FDT MIPS targets 2017-11-21 01:54:48 +00:00
octeon_cop2.c sys/mips: further adoption of SPDX licensing ID tags. 2017-11-27 15:07:26 +00:00
octeon_cop2_swtch.S Rename assym.s to assym.inc 2018-03-20 17:58:51 +00:00
ofw_machdep.c Fix a copyright glitch before it gets copy-pasted again. I think this must 2016-04-07 18:19:09 +00:00
pm_machdep.c Merge freebsd32_exec_setregs() into exec_setregs() on MIPS. 2020-05-20 19:51:39 +00:00
pmap.c Fix a race in pmap_emulate_modified(). 2020-04-24 21:21:49 +00:00
ptrace_machdep.c Regularize my copyright notice 2019-12-04 16:56:11 +00:00
sc_machdep.c sc(4) md bits: stop setting sc->kbd entirely 2019-12-30 02:07:55 +00:00
stack_machdep.c Reimplement stack capture of running threads on i386 and amd64. 2020-01-31 15:43:33 +00:00
stdatomic.c In __sync_bool_compare_and_swap(), return true if the returned value is the 2018-03-23 17:25:19 +00:00
support.S copystr(9): Move to deprecate (attempt #2) 2020-05-25 16:40:48 +00:00
swtch.S Simplify hot-patching cpu_switch() for lack of UserLocal register. 2020-05-20 21:15:43 +00:00
sys_machdep.c spdx: initial adoption of licensing ID tags. 2017-11-18 14:26:50 +00:00
tick.c Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
tlb.c [mips] remove check that is always false (unsinged < 0) 2019-01-25 19:58:56 +00:00
trap.c [mips] fix up the assembly generation of unaligned exception loads 2020-05-29 00:05:43 +00:00
uio_machdep.c sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
uma_machdep.c vm_wait() rework. 2018-02-20 10:13:13 +00:00
vm_machdep.c Preserve the inherited value of the status register in cpu_set_upcall(). 2020-01-14 18:00:04 +00:00