Skip to contentSkip to conversation

Mini-OS in dom0 - virtual memory problems

DISCUSSION Julian Stecklina 2 participants 5 messages Jan 25, 2007 – Feb 1, 2007

lore
Share & tools
lore
#0 lore raw

Hello,

I am trying to port Mini-OS (from xen-3.0.4-testing) to the domain 0 environment. Setting the right flags in x86_32.S and changing the start of the text section to 0xC0100000 enabled it to boot. I expected that most of the Mini-OS's functionality to be working except everything that relied on the Xenbus.

To my surprise there was an error setting up the virtual memory. Here is the console log:

Bootstrapping...
Xen Minimal OS!

start_info:   c0135000
  nr_pages:   26700  shared_inf: 00bed000
  pt_base:    c0136000  mod_start:  0x0
  mod_len:    0
  flags:      0x3
  cmd_line:
  stack:      c0117040-c0119040
MM: Init
  _text:        c0100000
  _etext:       c010a3b4
  _edata:       c010b760
  stack start:  c0117040
  _end:         c0119494
  start_pfn:    3b
  max_pfn:      684c

Mapping memory range 0xc0500000 - 0xc694c000
(XEN) mm.c:1664:d0 Bad type (saw e8000001 != exp 20000000) for mfn 1c3b (pfn 3b) (XEN) mm.c:1960:d0 Error while pinning mfn 1c3b
ERROR: pinning failed
Do_exit called!

The first message from the hypervisor seems very strange. I would be very thankful, if anyone can point to the source of the problem.

Regards,
Julian

#1 lore raw
Quoted 1 line · Julian Stecklina

To my surprise there was an error setting up the virtual memory. Here is the console log:

Perhaps this is helping, too:

(XEN) PHYSICAL MEMORY ARRANGEMENT:
(XEN) Dom0 alloc.: 01c00000->02000000 (25676 pages to be allocated)
(XEN) VIRTUAL MEMORY ARRANGEMENT:

(XEN)  Loaded kernel: c0100000->c0119494
(XEN)  Init. ramdisk: c011a000->c011a000
(XEN)  Phys-Mach map: c011a000->c0134130
(XEN)  Start info:    c0135000->c013546c
(XEN)  Page tables:   c0136000->c0138000
(XEN)  Boot stack:    c0138000->c0139000
(XEN)  TOTAL:         c0000000->c0400000
(XEN)  ENTRY ADDRESS: c0100000

Regards,
Julian

#2 lore raw
In reply to Julian Stecklina

Mini-OS assumes that the start of the text section is also the beginning of virtual address space[1]. However, it is generally bad idea not to start virtual address space at 4Mb boundary. The easiest way to fix your problem is to move text to 0xc0000000 or 0xc0400000. More extensive fix, which decouples VIRT_START from &_text is also possible, but I don't see a reason why it would be needed. Instead I've included a runtime check. Keir could you apply the patch?

Thanks
Gregor

[1]
include/x86/arch_mm.h line 209:
#define VIRT_START ((unsigned long)&_text)

Quoted 31 lines · Julian Stecklina

Hello,

I am trying to port Mini-OS (from xen-3.0.4-testing) to the domain 0 environment. Setting the right flags in x86_32.S and changing the start of the text section to 0xC0100000 enabled it to boot. I expected that most of the Mini-OS's functionality to be working except everything that relied on the Xenbus.

To my surprise there was an error setting up the virtual memory. Here is the console log:

Bootstrapping...
Xen Minimal OS!

start_info:   c0135000
  nr_pages:   26700  shared_inf: 00bed000
  pt_base:    c0136000  mod_start:  0x0
  mod_len:    0
  flags:      0x3
  cmd_line:
  stack:      c0117040-c0119040
MM: Init
  _text:        c0100000
  _etext:       c010a3b4
  _edata:       c010b760
  stack start:  c0117040
  _end:         c0119494
  start_pfn:    3b
  max_pfn:      684c

Mapping memory range 0xc0500000 - 0xc694c000
(XEN) mm.c:1664:d0 Bad type (saw e8000001 != exp 20000000) for mfn 1c3b (pfn 3b) (XEN) mm.c:1960:d0 Error while pinning mfn 1c3b
ERROR: pinning failed
Do_exit called!

The first message from the hypervisor seems very strange. I would be very thankful, if anyone can point to the source of the problem.

Quoted 8 lines

Regards,
Julian

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

extras/mini-os/arch/x86/setup.c +7 -0
diff -r 34ab61cd89bb extras/mini-os/arch/x86/setup.c
@@ -75,6 +75,13 @@ void
 void
 arch_init(start_info_t *si)
 {
+    if(VIRT_START & (L1_PAGETABLE_ENTRIES * PAGE_SIZE - 1))
+    {
+        printk("Virt address space has to start on 4Mb(2Mb for PAE) boundary. "
+               "\nPlease adjust start of the text section. Exiting\n");
+        do_exit();
+    }
+        
 	/* Copy the start_info struct to a globally-accessible area. */
 	/* WARN: don't do printk before here, it uses information from
 	   shared_info. Use xprintk instead. */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 1 line · Grzegorz Milos

Mini-OS assumes that the start of the text section is also the beginning of virtual address space[1]. However, it is generally bad idea not to start virtual address space at 4Mb boundary. The easiest way to fix your problem is to move text to 0xc0000000 or 0xc0400000. More extensive fix, which decouples VIRT_START from &_text is also possible, but I don't see a reason why it would be needed. Instead I've included a runtime check. Keir could you apply the patch?

I changed the beginning of text to 0xC0000000 and the page table setup seems to work, as does the rest of Mini-OS (except XenBus of course). Thank you very much!

Regards,
Julian

#4 lore raw
Quoted 3 lines
Quoted 1 line

Mini-OS assumes that the start of the text section is also the beginning of virtual address space[1]. However, it is generally bad idea not to start virtual address space at 4Mb boundary. The easiest way to fix your problem is to move text to 0xc0000000 or 0xc0400000. More extensive fix, which decouples VIRT_START from &_text is also possible, but I don't see a reason why it would be needed. Instead I've included a runtime check. Keir could you apply the patch?

I changed the beginning of text to 0xC0000000 and the page table setup seems to work, as does the rest of Mini-OS (except XenBus of course). Thank you very much!

There was indeed a XenBus bug, where request structures wouldn't be marked as free (Keir could you apply the attached patch?), however I don't think that's what you are referring to. What problems do you observe?

Cheers
Gregor

extras/mini-os/xenbus/xenbus.c +2 -0
diff -r 34ab61cd89bb extras/mini-os/xenbus/xenbus.c
@@ -178,6 +178,7 @@ static void release_xenbus_id(int id)
     BUG_ON(!req_info[id].in_use);
     spin_lock(&req_lock);
     nr_live_reqs--;
+    req_info[id].in_use = 0;
     if (nr_live_reqs == NR_REQS - 1)
         wake_up(&req_wq);
     spin_unlock(&req_lock);
@@ -212,6 +213,7 @@ static int allocate_xenbus_id(void)
     probe = o_probe + 1;
     spin_unlock(&req_lock);
     init_waitqueue_head(&req_info[o_probe].waitq);
+
     return o_probe;
 }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel