public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Remove memory size from linker script
@ 2007-10-09 21:31 Anthony Liguori
       [not found] ` <11919655141141-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Anthony Liguori @ 2007-10-09 21:31 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: Anthony Liguori, Jerone Young, Avi Kivity

The memory size is currently hardcoded into the linker script (end_of_memory).
This prevents the memory size from being specified dynamically in kvmctl.
This patch adds a PIO port that can be used to query the memory size in the
tests.

Signed-off-by: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

diff --git a/user/flat.lds b/user/flat.lds
index 7dd922c..61f1057 100644
--- a/user/flat.lds
+++ b/user/flat.lds
@@ -13,6 +13,5 @@ SECTIONS
     .bss : { *(.bss) }
     . = ALIGN(4K);
     edata = .;
-    end_of_memory = 128M;
 }
 
diff --git a/user/main.c b/user/main.c
index 3eb8dea..9a57a24 100644
--- a/user/main.c
+++ b/user/main.c
@@ -144,7 +144,15 @@ static int test_inl(void *opaque, uint16_t addr, uint32_t *value)
 {
 	if (apic_io(addr, 0, value))
 		return 0;
-	printf("inl 0x%x\n", addr);
+
+	switch (addr) {
+	case 0xd1:
+		*value = 128 * 1024 * 1024;
+		break;
+	default:
+		printf("inl 0x%x\n", addr);
+		break;
+	}
 	return 0;
 }
 
diff --git a/user/test/vm.c b/user/test/vm.c
index 2eb8d96..e0e78d7 100644
--- a/user/test/vm.c
+++ b/user/test/vm.c
@@ -58,7 +58,8 @@ void free_page(void *page)
     free = page;
 }
 
-extern char edata, end_of_memory;
+extern char edata;
+static unsigned long end_of_memory;
 
 #define PTE_PRESENT (1ull << 0)
 #define PTE_PSE     (1ull << 7)
@@ -202,10 +203,18 @@ static void setup_mmu(unsigned long len)
     print("paging enabled\n");
 }
 
+static unsigned int inl(unsigned short port)
+{
+    unsigned int val;
+    asm volatile("inl %w1, %0" : "=a"(val) : "Nd"(port));
+    return val;
+}
+
 void setup_vm()
 {
-    free_memory(&edata, &end_of_memory - &edata);
-    setup_mmu((long)&end_of_memory);
+    end_of_memory = inl(0xd1);
+    free_memory(&edata, end_of_memory - (unsigned long)&edata);
+    setup_mmu(end_of_memory);
 }
 
 void *vmalloc(unsigned long size)

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-10-09 22:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-09 21:31 [PATCH 1/2] Remove memory size from linker script Anthony Liguori
     [not found] ` <11919655141141-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-10-09 21:31   ` [PATCH 2/2] Allow memory to be specified in kvmctl Anthony Liguori
     [not found]     ` <11919655153228-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-10-09 21:54       ` Muli Ben-Yehuda
     [not found]         ` <20071009215449.GM4335-WD1JZD8MxeCTrf4lBMg6DdBPR1lH4CV8@public.gmane.org>
2007-10-09 22:09           ` Anthony Liguori
     [not found]             ` <470BFC0F.5040707-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-10-09 22:14               ` Muli Ben-Yehuda
     [not found]                 ` <20071009221404.GO4335-WD1JZD8MxeCTrf4lBMg6DdBPR1lH4CV8@public.gmane.org>
2007-10-09 22:18                   ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox