Bug#698064: patch for ARAnyM in Wheezy
Good morning, patch fixing the problem in ARAnyM 0.9.13 (as reported by Thorsten) is attached. Also the misleading "documentation" (the ARAnyM proposal page in ARAnyM wiki) has been corrected. Thank you all, Petr Index: src/include/natfeats.h === RCS file: /var/repos/aranym/src/include/natfeats.h,v retrieving revision 1.8 retrieving revision 1.13 diff -u -r1.8 -r1.13 --- src/include/natfeats.h 29 Nov 2007 18:00:21 - 1.8 +++ src/include/natfeats.h 14 Jan 2013 19:32:32 - 1.13 @@ -1,3 +1,26 @@ +/* + * natfeats.h - common functions for all NatFeats + * + * Copyright (c) 2001-2013 Petr Stehlik of ARAnyM dev team (see AUTHORS) + * + * This file is part of the ARAnyM project which builds a new and powerful + * TOS/FreeMiNT compatible virtual machine running on almost any hardware. + * + * ARAnyM is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * ARAnyM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ARAnyM; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #ifndef _NATFEATS_H #define _NATFEATS_H @@ -14,6 +37,9 @@ // should NatFeats work with physical (not MMU mapped) addresses #define NATFEAT_PHYS_ADDR 1 +// should NatFeats use direct memcpy() to/from guest provided pointer (fast but less safe) +#define NATFEAT_LIBC_MEMCPY 1 + #if NATFEAT_PHYS_ADDR # define ReadNFInt8 ReadAtariInt8 # define ReadNFInt16 ReadAtariInt16 @@ -30,53 +56,77 @@ # define WriteNFInt32 WriteInt32 #endif -static inline void Atari2Host_memcpy(void *dst, memptr src, size_t n) +static inline void Atari2Host_memcpy(void *_dst, memptr src, size_t count) { -#if NATFEAT_PHYS_ADDR - memcpy(dst, Atari2HostAddr(src), n); +#if NATFEAT_LIBC_MEMCPY && NATFEAT_PHYS_ADDR + memptr src_end = src + count - 1; + if (! ValidAtariAddr(src, false, 1)) + BUS_ERROR(src); + if (! ValidAtariAddr(src_end, false, 1)) + BUS_ERROR(src_end); + + memcpy(_dst, Atari2HostAddr(src), count); #else - uint8 *dest = (uint8 *)dst; - while ( n-- ) - *dest++ = (char)ReadInt8( (uint32)src++ ); + uint8 *dst = (uint8 *)_dst; + while ( count-- ) + *dst++ = (char)ReadNFInt8( src++ ); #endif } -static inline void Host2Atari_memcpy(memptr dest, const void *src, size_t n) +static inline void Host2Atari_memcpy(memptr dst, const void *_src, size_t count) { -#if NATFEAT_PHYS_ADDR - memcpy(Atari2HostAddr(dest), src, n); +#if NATFEAT_LIBC_MEMCPY && NATFEAT_PHYS_ADDR + memptr dst_end = dst + count - 1; + if (! ValidAtariAddr(dst, true, 1)) + BUS_ERROR(dst); + if (! ValidAtariAddr(dst_end, true, 1)) + BUS_ERROR(dst_end); + + memcpy(Atari2HostAddr(dst), _src, count); #else - uint8 *source = (uint8 *)src; - while ( n-- ) - WriteInt8( dest++, *source++ ); + uint8 *src = (uint8 *)_src; + while ( count-- ) + WriteNFInt8( dst++, *src++ ); #endif } -static inline void Atari2HostSafeStrncpy( char *dest, memptr source, size_t count ) +static inline void Atari2HostSafeStrncpy(char *dst, memptr src, size_t count) { -#if NATFEAT_PHYS_ADDR - safe_strncpy(dest, (const char*)Atari2HostAddr(source), count); +#if NATFEAT_LIBC_MEMCPY && NATFEAT_PHYS_ADDR + memptr src_end = src + count - 1; + if (! ValidAtariAddr(src, false, 1)) + BUS_ERROR(src); + if (! ValidAtariAddr(src_end, false, 1)) + BUS_ERROR(src_end); + + safe_strncpy(dst, (const char*)Atari2HostAddr(src), count); #else - while ( count > 1 && (*dest = (char)ReadInt8( source++ )) != 0 ) { + while ( count > 1 && (*dst = (char)ReadNFInt8( src++ )) != 0 ) { count--; - dest++; + dst++; } if (count > 0) - *dest = '\0'; + *dst = '\0'; #endif } -static inline void Host2AtariSafeStrncpy( memptr dest, const char *source, size_t count ) +static inline void Host2AtariSafeStrncpy(memptr dst, const char *src, size_t count) { -#if NATFEAT_PHYS_ADDR - safe_strncpy((char *)Atari2HostAddr(dest), source, count); +#if NATFEAT_LIBC_MEMCPY && NATFEAT_PHYS_ADDR + memptr dst_end = dst + count - 1; + if (! ValidAtariAddr(dst, true, 1)) + BUS_ERROR(dst); + if (! ValidAtariAddr(dst_end, true, 1)) + BUS_ERROR(dst_end); + + safe_strncpy((char *)Atari2HostAddr(dst), src, count); #else - while ( count > 1 && *source ) { - WriteInt8( dest++, (uint8)*source++ ); + while ( count > 1 && *src ) { + WriteNFInt8( dst++, (uint8)*src++ ); count--; } if (count > 0) - WriteInt8( dest, 0 ); + WriteNFInt8( dst, 0 ); #endif } #endif /* _NATFEATS_H */
Bug#698064: aranym: crashes from guest userspace when NatFeat is queried
Thorsten Glaser píše v St 10. 04. 2013 v 12:48 +0200: > On Mon, 14 Jan 2013, Petr Stehlik wrote: > > > I am all for putting together 0.9.15 for sid. > > ping? My fault, haven't had time to release new version yet. Will do it in less than 5 days, I promise. Petr -- To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#698064: aranym: crashes from guest userspace when NatFeat is queried
Thorsten Glaser píše v Ne 13. 01. 2013 v 22:32 +: > >> The specs specifically say the contrary: they must be in virtual > >> addresses, but still in physical memory: > > > >specs is probably incorrect :-/ Where did you get the following quotes > >from? > > http://wiki.aranym.org/natfeats/proposal "proposal"... Those were just ideas. The final implementation is different. Documentation needs to be corrected. > For detecting whether we run under virtualisation, this would have been > the way to go. In the very dark past NatFeats were meant to be called even from user space but later it was decided to use NatFeats from the kernel space only. Whatever needs to call host should use a device driver for that. And kernel space can work with physical (non-mapped) memory addresses easily thus providing the host with real contiguous memory blocks to read from/write to. Thanks to that host can use fast memcpy() when exchanging data with the guest. With logical (MMU mapped) addresses this wouldn't be possible because contiguous memory blocks would not be guaranteed. > Too bad if the specs are “incorrect” ☹ what you were trying was sort of NatFeat mis-use, anyway. Is user-space program supposed to do HW detection in Linux? I doubt it. Let the kernel detect hardware for you and then check /proc/hardware or so. > >I suppose the maintainer could grab the patch from CVS and apply it to > >ARAnyM in wheezy? Or I may prepare a 0.9.15 release of ARAnyM... > > I can probably NMU it, the maintainer isn’t a DD IIRC. Antonin Kral is (or has always been) a DD. > I think that, since a newer upstream version is in sid anyway, > we have to go through testing-proposed-updates already, so maybe > putting together a 0.9.15 with all fixes would be good, which we > can add to unstable, and I’ll apply the fix on top of 0.9.13 in > wheezy? I am all for putting together 0.9.15 for sid. Petr -- To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#698064: aranym: crashes from guest userspace when NatFeat is queried
Thorsten Glaser píše v Ne 13. 01. 2013 v 21:37 +: > >Could you show me the source code of nfimvirt, please? Seems like it > > I attached it. Thanks > >passed in an invalid pointer. You do know it needs to pass in physical > >(not MMU mapped) addresses, right? > > The specs specifically say the contrary: they must be in virtual > addresses, but still in physical memory: specs is probably incorrect :-/ Where did you get the following quotes from? > “On emulators implementing MMU and where physical addresses differ from > logical addresses, the memory that will be accessed by native features > uses the logical addresses (that is, exactly the same memory than that > seen by the CPU).” > > However: “All 68k memory accessed during the execution of a native > function, either directly (the stack), or indirectly (following > pointers) must reside in physical memory before the native function is > called.” – I added a call to mlock() before the NatFeat calls to ensure > that. > > Nevertheless, a user-space application absolutely MUST NOT crash the > emulator. Throw a SIGBUS if you must. I agree. Thus I have just fixed it (fix available in ARAnyM CVS, file src/include/natfeat.h). > @Debian: I suggest we tag this wheezy-ignore, because ⓐ it’s not a > regression, ⓑ the impact is low, and ⓒ some MIPS machines have (had?) > similar issues, so we have precedent. I suppose the maintainer could grab the patch from CVS and apply it to ARAnyM in wheezy? Or I may prepare a 0.9.15 release of ARAnyM... Petr -- To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#698064: aranym: crashes from guest userspace when NatFeat is queried
Thorsten Glaser píše v Ne 13. 01. 2013 v 19:12 +: > Then click into the SDL window, press Alt-F2 > and run /nfimvirt with no arguments. #1 0x081212b9 in safe_strncpy (dest=0xb0cc "", src=0x9005b25d , size=80) at /usr/include/i386-linux-gnu/bits/string3.h:121 #2 0x08108f6f in Atari2HostSafeStrncpy (count=80, source=, dest=0xb0cc "") at ./src/include/natfeats.h:58 #3 nf_get_id (stack=4018990244) at ./src/./natfeats.cpp:26 #4 0x08151bd6 in m68k_natfeat_id () at ./src/uae_cpu/newcpu.cpp:1367 #5 0x080b6bc8 in op_7300_0_ff(unsigned int) () Could you show me the source code of nfimvirt, please? Seems like it passed in an invalid pointer. You do know it needs to pass in physical (not MMU mapped) addresses, right? Petr -- To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#690007: aranym: FTBFS[kfreebsd]: libusb-1.0
> In file included from ./src/natfeat/nf_objs.cpp:62:0: > ./src/natfeat/usbhost.h:29:31: fatal error: libusb-1.0/libusb.h: No such file > or directory > compilation terminated. In configure.ac we have the following check: PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], [WITH_USBHOST="yes"], [WITH_USBHOST="no"]) It is supposed to check whether the host has the "libusb-1.0" library that we know it comes with libusb-1.0/libusb.h header file. This check works OK on all platforms where ARAnyM normally builds. The libusb2 on Debian/kfreebsd that claims it provides libusb-1.0 for Debian somehow tricks the PKG_CHECK_MODULES check that the libusb-1.0 library is available even though it is not. That's why the #include fails as seen above. Any suggestion how to work around this? Thanks Petr -- To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#690007: aranym: FTBFS[kfreebsd]: libusb-1.0
Christoph Egger píše v Po 08. 10. 2012 v 15:05 -0700: > Your package failed to build on the kfreebsd-* buildds: > > In file included from ./src/natfeat/nf_objs.cpp:62:0: > ./src/natfeat/usbhost.h:29:31: fatal error: libusb-1.0/libusb.h: No such file > or directory > compilation terminated. > make[1]: *** [obj_x86_64/nf_objs.o] Error 1 The following patch should help but I'd like to see a cleaner solution: --- configure.ac24 Sep 2012 19:40:49 - 1.62 +++ configure.ac9 Oct 2012 06:35:35 - @@ -1539,18 +1539,19 @@ WITH_USBHOST="no" if test "x$WANT_USBHOST" = "xyes"; then # Search using pkg-config -if test "x$PKG_CONFIG" != "x"; then - PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], [WITH_USBHOST="yes"], [WITH_USBHOST="no"]) -fi + # disabled because it is not safe on Debian/kfreebsd + # if test "x$PKG_CONFIG" != "x"; then + # PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], [WITH_USBHOST="yes"], [WITH_USBHOST="no"]) + # fi # Search the library and headers directly -if test "x$WITH_USBHOST" = "xno"; then + # if test "x$WITH_USBHOST" = "xno"; then AC_CHECK_HEADER(libusb-1.0/libusb.h, [WITH_USBHOST="yes"], [WITH_USBHOST="no"]) if test "x$WITH_USBHOST" = "xyes"; then AC_CHECK_LIB(usb-1.0, libusb_init, [], [WITH_USBHOST="no"]) LIBUSB_LIBS="-lusb-1.0" fi -fi + # fi if test "x$WITH_USBHOST" = "xno"; then AC_MSG_WARN([libusb is missing, USB NF disabled]) Petr -- To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#666947: patch
Hi, There were two post-release fixes to MMU MPFR emulation. The first one got included in the ARAnyM debian package while the second was committed after the debian package was uploaded. The attached patch will fix the issue, it's been tested by me and also Geert. Unofficial Debian binary packages containing this fix were available at http://aranym.org/download.html for some time already. Thanks Petr From: Petr Stehlik Date: Wed, 28 Mar 2012 10:09:27 +0200 Subject: fpu_mpfr longword conversion fix --- src/uae_cpu/fpu/fpu_mpfr.cpp |1 + 1 files changed, 2 insertions(+), 2 deletions(-) diff -u -r1.5 -r1.6 --- a/src/uae_cpu/fpu/fpu_mpfr.cpp 23 Mar 2012 15:42:15 - 1.5 +++ b/src/uae_cpu/fpu/fpu_mpfr.cpp 27 Mar 2012 15:02:48 - 1.6 @@ -869,7 +869,7 @@ switch (size) { case 0: - m68k_dreg (regs, reg) = extract_to_integer (*value, -0x8000, 0x7fff); + m68k_dreg (regs, reg) = extract_to_integer (*value, -0x7fff-1, 0x7fff); break; case 1: m68k_dreg (regs, reg) = extract_to_single (*value); @@ -933,7 +933,7 @@ switch (size) { case 0: - put_long (addr, extract_to_integer (*value, -0x8000, 0x7fff)); + put_long (addr, extract_to_integer (*value, -0x7fff-1, 0x7fff)); break; case 1: put_long (addr, extract_to_single (*value));