public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH kvm-unit-test] get memory size from fwcfg
@ 2013-02-11 13:10 Gleb Natapov
  2013-02-11 16:13 ` Lucas Meneghel Rodrigues
  0 siblings, 1 reply; 2+ messages in thread
From: Gleb Natapov @ 2013-02-11 13:10 UTC (permalink / raw)
  To: kvm; +Cc: mtosatti, lmr

Upstream test device does not implement port 0xd1.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/lib/x86/vm.c b/lib/x86/vm.c
index 71b70fd..2852c6c 100644
--- a/lib/x86/vm.c
+++ b/lib/x86/vm.c
@@ -1,3 +1,4 @@
+#include "fwcfg.h"
 #include "vm.h"
 #include "libcflat.h"
 
@@ -185,16 +186,9 @@ static void setup_mmu(unsigned long len)
     printf("cr4 = %x\n", read_cr4());
 }
 
-static unsigned int inl(unsigned short port)
-{
-    unsigned int val;
-    asm volatile("inl %w1, %0" : "=a"(val) : "Nd"(port));
-    return val;
-}
-
 void setup_vm()
 {
-    end_of_memory = inl(0xd1);
+    end_of_memory = fwcfg_get_u64(FW_CFG_RAM_SIZE);
     free_memory(&edata, end_of_memory - (unsigned long)&edata);
     setup_mmu(end_of_memory);
 }
diff --git a/x86/rmap_chain.c b/x86/rmap_chain.c
index 9add9b8..0df1bcb 100644
--- a/x86/rmap_chain.c
+++ b/x86/rmap_chain.c
@@ -1,6 +1,7 @@
 /* test long rmap chains */
 
 #include "libcflat.h"
+#include "fwcfg.h"
 #include "vm.h"
 #include "smp.h"
 
@@ -21,7 +22,7 @@ int main (void)
 
     setup_vm();
 
-    nr_pages = inl(0xd1) / PAGE_SIZE;
+    nr_pages = fwcfg_get_u64(FW_CFG_RAM_SIZE) / PAGE_SIZE;
     nr_pages -= 1000;
     target_page = alloc_page();
 
--
			Gleb.

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

* Re: [PATCH kvm-unit-test] get memory size from fwcfg
  2013-02-11 13:10 [PATCH kvm-unit-test] get memory size from fwcfg Gleb Natapov
@ 2013-02-11 16:13 ` Lucas Meneghel Rodrigues
  0 siblings, 0 replies; 2+ messages in thread
From: Lucas Meneghel Rodrigues @ 2013-02-11 16:13 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, mtosatti

On 02/11/2013 11:10 AM, Gleb Natapov wrote:
> Upstream test device does not implement port 0xd1.

I remember sending a similar patch a while ago, but it seems like it 
didn't get applied.

One thing that does occur to me - we will have to keep testing RHEL5, 
RHEL6 and Fedora with their old test devices. This change seems 
backwards compatible, since instead of using port 0xd1 we're getting RAM 
size from the firmware, which should work for both cases.

Given all that, this patch looks good to me. ACK.

Reviewed-by: Lucas Meneghel Rodrigues <lmr@redhat.com>

> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> diff --git a/lib/x86/vm.c b/lib/x86/vm.c
> index 71b70fd..2852c6c 100644
> --- a/lib/x86/vm.c
> +++ b/lib/x86/vm.c
> @@ -1,3 +1,4 @@
> +#include "fwcfg.h"
>   #include "vm.h"
>   #include "libcflat.h"
>
> @@ -185,16 +186,9 @@ static void setup_mmu(unsigned long len)
>       printf("cr4 = %x\n", read_cr4());
>   }
>
> -static unsigned int inl(unsigned short port)
> -{
> -    unsigned int val;
> -    asm volatile("inl %w1, %0" : "=a"(val) : "Nd"(port));
> -    return val;
> -}
> -
>   void setup_vm()
>   {
> -    end_of_memory = inl(0xd1);
> +    end_of_memory = fwcfg_get_u64(FW_CFG_RAM_SIZE);
>       free_memory(&edata, end_of_memory - (unsigned long)&edata);
>       setup_mmu(end_of_memory);
>   }
> diff --git a/x86/rmap_chain.c b/x86/rmap_chain.c
> index 9add9b8..0df1bcb 100644
> --- a/x86/rmap_chain.c
> +++ b/x86/rmap_chain.c
> @@ -1,6 +1,7 @@
>   /* test long rmap chains */
>
>   #include "libcflat.h"
> +#include "fwcfg.h"
>   #include "vm.h"
>   #include "smp.h"
>
> @@ -21,7 +22,7 @@ int main (void)
>
>       setup_vm();
>
> -    nr_pages = inl(0xd1) / PAGE_SIZE;
> +    nr_pages = fwcfg_get_u64(FW_CFG_RAM_SIZE) / PAGE_SIZE;
>       nr_pages -= 1000;
>       target_page = alloc_page();
>
> --
> 			Gleb.
>


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

end of thread, other threads:[~2013-02-11 16:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-11 13:10 [PATCH kvm-unit-test] get memory size from fwcfg Gleb Natapov
2013-02-11 16:13 ` Lucas Meneghel Rodrigues

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