From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] bios: resolve memory device roll over reporting issues with >32G guests Date: Sun, 09 Nov 2008 15:15:33 +0200 Message-ID: <4916E275.2000802@redhat.com> References: <491456C7.860B.008B.3@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Bill Rieske Return-path: Received: from mx2.redhat.com ([66.187.237.31]:38074 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751784AbYKINPh (ORCPT ); Sun, 9 Nov 2008 08:15:37 -0500 In-Reply-To: <491456C7.860B.008B.3@novell.com> Sender: kvm-owner@vger.kernel.org List-ID: Bill Rieske wrote: > The field within the Memory Device type 17 is only a word with the MSB being used to report MB/KB. Thereby, a guest with 32G and greater would report incorrect memory device information rolling over to 0. > > This presents more than one memory device and associated memory structures if the memory is larger than 16G > > Signed-off-by: Bill Rieske > > > diff --git a/bios/rombios32.c b/bios/rombios32.c > index a91b155..bc69945 100755 > --- a/bios/rombios32.c > +++ b/bios/rombios32.c > @@ -173,6 +173,26 @@ static inline int isdigit(int c) > return c >= '0' && c <= '9'; > } > > +char *itoa(char *a, unsigned int i) > +{ > + unsigned int _i = i, x = 0; > + > + do { > + x++; > + _i /= 10; > + } while ( _i != 0 ); > + > + a += x; > + *a-- = '\0'; > + > + do { > + *a-- = (i % 10) + '0'; > + i /= 10; > + } while ( i != 0 ); > + > + return a + 1; > +} > + > Instead of this, can you add an snprintf() (in a separate patch) and use it? There's already a vsnprintf() so all the heavy machinery is in place. > void *memset(void *d1, int val, size_t len) > { > uint8_t *d = d1; > @@ -220,6 +240,16 @@ size_t strlen(const char *s) > return s1 - s; > } > > +char * > +strcpy(char *dest, const char *src) > +{ > + char *p = dest; > + while ( *src ) > + *p++ = *src++; > + *p = 0; > + return dest; > +} > + > This would eliminate the need for strcpy(), I think. -- error compiling committee.c: too many arguments to function