Skip to content

Commit

Permalink
Add support for NetBSD/sparc.
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaible committed Oct 3, 2017
1 parent ef6f6d4 commit 4445cc0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -1,3 +1,11 @@
2017-10-03 Bruno Haible <bruno@clisp.org>

Add support for NetBSD/sparc.
* src/sigsegv.h.in (SIGSEGV_FAULT_ADDRESS_ALIGNMENT) [NetBSD/sparc]:
Define to 0x1000.
* m4/fault.m4 (SV_TRY_FAULT): On NetBSD/sparc, set
SIGSEGV_FAULT_ADDRESS_ROUNDOFF_BITS like on Linux/s390.

2017-10-03 Bruno Haible <bruno@clisp.org>

Fix a message.
Expand Down
4 changes: 2 additions & 2 deletions m4/fault.m4
@@ -1,4 +1,4 @@
# fault.m4 serial 7 (libsigsegv-2.11)
# fault.m4 serial 8 (libsigsegv-2.12)
dnl Copyright (C) 2002-2003, 2011 Bruno Haible <bruno@clisp.org>
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
Expand Down Expand Up @@ -43,7 +43,7 @@ $4
static int zero_fd;
# define map_flags MAP_FILE | MAP_PRIVATE
#endif
#if defined __linux__ && (defined __s390__ || defined __s390x__)
#if (defined __linux__ && (defined __s390__ || defined __s390x__)) || (defined __NetBSD__ && defined __sparc__)
# define SIGSEGV_FAULT_ADDRESS_ROUNDOFF_BITS (0x1000UL - 1)
#else
# define SIGSEGV_FAULT_ADDRESS_ROUNDOFF_BITS 0UL
Expand Down
2 changes: 1 addition & 1 deletion src/sigsegv.h.in
Expand Up @@ -66,7 +66,7 @@ extern int libsigsegv_version; /* Likewise */
* page into which the fault address falls. On these platforms,
* SIGSEGV_FAULT_ADDRESS_ALIGNMENT is greater than 1.
*/
#if defined __linux__ && (defined __s390__ || defined __s390x__)
#if (defined __linux__ && (defined __s390__ || defined __s390x__)) || (defined __NetBSD__ && defined __sparc__)
# define SIGSEGV_FAULT_ADDRESS_ALIGNMENT 0x1000UL
#else
# define SIGSEGV_FAULT_ADDRESS_ALIGNMENT 1UL
Expand Down

10 comments on commit 4445cc0

@krytarowski
Copy link

@krytarowski krytarowski commented on 4445cc0 Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be alerted that NetBSD/sparc64 also defines __sparc__, to set SIGSEGV_FAULT_ADDRESS_ALIGNMENT & co. just for the 32-bit version you need to add check for: !defined(__sparc64__).

@rurban
Copy link
Owner

@rurban rurban commented on 4445cc0 Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bruno will not read it here. You have to alert him over at the savannah gnu server.
https://git.savannah.gnu.org/git/libsigsegv.git
This is just a fork.

@krytarowski
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please forward it to him? He might did it on the purpose, but I would need to dig into sparc 32 vs 64-bit version..

@krytarowski
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rurban
Copy link
Owner

@rurban rurban commented on 4445cc0 Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done via mailinglist, thanks

@bhaible
Copy link
Contributor Author

@bhaible bhaible commented on 4445cc0 Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Kamil for the note.

I did receive all 5 comments by mail; apparently Github extracted the email address from the git commit and then matched it with my Github user account, so they knew I am OK to receive mail.

Do you know a way to run NetBSD/sparc64 in qemu? I succeeded for NetBSD/sparc with the installation image from https://cdn.netbsd.org/pub/NetBSD/iso/7.1/NetBSD-7.1-sparc.iso. But for sparc64, the installer installed a system, and when rebooted

  1. I have to enter the root device (wd0c) manually,
  2. It is not well configured:

mount

root_device on / type ffs (read-only, local)

If you cannot provide such instructions, maybe you are in a position to execute libsigsegv tarballs on a NetBSD/sparc64 machine. What is the result when you take https://ftp.gnu.org/gnu/libsigsegv/libsigsegv-2.11.tar.gz and run "./configure; make; make check"?

@krytarowski
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@utkarsh009 integrated sparc64 into Anita as far as I'm aware, he might have more insight how to run it in an emulator.

@utkarsh009
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bhaible The problem with root device detection was recently fixed by martin@ . It should have worked with current. Maybe the changes were not pushed to 7.1 (if that is what you used for sparc64 as well). In any case, the problem was related to the way openbios generates its device tree, so there should have been a conflict between the devices wd1 and wd0, which is not the case here. So, you might as well try using the first partition on the device wd0 (i.e. wd0a) as the root partition during installation and see if that helps. Anyways, I'll try it out myself and let you know.

@utkarsh009
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bhaible I just tested http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-8/201709170600Z/images/NetBSD-8.0_BETA-sparc64.iso on lyta. Like I already said, use wd0a as the root partition.
use

qemu-system-sparc64 -cdrom NetBSD-8.0_BETA-sparc64.iso -drive file=sparc64.img,media=disk,format=raw -m 128 -nographic -boot d

for installing it initially. When asked to partition the disk, choose 'set the partition sizes manually'. After that, select 'partition size ok'. It will automatically allocate the total space minus 128 MB (which is for swap) to wd0a and set it as /. This should do the trick for now.
As for rebooting, it's a bug and crashes the emulator (not sure how you managed to do that). We don't use reboot in anita. Instead we just kill the process after issuing halt, so it doesn't affect it. You can use anita for your testing purpose too. Just use

anita interact http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-8/201709170600Z/images/NetBSD-8.0_BETA-sparc64.iso

Hope this helps. For any further queries, feel free to contact me here as well as my email id: uanand009@gmail.com

Regards,
Utkarsh Anand

@bhaible
Copy link
Contributor Author

@bhaible bhaible commented on 4445cc0 Oct 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@utkarsh009 Thanks for the hint. This image at http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-8/201709170600Z/images/NetBSD-8.0_BETA-sparc64.iso works fine for me, using qemu-2.10.0 and manual disk partitioning.

With it, I could find that

  1. In the 32-bit subsystem ("gcc -m32") of this sparc64 system, getpagesize() is 0x2000 as opposed to 0x1000 on the other system, and 0x2000 is the value that libsigsegv needs to use in this case.
  2. The 64-bit subsystem ("gcc") of this sparc64 system has the same problem as the 32-bit subsystem, namely that the 'si_addr' in the siginfo_t struct is not the fault address, but the truncated fault address.

Workaround pushed: http://git.savannah.gnu.org/gitweb/?p=libsigsegv.git;a=commitdiff;h=8d59eced2b0d6e97d8bedd4cba221ae6e8ff7390

Please sign in to comment.