From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrii Tseglytskyi Subject: Re: run time memory trap question Date: Mon, 17 Feb 2014 17:01:12 +0200 Message-ID: References: <5301FA5F.8020602@linaro.org> <530219C4.3050304@linaro.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8337405805101902146==" Return-path: In-Reply-To: <530219C4.3050304@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Julien Grall Cc: Stefano Stabellini , Ian Campbell , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org --===============8337405805101902146== Content-Type: multipart/alternative; boundary=047d7b343f9a344d9704f29b6db8 --047d7b343f9a344d9704f29b6db8 Content-Type: text/plain; charset=ISO-8859-1 Hi Julien, > > > > > Can anyone clarify - is it possible to make a run time memory trap > in > > > Xen hypervisor? > > > > I guess you are talking about ARM? If so, it's not possible right > now. > > > > > > Does it mean, that it is possible on x86 ? > > Yes, you can look at register_io_handler in xen/arch/x86/hvm/intercept.c > > It's used a static array, but I don't think this is the solution for > ARM. We don't know in advance the maximum number of MMIO region to handle. > > What I'm thinking about for ARM - is to use linked list for MMIO handlers + API to register / unregister handler. xen/arch/arm/io.c: 25 static const struct mmio_handler *const mmio_handlers[] = 26 { 27 &vgic_distr_mmio_handler, 28 &vuart_mmio_handler, 29 }; This can be changed to list. New API will add / remove entries. VGIC and VUART will call something like mmio_register_handler(&vgic_distr_mmio_handle) during corresponding initcall. Than the only change which is required for existing int handle_mmio(mmio_info_t *info) function - is to enumerate list, instead of array 32 int handle_mmio(mmio_info_t *info) 33 { 34 struct vcpu *v = current; 35 int i; 36 37 for ( i = 0; i < MMIO_HANDLER_NR; i++ ) --> *list_for_each* 38 if ( mmio_handlers[i]->check_handler(v, info->gpa) ) 39 return info->dabt.write ? 40 mmio_handlers[i]->write_handler(v, info) : 41 mmio_handlers[i]->read_handler(v, info); 42 43 return 0; 44 } Something like this. Regards, Andrii > -- > Julien Grall > -- Andrii Tseglytskyi | Embedded Dev GlobalLogic www.globallogic.com --047d7b343f9a344d9704f29b6db8 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Julien,


>
> =A0 =A0 > Can anyone clarify - is it possible to make a run time me= mory trap in
> =A0 =A0 > Xen hypervisor?
>
> =A0 =A0 I guess you are talking about ARM? If so, it's not possibl= e right now.
>
>
> Does it mean, that it is possible on x86 ?

Yes, you can look at register_io_handler in xen/arch/x86/hvm/intercep= t.c

It's used a static array, but I don't think this is the solution fo= r
ARM. We don't know in advance the maximum number of MMIO region to hand= le.


What I'm thi= nking about for ARM - is to use linked list for MMIO handlers + API to regi= ster / unregister handler.

xen/arch/arm/io.c:

=A025 static const struct mmio_handler *cons= t mmio_handlers[] =3D
=A026 { =A0=A0
=A027 =A0 =A0 &= ;vgic_distr_mmio_handler,
=A028 =A0 =A0 &vuart_mmio_handler,<= /div>
=A029 }; =A0

This can be changed to list. New API will add / r= emove entries. VGIC and VUART will call something like mmio_register_handle= r(&vgic_distr_mmio_handle) during corresponding initcall.

Than the only change which is required for existing=A0int ha= ndle_mmio(mmio_info_t *info) function =A0- is to enumerate list, instead of= array
=A032 int handle_mmio(mmio_info_t *info)
= =A033 {
=A034 =A0 =A0 struct vcpu *v =3D current;
=A035 =A0 =A0 int = i;
=A036=A0
=A037 =A0 =A0 for ( i =3D 0; i < MMIO_HA= NDLER_NR; i++ ) --> *list_for_each*
=A038 =A0 =A0 =A0 =A0 if (= mmio_handlers[i]->check_handler(v, info->gpa) )
=A039 =A0 =A0 =A0 =A0 =A0 =A0 return info->dabt.write ?
= =A040 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 mmio_handlers[i]->write_handler(v,= info) :
=A041 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 mmio_handlers[i]-&= gt;read_handler(v, info);
=A042=A0
=A043 =A0 =A0 return 0;
=A044 }

So= mething like this.

Regards,
Andrii
=



--
Julien Grall



--
Andrii Tseglytskyi | Em= bedded Dev
GlobalLogic
www.globallogi= c.com
--047d7b343f9a344d9704f29b6db8-- --===============8337405805101902146== 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.xen.org http://lists.xen.org/xen-devel --===============8337405805101902146==--