From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: run time memory trap question Date: Mon, 17 Feb 2014 15:19:14 +0000 Message-ID: <53022872.80209@linaro.org> References: <5301FA5F.8020602@linaro.org> <530219C4.3050304@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrii Tseglytskyi Cc: Stefano Stabellini , Ian Campbell , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 02/17/2014 03:01 PM, Andrii Tseglytskyi wrote: > 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. This solution sounds good. If I remembered correctly, you are writing a driver for IPU/GPU MMU, right? In this case, I think a per-domain MMU handlers would be better. Most of handlers will be used for a specific guest (except the VGIC handler). -- Julien Grall