Date: Fri, 19 Jun 2020 16:26:43 +0000 (UTC) From: Michal Meloun <mmel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362388 - head/sys/arm64/arm64 Message-ID: <202006191626.05JGQhfY088473@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mmel Date: Fri Jun 19 16:26:42 2020 New Revision: 362388 URL: https://svnweb.freebsd.org/changeset/base/362388 Log: Use native-sized accesses when accessing memory from kdb. Not all MMIO mapped devices supports byte access. MFC after: 4 weeks Modified: head/sys/arm64/arm64/db_interface.c Modified: head/sys/arm64/arm64/db_interface.c ============================================================================== --- head/sys/arm64/arm64/db_interface.c Fri Jun 19 16:15:06 2020 (r362387) +++ head/sys/arm64/arm64/db_interface.c Fri Jun 19 16:26:42 2020 (r362388) @@ -118,12 +118,25 @@ db_read_bytes(vm_offset_t addr, size_t size, char *dat void *prev_jb; const char *src; int ret; + uint64_t tmp64; + uint32_t tmp32; + uint16_t tmp16; prev_jb = kdb_jmpbuf(jb); ret = setjmp(jb); if (ret == 0) { src = (const char *)addr; + if (size == 8 && (addr & 7) == 0) { + tmp64 = *((const int *)src); + src = (const char *)&tmp64; + } else if (size == 4 && (addr & 3) == 0) { + tmp32 = *((const int *)src); + src = (const char *)&tmp32; + } else if (size == 2 && (addr & 1) == 0) { + tmp16 = *((const short *)src); + src = (const char *)&tmp16; + } while (size-- > 0) *data++ = *src++; } @@ -142,14 +155,33 @@ db_write_bytes(vm_offset_t addr, size_t size, char *da void *prev_jb; char *dst; int ret; + uint64_t tmp64; + uint32_t tmp32; + uint16_t tmp16; prev_jb = kdb_jmpbuf(jb); ret = setjmp(jb); if (ret == 0) { - dst = (char *)addr; - while (size-- > 0) - *dst++ = *data++; - + if (size == 8 && (addr & 7) == 0) { + dst = (char *)&tmp64; + while (size-- > 0) + *dst++ = *data++; + *((uint64_t *)addr) = tmp64; + } else if (size == 4 && (addr & 3) == 0) { + dst = (char *)&tmp32; + while (size-- > 0) + *dst++ = *data++; + *((uint32_t *)addr) = tmp32; + } else if (size == 2 && (addr & 1) == 0) { + dst = (char *)&tmp16; + while (size-- > 0) + *dst++ = *data++; + *((uint32_t *)addr) = tmp16; + } else { + dst = (char *)addr; + while (size-- > 0) + *dst++ = *data++; + } dsb(ish); /* Clean D-cache and invalidate I-cache */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006191626.05JGQhfY088473>