From: Tim Deegan Subject: Re: [PATCH 18/38] arm: implement vpl011 (UART) emulator. Date: Thu, 7 Jun 2012 10:29:51 +0100 Message-ID: <20120607092951.GE70339@ocelot.phlegethon.org> References: <1338565113.17466.141.camel@zakaz.uk.xensource.com> <1338565207-2888-1-git-send-email-ian.campbell@citrix.com> <1338565207-2888-18-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1338565207-2888-18-git-send-email-ian.campbell@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org > +int domain_uart0_init(struct domain *d) > +{ > + int rc; > + if ( d->domain_id == 0 ) > + return 0; Why? There's no equivalent gate on the MMIO handlers. > + spin_lock_init(&d->arch.uart0.lock); > + d->arch.uart0.idx = 0; > + > + rc = -ENOMEM; > + d->arch.uart0.buf = xzalloc_array(char, VPL011_BUF_SIZE); > + if ( !d->arch.uart0.buf ) > + goto out; Just return ENOMEM here - the 'rc=foo; goto out' is overkill. > + > + rc = 0; > +out: > + return rc; > +} > +static int uart0_mmio_check(struct vcpu *v, paddr_t addr) > +{ > + return v->domain->domain_id && addr >= UART0_BASE_ADDRESS && addr < (UART0_BASE_ADDRESS+65536); > +} linewrap? > + > +static int uart0_mmio_read(struct vcpu *v, mmio_info_t *info) > +{ > + struct hsr_dabt dabt = info->dabt; > + struct cpu_user_regs *regs = guest_cpu_user_regs(); > + uint32_t *r = ®s->r0 + dabt.reg; > + int offset = (int)(info->gpa - UART0_BASE_ADDRESS); > + Need to check dabt.size != 0 here too? Tim.