From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Deegan Subject: Re: [PATCH] xen: get GIC addresses from DT Date: Fri, 30 Nov 2012 12:18:55 +0000 Message-ID: <20121130121855.GA95877@ocelot.phlegethon.org> References: <1354185641.25834.126.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline 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: Stefano Stabellini Cc: Anthony Perard , "xen-devel@lists.xensource.com" , Ian Campbell List-Id: xen-devel@lists.xenproject.org At 12:08 +0000 on 30 Nov (1354277311), Stefano Stabellini wrote: > arm: add few checks to gic_init > > Check for: > - uninitialized GIC interface addresses; > - non-page aligned GIC interface addresses. > > Return in both cases with an error message. > Also remove the code from GICH and GICC to handle non-page aligned > interfaces. > > Signed-off-by: Stefano Stabellini > > diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c > index 8efbeb3..301d223 100644 > --- a/xen/arch/arm/gic.c > +++ b/xen/arch/arm/gic.c > @@ -34,10 +34,8 @@ > > /* Access to the GIC Distributor registers through the fixmap */ > #define GICD ((volatile uint32_t *) FIXMAP_ADDR(FIXMAP_GICD)) > -#define GICC ((volatile uint32_t *) (FIXMAP_ADDR(FIXMAP_GICC1) \ > - + ((uint32_t) gic.cbase & 0xfff))) > -#define GICH ((volatile uint32_t *) (FIXMAP_ADDR(FIXMAP_GICH) \ > - + ((uint32_t) gic.hbase & 0xfff))) > +#define GICC ((volatile uint32_t *) FIXMAP_ADDR(FIXMAP_GICC1)) > +#define GICH ((volatile uint32_t *) FIXMAP_ADDR(FIXMAP_GICH)) > static void gic_restore_pending_irqs(struct vcpu *v); > > /* Global state */ > @@ -308,6 +306,23 @@ static void __cpuinit gic_hyp_disable(void) > /* Set up the GIC */ > void __init gic_init(void) > { > + if ( !early_info.gic.gic_dist_addr || Some hard tabs have snuck in here. > + !early_info.gic.gic_cpu_addr || > + !early_info.gic.gic_hyp_addr || > + !early_info.gic.gic_vcpu_addr ) > + { > + printk("error: incorrect physical address of the GIC interfaces.\n"); > + return; Maybe panic() here (and below) rather than printk? > + } > + if ( (early_info.gic.gic_dist_addr & ((1 << PAGE_SHIFT) - 1)) || (foo & ~PAGE_MASK) is usual for that. Cheers, Tim. > + (early_info.gic.gic_cpu_addr & ((1 << PAGE_SHIFT) - 1)) || > + (early_info.gic.gic_hyp_addr & ((1 << PAGE_SHIFT) - 1)) || > + (early_info.gic.gic_vcpu_addr & ((1 << PAGE_SHIFT) - 1)) ) > + { > + printk("error: GIC interfaces not page aligned.\n"); > + return; > + } > + > gic.dbase = early_info.gic.gic_dist_addr; > gic.cbase = early_info.gic.gic_cpu_addr; > gic.hbase = early_info.gic.gic_hyp_addr; > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel