All of lore.kernel.org
 help / color / mirror / Atom feed
* Doubt regarding virtual memory mapping from hypervisor to a domain
@ 2011-01-28 19:23 Kaustubh Kabra
  2011-01-31 15:36 ` Dan Magenheimer
  0 siblings, 1 reply; 4+ messages in thread
From: Kaustubh Kabra @ 2011-01-28 19:23 UTC (permalink / raw)
  To: xen-devel; +Cc: vasani.ashwin, Dan Magenheimer, keir, Tim.Deegan

Hi,
I have allocated few order=9 pages in Xen memory space using
alloc_domheap_pages(NULL,9,0) during boot time just before domain is
created (dom0 = domain_create(0, DOMCRF_s3_integrity, DOM0_SSIDREF) in
xen/arch/x86/setup.c).

I got the following virtual addresses in xen log message-
(XEN) a2k2: Virt_addr:ffff83011cc00000   MFN:11cc00
(XEN) a2k2: Virt_addr:ffff83011ca00000   MFN:11ca00
(XEN) a2k2: Virt_addr:ffff83011c800000   MFN:11c800
(XEN) a2k2: Virt_addr:ffff83011c600000   MFN:11c600
(XEN) a2k2: Virt_addr:ffff83011c400000   MFN:11c400
(XEN) a2k2: Virt_addr:ffff83011c200000   MFN:11c200
(XEN) a2k2: Virt_addr:ffff83011c000000   MFN:11c000
(XEN) a2k2: Virt_addr:ffff83011be00000   MFN:11be00

As per config.h file Xen memory map,the virtual mapping shows that the
memory is  allocated in
1:1 direct mapping of all physical memory .Can anyone elaborate
regarding this mapping ?

Now can I allocate this mapped memory reserved by Xen hypervisor to
any domain through any existing or my new hypercall?

--
Regards,
Kaustubh Kabra
Pune Institute Of Computer  Technology,
University of Pune,
India.

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

* RE: Doubt regarding virtual memory mapping from hypervisor to a domain
  2011-01-28 19:23 Doubt regarding virtual memory mapping from hypervisor to a domain Kaustubh Kabra
@ 2011-01-31 15:36 ` Dan Magenheimer
  2011-02-10 13:26   ` Kaustubh Kabra
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Magenheimer @ 2011-01-31 15:36 UTC (permalink / raw)
  To: Kaustubh Kabra, xen-devel; +Cc: vasani.ashwin, keir, Tim.Deegan

> From: Kaustubh Kabra [mailto:kaustubhwise@gmail.com]
> I have allocated few order=9 pages in Xen memory space using
> alloc_domheap_pages(NULL,9,0) during boot time just before domain is
> created (dom0 = domain_create(0, DOMCRF_s3_integrity, DOM0_SSIDREF) in
> xen/arch/x86/setup.c).
> 
> I got the following virtual addresses in xen log message-
> (XEN) a2k2: Virt_addr:ffff83011cc00000   MFN:11cc00
> (XEN) a2k2: Virt_addr:ffff83011ca00000   MFN:11ca00
> (XEN) a2k2: Virt_addr:ffff83011c800000   MFN:11c800
> (XEN) a2k2: Virt_addr:ffff83011c600000   MFN:11c600
> (XEN) a2k2: Virt_addr:ffff83011c400000   MFN:11c400
> (XEN) a2k2: Virt_addr:ffff83011c200000   MFN:11c200
> (XEN) a2k2: Virt_addr:ffff83011c000000   MFN:11c000
> (XEN) a2k2: Virt_addr:ffff83011be00000   MFN:11be00
> 
> As per config.h file Xen memory map,the virtual mapping shows that the
> memory is  allocated in
> 1:1 direct mapping of all physical memory .Can anyone elaborate
> regarding this mapping ?

It's not clear what you are asking.  Can you be more precise?
 
> Now can I allocate this mapped memory reserved by Xen hypervisor to
> any domain through any existing or my new hypercall?

Again, it's not clear what you are asking.  If you are
asking if the guest can map the order=9 page into its
memory space, I think the answer is no.  If you are
asking if Xen can use the memory on behalf of a
domain, for example to copy data from the domain into
Xen (like tmem does), I think the answer is yes.

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

* Re: Doubt regarding virtual memory mapping from hypervisor to a domain
  2011-01-31 15:36 ` Dan Magenheimer
@ 2011-02-10 13:26   ` Kaustubh Kabra
  2011-02-10 15:13     ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 4+ messages in thread
From: Kaustubh Kabra @ 2011-02-10 13:26 UTC (permalink / raw)
  To: Dan Magenheimer
  Cc: jeremy, xen-devel, vasani.ashwin, Tim.Deegan, kabrakaustubh, keir


[-- Attachment #1.1: Type: text/plain, Size: 2129 bytes --]

On Mon, Jan 31, 2011 at 9:06 PM, Dan Magenheimer <dan.magenheimer@oracle.com
> wrote:

> > From: Kaustubh Kabra [mailto:kaustubhwise@gmail.com]
> > I have allocated few order=9 pages in Xen memory space using
> > alloc_domheap_pages(NULL,9,0) during boot time just before domain is
> > created (dom0 = domain_create(0, DOMCRF_s3_integrity, DOM0_SSIDREF) in
> > xen/arch/x86/setup.c).
> >
> > I got the following virtual addresses in xen log message-
> > (XEN) a2k2: Virt_addr:ffff83011cc00000   MFN:11cc00
> > (XEN) a2k2: Virt_addr:ffff83011ca00000   MFN:11ca00
> > (XEN) a2k2: Virt_addr:ffff83011c800000   MFN:11c800
> > (XEN) a2k2: Virt_addr:ffff83011c600000   MFN:11c600
> > (XEN) a2k2: Virt_addr:ffff83011c400000   MFN:11c400
> > (XEN) a2k2: Virt_addr:ffff83011c200000   MFN:11c200
> > (XEN) a2k2: Virt_addr:ffff83011c000000   MFN:11c000
> > (XEN) a2k2: Virt_addr:ffff83011be00000   MFN:11be00
> >
> > As per config.h file Xen memory map,the virtual mapping shows that the
> > memory is  allocated in
> > 1:1 direct mapping of all physical memory .Can anyone elaborate
> > regarding this mapping ?
>
> It's not clear what you are asking.  Can you be more precise?
>
> > Now can I allocate this mapped memory reserved by Xen hypervisor to
> > any domain through any existing or my new hypercall?
>
>
Precisely, i want to allocate this mfn to a requesting domain by making a
PMD entry. I tried using xen_set_pte and other hugetlb functions but it
cannot write as it is in read-only area . So, I passed this new formed PTE
formed using this mfn to hypervisor and tried setting the required PMD entry
to this new PTE, but xen crashes .


> Again, it's not clear what you are asking.  If you are
> asking if the guest can map the order=9 page into its
> memory space, I think the answer is no.  If you are
> asking if Xen can use the memory on behalf of a
> domain, for example to copy data from the domain into
> Xen (like tmem does), I think the answer is yes.
>

Also attached are two patches for xen-4.0.1 and jeremy-2.6.32.27 to check
the modifications done till now.

-- 
Kaustubh Kabra* <http://www.kaustubhwise.000a.biz>*

[-- Attachment #1.2: Type: text/html, Size: 3014 bytes --]

[-- Attachment #2: xen-patch.patch --]
[-- Type: text/x-patch, Size: 10511 bytes --]

diff --git a/xen/arch/x86/x86_32/entry.S b/xen/arch/x86/x86_32/entry.S
index 12e51f1..2069265 100644
--- a/xen/arch/x86/x86_32/entry.S
+++ b/xen/arch/x86/x86_32/entry.S
@@ -706,7 +706,7 @@ ENTRY(hypercall_table)
         .long do_domctl
         .long do_kexec_op
         .long do_tmem_op
-	.long do_alloc_huge  /*39*A2K2 Hypercall*/
+	.long do_alloc_hugepage /*39*A2K2 Hypercall*/
         .rept __HYPERVISOR_arch_0-((.-hypercall_table)/4)
         .long do_ni_hypercall
         .endr
@@ -755,7 +755,7 @@ ENTRY(hypercall_args_table)
         .byte 1 /* do_domctl            */
         .byte 2 /* do_kexec_op          */
         .byte 1 /* do_tmem_op           */
-	.byte 1 /* do_alloc_huge	*/
+	.byte 3 /* do_alloc_huge	*/
         .rept __HYPERVISOR_arch_0-(.-hypercall_args_table)
         .byte 0 /* do_ni_hypercall      */
         .endr
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index 0925fbc..37de2fc 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -695,7 +695,7 @@ ENTRY(hypercall_table)
         .quad do_domctl
         .quad do_kexec_op
         .quad do_tmem_op
-	.quad do_alloc_huge /*a2k2 Hypercall for allocating hugepage from hugepool*/
+	.quad do_alloc_hugepage /*a2k2 Hypercall for allocating hugepage from hugepool*/
         .rept __HYPERVISOR_arch_0-((.-hypercall_table)/8)
         .quad do_ni_hypercall
         .endr
@@ -744,7 +744,7 @@ ENTRY(hypercall_args_table)
         .byte 1 /* do_domctl            */
         .byte 2 /* do_kexec             */
         .byte 1 /* do_tmem_op           */
-        .byte 1 /* do_alloc_huge        */
+        .byte 3 /* do_alloc_huge        */
         .rept __HYPERVISOR_arch_0-(.-hypercall_args_table)
         .byte 0 /* do_ni_hypercall      */
         .endr
--- a/xen/common/hugetable.c
+++ b/xen/common/hugetable.c
@@ -1,37 +1,184 @@
-#include <xen/hugetable.h>
+#include<xen/hugetable.h>
 
-int init_hugepages_pool(int order){
-  /*  	int k;
-	hugepage_cnt=0;
+static struct hugespace hugepool[20];
+static int start;
+/*
+This function is called from the setup.c file
+before domain is booted
+It will mark the pages as UNMARK which means this
+are freepages &not allocated to any domain.
+When pages is allocated to any domain id is stored 
+in hugepool info of that page.
+Importat: MFN's we got are from the 1-to-1
+mapping. For more info check config.h file. 
+ */
+int init_hugepages_pool(void){
+  
+    	int k;
+			
 	for(k=0;k<HUGEPAGE_POOL_SIZE;k++)
    	{ 
-    		hugepool[k].huge_vir_add = alloc_xenheap_pages(9,0);   
-		//hugepool[k].pg= alloc_domheap_pages(NULL,order,0);
-		hugepool[k].order=order;
-//		printk("\na2k2:%p\n",page_to_virt(hugepool[k].pg));
-		if(hugepool[k].huge_vir_add==NULL){
+		hugepool[k].mark=UNMARK_HUGEPAGE;
+		hugepool[k].order=9;
+    		hugepool[k].pg = alloc_domheap_pages(NULL,hugepool[k].order,0);
+		hugepool[k].virt=page_to_virt(hugepool[k].pg);
+		hugepool[k].mfn= page_to_mfn(hugepool[k].pg);
+		hugepool[k].pfn= pfn_to_paddr(hugepool[k].mfn);
+		printk("\na2k2: Virt_addr:%p   MFN:%lx  PFN:%lx\n",hugepool[k].virt,hugepool[k].mfn,hugepool[k].pfn);
+		
+		if(hugepool[k].virt==NULL){
 		  printk("\na2k2::Hugepages creation failed at %d\n",k);
   		  return 0;
 		}
 	}
-	printk("\na2k2::Hugepages pool created successfully\n");  */
+	printk("\na2k2::Hugepages pool created successfully\n");  
+	return 1;   
+	
+}
+/*
+int init_hugepages_pool_dom0(struct domain * dom0){
+    	int k;
+			
+	for(k=0;k<HUGEPAGE_POOL_SIZE;k++)
+   	{ 
+    		hugepool[k].pg = alloc_domheap_pages(dom0,9,0);
+		hugepool[k].virt=page_to_virt(hugepool[k].pg);
+		hugepool[k].mfn= page_to_mfn(hugepool[k].pg);
+		hugepool[k].pfn= pfn_to_paddr(hugepool[k].mfn);
+		printk("\na2k2: Virt_addr:%p   MFN:%lx  PFN:%lx\n",hugepool[k].virt,hugepool[k].mfn,hugepool[k].pfn);
+		
+		if(hugepool[k].virt==NULL){
+		  printk("\na2k2::Hugepages creation failed at %d\n",k);
+  		  return 0;
+		}
+	}
+	printk("\na2k2::Hugepages pool created successfully\n");  
 	return 1;   
 }
 
-/*EXPORT unsigned long  do_alloc_huge(int op){
-    
-  
-    return 1UL;
-}*/
+int reseve_hugepages_dom0(struct domain *dom0){
+    	int k;
+			
+	for(k=0;k<HUGEPAGE_POOL_SIZE;k++)
+   	{ 
+	  share_xen_page_with_guest(hugepool[k].pg,dom0,XENSHARE_writable);
+	  printk("\na2k2:Allocating : %d",k);
+	}
+	printk("\na2k2::Hugepages pool allocated to dom 0 successfully\n");  
+	return 1;   
+}
 
+void dom0_hugepages_pool(void){
+    	int k;
+			
+	for(k=0;k<HUGEPAGE_POOL_SIZE;k++)
+   	{ 
+    		printk("\na2k2: Mapping after dom 0 Virt_addr:%p   MFN:%lx  PFN:%lx\n",hugepool[k].virt,hugepool[k].mfn,hugepool[k].pfn);
+		
+		if(hugepool[k].virt==NULL){
+		  printk("\na2k2::Hugepages mapping failed at %d\n",k);
+		}
+	}
+	printk("\na2k2::Hugepages pool mapped to domain 0 successfully\n");  
+}
+*/
 
- unsigned long do_alloc_huge(int op){
-  if(op==MASK_HUGE_PAGE){
-  //  alloc_hugepage_from_pool(1,NULL);
+/*
+This function will get the pages from the pool 
+& will mark as MARKPAGES
+start is for quick accessing the next free pages index
+ */
+unsigned long  alloc_hugepage_from_pool(struct domain *d)
+{
+  
+      int k,flag=0;
+      printk("\na2k2:In alloc_hugepage_from_pool\n");
+      for(k=start;k<HUGEPAGE_POOL_SIZE;k++)
+      {
+	
+	if(hugepool[k].mark==UNMARK_HUGEPAGE)
+	{
+	  start=k;
+	  if(d!=NULL)
+	  flag=assign_pages(d,hugepool[k].pg,hugepool[k].order,0);
+	  /*assign_pages is for security
+	    
+	   */  
+	  if(flag==0)
+	    {
+	      //hugepool[k].domain_id=d->domain_id;  
+	    hugepool[k].mark=MARK_HUGEPAGE;
+	    printk("\na2k2::k = %d %sreturns %lx\n",k,__FUNCTION__,hugepool[k].mfn);
+	    return hugepool[k].mfn;
+	    }
+	    else
+	    {
+	      printk("\na2k2:Bad assign.\n");
+	      return 0UL;
+	    }
+	}
+      }
+	  printk("\na2k2:All huge pages allocated.\n");
+    	  return 0UL;
+}
+/*
+This functions will free the pages from the hugepool
+domain will pass the mfn to this function with order
+After passing security issues free call will be successful
+Free pages from the pool are markes as UNMARKED
+ */
+int free_hugepage_from_pool(struct domain *d, long mfn,int order)
+{
+  
+      int k,i;
+      
+      for(k=0;k<HUGEPAGE_POOL_SIZE;k++)
+      {
+	
+	if(hugepool[k].mark==MARK_HUGEPAGE&&hugepool[k].mfn==mfn&&hugepool[k].domain_id==d->domain_id&&hugepool[k].order==order)
+	{
+	  for ( i = 0; i < (1 << order); i++ )
+	  {
     
+            page_list_del2(hugepool[k].pg, &d->page_list, &d->arch.relmem_list);
+	  }
+
+	  d->tot_pages -= 1 << order;
+	  hugepool[k].mark==UNMARK_HUGEPAGE;
+	  
+	  printk("\na2k2:Freed.\n");
+	  return 1;
+	}
+      }
+	  printk("\na2k2:Not freed.\n");
+	
+	return 0;
+}
+/*a2k2:This is the code for the hypercall
+for allocating & deallocating hugepages .
+op=19 alloc_hugepage_from_pool
+op=20 free_hugepages_from_pool
+TODO:
+op=21 set pte for age
+*/
+unsigned long
+do_alloc_hugepage(int op,unsigned long *ptep,unsigned long pte)
+{
+  unsigned long  mfn;
+  switch(op){
+    case 1:
+      return alloc_hugepage_from_pool(current->domain);
+    case 2:  
+      return free_hugepage_from_pool(current->domain,0,9);
+    case 3:
+      mfn=alloc_hugepage_from_pool(current->domain);
+      pte = pte & 0xF000000000000FFF;
+      pte = pte | mfn << 12;
+      printk("\na2k2::ptp = %lx \n",pte);
+      //*ptep = pte;
+      printk("\na2k2::ptp = %lx \n",*ptep);
+      return pte;  
+      break;
   }
-  else if(op==UMASK_HUGE_PAGE){
-    //free_hugepages_from_pool(NULL); 
-  }
-  return 0UL;
+  return 0;
 }
--- a/xen/include/public/xen.h
+++ b/xen/include/public/xen.h
@@ -93,7 +93,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
 #define __HYPERVISOR_domctl               36
 #define __HYPERVISOR_kexec_op             37
 #define __HYPERVISOR_tmem_op              38
-#define __HYPERVISOR_alloc_huge		  39	
+#define __HYPERVISOR_alloc_hugepage		  39	
 /* Architecture-specific hypercall definitions. */
 #define __HYPERVISOR_arch_0               48
 #define __HYPERVISOR_arch_1               49
diff --git a/xen/include/xen/compile.h b/xen/include/xen/compile.h
index 3a28a2b..0ee0659 100644
--- a/xen/include/xen/compile.h
+++ b/xen/include/xen/compile.h
@@ -1,6 +1,6 @@
-#define XEN_COMPILE_DATE	"Sat Jan 29 16:12:07 IST 2011"
-#define XEN_COMPILE_TIME	"16:12:07"
-#define XEN_COMPILE_BY		"ashwin"
+#define XEN_COMPILE_DATE	"Thu Feb 10 12:02:37 IST 2011"
+#define XEN_COMPILE_TIME	"12:02:37"
+#define XEN_COMPILE_BY		"root"
 #define XEN_COMPILE_DOMAIN	"wildfire"
 #define XEN_COMPILE_HOST	"ashwin.wildfire"
 #define XEN_COMPILER		"gcc version 4.4.4 20100503 (Red Hat 4.4.4-2) (GCC) "
diff --git a/xen/include/xen/hugetable.h b/xen/include/xen/hugetable.h
old mode 100755
new mode 100644
index e2ae2b2..b7f4735
--- a/xen/include/xen/hugetable.h
+++ b/xen/include/xen/hugetable.h
@@ -1,26 +1,33 @@
 #ifndef __HUGETABLE_H__
 #define __HUGETABLE_H__
 #define HUGEPAGE_POOL_SIZE 20
-#define MASK_HUGE_PAGE 1
-#define UMASK_HUGE_PAGE 0
+#define MARK_HUGEPAGE 1
+#define UNMARK_HUGEPAGE 0
+#define ALLOCATE_HUGEPAGE 1
+#include<xen/sched.h>
+
 /*this struct is defined by team a2k2
  * huge_ref_cnt id for counting number of references
  * huge_mfn will give the mfn number of hugepage in RAM
  * order field by default is 9 but can be changed for future scope
  * domain_id will store the domain id whom the huge page is allocated
  */
-/*struct hugespace{
-  unsigned int mask;
+
+struct hugespace{
+  int mark;
   unsigned int huge_ref_cnt;
-  unsigned int huge_mfn;
+  unsigned long mfn;
+  unsigned long pfn;
   unsigned int order;
-  unsigned int domain;
+  unsigned int domain_id;
   struct page_info *pg;
-  void *huge_vir_add;  
-  }huge_pool[20];*/
-extern int hugepage_cnt;
-extern unsigned long  do_alloc_huge(int op);
-extern int init_hugepages_pool(int);
+  void *virt;  
+};
+
+//extern struct hugespace hugepool[20];
 
+extern int init_hugepages_pool(void);
+extern unsigned long  alloc_hugepage_from_pool(struct domain *d);
+extern int free_hugepage_from_pool(struct domain *d, long mfn,int order);
+extern unsigned long do_alloc_hugepage(int op,unsigned long * ptep,unsigned long pte);
 #endif
- 
diff --git a/xen/include/xen/hypercall.h b/xen/include/xen/hypercall.h
index db4a2ac..8123315 100644
--- a/xen/include/xen/hypercall.h
+++ b/xen/include/xen/hypercall.h
@@ -129,7 +129,8 @@ do_xenoprof_op(int op, XEN_GUEST_HANDLE(void) arg);
  * 
  **/
 extern unsigned long
-do_alloc_huge(int op);
+do_alloc_hugepage(int op,unsigned long *ptep,unsigned long pte);
+
 

[-- Attachment #3: jeremy2-6-32-27.patch --]
[-- Type: text/x-patch, Size: 13958 bytes --]

diff --git a/a.out b/a.out
deleted file mode 100755
index f7c6218..0000000
Binary files a/a.out and /dev/null differ
diff --git a/a.p b/a.p
deleted file mode 100644
index 20dda7f..0000000
--- a/a.p
+++ /dev/null
@@ -1,164 +0,0 @@
-diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h
-index 41c4be0..6a312a3 100644
---- a/arch/x86/include/asm/xen/hypercall.h
-+++ b/arch/x86/include/asm/xen/hypercall.h
-@@ -286,6 +286,11 @@ HYPERVISOR_fpu_taskswitch(int set)
- 	return _hypercall1(int, fpu_taskswitch, set);
- }
- 
-+static inline unsigned long
-+HYPERVISOR_alloc_hugepage(int set)
-+{
-+	return _hypercall1(unsigned long,alloc_hugepage, set);
-+}
- static inline int
- HYPERVISOR_sched_op(int cmd, void *arg)
- {
-diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
-index 32a1c65..181cefd 100644
---- a/arch/x86/xen/mmu.c
-+++ b/arch/x86/xen/mmu.c
-@@ -241,6 +241,7 @@ static void p2m_top_init(unsigned long ***top)
- 		top[i] = p2m_mid_missing;
- }
- 
-+
- static void p2m_top_mfn_init(unsigned long *top)
- {
- 	unsigned i;
-@@ -516,6 +517,7 @@ static bool alloc_p2m(unsigned long pfn)
- }
- 
- /* Try to install p2m mapping; fail if intermediate bits missing */
-+
- bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
- {
- 	unsigned topidx, mididx, idx;
-@@ -537,6 +539,15 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
- 	return true;
- }
- 
-+//a2k2:
-+static void xen_set_hugemfn(unsigned long pfn){
-+  unsigned long mfn;
-+  printk("\nak2k2: Before hyper\n");
-+  mfn=HYPERVISOR_alloc_hugepage(1);
-+  printk("\nak2k2: After hyper\n");
-+
-+  __set_phys_to_machine(pfn,mfn);
-+}
- bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
- {
- 	if (unlikely(xen_feature(XENFEAT_auto_translated_physmap))) {
-diff --git a/arch/x86/xen/mmu.h b/arch/x86/xen/mmu.h
-index 537bb9a..79040a4 100644
---- a/arch/x86/xen/mmu.h
-+++ b/arch/x86/xen/mmu.h
-@@ -56,6 +56,7 @@ pte_t xen_ptep_modify_prot_start(struct mm_struct *mm, unsigned long addr, pte_t
- void  xen_ptep_modify_prot_commit(struct mm_struct *mm, unsigned long addr,
- 				  pte_t *ptep, pte_t pte);
- 
-+
- unsigned long xen_read_cr2_direct(void);
- 
- extern void xen_init_mmu_ops(void);
-diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
-index 158cdd1..ce8f60d 100644
---- a/drivers/xen/balloon.c
-+++ b/drivers/xen/balloon.c
-@@ -245,8 +245,9 @@ static int increase_reservation(unsigned long nr_pages)
- 
- 	if (nr_pages > ARRAY_SIZE(frame_list))
- 		nr_pages = ARRAY_SIZE(frame_list);
--
-+	printk("\na2k2:inc first page\n");
- 	page = balloon_first_page();
-+	printk("\na2k2:inc after first page\n");
- 	for (i = 0; i < nr_pages; i++) {
- 		BUG_ON(page == NULL);
- 		frame_list[i] = page_to_pfn(page);
-@@ -308,6 +309,7 @@ static int decrease_reservation(unsigned long nr_pages)
- 		.domid        = DOMID_SELF
- 	};
- 
-+	printk("\na2k2:dec first page\n");
- 	if (nr_pages > ARRAY_SIZE(frame_list))
- 		nr_pages = ARRAY_SIZE(frame_list);
- 
-@@ -364,7 +366,7 @@ static int decrease_reservation(unsigned long nr_pages)
- 	reservation.extent_order = balloon_order;
- 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
- 	BUG_ON(ret != nr_pages);
--
-+	printk("\na2k2:dec after hyper call\n");
- 	return need_sleep;
- }
- 
-diff --git a/fs/exec.c b/fs/exec.c
-index a0410eb..e2929e7 100644
---- a/fs/exec.c
-+++ b/fs/exec.c
-@@ -1876,7 +1876,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
- 			 * core_pattern process dies.
- 			 */
- 			printk(KERN_WARNING
--				"Process %d(%s) has RLIMIT_CORE set to 0\n",
-+				"a2k2:Process %d(%s) has RLIMIT_CORE set to 0\n",
- 				task_tgid_vnr(current), current->comm);
- 			printk(KERN_WARNING "Aborting core\n");
- 			goto fail_unlock;
-diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h
-index 9ffaee0..f200a33 100644
---- a/include/xen/interface/xen.h
-+++ b/include/xen/interface/xen.h
-@@ -58,7 +58,7 @@
- #define __HYPERVISOR_event_channel_op     32
- #define __HYPERVISOR_physdev_op           33
- #define __HYPERVISOR_hvm_op               34
--
-+#define __HYPERVISOR_alloc_hugepage	  39 //a2k2
- /* Architecture-specific hypercall definitions. */
- #define __HYPERVISOR_arch_0               48
- #define __HYPERVISOR_arch_1               49
-diff --git a/mm/hugetlb.c b/mm/hugetlb.c
-index f5a106e..0f11be1 100644
---- a/mm/hugetlb.c
-+++ b/mm/hugetlb.c
-@@ -18,7 +18,6 @@
- #include <linux/mutex.h>
- #include <linux/bootmem.h>
- #include <linux/sysfs.h>
--
- #include <asm/page.h>
- #include <asm/pgtable.h>
- #include <asm/io.h>
-@@ -69,6 +68,7 @@ struct file_region {
- 	long to;
- };
- 
-+
- static long region_add(struct list_head *head, long f, long t)
- {
- 	struct file_region *rg, *nrg, *trg;
-@@ -455,7 +455,8 @@ static void enqueue_huge_page(struct hstate *h, struct page *page)
- 	h->free_huge_pages++;
- 	h->free_huge_pages_node[nid]++;
- }
--
-+//a2k2:
-+extern void xen_set_hugemfn(unsigned long pfn);
- static struct page *dequeue_huge_page_vma(struct hstate *h,
- 				struct vm_area_struct *vma,
- 				unsigned long address, int avoid_reserve)
-@@ -499,7 +500,11 @@ static struct page *dequeue_huge_page_vma(struct hstate *h,
- 			break;
- 		}
- 	}
-+	printk("\nHello \n");
- 	mpol_cond_put(mpol);
-+	//a2k2:
-+	printk("\na2k2: %s \n",__FUNCTION__);
-+	xen_set_hugemfn(page_to_pfn(page));
- 	return page;
- }
- 
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index 20c62f7..3202dcc 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -262,10 +262,8 @@ struct pv_mmu_ops {
 	void (*release_pte)(unsigned long pfn);
 	void (*release_pmd)(unsigned long pfn);
 	void (*release_pud)(unsigned long pfn);
-  
+
 	/* Pagetable manipulation functions */
-        //a2k2:
-  ///void (*xen_set_hugemfn)(unsigned long pfn); 
 	void (*set_pte)(pte_t *ptep, pte_t pteval);
 	void (*set_pte_at)(struct mm_struct *mm, unsigned long addr,
 			   pte_t *ptep, pte_t pteval);
diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h
index b26fbff..41c4be0 100644
--- a/arch/x86/include/asm/xen/hypercall.h
+++ b/arch/x86/include/asm/xen/hypercall.h
@@ -286,11 +286,6 @@ HYPERVISOR_fpu_taskswitch(int set)
 	return _hypercall1(int, fpu_taskswitch, set);
 }
 
-static inline unsigned long
-HYPERVISOR_alloc_hugepage(int set,unsigned long *ptep,unsigned long pte)
-{
-	return _hypercall3(unsigned long,alloc_hugepage, set,ptep,pte);
-}
 static inline int
 HYPERVISOR_sched_op(int cmd, void *arg)
 {
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 360ab32..32a1c65 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -241,7 +241,6 @@ static void p2m_top_init(unsigned long ***top)
 		top[i] = p2m_mid_missing;
 }
 
-
 static void p2m_top_mfn_init(unsigned long *top)
 {
 	unsigned i;
@@ -517,7 +516,6 @@ static bool alloc_p2m(unsigned long pfn)
 }
 
 /* Try to install p2m mapping; fail if intermediate bits missing */
-
 bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
 {
 	unsigned topidx, mididx, idx;
@@ -539,28 +537,6 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
 	return true;
 }
 
-//a2k2:
-
-void xen_set_hugemfn(unsigned long pfn,pte_t *ptep, pte_t pte){
-  unsigned long mfn;//,**ppp,*pt;
-  //pmd_t *pp,pte1;
-  //ppp=(unsigned long**)&pp;
-  //*ppp=ptep;
-  printk("ak2k2: Before hyper \n");
-  pte.pte=HYPERVISOR_alloc_hugepage(3,(unsigned long *)ptep,(unsigned long)pte.pte);
-  mfn=(pte.pte >> 12) & 0x0ffffffffffff;
-  printk("MFN: %lx \n",mfn);
-  printk("ak2k2: After hyper \n");
-  printk("a2k2:: %lx",get_phys_to_machine(pfn));
-  //pt=(unsigned long*)&pte1;
-  //*pt=pte;
-
-  if(mfn>0 && pfn > 0)
-  __set_phys_to_machine(pfn,mfn);
-  xen_set_pte(ptep,pte);
-  //xen_set_pmd(pp,pte1);
-  printk("pte=%lx\n",pte.pte);
-}
 bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
 {
 	if (unlikely(xen_feature(XENFEAT_auto_translated_physmap))) {
@@ -2335,7 +2311,6 @@ static __init void xen_post_allocator_init(void)
 	pv_mmu_ops.set_pte = xen_set_pte;
 	pv_mmu_ops.set_pmd = xen_set_pmd;
 	pv_mmu_ops.set_pud = xen_set_pud;
-//	pv_mmu_ops.set_xen_hugemfn=xen_set_hugemfn;
 #if PAGETABLE_LEVELS == 4
 	pv_mmu_ops.set_pgd = xen_set_pgd;
 #endif
@@ -2396,7 +2371,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = {
 	.set_pte = xen_set_pte_init,
 	.set_pte_at = xen_set_pte_at,
 	.set_pmd = xen_set_pmd_hyper,
-	//.set_xen_hugemfn=set_xen_hugemfn,
+
 	.ptep_modify_prot_start = __ptep_modify_prot_start,
 	.ptep_modify_prot_commit = __ptep_modify_prot_commit,
 
diff --git a/arch/x86/xen/mmu.h b/arch/x86/xen/mmu.h
index 2066446..537bb9a 100644
--- a/arch/x86/xen/mmu.h
+++ b/arch/x86/xen/mmu.h
@@ -2,7 +2,7 @@
 
 #include <linux/linkage.h>
 #include <asm/page.h>
-#include <linux/myhuge.h>
+
 enum pt_level {
 	PT_PGD,
 	PT_PUD,
@@ -56,7 +56,6 @@ pte_t xen_ptep_modify_prot_start(struct mm_struct *mm, unsigned long addr, pte_t
 void  xen_ptep_modify_prot_commit(struct mm_struct *mm, unsigned long addr,
 				  pte_t *ptep, pte_t pte);
 
-
 unsigned long xen_read_cr2_direct(void);
 
 extern void xen_init_mmu_ops(void);
diff --git a/b.p b/b.p
deleted file mode 100644
index e69de29..0000000
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index a2d4f30..158cdd1 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -245,6 +245,7 @@ static int increase_reservation(unsigned long nr_pages)
 
 	if (nr_pages > ARRAY_SIZE(frame_list))
 		nr_pages = ARRAY_SIZE(frame_list);
+
 	page = balloon_first_page();
 	for (i = 0; i < nr_pages; i++) {
 		BUG_ON(page == NULL);
@@ -363,6 +364,7 @@ static int decrease_reservation(unsigned long nr_pages)
 	reservation.extent_order = balloon_order;
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
 	BUG_ON(ret != nr_pages);
+
 	return need_sleep;
 }
 
diff --git a/fs/exec.c b/fs/exec.c
index e2929e7..a0410eb 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1876,7 +1876,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
 			 * core_pattern process dies.
 			 */
 			printk(KERN_WARNING
-				"a2k2:Process %d(%s) has RLIMIT_CORE set to 0\n",
+				"Process %d(%s) has RLIMIT_CORE set to 0\n",
 				task_tgid_vnr(current), current->comm);
 			printk(KERN_WARNING "Aborting core\n");
 			goto fail_unlock;
diff --git a/include/linux/myhuge.h b/include/linux/myhuge.h
deleted file mode 100644
index be665ba..0000000
--- a/include/linux/myhuge.h
+++ /dev/null
@@ -1,5 +0,0 @@
-#ifndef __MY_HUGE_H__
-#define __MY_HUGE_H__
-extern void xen_set_hugemfn(unsigned long pfn,pte_t *ptep, pte_t pte);
-
-#endif
diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h
index f200a33..9ffaee0 100644
--- a/include/xen/interface/xen.h
+++ b/include/xen/interface/xen.h
@@ -58,7 +58,7 @@
 #define __HYPERVISOR_event_channel_op     32
 #define __HYPERVISOR_physdev_op           33
 #define __HYPERVISOR_hvm_op               34
-#define __HYPERVISOR_alloc_hugepage	  39 //a2k2
+
 /* Architecture-specific hypercall definitions. */
 #define __HYPERVISOR_arch_0               48
 #define __HYPERVISOR_arch_1               49
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 06ffe4a..f5a106e 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -18,14 +18,13 @@
 #include <linux/mutex.h>
 #include <linux/bootmem.h>
 #include <linux/sysfs.h>
+
 #include <asm/page.h>
 #include <asm/pgtable.h>
 #include <asm/io.h>
 
 #include <linux/hugetlb.h>
-#include <linux/myhuge.h>
 #include "internal.h"
-//#include "../include/asm-generic/page.h"
 
 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
 static gfp_t htlb_alloc_mask = GFP_HIGHUSER;
@@ -70,7 +69,6 @@ struct file_region {
 	long to;
 };
 
-
 static long region_add(struct list_head *head, long f, long t)
 {
 	struct file_region *rg, *nrg, *trg;
@@ -457,8 +455,7 @@ static void enqueue_huge_page(struct hstate *h, struct page *page)
 	h->free_huge_pages++;
 	h->free_huge_pages_node[nid]++;
 }
-//a2k2:
-//extern void xen_set_hugemfn(unsigned long pfn);
+
 static struct page *dequeue_huge_page_vma(struct hstate *h,
 				struct vm_area_struct *vma,
 				unsigned long address, int avoid_reserve)
@@ -502,9 +499,7 @@ static struct page *dequeue_huge_page_vma(struct hstate *h,
 			break;
 		}
 	}
-	
 	mpol_cond_put(mpol);
-	//xen_set_hugemfn(page_to_pfn(page));
 	return page;
 }
 
@@ -1100,7 +1095,6 @@ static void __init hugetlb_init_hstates(void)
 {
 	struct hstate *h;
 
-	printk("\na2k2:%s\n",__FUNCTION__);
 	for_each_hstate(h) {
 		/* oversize hugepages were init'ed in early boot */
 		if (h->order < MAX_ORDER)
@@ -1740,7 +1734,8 @@ static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page,
 	pte_t entry;
 
 	if (writable) {
-		entry =pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
+		entry =
+		    pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
 	} else {
 		entry = huge_pte_wrprotect(mk_pte(page, vma->vm_page_prot));
 	}
@@ -2128,14 +2123,10 @@ retry:
 	if (!huge_pte_none(huge_ptep_get(ptep)))
 		goto backout;
 
-	printk("\na2k2:%s ,pte=%lu \n",__FUNCTION__,ptep->pte);
 	new_pte = make_huge_pte(vma, page, ((vma->vm_flags & VM_WRITE)
 				&& (vma->vm_flags & VM_SHARED)));
 	set_huge_pte_at(mm, address, ptep, new_pte);
-	printk("\na2k2:%s ,pte=%lx ,new_pte=%lx --11 \n",__FUNCTION__,ptep->pte,new_pte.pte);
-	xen_set_hugemfn(page_to_pfn(page),ptep,new_pte);
-	printk("\na2k2:%s ,pte=%lx ,new_pte=%lx \n",__FUNCTION__,ptep->pte,new_pte.pte);
-	
+
 	if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
 		/* Optimization, do the COW without a second fault */
 		ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
diff --git a/temp.c b/temp.c
deleted file mode 100644
index ccd4c92..0000000
--- a/temp.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include<stdio.h>
-#define swap (x,y,z) (x t;t=y;y=z;z=t;)
-main()
-{
-
-int a,b,c;
-
-swap(int,a,b);
-}

[-- Attachment #4: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

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

* Re: Re: Doubt regarding virtual memory mapping from hypervisor to a domain
  2011-02-10 13:26   ` Kaustubh Kabra
@ 2011-02-10 15:13     ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 4+ messages in thread
From: Konrad Rzeszutek Wilk @ 2011-02-10 15:13 UTC (permalink / raw)
  To: Kaustubh Kabra
  Cc: Dan Magenheimer, xen-devel, vasani.ashwin, Tim.Deegan, jeremy,
	kabrakaustubh, keir

On Thu, Feb 10, 2011 at 06:56:52PM +0530, Kaustubh Kabra wrote:
> On Mon, Jan 31, 2011 at 9:06 PM, Dan Magenheimer <dan.magenheimer@oracle.com
> > wrote:
> 
> > > From: Kaustubh Kabra [mailto:kaustubhwise@gmail.com]
> > > I have allocated few order=9 pages in Xen memory space using
> > > alloc_domheap_pages(NULL,9,0) during boot time just before domain is
> > > created (dom0 = domain_create(0, DOMCRF_s3_integrity, DOM0_SSIDREF) in
> > > xen/arch/x86/setup.c).
> > >
> > > I got the following virtual addresses in xen log message-
> > > (XEN) a2k2: Virt_addr:ffff83011cc00000   MFN:11cc00
> > > (XEN) a2k2: Virt_addr:ffff83011ca00000   MFN:11ca00
> > > (XEN) a2k2: Virt_addr:ffff83011c800000   MFN:11c800
> > > (XEN) a2k2: Virt_addr:ffff83011c600000   MFN:11c600
> > > (XEN) a2k2: Virt_addr:ffff83011c400000   MFN:11c400
> > > (XEN) a2k2: Virt_addr:ffff83011c200000   MFN:11c200
> > > (XEN) a2k2: Virt_addr:ffff83011c000000   MFN:11c000
> > > (XEN) a2k2: Virt_addr:ffff83011be00000   MFN:11be00
> > >
> > > As per config.h file Xen memory map,the virtual mapping shows that the
> > > memory is  allocated in
> > > 1:1 direct mapping of all physical memory .Can anyone elaborate
> > > regarding this mapping ?
> >
> > It's not clear what you are asking.  Can you be more precise?
> >
> > > Now can I allocate this mapped memory reserved by Xen hypervisor to
> > > any domain through any existing or my new hypercall?
> >
> >
> Precisely, i want to allocate this mfn to a requesting domain by making a
> PMD entry. I tried using xen_set_pte and other hugetlb functions but it
> cannot write as it is in read-only area . So, I passed this new formed PTE
> formed using this mfn to hypervisor and tried setting the required PMD entry
> to this new PTE, but xen crashes .

With what?

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

end of thread, other threads:[~2011-02-10 15:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-28 19:23 Doubt regarding virtual memory mapping from hypervisor to a domain Kaustubh Kabra
2011-01-31 15:36 ` Dan Magenheimer
2011-02-10 13:26   ` Kaustubh Kabra
2011-02-10 15:13     ` Konrad Rzeszutek Wilk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.