From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Christoph Egger" Subject: [PATCH 3/3] Add support for OpenBSD Date: Tue, 17 Oct 2006 16:44:46 +0200 Message-ID: <200610171644.46737.Christoph.Egger@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_exONFHVv1H0FELR" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --Boundary-00=_exONFHVv1H0FELR Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi! This is the third and last patch. This patch makes the xen kernel buildable on OpenBSD by adding support for ProPolice. ProPolice has been added to standard GCC in version 4.1.x under the name Stack Smashing Protection (SSP). Cheers Christoph --Boundary-00=_exONFHVv1H0FELR Content-Type: text/x-diff; charset=us-ascii; name=openbsd_propolice.diff Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=openbsd_propolice.diff diff -r bd207697f0c7 xen/arch/x86/boot/mkelf32.c =2D-- a/xen/arch/x86/boot/mkelf32.c Wed Oct 18 13:43:35 2006 +0100 +++ b/xen/arch/x86/boot/mkelf32.c Tue Oct 17 16:39:13 2006 +0200 @@ -90,9 +90,15 @@ static Elf32_Shdr out_shdr[] =3D { } }; =20 +#ifndef swap16 #define swap16(_v) ((((u16)(_v)>>8)&0xff)|(((u16)(_v)&0xff)<<8)) +#endif +#ifndef swap32 #define swap32(_v) (((u32)swap16((u16)(_v))<<16)|(u32)swap16((u32)((_v)>>1= 6))) +#endif +#ifndef swap64 #define swap64(_v) (((u64)swap32((u32)(_v))<<32)|(u64)swap32((u32)((_v)>>3= 2))) +#endif =20 static int big_endian; =20 diff -r bd207697f0c7 xen/arch/x86/setup.c =2D-- a/xen/arch/x86/setup.c Wed Oct 18 13:43:35 2006 +0100 +++ b/xen/arch/x86/setup.c Tue Oct 17 16:39:13 2006 +0200 @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -625,6 +626,8 @@ void __init __start_xen(multiboot_info_t cmdline) !=3D 0) panic("Could not set up DOM0 guest OS\n"); =20 + init_guard(); + /* Scrub RAM that is still free and so may go to an unprivileged domai= n. */ scrub_heap_pages(); =20 diff -r bd207697f0c7 xen/common/Makefile =2D-- a/xen/common/Makefile Wed Oct 18 13:43:35 2006 +0100 +++ b/xen/common/Makefile Tue Oct 17 16:39:13 2006 +0200 @@ -5,6 +5,7 @@ obj-y +=3D elf.o obj-y +=3D elf.o obj-y +=3D event_channel.o obj-y +=3D grant_table.o +obj-y +=3D guard.o obj-y +=3D kernel.o obj-y +=3D keyhandler.o obj-y +=3D lib.o diff -r bd207697f0c7 xen/common/guard.c =2D-- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xen/common/guard.c Tue Oct 17 16:39:13 2006 +0200 @@ -0,0 +1,34 @@ + +#include + +long __guard[8]; + +void __stack_smash_handler(char [], int __attribute__((unused))); + +void +__stack_smash_handler(char func[], int damaged) +{ + panic("smashed stack in %s", func); +} + + +void init_guard(void) +{ + volatile long newguard[8]; + int i; + + /* XXX newguard is intended to get filled with random values. + * But there's nothing to use, so this is just something + * out of my head :) */ + newguard[0] =3D 103958; + newguard[1] =3D 3505; + newguard[2] =3D 75601; + newguard[3] =3D 35703; + newguard[4] =3D 94; + newguard[5] =3D 721; + newguard[6] =3D 3094; + newguard[7] =3D 217; + + for (i =3D sizeof(__guard) / sizeof(__guard[0]) - 1; i; i--) + __guard[i] =3D newguard[i]; +} diff -r bd207697f0c7 xen/include/xen/guard.h =2D-- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xen/include/xen/guard.h Tue Oct 17 16:39:13 2006 +0200 @@ -0,0 +1,3 @@ + + +void init_guard(void); + --Boundary-00=_exONFHVv1H0FELR Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_exONFHVv1H0FELR--