All of lore.kernel.org
 help / color / mirror / Atom feed
* Announcing OpenBSD/amd64 Xen port
@ 2006-06-08  9:48 Mathieu Ropert
  2006-06-09  9:27 ` Keir Fraser
  0 siblings, 1 reply; 4+ messages in thread
From: Mathieu Ropert @ 2006-06-08  9:48 UTC (permalink / raw)
  To: misc, xen-devel, xen-users

Hi,

I've been working toward porting OpenBSD/amd64 for the Xen Virtual 
Machine Monitor for a few months.
It's not 100% complete, but most is already working for domU.

Here's a list of the current issues/missing things:
- virtual NIC driver is not fonctionnal, some part of the code still 
needs to be fixed for packet transfer from/to Xen to work.
- events/clock issue: there seems to be a race condition leading to 
clock not ticking, hence putting system to sleep till a 
keyboard/network/disk interrupt is received.
- SMP is currently not supported.

I'll make a kernel binary, a disk image and sources available shortly.

Regards,
Mathieu

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

* Re: Announcing OpenBSD/amd64 Xen port
  2006-06-08  9:48 Announcing OpenBSD/amd64 Xen port Mathieu Ropert
@ 2006-06-09  9:27 ` Keir Fraser
  2006-06-09  9:54   ` [Xen-devel] " Mathieu Ropert
  2006-06-09 10:57   ` Mathieu Ropert
  0 siblings, 2 replies; 4+ messages in thread
From: Keir Fraser @ 2006-06-09  9:27 UTC (permalink / raw)
  To: Mathieu Ropert; +Cc: misc, xen-devel, xen-users


On 8 Jun 2006, at 10:48, Mathieu Ropert wrote:

> - events/clock issue: there seems to be a race condition leading to 
> clock not ticking, hence putting system to sleep till a 
> keyboard/network/disk interrupt is received.

The ticker doesn't tick when you block. Your idle loop needs to disable 
interrupts, set a one-shot timer, then block. See safe_halt() in our 
Linux source tree (arch/i386/kernel/time-xen.c) -- the function expects 
to be called with interrupts disabled and caller should also have 
already checked for any other threads being runnable.

  -- Keir

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

* Re: [Xen-devel] Announcing OpenBSD/amd64 Xen port
  2006-06-09  9:27 ` Keir Fraser
@ 2006-06-09  9:54   ` Mathieu Ropert
  2006-06-09 10:57   ` Mathieu Ropert
  1 sibling, 0 replies; 4+ messages in thread
From: Mathieu Ropert @ 2006-06-09  9:54 UTC (permalink / raw)
  To: Keir Fraser; +Cc: misc, xen-devel, xen-users

Keir Fraser wrote:

>
> On 8 Jun 2006, at 10:48, Mathieu Ropert wrote:
>
>> - events/clock issue: there seems to be a race condition leading to 
>> clock not ticking, hence putting system to sleep till a 
>> keyboard/network/disk interrupt is received.
>
>
> The ticker doesn't tick when you block. Your idle loop needs to 
> disable interrupts, set a one-shot timer, then block. See safe_halt() 
> in our Linux source tree (arch/i386/kernel/time-xen.c) -- the function 
> expects to be called with interrupts disabled and caller should also 
> have already checked for any other threads being runnable.
>
>  -- Keir
>
Thanks! That solved my issue. Just disabling interrupts before i call my 
idle function did the trick.

Mathieu

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

* Re: Announcing OpenBSD/amd64 Xen port
  2006-06-09  9:27 ` Keir Fraser
  2006-06-09  9:54   ` [Xen-devel] " Mathieu Ropert
@ 2006-06-09 10:57   ` Mathieu Ropert
  1 sibling, 0 replies; 4+ messages in thread
From: Mathieu Ropert @ 2006-06-09 10:57 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1073 bytes --]

Keir Fraser wrote:

>
> On 8 Jun 2006, at 10:48, Mathieu Ropert wrote:
>
>> - events/clock issue: there seems to be a race condition leading to 
>> clock not ticking, hence putting system to sleep till a 
>> keyboard/network/disk interrupt is received.
>
>
> The ticker doesn't tick when you block. Your idle loop needs to 
> disable interrupts, set a one-shot timer, then block. See safe_halt() 
> in our Linux source tree (arch/i386/kernel/time-xen.c) -- the function 
> expects to be called with interrupts disabled and caller should also 
> have already checked for any other threads being runnable.
>
>  -- Keir
>
I've attached  3 patches needed for OpenBSD/amd64 to work. The two first 
address a bug in loadelfsymtab() which load the ELF symbol table at a 
bad address on x86_64. More explanations can be found in one of my older 
posts.
The third is a first try to fix the issue I have with linear pagetables. 
It does fix my issue, and doesn't break my Linux dom0, but besides this 
fact, I have no guarantee. Any feedback or advice would be appreciated.

Mathieu

[-- Attachment #2: xc_loadelfsymtab.patch --]
[-- Type: text/plain, Size: 589 bytes --]

diff -r -bu a/tools/libxc/xc_load_elf.c b/tools/libxc/xc_load_elf.c
--- a/tools/libxc/xc_load_elf.c	2006-06-09 12:32:22.000000000 +0200
+++ b/tools/libxc/xc_load_elf.c	2006-06-09 12:37:04.000000000 +0200
@@ -283,8 +283,9 @@
         return 0;
 
     maxva = (dsi->v_kernend + ELFROUND - 1) & ~(ELFROUND - 1);
-    symva = maxva;
-    maxva += sizeof(int);
+    if (maxva - dsi->v_kernend < sizeof(int))
+        maxva += ELFROUND;
+    symva = maxva - sizeof(int);
     dsi->symtab_addr = maxva;
     dsi->symtab_len = 0;
     maxva += sizeof(Elf_Ehdr) + ehdr->e_shnum * sizeof(Elf_Shdr);

[-- Attachment #3: hypervisor_loadelfsymtab.patch --]
[-- Type: text/plain, Size: 548 bytes --]

diff -r -bu a/xen/common/elf.c b/xen/common/elf.c
--- a/xen/common/elf.c	2006-06-09 12:32:24.000000000 +0200
+++ b/xen/common/elf.c	2006-06-09 12:36:57.000000000 +0200
@@ -185,8 +185,9 @@
         return;
 
     maxva = (dsi->v_kernend + ELFROUND - 1) & ~(ELFROUND - 1);
-    symva = maxva;
-    maxva += sizeof(int);
+    if (maxva - dsi->v_kernend < sizeof(int))
+	    maxva += ELFROUND;
+    symva = maxva - sizeof(int);
     dsi->symtab_addr = maxva;
     dsi->symtab_len = 0;
     maxva += sizeof(Elf_Ehdr) + ehdr->e_shnum * sizeof(Elf_Shdr);

[-- Attachment #4: linear_pagetables.patch --]
[-- Type: text/plain, Size: 6507 bytes --]

diff -r -bu a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c	2006-06-09 12:32:24.000000000 +0200
+++ b/xen/arch/x86/mm.c	2006-06-09 12:41:04.000000000 +0200
@@ -493,7 +493,7 @@
  */
 static int 
 get_linear_pagetable(
-    root_pgentry_t re, unsigned long re_pfn, struct domain *d)
+    pgentry_t re, unsigned long re_pfn, struct domain *d, int level)
 {
     unsigned long x, y;
     struct page_info *page;
@@ -501,13 +501,13 @@
 
     ASSERT( !shadow_mode_refcounts(d) );
 
-    if ( (root_get_flags(re) & _PAGE_RW) )
+    if ( (pgentry_get_flags(re, level) & _PAGE_RW) )
     {
         MEM_LOG("Attempt to create linear p.t. with write perms");
         return 0;
     }
 
-    if ( (pfn = root_get_pfn(re)) != re_pfn )
+    if ( (pfn = pgentry_get_pfn(re, level)) != re_pfn )
     {
         /* Make sure the mapped frame belongs to the correct domain. */
         if ( unlikely(!get_page_from_pagenr(pfn, d)) )
@@ -522,8 +522,7 @@
         do {
             x = y;
             if ( unlikely((x & PGT_count_mask) == PGT_count_mask) ||
-                 unlikely((x & (PGT_type_mask|PGT_validated)) != 
-                          (PGT_root_page_table|PGT_validated)) )
+                 unlikely(!(x & PGT_validated) || !is_ptp(x)))
             {
                 put_page(page);
                 return 0;
@@ -611,9 +610,12 @@
     vaddr <<= PGT_va_shift;
     rc = get_page_and_type_from_pagenr(
         l2e_get_pfn(l2e), PGT_l1_page_table | vaddr, d);
-#if CONFIG_PAGING_LEVELS == 2
-    if ( unlikely(!rc) )
-        rc = get_linear_pagetable(l2e, pfn, d);
+#if CONFIG_PAGING_LEVELS >= 2
+    if ( unlikely(!rc) ) {
+        pgentry_t re;
+        re.l2.l2 = l2e.l2;
+        rc = get_linear_pagetable(re, pfn, d, 2);
+    }
 #endif
     return rc;
 }
@@ -643,6 +645,13 @@
     rc = get_page_and_type_from_pagenr(
         l3e_get_pfn(l3e),
         PGT_l2_page_table | vaddr, d);
+
+    if ( unlikely(!rc) ) {
+        pgentry_t re;
+        re.l3.l3 = l3e.l3;
+        rc = get_linear_pagetable(re, pfn, d, 3);
+    }
+
     return rc;
 }
 #endif /* 3 level */
@@ -672,8 +681,11 @@
         l4e_get_pfn(l4e), 
         PGT_l3_page_table | vaddr, d);
 
-    if ( unlikely(!rc) )
-        rc = get_linear_pagetable(l4e, pfn, d);
+    if ( unlikely(!rc) ) {
+        pgentry_t re;
+        re.l4.l4 = l4e.l4;
+        rc = get_linear_pagetable(re, pfn, d, 4);
+    }	
 
     return rc;
 }
diff -r -bu a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h
--- a/xen/include/asm-x86/page.h	2006-06-09 12:32:24.000000000 +0200
+++ b/xen/include/asm-x86/page.h	2006-06-09 12:44:03.000000000 +0200
@@ -179,6 +179,69 @@
 #define pagetable_from_page(pg) pagetable_from_pfn(page_to_mfn(pg))
 #define pagetable_from_paddr(p) pagetable_from_pfn((p)>>PAGE_SHIFT)
 #define pagetable_null()        pagetable_from_pfn(0)
+
+/* Guest linear PT handling */
+typedef union {
+    l1_pgentry_t l1;
+#if CONFIG_PAGING_LEVELS >= 2
+    l2_pgentry_t l2;
+#if CONFIG_PAGING_LEVELS >= 3
+    l3_pgentry_t l3;
+#if CONFIG_PAGING_LEVELS == 4
+    l4_pgentry_t l4;
+#endif	/* LEVELS == 4 */
+#endif	/* LEVELS >= 3 */
+#endif	/* LEVELS >= 2 */
+} pgentry_t;
+
+static inline intpte_t pgentry_get_flags(pgentry_t p, int level)
+{
+    switch (level)
+    {
+    case 1:
+        return l1e_get_flags(p.l1);
+#if CONFIG_PAGING_LEVELS >= 2
+    case 2:
+        return l2e_get_flags(p.l2);
+#if CONFIG_PAGING_LEVELS >= 3
+    case 3:
+        return l3e_get_flags(p.l3);
+#if CONFIG_PAGING_LEVELS == 4
+    case 4:
+        return l4e_get_flags(p.l4);
+#endif	/* LEVELS == 4 */
+#endif	/* LEVELS >= 3 */
+#endif	/* LEVELS >= 2 */
+    default:
+        /* should not happen */
+        return 0;
+    }
+}
+
+static inline intpte_t pgentry_get_pfn(pgentry_t p, int level)
+{
+    switch (level)
+    {
+    case 1:
+        return l1e_get_pfn(p.l1);
+#if CONFIG_PAGING_LEVELS >= 2
+    case 2:
+        return l2e_get_pfn(p.l2);
+#if CONFIG_PAGING_LEVELS >= 3
+    case 3:
+        return l3e_get_pfn(p.l3);
+#if CONFIG_PAGING_LEVELS == 4
+    case 4:
+        return l4e_get_pfn(p.l4);
+#endif	/* LEVELS == 4 */
+#endif	/* LEVELS >= 3 */
+#endif	/* LEVELS >= 2 */
+    default:
+        /* should not happen */
+        return 0;
+    }
+}
+
 #endif
 
 #define clear_page(_p)      memset((void *)(_p), 0, PAGE_SIZE)
diff -r -bu a/xen/include/asm-x86/x86_32/page-2level.h b/xen/include/asm-x86/x86_32/page-2level.h
--- a/xen/include/asm-x86/x86_32/page-2level.h	2006-06-09 12:32:24.000000000 +0200
+++ b/xen/include/asm-x86/x86_32/page-2level.h	2006-06-09 12:37:10.000000000 +0200
@@ -28,6 +28,11 @@
 
 #endif /* !__ASSEMBLY__ */
 
+/* Check if page type is page table (any level) */
+#define is_ptp(x)                                   \
+        ((x & PGT_type_mask) == PGT_l1_page_table   \
+        || (x & PGT_type_mask) == PGT_l2_page_table)
+
 /* root table */
 #define root_get_pfn              l2e_get_pfn
 #define root_get_flags            l2e_get_flags
diff -r -bu a/xen/include/asm-x86/x86_32/page-3level.h b/xen/include/asm-x86/x86_32/page-3level.h
--- a/xen/include/asm-x86/x86_32/page-3level.h	2006-06-09 12:32:24.000000000 +0200
+++ b/xen/include/asm-x86/x86_32/page-3level.h	2006-06-09 12:37:10.000000000 +0200
@@ -38,6 +38,12 @@
 
 #endif /* !__ASSEMBLY__ */
 
+/* Check if page type is page table (any level) */
+#define is_ptp(x)                                   \
+        ((x & PGT_type_mask) == PGT_l1_page_table   \
+        || (x & PGT_type_mask) == PGT_l2_page_table \
+        || (x & PGT_type_mask) == PGT_l3_page_table)
+
 /* root table */
 #define root_get_pfn              l3e_get_pfn
 #define root_get_flags            l3e_get_flags
diff -r -bu a/xen/include/asm-x86/x86_64/page.h b/xen/include/asm-x86/x86_64/page.h
--- a/xen/include/asm-x86/x86_64/page.h	2006-06-09 12:32:24.000000000 +0200
+++ b/xen/include/asm-x86/x86_64/page.h	2006-06-09 12:37:10.000000000 +0200
@@ -41,6 +41,13 @@
 
 #endif /* !__ASSEMBLY__ */
 
+/* Check if page type is page table (any level) */
+#define is_ptp(x)                                   \
+        ((x & PGT_type_mask) == PGT_l1_page_table   \
+        || (x & PGT_type_mask) == PGT_l2_page_table \
+        || (x & PGT_type_mask) == PGT_l3_page_table \
+        || (x & PGT_type_mask) == PGT_l4_page_table)
+
 /* Given a virtual address, get an entry offset into a linear page table. */
 #define l1_linear_offset(_a) (((_a) & VADDR_MASK) >> L1_PAGETABLE_SHIFT)
 #define l2_linear_offset(_a) (((_a) & VADDR_MASK) >> L2_PAGETABLE_SHIFT)

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

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

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

end of thread, other threads:[~2006-06-09 10:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-08  9:48 Announcing OpenBSD/amd64 Xen port Mathieu Ropert
2006-06-09  9:27 ` Keir Fraser
2006-06-09  9:54   ` [Xen-devel] " Mathieu Ropert
2006-06-09 10:57   ` Mathieu Ropert

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.