From patchwork Wed Aug 31 21:11:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 1117632 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7VLBUCJ021170 for ; Wed, 31 Aug 2011 21:11:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755278Ab1HaVL1 (ORCPT ); Wed, 31 Aug 2011 17:11:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21505 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752604Ab1HaVL1 (ORCPT ); Wed, 31 Aug 2011 17:11:27 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7VLBPMP000525 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 31 Aug 2011 17:11:25 -0400 Received: from freedom.local.com (vpn-232-151.phx2.redhat.com [10.3.232.151]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7VLBNPW032404; Wed, 31 Aug 2011 17:11:23 -0400 From: Lucas Meneghel Rodrigues To: kvm@vger.kernel.org Cc: qemu-devel@nongnu.org, Lucas Meneghel Rodrigues , Avi Kivity , Marcelo Tosatti Subject: [PATCH] kvm_unit_tests: vm.c - Retrieve RAM size from fwcfg Date: Wed, 31 Aug 2011 18:11:12 -0300 Message-Id: <1314825072-27967-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 31 Aug 2011 21:11:31 +0000 (UTC) Rather than letting the test dev do it. CC: Avi Kivity CC: Marcelo Tosatti Signed-off-by: Lucas Meneghel Rodrigues --- lib/x86/fwcfg.c | 5 +++++ lib/x86/fwcfg.h | 1 + lib/x86/vm.c | 2 +- 3 files changed, 7 insertions(+), 1 deletions(-) diff --git a/lib/x86/fwcfg.c b/lib/x86/fwcfg.c index e2cdd15..df8548c 100644 --- a/lib/x86/fwcfg.c +++ b/lib/x86/fwcfg.c @@ -43,3 +43,8 @@ unsigned fwcfg_get_nb_cpus(void) { return fwcfg_get_u16(FW_CFG_NB_CPUS); } + +unsigned fwcfg_get_ram_size(void) +{ + return fwcfg_get_u64(FW_CFG_RAM_SIZE); +} diff --git a/lib/x86/fwcfg.h b/lib/x86/fwcfg.h index e0836ca..96c75b8 100644 --- a/lib/x86/fwcfg.h +++ b/lib/x86/fwcfg.h @@ -39,6 +39,7 @@ uint32_t fwcfg_get_u32(unsigned index); uint64_t fwcfg_get_u64(unsigned index); unsigned fwcfg_get_nb_cpus(void); +unsigned fwcfg_get_ram_size(void); #endif diff --git a/lib/x86/vm.c b/lib/x86/vm.c index abbb0c9..5b31892 100644 --- a/lib/x86/vm.c +++ b/lib/x86/vm.c @@ -194,7 +194,7 @@ static unsigned int inl(unsigned short port) void setup_vm() { - end_of_memory = inl(0xd1); + end_of_memory = fwcfg_get_ram_size(); free_memory(&edata, end_of_memory - (unsigned long)&edata); setup_mmu(end_of_memory); }