From: Ian Campbell Subject: Re: [PATCH] readnote: Add bzImage kernel support Date: Fri, 13 Apr 2012 11:08:50 +0100 Message-ID: <1334311730.14560.22.camel@zakaz.uk.xensource.com> References: 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: Xuesen Guo Cc: "xen-devel@lists.xensource.com" , Ian Jackson , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Thu, 2012-04-12 at 02:38 +0100, Xuesen Guo wrote: > Add the check of bzImage kernel and make it work > with RHEL 6 bzipped kernels Thanks, a single small nit inline below. > @@ -159,6 +204,27 @@ int main(int argc, char **argv) > fprintf(stderr, "Unable to map %s: %s\n", f, strerror(errno)); > return 1; > } > + > + /* Check the magic of bzImage kernel */ > + hdr = (struct setup_header *)image; > + if ( memcmp(&hdr->header, HDR_MAGIC, HDR_MAGIC_SZ) == 0 ) > + { > + if ( hdr->version < VERSION(2,8) ) > + { > + printf("%s: boot protocol too old (%04x)", __FUNCTION__, hdr->version); > + return -EINVAL; Should be return 1 in this context. Thanks, Ian. > + } > + > + /* upcast to 64 bits to avoid overflow */ > + /* setup_sects is u8 and so cannot overflow */ > + payload_offset = (hdr->setup_sects + 1) * 512; > + payload_offset += hdr->payload_offset; > + payload_length = hdr->payload_length; > + > + image = image + payload_offset; > + st.st_size = payload_length; > + } > + > size = st.st_size; > > usize = xc_dom_check_gzip(xch, image, st.st_size);