Subject: Re: Patch for KVM86 support on MP kernels
To: None <port-i386@netbsd.org>
From: Eric Auge <eau@phear.org>
List: port-i386
Date: 01/07/2007 01:06:24
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig85DA0BE801A6E7943D328300
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello,

so far so good, works perfectly on my x60 for now... :)
1024x768 on NetBSD 4.0_BETA2 smp enabled.

thanks,

Regards,
Eric.

Pierre Pronchery wrote:
> 	Hi,
>=20
> I am probably not knowing what I am doing, but here is my humble attemp=
t
> at allowing the framebuffer code to compile (and hopefully work) on MP
> machines. I got the inspiration from an earlier unanswered post by Eric=

> Auge [1], and the current equivalent in OpenBSD [2]. They say there are=

> probably still problems.
>=20
> [1] http://mail-index.netbsd.org/netbsd-users/2006/12/01/0000.html
> [2] http://www.openbsd.org/cgi-bin/cvsweb/src/sys/arch/i386/i386/kvm86.=
c
>=20
> I did not test that code, nor could 100% check that the code is
> otherwise equivalent to the version from OpenBSD.
>=20
> HTH,
>=20
>=20
> -----------------------------------------------------------------------=
-
>=20
> Index: kvm86.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> RCS file: /cvsroot/src/sys/arch/i386/i386/kvm86.c,v
> retrieving revision 1.10
> diff -u -r1.10 kvm86.c
> --- kvm86.c	26 Dec 2005 19:23:59 -0000	1.10
> +++ kvm86.c	5 Jan 2007 04:15:03 -0000
> @@ -36,6 +36,7 @@
>  #include <sys/proc.h>
>  #include <sys/user.h>
>  #include <sys/malloc.h>
> +#include <sys/lock.h>
>  #include <uvm/uvm.h>
>  #include <machine/pcb.h>
>  #include <machine/pte.h>
> @@ -70,6 +71,8 @@
>  /* a virtual page to map in vm86 memory temporarily */
>  vaddr_t bioscalltmpva;
> =20
> +struct lock kvm86_mp_lock;
> +
>  #define KVM86_IOPL3 /* not strictly necessary, saves a lot of traps */=

> =20
>  void
> @@ -119,6 +122,7 @@
>  		  BIOSCALLSCRATCHPAGE_VMVA);
>  	bioscallvmd =3D vmd;
>  	bioscalltmpva =3D uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_VAON=
LY);
> +	lockinit(&kvm86_mp_lock, 0, "KVM86 MP", 0, LK_RECURSEFAIL);
>  }
> =20
>  /*
> @@ -136,10 +140,6 @@
>  	extern struct trapframe *vm86frame;
>  	extern pt_entry_t *vm86pgtableva;
> =20
> -#ifdef MULTIPROCESSOR
> -#error this needs a rewrite for MP
> -#endif
> -
>  	vm86newptd =3D vtophys((vaddr_t)vmd) | PG_V | PG_RW | PG_U | PG_u;
>  	vm86pgtableva =3D vmd->pgtbl;
>  	vm86frame =3D (struct trapframe *)vmd - 1;
> @@ -276,7 +276,9 @@
>  	tf.tf_edi =3D r->EDI;
>  	tf.tf_vm86_es =3D r->ES;
> =20
> +	lockmgr(&kvm86_mp_lock, LK_EXCLUSIVE, NULL);
>  	res =3D kvm86_bioscall(intno, &tf);
> +	lockmgr(&kvm86_mp_lock, LK_RELEASE, NULL);
> =20
>  	r->EAX =3D tf.tf_eax;
>  	r->EBX =3D tf.tf_ebx;
> Index: trap.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> RCS file: /cvsroot/src/sys/arch/i386/i386/trap.c,v
> retrieving revision 1.214
> diff -u -r1.214 trap.c
> --- trap.c	29 Sep 2006 14:48:15 -0000	1.214
> +++ trap.c	5 Jan 2007 04:15:03 -0000
> @@ -135,9 +135,6 @@
>  #endif
> =20
>  #ifdef KVM86
> -#ifdef MULTIPROCESSOR
> -#error KVM86 needs a rewrite to support MP systems.
> -#endif
>  #include <machine/kvm86.h>
>  #define KVM86MODE (kvm86_incall)
>  #else
> @@ -437,9 +434,11 @@
>  		return;
> =20
>  	case T_PROTFLT|T_USER:		/* protection fault */
> +		KERNEL_PROC_LOCK(l);
>  #ifdef VM86
>  		if (frame->tf_eflags & PSL_VM) {
>  			vm86_gpfault(l, type & ~T_USER);
> +			KERNEL_PROC_UNLOCK(l);
>  			goto out;
>  		}
>  #endif
> @@ -447,12 +446,14 @@
>  		/* If pmap_exec_fixup does something, let's retry the trap. */
>  		if (pmap_exec_fixup(&p->p_vmspace->vm_map, frame,
>  		    &l->l_addr->u_pcb)) {
> +			KERNEL_PROC_UNLOCK(l);
>  			goto out;
>  		}
>  		KSI_INIT_TRAP(&ksi);
>  		ksi.ksi_signo =3D SIGSEGV;
>  		ksi.ksi_addr =3D (void *)rcr2();
>  		ksi.ksi_code =3D SEGV_ACCERR;
> +		KERNEL_PROC_UNLOCK(l);
>  		goto trapsignal;
> =20
>  	case T_TSSFLT|T_USER:


--------------enig85DA0BE801A6E7943D328300
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (NetBSD)

iD8DBQFFoDmDSdZNA80H8MYRAhsLAJ9S06XvisIvAE4NhvhTwVxelCQqTgCgubcW
FOT/CD4mqtBjStfLpb5C1us=
=XDEu
-----END PGP SIGNATURE-----

--------------enig85DA0BE801A6E7943D328300--