* [PATCH] FreeBSD 64-bit kernel support
@ 2009-04-12 19:19 Bean
2009-04-12 19:26 ` phcoder
` (3 more replies)
0 siblings, 4 replies; 25+ messages in thread
From: Bean @ 2009-04-12 19:19 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 272 bytes --]
Hi,
This patch allows you to load amd64 freebsd kernel directly, here is an example:
set root=(hd0,1,a)
freebsd /boot/kernel/kernel
freebsd_loadenv /boot/device.hints
set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s1a
boot
Test successfully on FreeBSD 7.1 amd64.
--
Bean
[-- Attachment #2: bsd64.diff --]
[-- Type: text/x-patch, Size: 10650 bytes --]
diff --git a/include/grub/i386/bsd.h b/include/grub/i386/bsd.h
index f50f18e..f784d6a 100644
--- a/include/grub/i386/bsd.h
+++ b/include/grub/i386/bsd.h
@@ -80,9 +80,12 @@
#define FREEBSD_MODINFOMD_SHDR 0x0009 /* section header table */
#define FREEBSD_MODINFOMD_NOCOPY 0x8000 /* don't copy this metadata to the kernel */
+#define FREEBSD_MODINFOMD_SMAP 0x1001
+
#define FREEBSD_MODINFOMD_DEPLIST (0x4001 | FREEBSD_MODINFOMD_NOCOPY) /* depends on */
#define FREEBSD_MODTYPE_KERNEL "elf kernel"
+#define FREEBSD_MODTYPE_KERNEL64 "elf64 kernel"
#define FREEBSD_MODTYPE_MODULE "elf module"
#define FREEBSD_MODTYPE_RAW "raw"
diff --git a/include/grub/i386/loader.h b/include/grub/i386/loader.h
index afd3eb9..4d5a913 100644
--- a/include/grub/i386/loader.h
+++ b/include/grub/i386/loader.h
@@ -35,4 +35,7 @@ grub_err_t EXPORT_FUNC(grub_linux16_boot) (void);
void EXPORT_FUNC(grub_unix_real_boot) (grub_addr_t entry, ...)
__attribute__ ((cdecl,noreturn));
+void EXPORT_FUNC(grub_bsd64_boot) (grub_addr_t entry, ...)
+ __attribute__ ((cdecl,noreturn));
+
#endif /* ! GRUB_LOADER_CPU_HEADER */
diff --git a/kern/i386/bsd64.S b/kern/i386/bsd64.S
new file mode 100644
index 0000000..7a49d0b
--- /dev/null
+++ b/kern/i386/bsd64.S
@@ -0,0 +1,93 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * GRUB is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GRUB is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define MSR_EFER 0xc0000080
+#define EFER_LME 0x00000100
+#define CR4_PAE 0x00000020
+#define CR4_PSE 0x00000010
+#define CR0_PG 0x80000000
+
+ .p2align 2
+
+bsd64_gdt:
+ .long 0
+ .long 0
+ .long 0x00000000
+ .long 0x00209800
+ .long 0x00000000
+ .long 0x00008000
+bsd64_gdtend:
+
+bsd64_gdtdesc:
+ .word bsd64_gdtend - bsd64_gdt
+ .long bsd64_gdt
+
+
+FUNCTION(grub_bsd64_boot)
+
+ call EXT_C(grub_dl_unload_all)
+
+ /* Discard `grub_unix_real_boot' return address. */
+ popl %eax
+
+ /* entry */
+ popl %edi
+
+ /* entry_hi */
+ popl %esi
+
+ cli
+
+ /* Turn on EFER.LME. */
+ movl $MSR_EFER, %ecx
+ rdmsr
+ orl $EFER_LME, %eax
+ wrmsr
+
+ /* Turn on PAE. */
+ movl %cr4, %eax
+ orl $(CR4_PAE | CR4_PSE), %eax
+ movl %eax, %cr4
+
+ /* Set %cr3 for PT4. */
+ popl %eax
+ movl %eax, %cr3
+
+ /* Push a dummy return address. */
+ pushl %eax
+
+ /* Turn on paging (implicitly sets EFER.LMA). */
+ movl %cr0, %eax
+ orl $CR0_PG, %eax
+ movl %eax, %cr0
+
+ /* Now we're in compatability mode. set %cs for long mode. */
+ lgdt bsd64_gdtdesc
+ ljmp $0x8, $ABS(bsd64_longmode)
+
+ .code64
+
+bsd64_longmode:
+ /* We're still running V=P, jump to entry point. */
+ movl %esi, %eax
+ salq $32, %rax
+ orq %rdi, %rax
+ pushq %rax
+ ret
+
+ .code32
diff --git a/kern/i386/pc/startup.S b/kern/i386/pc/startup.S
index 8e8b661..e0e2caf 100644
--- a/kern/i386/pc/startup.S
+++ b/kern/i386/pc/startup.S
@@ -650,6 +650,8 @@ FUNCTION(grub_chainloader_real_boot)
#include "../loader.S"
+#include "../bsd64.S"
+
/*
* int grub_biosdisk_rw_int13_extensions (int ah, int drive, void *dap)
*
diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c
index 355cb3f..7a4b474 100644
--- a/loader/i386/bsd.c
+++ b/loader/i386/bsd.c
@@ -33,17 +33,19 @@
#include <grub/command.h>
#define ALIGN_DWORD(a) ALIGN_UP (a, 4)
+#define ALIGN_QWORD(a) ALIGN_UP (a, 8)
+#define ALIGN_VAR(a) ((is_64bit) ? (ALIGN_QWORD(a)) : (ALIGN_DWORD(a)))
#define ALIGN_PAGE(a) ALIGN_UP (a, 4096)
#define MOD_BUF_ALLOC_UNIT 4096
static int kernel_type;
static grub_dl_t my_mod;
-static grub_addr_t entry, kern_start, kern_end;
+static grub_addr_t entry, entry_hi, kern_start, kern_end;
static grub_uint32_t bootflags;
static char *mod_buf;
-static grub_uint32_t mod_buf_len, mod_buf_max;
-static int is_elf_kernel;
+static grub_uint32_t mod_buf_len, mod_buf_max, kern_end_mdofs;
+static int is_elf_kernel, is_64bit;
static const char freebsd_opts[] = "DhaCcdgmnpqrsv";
static const grub_uint32_t freebsd_flags[] =
@@ -135,11 +137,58 @@ grub_freebsd_add_meta (grub_uint32_t type, void *data, grub_uint32_t len)
if (len)
grub_memcpy (mod_buf + mod_buf_len, data, len);
- mod_buf_len = ALIGN_DWORD (mod_buf_len + len);
+ mod_buf_len = ALIGN_VAR (mod_buf_len + len);
return GRUB_ERR_NONE;
}
+struct grub_e820_mmap
+{
+ grub_uint64_t addr;
+ grub_uint64_t size;
+ grub_uint32_t type;
+} __attribute__((packed));
+
+static grub_err_t
+grub_freebsd_add_mmap (void)
+{
+ grub_size_t len = 0;
+ struct grub_e820_mmap *mmap = 0;
+
+ auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t);
+ int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size,
+ grub_uint32_t type)
+ {
+ if (mmap)
+ {
+ mmap->addr = addr;
+ mmap->size = size;
+ mmap->type = type;
+ mmap++;
+ }
+ else
+ len += sizeof (struct grub_e820_mmap);
+
+ return 0;
+ }
+
+ struct grub_e820_mmap *mmap_buf;
+
+ grub_machine_mmap_iterate (hook);
+ mmap_buf = mmap = grub_malloc (len);
+ if (! mmap)
+ return grub_errno;
+
+ grub_machine_mmap_iterate (hook);
+
+ grub_freebsd_add_meta (FREEBSD_MODINFO_METADATA |
+ FREEBSD_MODINFOMD_SMAP, mmap_buf, len);
+
+ grub_free (mmap_buf);
+
+ return grub_errno;
+}
+
static grub_err_t
grub_freebsd_add_meta_module (int is_kern, int argc, char **argv,
grub_addr_t addr, grub_uint32_t size)
@@ -166,7 +215,9 @@ grub_freebsd_add_meta_module (int is_kern, int argc, char **argv,
argv++;
}
else
- type = (is_kern) ? FREEBSD_MODTYPE_KERNEL : FREEBSD_MODTYPE_RAW;
+ type = ((is_kern) ?
+ ((is_64bit) ? FREEBSD_MODTYPE_KERNEL64 : FREEBSD_MODTYPE_KERNEL)
+ : FREEBSD_MODTYPE_RAW);
if ((grub_freebsd_add_meta (FREEBSD_MODINFO_TYPE, type,
grub_strlen (type) + 1)) ||
@@ -202,6 +253,23 @@ grub_freebsd_add_meta_module (int is_kern, int argc, char **argv,
}
}
+ if (is_kern)
+ {
+ int len = (is_64bit) ? 8 : 4;
+ grub_uint64_t data = 0;
+
+ if ((grub_freebsd_add_meta (FREEBSD_MODINFO_METADATA |
+ FREEBSD_MODINFOMD_HOWTO, &data, 4)) ||
+ (grub_freebsd_add_meta (FREEBSD_MODINFO_METADATA |
+ FREEBSD_MODINFOMD_ENVP, &data, len)) ||
+ (grub_freebsd_add_meta (FREEBSD_MODINFO_METADATA |
+ FREEBSD_MODINFOMD_KERNEND, &data, len)))
+ return grub_errno;
+ kern_end_mdofs = mod_buf_len - len;
+
+ return grub_freebsd_add_mmap ();
+ }
+
return GRUB_ERR_NONE;
}
@@ -241,7 +309,7 @@ grub_freebsd_list_modules (void)
}
}
- pos = ALIGN_DWORD (pos + size);
+ pos = ALIGN_VAR (pos + size);
}
}
@@ -291,6 +359,9 @@ grub_freebsd_boot (void)
if (is_elf_kernel)
{
+ grub_addr_t md_ofs;
+ int ofs;
+
if (grub_freebsd_add_meta (FREEBSD_MODINFO_END, 0, 0))
return grub_errno;
@@ -298,12 +369,61 @@ grub_freebsd_boot (void)
bi.bi_modulep = kern_end;
kern_end = ALIGN_PAGE (kern_end + mod_buf_len);
+
+ if (is_64bit)
+ kern_end += 4096 * 3;
+
+ md_ofs = bi.bi_modulep + kern_end_mdofs;
+ ofs = (is_64bit) ? 16 : 12;
+ *((grub_uint32_t *) md_ofs) = kern_end;
+ md_ofs -= ofs;
+ *((grub_uint32_t *) md_ofs) = bi.bi_envp;
+ md_ofs -= ofs;
+ *((grub_uint32_t *) md_ofs) = bootflags;
}
bi.bi_kernend = kern_end;
- grub_unix_real_boot (entry, bootflags | FREEBSD_RB_BOOTINFO, bootdev,
- 0, 0, 0, &bi, bi.bi_modulep, kern_end);
+ if (is_64bit)
+ {
+ int i;
+ grub_uint64_t *pt2, *pt3, *pt4;
+
+#define PG_V 0x001
+#define PG_RW 0x002
+#define PG_U 0x004
+#define PG_PS 0x080
+
+ pt4 = (grub_uint64_t *) (kern_end - 12288);
+ pt3 = (grub_uint64_t *) (kern_end - 8192);
+ pt2 = (grub_uint64_t *) (kern_end - 4096);
+
+ grub_memset ((char *) pt4, 0, 4096 * 3);
+
+ /*
+ * This is kinda brutal, but every single 1GB VM memory segment points to
+ * the same first 1GB of physical memory. But it is more than adequate.
+ */
+ for (i = 0; i < 512; i++)
+ {
+ /* Each slot of the level 4 pages points to the same level 3 page */
+ pt4[i] = (grub_addr_t) &pt3[0];
+ pt4[i] |= PG_V | PG_RW | PG_U;
+
+ /* Each slot of the level 3 pages points to the same level 2 page */
+ pt3[i] = (grub_addr_t) &pt2[0];
+ pt3[i] |= PG_V | PG_RW | PG_U;
+
+ /* The level 2 page slots are mapped with 2MB pages for 1GB. */
+ pt2[i] = i * (2 * 1024 * 1024);
+ pt2[i] |= PG_V | PG_RW | PG_PS | PG_U;
+ }
+
+ grub_bsd64_boot (entry, entry_hi, pt4, bi.bi_modulep, kern_end);
+ }
+ else
+ grub_unix_real_boot (entry, bootflags | FREEBSD_RB_BOOTINFO, bootdev,
+ 0, 0, 0, &bi, bi.bi_modulep, kern_end);
/* Not reached. */
return GRUB_ERR_NONE;
@@ -478,6 +598,29 @@ grub_bsd_elf32_hook (Elf32_Phdr * phdr, grub_addr_t * addr)
}
static grub_err_t
+grub_bsd_elf64_hook (Elf64_Phdr * phdr, grub_addr_t * addr)
+{
+ Elf64_Addr paddr;
+
+ paddr = phdr->p_paddr & 0xffffff;
+
+ if ((paddr < grub_os_area_addr)
+ || (paddr + phdr->p_memsz > grub_os_area_addr + grub_os_area_size))
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, "Address 0x%x is out of range",
+ paddr);
+
+ if ((!kern_start) || (paddr < kern_start))
+ kern_start = paddr;
+
+ if (paddr + phdr->p_memsz > kern_end)
+ kern_end = paddr + phdr->p_memsz;
+
+ *addr = paddr;
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_err_t
grub_bsd_load_elf (grub_elf_t elf)
{
kern_start = kern_end = 0;
@@ -487,6 +630,13 @@ grub_bsd_load_elf (grub_elf_t elf)
entry = elf->ehdr.ehdr32.e_entry & 0xFFFFFF;
return grub_elf32_load (elf, grub_bsd_elf32_hook, 0, 0);
}
+ else if (grub_elf_is_elf64 (elf))
+ {
+ is_64bit = 1;
+ entry = elf->ehdr.ehdr64.e_entry & 0xffffffff;
+ entry_hi = (elf->ehdr.ehdr64.e_entry >> 32) & 0xffffffff;
+ return grub_elf64_load (elf, grub_bsd_elf64_hook, 0, 0);
+ }
else
return grub_error (GRUB_ERR_BAD_OS, "invalid elf");
}
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-12 19:19 [PATCH] FreeBSD 64-bit kernel support Bean @ 2009-04-12 19:26 ` phcoder 2009-04-12 19:29 ` phcoder 2009-04-13 1:27 ` phcoder ` (2 subsequent siblings) 3 siblings, 1 reply; 25+ messages in thread From: phcoder @ 2009-04-12 19:26 UTC (permalink / raw) To: The development of GRUB 2 Hello, you were faster than me. I will test it today. However I would suggest to move all asm stuff to bsd.mod and not in the kernel. Look my patch "move bsd helpers out of kernel" Bean wrote: > Hi, > > This patch allows you to load amd64 freebsd kernel directly, here is an example: > > set root=(hd0,1,a) > freebsd /boot/kernel/kernel > freebsd_loadenv /boot/device.hints > set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s1a > boot > > Test successfully on FreeBSD 7.1 amd64. > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel -- Regards Vladimir 'phcoder' Serbinenko ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-12 19:26 ` phcoder @ 2009-04-12 19:29 ` phcoder 0 siblings, 0 replies; 25+ messages in thread From: phcoder @ 2009-04-12 19:29 UTC (permalink / raw) To: The development of GRUB 2 Also asm helpers are verbatim copy from bsd so the copyright line is probably incorrect phcoder wrote: > Hello, you were faster than me. I will test it today. However I would > suggest to move all asm stuff to bsd.mod and not in the kernel. Look my > patch "move bsd helpers out of kernel" > Bean wrote: >> Hi, >> >> This patch allows you to load amd64 freebsd kernel directly, here is >> an example: >> >> set root=(hd0,1,a) >> freebsd /boot/kernel/kernel >> freebsd_loadenv /boot/device.hints >> set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s1a >> boot >> >> Test successfully on FreeBSD 7.1 amd64. >> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Grub-devel mailing list >> Grub-devel@gnu.org >> http://lists.gnu.org/mailman/listinfo/grub-devel > > -- Regards Vladimir 'phcoder' Serbinenko ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-12 19:19 [PATCH] FreeBSD 64-bit kernel support Bean 2009-04-12 19:26 ` phcoder @ 2009-04-13 1:27 ` phcoder 2009-04-13 2:26 ` Chip Panarchy 2009-04-13 5:33 ` Joey Korkames 2009-04-21 21:10 ` Vladimir Serbinenko 2009-05-03 9:13 ` Vladimir 'phcoder' Serbinenko 3 siblings, 2 replies; 25+ messages in thread From: phcoder @ 2009-04-13 1:27 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 863 bytes --] Bean kindly allowed me to mess with this patch. So here comes an improved version. I moved helpers out of the kernels. Because of how FreeBSD expects the initial virtual memory mapping only first GB of physical memory is accessible so it was required to use of trampoline technique. Bean wrote: > Hi, > > This patch allows you to load amd64 freebsd kernel directly, here is an example: > > set root=(hd0,1,a) > freebsd /boot/kernel/kernel > freebsd_loadenv /boot/device.hints > set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s1a > boot > > Test successfully on FreeBSD 7.1 amd64. > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel -- Regards Vladimir 'phcoder' Serbinenko [-- Attachment #2: bsd64.diff --] [-- Type: text/x-diff, Size: 14034 bytes --] diff --git a/DISTLIST b/DISTLIST index bec628e..eefa982 100644 --- a/DISTLIST +++ b/DISTLIST @@ -400,6 +400,7 @@ loader/multiboot_loader.c loader/efi/appleloader.c loader/efi/chainloader.c loader/i386/bsd.c +loader/i386/bsd_helper.S loader/i386/linux.c loader/i386/multiboot.c loader/i386/multiboot_elfxx.c diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 7dfb854..311551a 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -295,9 +295,10 @@ aout_mod_CFLAGS = $(COMMON_CFLAGS) aout_mod_LDFLAGS = $(COMMON_LDFLAGS) # For bsd.mod -bsd_mod_SOURCES = loader/i386/bsd.c +bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd_helper.S bsd_mod_CFLAGS = $(COMMON_CFLAGS) bsd_mod_LDFLAGS = $(COMMON_LDFLAGS) +bsd_mod_ASFLAGS = $(COMMON_ASFLAGS) # For usb.mod usb_mod_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c diff --git a/include/grub/i386/bsd.h b/include/grub/i386/bsd.h index f50f18e..3706f4d 100644 --- a/include/grub/i386/bsd.h +++ b/include/grub/i386/bsd.h @@ -80,9 +80,12 @@ #define FREEBSD_MODINFOMD_SHDR 0x0009 /* section header table */ #define FREEBSD_MODINFOMD_NOCOPY 0x8000 /* don't copy this metadata to the kernel */ +#define FREEBSD_MODINFOMD_SMAP 0x1001 + #define FREEBSD_MODINFOMD_DEPLIST (0x4001 | FREEBSD_MODINFOMD_NOCOPY) /* depends on */ #define FREEBSD_MODTYPE_KERNEL "elf kernel" +#define FREEBSD_MODTYPE_KERNEL64 "elf64 kernel" #define FREEBSD_MODTYPE_MODULE "elf module" #define FREEBSD_MODTYPE_RAW "raw" @@ -222,4 +225,11 @@ struct grub_netbsd_btinfo_bootdisk int partition; }; +void grub_unix_real_boot (grub_addr_t entry, ...) + __attribute__ ((cdecl,noreturn)); + +extern grub_uint8_t grub_bsd64_trampoline_start, grub_bsd64_trampoline_end; +extern grub_uint32_t grub_bsd64_trampoline_selfjump; +extern grub_uint32_t grub_bsd64_trampoline_gdt; + #endif /* ! GRUB_BSD_CPU_HEADER */ diff --git a/include/grub/i386/loader.h b/include/grub/i386/loader.h index afd3eb9..72a44d0 100644 --- a/include/grub/i386/loader.h +++ b/include/grub/i386/loader.h @@ -32,7 +32,4 @@ extern grub_size_t EXPORT_VAR(grub_os_area_size); grub_err_t EXPORT_FUNC(grub_linux16_boot) (void); -void EXPORT_FUNC(grub_unix_real_boot) (grub_addr_t entry, ...) - __attribute__ ((cdecl,noreturn)); - #endif /* ! GRUB_LOADER_CPU_HEADER */ diff --git a/kern/i386/loader.S b/kern/i386/loader.S index bbd2187..3e9c713 100644 --- a/kern/i386/loader.S +++ b/kern/i386/loader.S @@ -118,25 +118,3 @@ linux_setup_seg: .word 0 .code32 -/* - * Use cdecl calling convention for *BSD kernels. - */ - -FUNCTION(grub_unix_real_boot) - - call EXT_C(grub_dl_unload_all) - - /* Interrupts should be disabled. */ - cli - - /* Discard `grub_unix_real_boot' return address. */ - popl %eax - - /* Fetch `entry' address ... */ - popl %eax - - /* - * ... and put our return address in its place. The kernel will - * ignore it, but it expects %esp to point to it. - */ - call *%eax diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 355cb3f..8c59c1b 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -33,17 +33,19 @@ #include <grub/command.h> #define ALIGN_DWORD(a) ALIGN_UP (a, 4) +#define ALIGN_QWORD(a) ALIGN_UP (a, 8) +#define ALIGN_VAR(a) ((is_64bit) ? (ALIGN_QWORD(a)) : (ALIGN_DWORD(a))) #define ALIGN_PAGE(a) ALIGN_UP (a, 4096) #define MOD_BUF_ALLOC_UNIT 4096 static int kernel_type; static grub_dl_t my_mod; -static grub_addr_t entry, kern_start, kern_end; +static grub_addr_t entry, entry_hi, kern_start, kern_end; static grub_uint32_t bootflags; static char *mod_buf; -static grub_uint32_t mod_buf_len, mod_buf_max; -static int is_elf_kernel; +static grub_uint32_t mod_buf_len, mod_buf_max, kern_end_mdofs; +static int is_elf_kernel, is_64bit; static const char freebsd_opts[] = "DhaCcdgmnpqrsv"; static const grub_uint32_t freebsd_flags[] = @@ -135,11 +137,58 @@ grub_freebsd_add_meta (grub_uint32_t type, void *data, grub_uint32_t len) if (len) grub_memcpy (mod_buf + mod_buf_len, data, len); - mod_buf_len = ALIGN_DWORD (mod_buf_len + len); + mod_buf_len = ALIGN_VAR (mod_buf_len + len); return GRUB_ERR_NONE; } +struct grub_e820_mmap +{ + grub_uint64_t addr; + grub_uint64_t size; + grub_uint32_t type; +} __attribute__((packed)); + +static grub_err_t +grub_freebsd_add_mmap (void) +{ + grub_size_t len = 0; + struct grub_e820_mmap *mmap = 0; + + auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t); + int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, + grub_uint32_t type) + { + if (mmap) + { + mmap->addr = addr; + mmap->size = size; + mmap->type = type; + mmap++; + } + else + len += sizeof (struct grub_e820_mmap); + + return 0; + } + + struct grub_e820_mmap *mmap_buf; + + grub_machine_mmap_iterate (hook); + mmap_buf = mmap = grub_malloc (len); + if (! mmap) + return grub_errno; + + grub_machine_mmap_iterate (hook); + + grub_freebsd_add_meta (FREEBSD_MODINFO_METADATA | + FREEBSD_MODINFOMD_SMAP, mmap_buf, len); + + grub_free (mmap_buf); + + return grub_errno; +} + static grub_err_t grub_freebsd_add_meta_module (int is_kern, int argc, char **argv, grub_addr_t addr, grub_uint32_t size) @@ -166,7 +215,9 @@ grub_freebsd_add_meta_module (int is_kern, int argc, char **argv, argv++; } else - type = (is_kern) ? FREEBSD_MODTYPE_KERNEL : FREEBSD_MODTYPE_RAW; + type = ((is_kern) ? + ((is_64bit) ? FREEBSD_MODTYPE_KERNEL64 : FREEBSD_MODTYPE_KERNEL) + : FREEBSD_MODTYPE_RAW); if ((grub_freebsd_add_meta (FREEBSD_MODINFO_TYPE, type, grub_strlen (type) + 1)) || @@ -202,6 +253,23 @@ grub_freebsd_add_meta_module (int is_kern, int argc, char **argv, } } + if (is_kern) + { + int len = (is_64bit) ? 8 : 4; + grub_uint64_t data = 0; + + if ((grub_freebsd_add_meta (FREEBSD_MODINFO_METADATA | + FREEBSD_MODINFOMD_HOWTO, &data, 4)) || + (grub_freebsd_add_meta (FREEBSD_MODINFO_METADATA | + FREEBSD_MODINFOMD_ENVP, &data, len)) || + (grub_freebsd_add_meta (FREEBSD_MODINFO_METADATA | + FREEBSD_MODINFOMD_KERNEND, &data, len))) + return grub_errno; + kern_end_mdofs = mod_buf_len - len; + + return grub_freebsd_add_mmap (); + } + return GRUB_ERR_NONE; } @@ -241,10 +309,16 @@ grub_freebsd_list_modules (void) } } - pos = ALIGN_DWORD (pos + size); + pos = ALIGN_VAR (pos + size); } } +struct gdt_descriptor +{ + grub_uint16_t limit; + void *base; +} __attribute__ ((packed)); + static grub_err_t grub_freebsd_boot (void) { @@ -291,6 +365,9 @@ grub_freebsd_boot (void) if (is_elf_kernel) { + grub_addr_t md_ofs; + int ofs; + if (grub_freebsd_add_meta (FREEBSD_MODINFO_END, 0, 0)) return grub_errno; @@ -298,12 +375,98 @@ grub_freebsd_boot (void) bi.bi_modulep = kern_end; kern_end = ALIGN_PAGE (kern_end + mod_buf_len); + + if (is_64bit) + kern_end += 4096 * 4; + + md_ofs = bi.bi_modulep + kern_end_mdofs; + ofs = (is_64bit) ? 16 : 12; + *((grub_uint32_t *) md_ofs) = kern_end; + md_ofs -= ofs; + *((grub_uint32_t *) md_ofs) = bi.bi_envp; + md_ofs -= ofs; + *((grub_uint32_t *) md_ofs) = bootflags; } bi.bi_kernend = kern_end; - grub_unix_real_boot (entry, bootflags | FREEBSD_RB_BOOTINFO, bootdev, - 0, 0, 0, &bi, bi.bi_modulep, kern_end); + if (is_64bit) + { + int i; + grub_uint64_t *pt2, *pt3, *pt4; + grub_uint32_t *gdt; + grub_uint8_t *trampoline; + void (*launch_trampoline) (grub_addr_t entry, ...) + __attribute__ ((cdecl, regparm (0))); + + struct gdt_descriptor *gdtdesc; + +#define PG_V 0x001 +#define PG_RW 0x002 +#define PG_U 0x004 +#define PG_PS 0x080 + + pt4 = (grub_uint64_t *) (kern_end - 16384); + pt3 = (grub_uint64_t *) (kern_end - 12288); + pt2 = (grub_uint64_t *) (kern_end - 8192); + + grub_memset ((char *) pt4, 0, 4096 * 3); + + /* + * This is kinda brutal, but every single 1GB VM memory segment points to + * the same first 1GB of physical memory. But it is how BSD expects + * it to be. + */ + for (i = 0; i < 512; i++) + { + /* Each slot of the level 4 pages points to the same level 3 page */ + pt4[i] = (grub_addr_t) &pt3[0]; + pt4[i] |= PG_V | PG_RW | PG_U; + + /* Each slot of the level 3 pages points to the same level 2 page */ + pt3[i] = (grub_addr_t) &pt2[0]; + pt3[i] |= PG_V | PG_RW | PG_U; + + /* The level 2 page slots are mapped with 2MB pages for 1GB. */ + pt2[i] = i * (2 * 1024 * 1024); + pt2[i] |= PG_V | PG_RW | PG_PS | PG_U; + } + + /* Create GDT. */ + gdt = (grub_uint32_t *) (kern_end - 4096); + gdt[0] = 0; + gdt[1] = 0; + gdt[2] = 0x00000000; + gdt[3] = 0x00209800; + gdt[4] = 0x00000000; + gdt[5] = 0x00008000; + + /* Create GDT descriptor. */ + gdtdesc = (struct gdt_descriptor *) (kern_end - 4096 + 24); + gdtdesc->limit = 24; + gdtdesc->base = gdt; + + /* Prepare trampoline. */ + trampoline = (grub_uint8_t *) (kern_end - 4096 + 24 + + sizeof (struct gdt_descriptor)); + launch_trampoline = (void __attribute__ ((cdecl, regparm (0))) + (*) (grub_addr_t entry, ...)) trampoline; + grub_bsd64_trampoline_gdt = (grub_uint32_t) gdtdesc; + grub_bsd64_trampoline_selfjump + = (grub_uint32_t) (trampoline + 6 + + ((grub_uint8_t *) &grub_bsd64_trampoline_selfjump + - &grub_bsd64_trampoline_start)); + + /* Prepare trampoline. */ + grub_memcpy (trampoline, &grub_bsd64_trampoline_start, + &grub_bsd64_trampoline_end - &grub_bsd64_trampoline_start); + + /* Launch trampoline. */ + launch_trampoline (entry, entry_hi, pt4, bi.bi_modulep, kern_end); + } + else + grub_unix_real_boot (entry, bootflags | FREEBSD_RB_BOOTINFO, bootdev, + 0, 0, 0, &bi, bi.bi_modulep, kern_end); /* Not reached. */ return GRUB_ERR_NONE; @@ -478,6 +641,29 @@ grub_bsd_elf32_hook (Elf32_Phdr * phdr, grub_addr_t * addr) } static grub_err_t +grub_bsd_elf64_hook (Elf64_Phdr * phdr, grub_addr_t * addr) +{ + Elf64_Addr paddr; + + paddr = phdr->p_paddr & 0xffffff; + + if ((paddr < grub_os_area_addr) + || (paddr + phdr->p_memsz > grub_os_area_addr + grub_os_area_size)) + return grub_error (GRUB_ERR_OUT_OF_RANGE, "Address 0x%x is out of range", + paddr); + + if ((!kern_start) || (paddr < kern_start)) + kern_start = paddr; + + if (paddr + phdr->p_memsz > kern_end) + kern_end = paddr + phdr->p_memsz; + + *addr = paddr; + + return GRUB_ERR_NONE; +} + +static grub_err_t grub_bsd_load_elf (grub_elf_t elf) { kern_start = kern_end = 0; @@ -487,6 +673,13 @@ grub_bsd_load_elf (grub_elf_t elf) entry = elf->ehdr.ehdr32.e_entry & 0xFFFFFF; return grub_elf32_load (elf, grub_bsd_elf32_hook, 0, 0); } + else if (grub_elf_is_elf64 (elf)) + { + is_64bit = 1; + entry = elf->ehdr.ehdr64.e_entry & 0xffffffff; + entry_hi = (elf->ehdr.ehdr64.e_entry >> 32) & 0xffffffff; + return grub_elf64_load (elf, grub_bsd_elf64_hook, 0, 0); + } else return grub_error (GRUB_ERR_BAD_OS, "invalid elf"); } diff --git a/loader/i386/bsd_helper.S b/loader/i386/bsd_helper.S new file mode 100644 index 0000000..2ed0f50 --- /dev/null +++ b/loader/i386/bsd_helper.S @@ -0,0 +1,114 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see <http://www.gnu.org/licenses/>. + */ + +#define MSR_EFER 0xc0000080 +#define EFER_LME 0x00000100 +#define CR4_PAE 0x00000020 +#define CR4_PSE 0x00000010 +#define CR0_PG 0x80000000 + +#include <grub/symbol.h> + + .p2align 2 + + + .code32 + +VARIABLE(grub_bsd64_trampoline_start) + + /* Discard `grub_unix_real_boot' return address. */ + popl %eax + + /* entry */ + popl %edi + + /* entry_hi */ + popl %esi + + cli + + /* Turn on EFER.LME. */ + movl $MSR_EFER, %ecx + rdmsr + orl $EFER_LME, %eax + wrmsr + + /* Turn on PAE. */ + movl %cr4, %eax + orl $(CR4_PAE | CR4_PSE), %eax + movl %eax, %cr4 + + /* Set %cr3 for PT4. */ + popl %eax + movl %eax, %cr3 + + /* Push a dummy return address. */ + pushl %eax + + /* Turn on paging (implicitly sets EFER.LMA). */ + movl %cr0, %eax + orl $CR0_PG, %eax + movl %eax, %cr0 + + /* Now we're in compatability mode. set %cs for long mode. */ + /* lgdt */ + .byte 0x0f + .byte 0x01 + .byte 0x15 +VARIABLE (grub_bsd64_trampoline_gdt) + .long 0x0 + + /* ljmp */ + .byte 0xea +VARIABLE (grub_bsd64_trampoline_selfjump) + .long 0x0 + .word 0x08 + + .code64 + +bsd64_longmode: + /* We're still running V=P, jump to entry point. */ + movl %esi, %eax + salq $32, %rax + orq %rdi, %rax + pushq %rax + ret +VARIABLE(grub_bsd64_trampoline_end) + + .code32 + +/* + * Use cdecl calling convention for *BSD kernels. + */ + +FUNCTION(grub_unix_real_boot) + + /* Interrupts should be disabled. */ + cli + + /* Discard `grub_unix_real_boot' return address. */ + popl %eax + + /* Fetch `entry' address ... */ + popl %eax + + /* + * ... and put our return address in its place. The kernel will + * ignore it, but it expects %esp to point to it. + */ + call *%eax ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 1:27 ` phcoder @ 2009-04-13 2:26 ` Chip Panarchy 2009-04-13 2:58 ` Chip Panarchy 2009-04-13 5:33 ` Joey Korkames 1 sibling, 1 reply; 25+ messages in thread From: Chip Panarchy @ 2009-04-13 2:26 UTC (permalink / raw) To: The development of GRUB 2 +1 Beautiful! Thanks a heap Bean... Haven't tried it yet, but will! Exactly what I've been requested, thanks once again! Panarchy On Mon, Apr 13, 2009 at 1:27 AM, phcoder <phcoder@gmail.com> wrote: > Bean kindly allowed me to mess with this patch. So here comes an improved > version. I moved helpers out of the kernels. Because of how FreeBSD expects > the initial virtual memory mapping only first GB of physical memory is > accessible so it was required to use of trampoline technique. > Bean wrote: >> >> Hi, >> >> This patch allows you to load amd64 freebsd kernel directly, here is an >> example: >> >> set root=(hd0,1,a) >> freebsd /boot/kernel/kernel >> freebsd_loadenv /boot/device.hints >> set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s1a >> boot >> >> Test successfully on FreeBSD 7.1 amd64. >> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Grub-devel mailing list >> Grub-devel@gnu.org >> http://lists.gnu.org/mailman/listinfo/grub-devel > > > -- > > Regards > Vladimir 'phcoder' Serbinenko > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 2:26 ` Chip Panarchy @ 2009-04-13 2:58 ` Chip Panarchy 2009-04-13 3:53 ` Bean 0 siblings, 1 reply; 25+ messages in thread From: Chip Panarchy @ 2009-04-13 2:58 UTC (permalink / raw) To: The development of GRUB 2 Hello Sorry, I forgot to thank PHcoder. Thank you also PHcoder, with Bean's patch, and your enchancements/patch-of-patch, I should be able to successfully install FreeBSD 64-bit onto a Logical Partition (http://forums.freebsd.org/showthread.php?t=3248), by using the GRUB2 bootloader, instead of the FreeBSD BootLoader. So much thanks to both PHcoder and Bean! You have greatly helped me (and others), this will help me so much!!! Thanks once again, Panarchy On Mon, Apr 13, 2009 at 12:26 PM, Chip Panarchy <forumanarchy@gmail.com> wrote: > +1 > > Beautiful! > > Thanks a heap Bean... > > Haven't tried it yet, but will! > > Exactly what I've been requested, thanks once again! > > Panarchy > > On Mon, Apr 13, 2009 at 1:27 AM, phcoder <phcoder@gmail.com> wrote: >> Bean kindly allowed me to mess with this patch. So here comes an improved >> version. I moved helpers out of the kernels. Because of how FreeBSD expects >> the initial virtual memory mapping only first GB of physical memory is >> accessible so it was required to use of trampoline technique. >> Bean wrote: >>> >>> Hi, >>> >>> This patch allows you to load amd64 freebsd kernel directly, here is an >>> example: >>> >>> set root=(hd0,1,a) >>> freebsd /boot/kernel/kernel >>> freebsd_loadenv /boot/device.hints >>> set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s1a >>> boot >>> >>> Test successfully on FreeBSD 7.1 amd64. >>> >>> >>> >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> Grub-devel mailing list >>> Grub-devel@gnu.org >>> http://lists.gnu.org/mailman/listinfo/grub-devel >> >> >> -- >> >> Regards >> Vladimir 'phcoder' Serbinenko >> >> _______________________________________________ >> Grub-devel mailing list >> Grub-devel@gnu.org >> http://lists.gnu.org/mailman/listinfo/grub-devel >> >> > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 2:58 ` Chip Panarchy @ 2009-04-13 3:53 ` Bean 2009-04-13 5:26 ` Chip Panarchy 0 siblings, 1 reply; 25+ messages in thread From: Bean @ 2009-04-13 3:53 UTC (permalink / raw) To: The development of GRUB 2 On Mon, Apr 13, 2009 at 10:58 AM, Chip Panarchy <forumanarchy@gmail.com> wrote: > Hello > > Sorry, I forgot to thank PHcoder. > > Thank you also PHcoder, with Bean's patch, and your > enchancements/patch-of-patch, I should be able to successfully install > FreeBSD 64-bit onto a Logical Partition > (http://forums.freebsd.org/showthread.php?t=3248), by using the GRUB2 > bootloader, instead of the FreeBSD BootLoader. > > So much thanks to both PHcoder and Bean! > > You have greatly helped me (and others), this will help me so much!!! > > Thanks once again, Hi, You're welcome. I only test primary partition, but logical partition should be working as well. BTW, there is currently no port for grub2 in freebsd, but I think it should build properly, anyone wants to maintain a port ? -- Bean ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 3:53 ` Bean @ 2009-04-13 5:26 ` Chip Panarchy 0 siblings, 0 replies; 25+ messages in thread From: Chip Panarchy @ 2009-04-13 5:26 UTC (permalink / raw) To: The development of GRUB 2 Hello Thanks once again for replying. I wouldn't mind maintaining the port, though probably only temporarily, seeing as I have a job starting tomorrow. However, first I need to get GRUB2 working properly, with the 64-bit FreeBSD entry. I have Fedora 64-bit installed onto an ext3 partition. How do I install this patch to the GRUB contained on this partition?; #################### # title Fedora (2.6.27.5-117.fc10.x86_64) # # root (hd0,6) # # kernel /boot/vmlinuz-2.6.27.5-117.fc10.x86_64 ro root=UUID=385fefd2-c92b-40c6-a9b0-ada4fd408dba rhgb quiet # initrd /boot/initrd-2.6.27.5-117.fc10.x86_64.img #################### I would also like to add this capability to Ubuntu 64-bit's GRUB, which is contained in its bootsector (hd0,8) Please tell me how to add 64-bit FreeBSD capability to my GRUB2 and (if possible) my GRUB. Thanks in advance, Panarchy On Mon, Apr 13, 2009 at 1:53 PM, Bean <bean123ch@gmail.com> wrote: > On Mon, Apr 13, 2009 at 10:58 AM, Chip Panarchy <forumanarchy@gmail.com> wrote: >> Hello >> >> Sorry, I forgot to thank PHcoder. >> >> Thank you also PHcoder, with Bean's patch, and your >> enchancements/patch-of-patch, I should be able to successfully install >> FreeBSD 64-bit onto a Logical Partition >> (http://forums.freebsd.org/showthread.php?t=3248), by using the GRUB2 >> bootloader, instead of the FreeBSD BootLoader. >> >> So much thanks to both PHcoder and Bean! >> >> You have greatly helped me (and others), this will help me so much!!! >> >> Thanks once again, > > Hi, > > You're welcome. I only test primary partition, but logical partition > should be working as well. > > BTW, there is currently no port for grub2 in freebsd, but I think it > should build properly, anyone wants to maintain a port ? > > -- > Bean > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 1:27 ` phcoder 2009-04-13 2:26 ` Chip Panarchy @ 2009-04-13 5:33 ` Joey Korkames 2009-04-13 8:51 ` Joey Korkames 1 sibling, 1 reply; 25+ messages in thread From: Joey Korkames @ 2009-04-13 5:33 UTC (permalink / raw) To: The development of GRUB 2 I can't make grub2 build with phcoder's bsd64.diff. My guess it is beacuse conf/i386.mk is missing stuff related to loader/i386/bsd_helper.S $(loader/i386/bsd_helper.S_DEPENDENCIES)?, but I wouldn't how or where to add it in. .... cat kernel_syms.lst def-biosdisk.lst def-chain.lst def-linux16.lst def-linux.lst def-normal.lst def-reboot.lst def-halt.lst def-serial.lst def-multiboot.lst def-vbe.lst def-vbeinfo.lst def-vbetest.lst def-play.lst def-ata.lst def-vga.lst def-memdisk.lst def-pci.lst def-lspci.lst def-aout.lst def-bsd.lst def-usb.lst def-usbtest.lst def-uhci.lst def-ohci.lst def-usbms.lst def-usb_keyboard.lst def-pxe.lst def-pxecmd.lst def-datetime.lst def-date.lst def-datehook.lst def-lsmmap.lst def-ata_pthru.lst def-hdparm.lst def-cpuid.lst def-at_keyboard.lst def-vga_text.lst def-fshelp.lst def-fat.lst def-ufs.lst def-ext2.lst def-ntfs.lst def-ntfscomp.lst def-minix.lst def-hfs.lst def-jfs.lst def-iso9660.lst def-xfs.lst def-affs.lst def-sfs.lst def-hfsplus.lst def-reiserfs.lst def-cpio.lst def-tar.lst def-udf.lst def-afs.lst def-amiga.lst def-apple.lst def-pc.lst def-sun.lst def-acorn.lst def-gpt.lst def-raid.lst def-raid5rec.lst def-raid6rec.lst def-mdraid.lst def-dm_nv.lst def-lvm.lst def-scsi.lst def-minicmd.lst def-extcmd.lst def-hello.lst def-parttool.lst def-pcpart.lst def-handler.lst def-ls.lst def-cmp.lst def-cat.lst def-echo.lst def-help.lst def-search.lst def-test.lst def-loopback.lst def-fs_uuid.lst def-configfile.lst def-terminfo.lst def-blocklist.lst def-hexdump.lst def-read.lst def-sleep.lst def-loadenv.lst def-crc.lst def-memrw.lst def-video.lst def-videotest.lst def-bitmap.lst def-tga.lst def-jpeg.lst def-png.lst def-font.lst def-gfxterm.lst def-elf.lst def-gzio.lst def-bufio.lst /dev/null \ | gawk -f /build/root-grub2_1.96+20090413-kfx.1-amd64-rOO4X2/grub2-1.96+20090413-kfx.1/genmoddep.awk und-biosdisk.lst und-chain.lst und-linux16.lst und-linux.lst und-normal.lst und-reboot.lst und-halt.lst und-serial.lst und-multiboot.lst und-vbe.lst und-vbeinfo.lst und-vbetest.lst und-play.lst und-ata.lst und-vga.lst und-memdisk.lst und-pci.lst und-lspci.lst und-aout.lst und-bsd.lst und-usb.lst und-usbtest.lst und-uhci.lst und-ohci.lst und-usbms.lst und-usb_keyboard.lst und-pxe.lst und-pxecmd.lst und-datetime.lst und-date.lst und-datehook.lst und-lsmmap.lst und-ata_pthru.lst und-hdparm.lst und-cpuid.lst und-at_keyboard.lst und-vga_text.lst und-fshelp.lst und-fat.lst und-ufs.lst und-ext2.lst und-ntfs.lst und-ntfscomp.lst und-minix.lst und-hfs.lst und-jfs.lst und-iso9660.lst und-xfs.lst und-affs.lst und-sfs.lst und-hfsplus.lst und-reiserfs.lst und-cpio.lst und-tar.lst und-udf.lst und-afs.lst und-amiga.lst und-apple.lst und-pc.lst und-sun.lst und-acorn.lst und-gpt.lst und-raid.lst und-raid5rec.lst und-raid6rec.lst und-mdraid.lst und-dm_nv.lst und-lvm.lst und-scsi.lst und-minicmd.lst und-extcmd.lst und-hello.lst und-parttool.lst und-pcpart.lst und-handler.lst und-ls.lst und-cmp.lst und-cat.lst und-echo.lst und-help.lst und-search.lst und-test.lst und-loopback.lst und-fs_uuid.lst und-configfile.lst und-terminfo.lst und-blocklist.lst und-hexdump.lst und-read.lst und-sleep.lst und-loadenv.lst und-crc.lst und-memrw.lst und-video.lst und-videotest.lst und-bitmap.lst und-tga.lst und-jpeg.lst und-png.lst und-font.lst und-gfxterm.lst und-elf.lst und-gzio.lst und-bufio.lst > moddep.lst \ || (rm -f moddep.lst; exit 1) grub_bsd64_trampoline_gdt in bsd is not defined make[1]: *** [moddep.lst] Error 1 make[1]: Leaving directory `/build/root-grub2_1.96+20090413-kfx.1-amd64-rOO4X2/grub2-1.96+20090413-kfx.1/build/grub-common' make: *** [build/grub-common] Error 2 Thanks -joey phcoder writes: > Bean kindly allowed me to mess with this patch. So here comes an > improved version. I moved helpers out of the kernels. Because of how > FreeBSD expects the initial virtual memory mapping only first GB of > physical memory is accessible so it was required to use of trampoline > technique. > Bean wrote: ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 5:33 ` Joey Korkames @ 2009-04-13 8:51 ` Joey Korkames 2009-04-13 9:03 ` phcoder 2009-04-13 9:10 ` Joey Korkames 0 siblings, 2 replies; 25+ messages in thread From: Joey Korkames @ 2009-04-13 8:51 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 783 bytes --] Figured it out, s/multiboot_mod-loader_i386_multiboot_helper/bsd_mod-loader_i386_bsd_helper/ and bingo! Worked ion both Xen HVM and on a real amd64 box (over PXE) Yay GRUB2 and its devs! -joey Joey Korkames writes: > I can't make grub2 build with phcoder's bsd64.diff. My guess it is beacuse conf/i386.mk is missing stuff related to > loader/i386/bsd_helper.S $(loader/i386/bsd_helper.S_DEPENDENCIES)?, but I wouldn't how or where to add it in. > > > phcoder writes: > >> Bean kindly allowed me to mess with this patch. So here comes an >> improved version. I moved helpers out of the kernels. Because of how >> FreeBSD expects the initial virtual memory mapping only first GB of >> physical memory is accessible so it was required to use of trampoline >> technique. [-- Attachment #2: bsd64_conf.diff --] [-- Type: text/x-diff, Size: 3621 bytes --] diff --git a/conf/i386-pc.mk b/conf/i386-pc.mk index ab14e08..806ea10 100644 --- a/conf/i386-pc.mk +++ b/conf/i386-pc.mk @@ -2575,13 +2575,13 @@ aout_mod_CFLAGS = $(COMMON_CFLAGS) aout_mod_LDFLAGS = $(COMMON_LDFLAGS) # For bsd.mod -bsd_mod_SOURCES = loader/i386/bsd.c -CLEANFILES += bsd.mod mod-bsd.o mod-bsd.c pre-bsd.o bsd_mod-loader_i386_bsd.o und-bsd.lst +bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd_helper.S +CLEANFILES += bsd.mod mod-bsd.o mod-bsd.c pre-bsd.o bsd_mod-loader_i386_bsd.o bsd_mod-loader_i386_bsd_helper.o und-bsd.lst ifneq ($(bsd_mod_EXPORTS),no) CLEANFILES += def-bsd.lst DEFSYMFILES += def-bsd.lst endif -MOSTLYCLEANFILES += bsd_mod-loader_i386_bsd.d +MOSTLYCLEANFILES += bsd_mod-loader_i386_bsd.d bsd_mod-loader_i386_bsd.d UNDSYMFILES += und-bsd.lst bsd.mod: pre-bsd.o mod-bsd.o $(TARGET_OBJ2ELF) @@ -2590,9 +2590,9 @@ bsd.mod: pre-bsd.o mod-bsd.o $(TARGET_OBJ2ELF) if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@ -pre-bsd.o: $(bsd_mod_DEPENDENCIES) bsd_mod-loader_i386_bsd.o +pre-bsd.o: $(bsd_mod_DEPENDENCIES) bsd_mod-loader_i386_bsd.o bsd_mod-loader_i386_bsd_helper.o -rm -f $@ - $(TARGET_CC) $(bsd_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ bsd_mod-loader_i386_bsd.o + $(TARGET_CC) $(bsd_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ bsd_mod-loader_i386_bsd.o bsd_mod-loader_i386_bsd_helper.o mod-bsd.o: mod-bsd.c $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(bsd_mod_CFLAGS) -c -o $@ $< @@ -2628,6 +2628,24 @@ partmap-bsd_mod-loader_i386_bsd.lst: loader/i386/bsd.c $(loader/i386/bsd.c_DEPEN set -e; $(TARGET_CC) -Iloader/i386 -I$(srcdir)/loader/i386 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(bsd_mod_CFLAGS) -E $< | sh $(srcdir)/genpartmaplist.sh bsd > $@ || (rm -f $@; exit 1) +bsd_mod-loader_i386_bsd_helper.o: loader/i386/bsd_helper.S $(loader/i386/bsd_helper.S_DEPENDENCIES) + $(TARGET_CC) -Iloader/i386 -I$(srcdir)/loader/i386 $(TARGET_CPPFLAGS) -DASM_FILE=1 $(TARGET_ASFLAGS) $(multiboot_mod_ASFLAGS) -MD -c -o $@ $< +-include bsd_mod-loader_i386_bsd_helper.d + +CLEANFILES += cmd-bsd_mod-loader_i386_bsd_helper.lst fs-bsd_mod-loader_i386_bsd_helper.lst partmap-bsd_mod-loader_i386_bsd_helper.lst +COMMANDFILES += cmd-bsd_mod-loader_i386_bsd_helper.lst +FSFILES += fs-bsd_mod-loader_i386_bsd_helper.lst +PARTMAPFILES += partmap-bsd_mod-loader_i386_bsd_helper.lst + +cmd-bsd_mod-loader_i386_bsd_helper.lst: loader/i386/multiboot_helper.S $(loader/i386/multiboot_helper.S_DEPENDENCIES) gencmdlist.sh + set -e; $(TARGET_CC) -Iloader/i386 -I$(srcdir)/loader/i386 $(TARGET_CPPFLAGS) -DASM_FILE=1 $(TARGET_ASFLAGS) $(multiboot_mod_ASFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh bsd > $@ || (rm -f $@; exit 1) + +fs-bsd_mod-loader_i386_bsd_helper.lst: loader/i386/multiboot_helper.S $(loader/i386/multiboot_helper.S_DEPENDENCIES) genfslist.sh + set -e; $(TARGET_CC) -Iloader/i386 -I$(srcdir)/loader/i386 $(TARGET_CPPFLAGS) -DASM_FILE=1 $(TARGET_ASFLAGS) $(multiboot_mod_ASFLAGS) -E $< | sh $(srcdir)/genfslist.sh bsd > $@ || (rm -f $@; exit 1) + +partmap-bsd_mod-loader_i386_bsd_helper.lst: loader/i386/multiboot_helper.S $(loader/i386/multiboot_helper.S_DEPENDENCIES) genpartmaplist.sh + set -e; $(TARGET_CC) -Iloader/i386 -I$(srcdir)/loader/i386 $(TARGET_CPPFLAGS) -DASM_FILE=1 $(TARGET_ASFLAGS) $(multiboot_mod_ASFLAGS) -E $< | sh $(srcdir)/genpartmaplist.sh bsd > $@ || (rm -f $@; exit 1) + bsd_mod_CFLAGS = $(COMMON_CFLAGS) bsd_mod_LDFLAGS = $(COMMON_LDFLAGS) ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 8:51 ` Joey Korkames @ 2009-04-13 9:03 ` phcoder 2009-04-13 9:10 ` Joey Korkames 1 sibling, 0 replies; 25+ messages in thread From: phcoder @ 2009-04-13 9:03 UTC (permalink / raw) To: The development of GRUB 2 It seems that your build system wasn't up-to-date. The possible fix is: make maintainer-clean ./autogen.sh <recompile> Joey Korkames wrote: > Figured it out, > s/multiboot_mod-loader_i386_multiboot_helper/bsd_mod-loader_i386_bsd_helper/ > and bingo! > > Worked ion both Xen HVM and on a real amd64 box (over PXE) > > Yay GRUB2 and its devs! > -joey > > Joey Korkames writes: > >> I can't make grub2 build with phcoder's bsd64.diff. My guess it is >> beacuse conf/i386.mk is missing stuff related to >> loader/i386/bsd_helper.S $(loader/i386/bsd_helper.S_DEPENDENCIES)?, >> but I wouldn't how or where to add it in. >> >> >> phcoder writes: >> >>> Bean kindly allowed me to mess with this patch. So here comes an >>> improved version. I moved helpers out of the kernels. Because of how >>> FreeBSD expects the initial virtual memory mapping only first GB of >>> physical memory is accessible so it was required to use of trampoline >>> technique. > > > ------------------------------------------------------------------------ > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel -- Regards Vladimir 'phcoder' Serbinenko ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 8:51 ` Joey Korkames 2009-04-13 9:03 ` phcoder @ 2009-04-13 9:10 ` Joey Korkames 2009-04-13 9:20 ` phcoder 1 sibling, 1 reply; 25+ messages in thread From: Joey Korkames @ 2009-04-13 9:10 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 1610 bytes --] Hmm, FreeBSD seems to choke when trying to load the grub-bootstrapped mfsroot.gz (as the root device - haven't tried loading without rooting from it)... This is a custom mfsroot, booted like so: menuentry "FreeBSD 7.1-STABLE amd64" { freebsd /osstore/STAGE2/FREEBSD/amd64/kernel.gz Dh freebsd_loadenv /osstore/STAGE2/FREEBSD/amd64/device.hints freebsd_module /osstore/STAGE2/FREEBSD/amd64/mfsroot.gz type=mfs_root set FreeBSD.vfs.root.mountfrom=ufs:/dev/md0 } perhaps I'll try with the Sysinstall floppy's mfsroot - it might be a little smaller. PS. A correction for that last patch: -MOSTLYCLEANFILES += bsd_mod-loader_i386_bsd.d bsd_mod-loader_i386_bsd.d +MOSTLYCLEANFILES += bsd_mod-loader_i386_bsd.d bsd_mod-loader_i386_bsd_helper.d Thanks joey Joey Korkames writes: > Figured it out, > s/multiboot_mod-loader_i386_multiboot_helper/bsd_mod-loader_i386_bsd_helper/ > and bingo! > > Worked ion both Xen HVM and on a real amd64 box (over PXE) > > Yay GRUB2 and its devs! > -joey > > Joey Korkames writes: > >> I can't make grub2 build with phcoder's bsd64.diff. My guess it is beacuse conf/i386.mk is missing stuff related to >> loader/i386/bsd_helper.S $(loader/i386/bsd_helper.S_DEPENDENCIES)?, but I wouldn't how or where to add it in. >> >> >> phcoder writes: >> >>> Bean kindly allowed me to mess with this patch. So here comes an >>> improved version. I moved helpers out of the kernels. Because of how >>> FreeBSD expects the initial virtual memory mapping only first GB of >>> physical memory is accessible so it was required to use of trampoline >>> technique. > [-- Attachment #2: crash.txt --] [-- Type: text/plain, Size: 8631 bytes --] Copyright (c) 1992-2009 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD is a registered trademark of The FreeBSD Foundation. FreeBSD 7.1-RELEASE #0: Thu Jan 1 08:58:24 UTC 2009 root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC Timecounter "i8254" frequency 1193182 Hz quality 0 CPU: Intel(R) Xeon(R) CPU 5140 @ 2.33GHz (2333.35-MHz K8-class CPU) Origin = "GenuineIntel" Id = 0x6f6 Stepping = 6 Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> Features2=0x4e3bd<SSE3,RSVD2,MON,DS_CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,DCA> AMD Features=0x20000800<SYSCALL,LM> AMD Features2=0x1<LAHF> Cores per package: 2 usable memory = 17155354624 (16360 MB) avail memory = 16608129024 (15838 MB) ACPI APIC Table: <PTLTD APIC > FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs cpu0 (BSP): APIC ID: 0 cpu1 (AP): APIC ID: 1 ioapic0 <Version 2.0> irqs 0-23 on motherboard ioapic1 <Version 2.0> irqs 24-47 on motherboard kbd1 at kbdmux0 ath_hal: 0.9.20.3 (AR5210, AR5211, AR5212, RF5111, RF5112, RF2413, RF5413) acpi0: <PTLTD RSDT> on motherboard acpi0: [ITHREAD] acpi0: Power Button (fixed) Timecounter "ACPI-safe" frequency 3579545 Hz quality 850 acpi_timer0: <24-bit timer at 3.579545MHz> port 0x1008-0x100b on acpi0 pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0 pci0: <ACPI PCI bus> on pcib0 pcib1: <ACPI PCI-PCI bridge> at device 2.0 on pci0 pci1: <ACPI PCI bus> on pcib1 pcib2: <ACPI PCI-PCI bridge> irq 16 at device 0.0 on pci1 pci2: <ACPI PCI bus> on pcib2 pcib3: <ACPI PCI-PCI bridge> irq 16 at device 0.0 on pci2 pci3: <ACPI PCI bus> on pcib3 pcib4: <ACPI PCI-PCI bridge> at device 0.0 on pci3 pci4: <ACPI PCI bus> on pcib4 ahd0: <Adaptec AIC7902 Ultra320 SCSI adapter> port 0x2400-0x24ff,0x2000-0x20ff mem 0xc8200000-0xc8201fff irq 16 at device 2.0 on pci4 ahd0: [ITHREAD] aic7902: Ultra320 Wide Channel A, SCSI Id=7, PCI-X 67-100Mhz, 512 SCBs ahd1: <Adaptec AIC7902 Ultra320 SCSI adapter> port 0x2c00-0x2cff,0x2800-0x28ff mem 0xc8202000-0xc8203fff irq 17 at device 2.1 on pci4 ahd1: [ITHREAD] aic7902: Ultra320 Wide Channel B, SCSI Id=7, PCI-X 67-100Mhz, 512 SCBs pcib5: <ACPI PCI-PCI bridge> at device 0.2 on pci3 pci5: <ACPI PCI bus> on pcib5 pcib6: <ACPI PCI-PCI bridge> irq 18 at device 2.0 on pci2 pci6: <ACPI PCI bus> on pcib6 em0: <Intel(R) PRO/1000 Network Connection 6.9.6> port 0x3000-0x301f mem 0xc8300000-0xc831ffff irq 18 at device 0.0 on pci6 em0: Using MSI interrupt em0: [FILTER] em0: Ethernet address: 00:30:48:31:6b:10 em1: <Intel(R) PRO/1000 Network Connection 6.9.6> port 0x3020-0x303f mem 0xc8320000-0xc833ffff irq 19 at device 0.1 on pci6 em1: Using MSI interrupt em1: [FILTER] em1: Ethernet address: 00:30:48:31:6b:11 pcib7: <ACPI PCI-PCI bridge> at device 0.3 on pci1 pci7: <ACPI PCI bus> on pcib7 mpt0: <LSILogic SAS/SATA Adapter> port 0x4000-0x40ff mem 0xc8410000-0xc8413fff,0xc8400000-0xc840ffff irq 24 at device 1.0 on pci7 mpt0: [ITHREAD] mpt0: MPI Version=1.5.13.0 mpt0: Capabilities: ( RAID-0 RAID-1E RAID-1 ) mpt0: 0 Active Volumes (2 Max) mpt0: 0 Hidden Drive Members (10 Max) pcib8: <ACPI PCI-PCI bridge> at device 4.0 on pci0 pci8: <ACPI PCI bus> on pcib8 pcib9: <ACPI PCI-PCI bridge> at device 6.0 on pci0 pci9: <ACPI PCI bus> on pcib9 pci0: <base peripheral> at device 8.0 (no driver attached) pcib10: <ACPI PCI-PCI bridge> irq 17 at device 28.0 on pci0 pci10: <ACPI PCI bus> on pcib10 uhci0: <Intel 631XESB/632XESB/3100 USB controller USB-1> port 0x1800-0x181f irq 17 at device 29.0 on pci0 uhci0: [GIANT-LOCKED] uhci0: [ITHREAD] usb0: <Intel 631XESB/632XESB/3100 USB controller USB-1> on uhci0 usb0: USB revision 1.0 uhub0: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb0 uhub0: 2 ports with 2 removable, self powered uhci1: <Intel 631XESB/632XESB/3100 USB controller USB-2> port 0x1820-0x183f irq 19 at device 29.1 on pci0 uhci1: [GIANT-LOCKED] uhci1: [ITHREAD] usb1: <Intel 631XESB/632XESB/3100 USB controller USB-2> on uhci1 usb1: USB revision 1.0 uhub1: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb1 uhub1: 2 ports with 2 removable, self powered uhci2: <Intel 631XESB/632XESB/3100 USB controller USB-3> port 0x1840-0x185f irq 18 at device 29.2 on pci0 uhci2: [GIANT-LOCKED] uhci2: [ITHREAD] usb2: <Intel 631XESB/632XESB/3100 USB controller USB-3> on uhci2 usb2: USB revision 1.0 uhub2: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb2 uhub2: 2 ports with 2 removable, self powered ehci0: <Intel 63XXESB USB 2.0 controller> mem 0xc8000000-0xc80003ff irq 17 at device 29.7 on pci0 ehci0: [GIANT-LOCKED] ehci0: [ITHREAD] usb3: EHCI version 1.0 usb3: companion controllers, 2 ports each: usb0 usb1 usb2 usb3: <Intel 63XXESB USB 2.0 controller> on ehci0 usb3: USB revision 2.0 uhub3: <Intel EHCI root hub, class 9/0, rev 2.00/1.00, addr 1> on usb3 uhub3: 6 ports with 6 removable, self powered pcib11: <ACPI PCI-PCI bridge> at device 30.0 on pci0 pci11: <ACPI PCI bus> on pcib11 vgapci0: <VGA-compatible display> port 0x5000-0x50ff mem 0xd0000000-0xd7ffffff,0xc8500000-0xc850ffff irq 18 at device 1.0 on pci11 isab0: <PCI-ISA bridge> at device 31.0 on pci0 isa0: <ISA bus> on isab0 atapci0: <Intel 63XXESB2 UDMA100 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0x1860-0x186f at device 31.1 on pci0 ata0: <ATA channel 0> on atapci0 ata0: [ITHREAD] ata1: <ATA channel 1> on atapci0 ata1: [ITHREAD] pci0: <serial bus, SMBus> at device 31.3 (no driver attached) acpi_button0: <Power Button> on acpi0 atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0 atkbd0: <AT Keyboard> irq 1 on atkbdc0 kbd0 at atkbd0 atkbd0: [GIANT-LOCKED] atkbd0: [ITHREAD] sio0: configured irq 4 not in bitmap of probed irqs 0 sio0: port may not be enabled sio0: configured irq 4 not in bitmap of probed irqs 0 sio0: port may not be enabled sio0: <16550A-compatible COM port> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0 sio0: type 16550A, console sio0: [FILTER] sio1: configured irq 3 not in bitmap of probed irqs 0 sio1: port may not be enabled sio1: configured irq 3 not in bitmap of probed irqs 0 sio1: port may not be enabled sio1: <16550A-compatible COM port> port 0x2f8-0x2ff irq 3 on acpi0 sio1: type 16550A sio1: [FILTER] fdc0: <floppy drive controller> port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on acpi0 fdc0: [FILTER] ppc0: <Parallel port> port 0x378-0x37f,0x778-0x77f irq 7 drq 3 on acpi0 ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode ppc0: FIFO with 16/16/9 bytes threshold ppbus0: <Parallel port bus> on ppc0 ppbus0: [ITHREAD] plip0: <PLIP network interface> on ppbus0 plip0: WARNING: using obsoleted IFF_NEEDSGIANT flag lpt0: <Printer> on ppbus0 lpt0: Interrupt-driven port ppi0: <Parallel I/O> on ppbus0 ppc0: [GIANT-LOCKED] ppc0: [ITHREAD] cpu0: <ACPI CPU> on acpi0 est0: <Enhanced SpeedStep Frequency Control> on cpu0 est: CPU supports Enhanced Speedstep, but is not recognized. est: cpu_vendor GenuineIntel, msr 728072806000728 device_attach: est0 attach returned 6 p4tcc0: <CPU Frequency Thermal Control> on cpu0 cpu1: <ACPI CPU> on acpi0 est1: <Enhanced SpeedStep Frequency Control> on cpu1 est: CPU supports Enhanced Speedstep, but is not recognized. est: cpu_vendor GenuineIntel, msr 728072806000728 device_attach: est1 attach returned 6 p4tcc1: <CPU Frequency Thermal Control> on cpu1 orm0: <ISA Option ROMs> at iomem 0xc0000-0xcafff,0xcb000-0xcbfff,0xcc000-0xcc7ff on isa0 sc0: <System console> at flags 0x100 on isa0 sc0: VGA <16 virtual consoles, flags=0x300> vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 Timecounters tick every 1.000 msec md0: Preloaded image <mfsroot.gz> 11771904 bytes at 0x7380afd000 Fatal trap 12: page fault while in kernel mode cpuid = 0; apic id = 00 fault virtual address = 0x7380afd000 fault code = supervisor read data, page not present instruction pointer = 0x8:0xffffffff80789636 stack pointer = 0x10:0xffffffffaeee2bd0 frame pointer = 0x10:0xffffff000420a800 code segment = base 0x0, limit 0xfffff, type 0x1b = DPL 0, pres 1, long 1, def32 0, gran 1 processor eflags = interrupt enabled, resume, IOPL = 0 current process = 47 (md0) trap number = 12 panic: page fault cpuid = 0 Uptime: 1s Cannot dump. No dump device defined. Automatic reboot in 15 seconds - press a key on the console to abort --> Press a key on the console to reboot, --> or switch off the system now. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 9:10 ` Joey Korkames @ 2009-04-13 9:20 ` phcoder 2009-04-13 9:37 ` Joey Korkames 0 siblings, 1 reply; 25+ messages in thread From: phcoder @ 2009-04-13 9:20 UTC (permalink / raw) To: The development of GRUB 2 Joey Korkames wrote: > Hmm, FreeBSD seems to choke when trying to load the grub-bootstrapped > mfsroot.gz (as the root device - haven't tried loading without rooting > from it)... Thank you for the testing. Can you define "choke" more exactly? > > This is a custom mfsroot, booted like so: > menuentry "FreeBSD 7.1-STABLE amd64" { > freebsd /osstore/STAGE2/FREEBSD/amd64/kernel.gz Dh > freebsd_loadenv /osstore/STAGE2/FREEBSD/amd64/device.hints > freebsd_module /osstore/STAGE2/FREEBSD/amd64/mfsroot.gz type=mfs_root > set FreeBSD.vfs.root.mountfrom=ufs:/dev/md0 > } > > perhaps I'll try with the Sysinstall floppy's mfsroot - it might be a > little smaller. > > PS. A correction for that last patch: > -MOSTLYCLEANFILES += bsd_mod-loader_i386_bsd.d bsd_mod-loader_i386_bsd.d > +MOSTLYCLEANFILES += bsd_mod-loader_i386_bsd.d > bsd_mod-loader_i386_bsd_helper.d > Just run commands I gave you. You also need ruby to regenerate all these autogenerated files. > Thanks > joey > > Joey Korkames writes: > >> Figured it out, >> s/multiboot_mod-loader_i386_multiboot_helper/bsd_mod-loader_i386_bsd_helper/ >> and bingo! >> >> Worked ion both Xen HVM and on a real amd64 box (over PXE) >> >> Yay GRUB2 and its devs! >> -joey >> >> Joey Korkames writes: >> >>> I can't make grub2 build with phcoder's bsd64.diff. My guess it is >>> beacuse conf/i386.mk is missing stuff related to >>> loader/i386/bsd_helper.S $(loader/i386/bsd_helper.S_DEPENDENCIES)?, >>> but I wouldn't how or where to add it in. >>> >>> >>> phcoder writes: >>> >>>> Bean kindly allowed me to mess with this patch. So here comes an >>>> improved version. I moved helpers out of the kernels. Because of how >>>> FreeBSD expects the initial virtual memory mapping only first GB of >>>> physical memory is accessible so it was required to use of >>>> trampoline technique. >> > > ------------------------------------------------------------------------ > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel -- Regards Vladimir 'phcoder' Serbinenko ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 9:20 ` phcoder @ 2009-04-13 9:37 ` Joey Korkames 2009-04-13 9:43 ` phcoder 2009-04-13 10:05 ` phcoder 0 siblings, 2 replies; 25+ messages in thread From: Joey Korkames @ 2009-04-13 9:37 UTC (permalink / raw) To: The development of GRUB 2 phcoder writes: > Joey Korkames wrote: >> Hmm, FreeBSD seems to choke when trying to load the grub-bootstrapped >> mfsroot.gz (as the root device - haven't tried loading without rooting >> from it)... > Thank you for the testing. Can you define "choke" more exactly? >> Hmm, did my log attachment not make it? I'll inline it below. "md0: Preloaded image <mfsroot.gz> 11771904 bytes at 0x7380afd000" I gunzipped the mfsroot.gz on my PXE server, this reported size matches the uncompressed mfsroot file. >> > Just run commands I gave you. You also need ruby to regenerate all these > autogenerated files. All things Ruby (including the *.rmk files) purposefully try to escape my attention ;-) adding maintainer-clean before autogen in my build scripts fixed the issue -thanks. "Choking": Copyright (c) 1992-2009 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD is a registered trademark of The FreeBSD Foundation. FreeBSD 7.1-RELEASE #0: Thu Jan 1 08:58:24 UTC 2009 root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC Timecounter "i8254" frequency 1193182 Hz quality 0 CPU: Intel(R) Xeon(R) CPU 5140 @ 2.33GHz (2333.35-MHz K8-class CPU) Origin = "GenuineIntel" Id = 0x6f6 Stepping = 6 Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> Features2=0x4e3bd<SSE3,RSVD2,MON,DS_CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,DCA> AMD Features=0x20000800<SYSCALL,LM> AMD Features2=0x1<LAHF> Cores per package: 2 usable memory = 17155354624 (16360 MB) avail memory = 16608129024 (15838 MB) ACPI APIC Table: <PTLTD APIC > FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs cpu0 (BSP): APIC ID: 0 cpu1 (AP): APIC ID: 1 ioapic0 <Version 2.0> irqs 0-23 on motherboard ioapic1 <Version 2.0> irqs 24-47 on motherboard kbd1 at kbdmux0 ath_hal: 0.9.20.3 (AR5210, AR5211, AR5212, RF5111, RF5112, RF2413, RF5413) acpi0: <PTLTD RSDT> on motherboard acpi0: [ITHREAD] acpi0: Power Button (fixed) Timecounter "ACPI-safe" frequency 3579545 Hz quality 850 acpi_timer0: <24-bit timer at 3.579545MHz> port 0x1008-0x100b on acpi0 pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0 pci0: <ACPI PCI bus> on pcib0 pcib1: <ACPI PCI-PCI bridge> at device 2.0 on pci0 pci1: <ACPI PCI bus> on pcib1 pcib2: <ACPI PCI-PCI bridge> irq 16 at device 0.0 on pci1 pci2: <ACPI PCI bus> on pcib2 pcib3: <ACPI PCI-PCI bridge> irq 16 at device 0.0 on pci2 pci3: <ACPI PCI bus> on pcib3 pcib4: <ACPI PCI-PCI bridge> at device 0.0 on pci3 pci4: <ACPI PCI bus> on pcib4 ahd0: <Adaptec AIC7902 Ultra320 SCSI adapter> port 0x2400-0x24ff,0x2000-0x20ff mem 0xc8200000-0xc8201fff irq 16 at device 2.0 on pci4 ahd0: [ITHREAD] aic7902: Ultra320 Wide Channel A, SCSI Id=7, PCI-X 67-100Mhz, 512 SCBs ahd1: <Adaptec AIC7902 Ultra320 SCSI adapter> port 0x2c00-0x2cff,0x2800-0x28ff mem 0xc8202000-0xc8203fff irq 17 at device 2.1 on pci4 ahd1: [ITHREAD] aic7902: Ultra320 Wide Channel B, SCSI Id=7, PCI-X 67-100Mhz, 512 SCBs pcib5: <ACPI PCI-PCI bridge> at device 0.2 on pci3 pci5: <ACPI PCI bus> on pcib5 pcib6: <ACPI PCI-PCI bridge> irq 18 at device 2.0 on pci2 pci6: <ACPI PCI bus> on pcib6 em0: <Intel(R) PRO/1000 Network Connection 6.9.6> port 0x3000-0x301f mem 0xc8300000-0xc831ffff irq 18 at device 0.0 on pci6 em0: Using MSI interrupt em0: [FILTER] em0: Ethernet address: 00:30:48:31:6b:10 em1: <Intel(R) PRO/1000 Network Connection 6.9.6> port 0x3020-0x303f mem 0xc8320000-0xc833ffff irq 19 at device 0.1 on pci6 em1: Using MSI interrupt em1: [FILTER] em1: Ethernet address: 00:30:48:31:6b:11 pcib7: <ACPI PCI-PCI bridge> at device 0.3 on pci1 pci7: <ACPI PCI bus> on pcib7 mpt0: <LSILogic SAS/SATA Adapter> port 0x4000-0x40ff mem 0xc8410000-0xc8413fff,0xc8400000-0xc840ffff irq 24 at device 1.0 on pci7 mpt0: [ITHREAD] mpt0: MPI Version=1.5.13.0 mpt0: Capabilities: ( RAID-0 RAID-1E RAID-1 ) mpt0: 0 Active Volumes (2 Max) mpt0: 0 Hidden Drive Members (10 Max) pcib8: <ACPI PCI-PCI bridge> at device 4.0 on pci0 pci8: <ACPI PCI bus> on pcib8 pcib9: <ACPI PCI-PCI bridge> at device 6.0 on pci0 pci9: <ACPI PCI bus> on pcib9 pci0: <base peripheral> at device 8.0 (no driver attached) pcib10: <ACPI PCI-PCI bridge> irq 17 at device 28.0 on pci0 pci10: <ACPI PCI bus> on pcib10 uhci0: <Intel 631XESB/632XESB/3100 USB controller USB-1> port 0x1800-0x181f irq 17 at device 29.0 on pci0 uhci0: [GIANT-LOCKED] uhci0: [ITHREAD] usb0: <Intel 631XESB/632XESB/3100 USB controller USB-1> on uhci0 usb0: USB revision 1.0 uhub0: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb0 uhub0: 2 ports with 2 removable, self powered uhci1: <Intel 631XESB/632XESB/3100 USB controller USB-2> port 0x1820-0x183f irq 19 at device 29.1 on pci0 uhci1: [GIANT-LOCKED] uhci1: [ITHREAD] usb1: <Intel 631XESB/632XESB/3100 USB controller USB-2> on uhci1 usb1: USB revision 1.0 uhub1: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb1 uhub1: 2 ports with 2 removable, self powered uhci2: <Intel 631XESB/632XESB/3100 USB controller USB-3> port 0x1840-0x185f irq 18 at device 29.2 on pci0 uhci2: [GIANT-LOCKED] uhci2: [ITHREAD] usb2: <Intel 631XESB/632XESB/3100 USB controller USB-3> on uhci2 usb2: USB revision 1.0 uhub2: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb2 uhub2: 2 ports with 2 removable, self powered ehci0: <Intel 63XXESB USB 2.0 controller> mem 0xc8000000-0xc80003ff irq 17 at device 29.7 on pci0 ehci0: [GIANT-LOCKED] ehci0: [ITHREAD] usb3: EHCI version 1.0 usb3: companion controllers, 2 ports each: usb0 usb1 usb2 usb3: <Intel 63XXESB USB 2.0 controller> on ehci0 usb3: USB revision 2.0 uhub3: <Intel EHCI root hub, class 9/0, rev 2.00/1.00, addr 1> on usb3 uhub3: 6 ports with 6 removable, self powered pcib11: <ACPI PCI-PCI bridge> at device 30.0 on pci0 pci11: <ACPI PCI bus> on pcib11 vgapci0: <VGA-compatible display> port 0x5000-0x50ff mem 0xd0000000-0xd7ffffff,0xc8500000-0xc850ffff irq 18 at device 1.0 on pci11 isab0: <PCI-ISA bridge> at device 31.0 on pci0 isa0: <ISA bus> on isab0 atapci0: <Intel 63XXESB2 UDMA100 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0x1860-0x186f at device 31.1 on pci0 ata0: <ATA channel 0> on atapci0 ata0: [ITHREAD] ata1: <ATA channel 1> on atapci0 ata1: [ITHREAD] pci0: <serial bus, SMBus> at device 31.3 (no driver attached) acpi_button0: <Power Button> on acpi0 atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0 atkbd0: <AT Keyboard> irq 1 on atkbdc0 kbd0 at atkbd0 atkbd0: [GIANT-LOCKED] atkbd0: [ITHREAD] sio0: configured irq 4 not in bitmap of probed irqs 0 sio0: port may not be enabled sio0: configured irq 4 not in bitmap of probed irqs 0 sio0: port may not be enabled sio0: <16550A-compatible COM port> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0 sio0: type 16550A, console sio0: [FILTER] sio1: configured irq 3 not in bitmap of probed irqs 0 sio1: port may not be enabled sio1: configured irq 3 not in bitmap of probed irqs 0 sio1: port may not be enabled sio1: <16550A-compatible COM port> port 0x2f8-0x2ff irq 3 on acpi0 sio1: type 16550A sio1: [FILTER] fdc0: <floppy drive controller> port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on acpi0 fdc0: [FILTER] ppc0: <Parallel port> port 0x378-0x37f,0x778-0x77f irq 7 drq 3 on acpi0 ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode ppc0: FIFO with 16/16/9 bytes threshold ppbus0: <Parallel port bus> on ppc0 ppbus0: [ITHREAD] plip0: <PLIP network interface> on ppbus0 plip0: WARNING: using obsoleted IFF_NEEDSGIANT flag lpt0: <Printer> on ppbus0 lpt0: Interrupt-driven port ppi0: <Parallel I/O> on ppbus0 ppc0: [GIANT-LOCKED] ppc0: [ITHREAD] cpu0: <ACPI CPU> on acpi0 est0: <Enhanced SpeedStep Frequency Control> on cpu0 est: CPU supports Enhanced Speedstep, but is not recognized. est: cpu_vendor GenuineIntel, msr 728072806000728 device_attach: est0 attach returned 6 p4tcc0: <CPU Frequency Thermal Control> on cpu0 cpu1: <ACPI CPU> on acpi0 est1: <Enhanced SpeedStep Frequency Control> on cpu1 est: CPU supports Enhanced Speedstep, but is not recognized. est: cpu_vendor GenuineIntel, msr 728072806000728 device_attach: est1 attach returned 6 p4tcc1: <CPU Frequency Thermal Control> on cpu1 orm0: <ISA Option ROMs> at iomem 0xc0000-0xcafff,0xcb000-0xcbfff,0xcc000-0xcc7ff on isa0 sc0: <System console> at flags 0x100 on isa0 sc0: VGA <16 virtual consoles, flags=0x300> vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 Timecounters tick every 1.000 msec md0: Preloaded image <mfsroot.gz> 11771904 bytes at 0x7380afd000 Fatal trap 12: page fault while in kernel mode cpuid = 0; apic id = 00 fault virtual address = 0x7380afd000 fault code = supervisor read data, page not present instruction pointer = 0x8:0xffffffff80789636 stack pointer = 0x10:0xffffffffaeee2bd0 frame pointer = 0x10:0xffffff000420a800 code segment = base 0x0, limit 0xfffff, type 0x1b = DPL 0, pres 1, long 1, def32 0, gran 1 processor eflags = interrupt enabled, resume, IOPL = 0 current process = 47 (md0) trap number = 12 panic: page fault cpuid = 0 Uptime: 1s Cannot dump. No dump device defined. Automatic reboot in 15 seconds - press a key on the console to abort --> Press a key on the console to reboot, --> or switch off the system now. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 9:37 ` Joey Korkames @ 2009-04-13 9:43 ` phcoder 2009-04-13 10:05 ` phcoder 1 sibling, 0 replies; 25+ messages in thread From: phcoder @ 2009-04-13 9:43 UTC (permalink / raw) To: The development of GRUB 2 Hello, I know where you problem comes from I'll try to fix it now. Joey Korkames wrote: > phcoder writes: > >> Joey Korkames wrote: >>> Hmm, FreeBSD seems to choke when trying to load the grub-bootstrapped >>> mfsroot.gz (as the root device - haven't tried loading without >>> rooting from it)... > >> Thank you for the testing. Can you define "choke" more exactly? >>> > > Hmm, did my log attachment not make it? I'll inline it below. > > "md0: Preloaded image <mfsroot.gz> 11771904 bytes at 0x7380afd000" > I gunzipped the mfsroot.gz on my PXE server, this reported size matches > the uncompressed mfsroot file. > >>> >> Just run commands I gave you. You also need ruby to regenerate all >> these autogenerated files. > > All things Ruby (including the *.rmk files) purposefully try to escape > my attention ;-) > adding maintainer-clean before autogen in my build scripts fixed the > issue -thanks. > > > "Choking": > > Copyright (c) 1992-2009 The FreeBSD Project. > Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 > The Regents of the University of California. All rights reserved. > FreeBSD is a registered trademark of The FreeBSD Foundation. > FreeBSD 7.1-RELEASE #0: Thu Jan 1 08:58:24 UTC 2009 > root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC > Timecounter "i8254" frequency 1193182 Hz quality 0 > CPU: Intel(R) Xeon(R) CPU 5140 @ 2.33GHz (2333.35-MHz > K8-class CPU) > Origin = "GenuineIntel" Id = 0x6f6 Stepping = 6 > Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> > > Features2=0x4e3bd<SSE3,RSVD2,MON,DS_CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,DCA> > > AMD Features=0x20000800<SYSCALL,LM> > AMD Features2=0x1<LAHF> > Cores per package: 2 > usable memory = 17155354624 (16360 MB) > avail memory = 16608129024 (15838 MB) > ACPI APIC Table: <PTLTD APIC > > FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs > cpu0 (BSP): APIC ID: 0 > cpu1 (AP): APIC ID: 1 > ioapic0 <Version 2.0> irqs 0-23 on motherboard > ioapic1 <Version 2.0> irqs 24-47 on motherboard > kbd1 at kbdmux0 > ath_hal: 0.9.20.3 (AR5210, AR5211, AR5212, RF5111, RF5112, RF2413, RF5413) > acpi0: <PTLTD RSDT> on motherboard > acpi0: [ITHREAD] > acpi0: Power Button (fixed) > Timecounter "ACPI-safe" frequency 3579545 Hz quality 850 > acpi_timer0: <24-bit timer at 3.579545MHz> port 0x1008-0x100b on acpi0 > pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0 > pci0: <ACPI PCI bus> on pcib0 > pcib1: <ACPI PCI-PCI bridge> at device 2.0 on pci0 > pci1: <ACPI PCI bus> on pcib1 > pcib2: <ACPI PCI-PCI bridge> irq 16 at device 0.0 on pci1 > pci2: <ACPI PCI bus> on pcib2 > pcib3: <ACPI PCI-PCI bridge> irq 16 at device 0.0 on pci2 > pci3: <ACPI PCI bus> on pcib3 > pcib4: <ACPI PCI-PCI bridge> at device 0.0 on pci3 > pci4: <ACPI PCI bus> on pcib4 > ahd0: <Adaptec AIC7902 Ultra320 SCSI adapter> port > 0x2400-0x24ff,0x2000-0x20ff mem 0xc8200000-0xc8201fff irq 16 at device > 2.0 on pci4 > ahd0: [ITHREAD] > aic7902: Ultra320 Wide Channel A, SCSI Id=7, PCI-X 67-100Mhz, 512 SCBs > ahd1: <Adaptec AIC7902 Ultra320 SCSI adapter> port > 0x2c00-0x2cff,0x2800-0x28ff mem 0xc8202000-0xc8203fff irq 17 at device > 2.1 on pci4 > ahd1: [ITHREAD] > aic7902: Ultra320 Wide Channel B, SCSI Id=7, PCI-X 67-100Mhz, 512 SCBs > pcib5: <ACPI PCI-PCI bridge> at device 0.2 on pci3 > pci5: <ACPI PCI bus> on pcib5 > pcib6: <ACPI PCI-PCI bridge> irq 18 at device 2.0 on pci2 > pci6: <ACPI PCI bus> on pcib6 > em0: <Intel(R) PRO/1000 Network Connection 6.9.6> port 0x3000-0x301f mem > 0xc8300000-0xc831ffff irq 18 at device 0.0 on pci6 > em0: Using MSI interrupt > em0: [FILTER] > em0: Ethernet address: 00:30:48:31:6b:10 > em1: <Intel(R) PRO/1000 Network Connection 6.9.6> port 0x3020-0x303f mem > 0xc8320000-0xc833ffff irq 19 at device 0.1 on pci6 > em1: Using MSI interrupt > em1: [FILTER] > em1: Ethernet address: 00:30:48:31:6b:11 > pcib7: <ACPI PCI-PCI bridge> at device 0.3 on pci1 > pci7: <ACPI PCI bus> on pcib7 > mpt0: <LSILogic SAS/SATA Adapter> port 0x4000-0x40ff mem > 0xc8410000-0xc8413fff,0xc8400000-0xc840ffff irq 24 at device 1.0 on pci7 > mpt0: [ITHREAD] > mpt0: MPI Version=1.5.13.0 > mpt0: Capabilities: ( RAID-0 RAID-1E RAID-1 ) > mpt0: 0 Active Volumes (2 Max) > mpt0: 0 Hidden Drive Members (10 Max) > pcib8: <ACPI PCI-PCI bridge> at device 4.0 on pci0 > pci8: <ACPI PCI bus> on pcib8 > pcib9: <ACPI PCI-PCI bridge> at device 6.0 on pci0 > pci9: <ACPI PCI bus> on pcib9 > pci0: <base peripheral> at device 8.0 (no driver attached) > pcib10: <ACPI PCI-PCI bridge> irq 17 at device 28.0 on pci0 > pci10: <ACPI PCI bus> on pcib10 > uhci0: <Intel 631XESB/632XESB/3100 USB controller USB-1> port > 0x1800-0x181f irq 17 at device 29.0 on pci0 > uhci0: [GIANT-LOCKED] > uhci0: [ITHREAD] > usb0: <Intel 631XESB/632XESB/3100 USB controller USB-1> on uhci0 > usb0: USB revision 1.0 > uhub0: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb0 > uhub0: 2 ports with 2 removable, self powered > uhci1: <Intel 631XESB/632XESB/3100 USB controller USB-2> port > 0x1820-0x183f irq 19 at device 29.1 on pci0 > uhci1: [GIANT-LOCKED] > uhci1: [ITHREAD] > usb1: <Intel 631XESB/632XESB/3100 USB controller USB-2> on uhci1 > usb1: USB revision 1.0 > uhub1: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb1 > uhub1: 2 ports with 2 removable, self powered > uhci2: <Intel 631XESB/632XESB/3100 USB controller USB-3> port > 0x1840-0x185f irq 18 at device 29.2 on pci0 > uhci2: [GIANT-LOCKED] > uhci2: [ITHREAD] > usb2: <Intel 631XESB/632XESB/3100 USB controller USB-3> on uhci2 > usb2: USB revision 1.0 > uhub2: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb2 > uhub2: 2 ports with 2 removable, self powered > ehci0: <Intel 63XXESB USB 2.0 controller> mem 0xc8000000-0xc80003ff irq > 17 at device 29.7 on pci0 > ehci0: [GIANT-LOCKED] > ehci0: [ITHREAD] > usb3: EHCI version 1.0 > usb3: companion controllers, 2 ports each: usb0 usb1 usb2 > usb3: <Intel 63XXESB USB 2.0 controller> on ehci0 > usb3: USB revision 2.0 > uhub3: <Intel EHCI root hub, class 9/0, rev 2.00/1.00, addr 1> on usb3 > uhub3: 6 ports with 6 removable, self powered > pcib11: <ACPI PCI-PCI bridge> at device 30.0 on pci0 > pci11: <ACPI PCI bus> on pcib11 > vgapci0: <VGA-compatible display> port 0x5000-0x50ff mem > 0xd0000000-0xd7ffffff,0xc8500000-0xc850ffff irq 18 at device 1.0 on pci11 > isab0: <PCI-ISA bridge> at device 31.0 on pci0 > isa0: <ISA bus> on isab0 > atapci0: <Intel 63XXESB2 UDMA100 controller> port > 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0x1860-0x186f at device 31.1 on pci0 > ata0: <ATA channel 0> on atapci0 > ata0: [ITHREAD] > ata1: <ATA channel 1> on atapci0 > ata1: [ITHREAD] > pci0: <serial bus, SMBus> at device 31.3 (no driver attached) > acpi_button0: <Power Button> on acpi0 > atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0 > atkbd0: <AT Keyboard> irq 1 on atkbdc0 > kbd0 at atkbd0 > atkbd0: [GIANT-LOCKED] > atkbd0: [ITHREAD] > sio0: configured irq 4 not in bitmap of probed irqs 0 > sio0: port may not be enabled > sio0: configured irq 4 not in bitmap of probed irqs 0 > sio0: port may not be enabled > sio0: <16550A-compatible COM port> port 0x3f8-0x3ff irq 4 flags 0x10 on > acpi0 > sio0: type 16550A, console > sio0: [FILTER] > sio1: configured irq 3 not in bitmap of probed irqs 0 > sio1: port may not be enabled > sio1: configured irq 3 not in bitmap of probed irqs 0 > sio1: port may not be enabled > sio1: <16550A-compatible COM port> port 0x2f8-0x2ff irq 3 on acpi0 > sio1: type 16550A > sio1: [FILTER] > fdc0: <floppy drive controller> port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on acpi0 > fdc0: [FILTER] > ppc0: <Parallel port> port 0x378-0x37f,0x778-0x77f irq 7 drq 3 on acpi0 > ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode > ppc0: FIFO with 16/16/9 bytes threshold > ppbus0: <Parallel port bus> on ppc0 > ppbus0: [ITHREAD] > plip0: <PLIP network interface> on ppbus0 > plip0: WARNING: using obsoleted IFF_NEEDSGIANT flag > lpt0: <Printer> on ppbus0 > lpt0: Interrupt-driven port > ppi0: <Parallel I/O> on ppbus0 > ppc0: [GIANT-LOCKED] > ppc0: [ITHREAD] > cpu0: <ACPI CPU> on acpi0 > est0: <Enhanced SpeedStep Frequency Control> on cpu0 > est: CPU supports Enhanced Speedstep, but is not recognized. > est: cpu_vendor GenuineIntel, msr 728072806000728 > device_attach: est0 attach returned 6 > p4tcc0: <CPU Frequency Thermal Control> on cpu0 > cpu1: <ACPI CPU> on acpi0 > est1: <Enhanced SpeedStep Frequency Control> on cpu1 > est: CPU supports Enhanced Speedstep, but is not recognized. > est: cpu_vendor GenuineIntel, msr 728072806000728 > device_attach: est1 attach returned 6 > p4tcc1: <CPU Frequency Thermal Control> on cpu1 > orm0: <ISA Option ROMs> at iomem > 0xc0000-0xcafff,0xcb000-0xcbfff,0xcc000-0xcc7ff on isa0 > sc0: <System console> at flags 0x100 on isa0 > sc0: VGA <16 virtual consoles, flags=0x300> > vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 > Timecounters tick every 1.000 msec > md0: Preloaded image <mfsroot.gz> 11771904 bytes at 0x7380afd000 > > > Fatal trap 12: page fault while in kernel mode > cpuid = 0; apic id = 00 > fault virtual address = 0x7380afd000 > fault code = supervisor read data, page not present > instruction pointer = 0x8:0xffffffff80789636 > stack pointer = 0x10:0xffffffffaeee2bd0 > frame pointer = 0x10:0xffffff000420a800 > code segment = base 0x0, limit 0xfffff, type 0x1b > = DPL 0, pres 1, long 1, def32 0, gran 1 > processor eflags = interrupt enabled, resume, IOPL = 0 > current process = 47 (md0) > trap number = 12 > panic: page fault > cpuid = 0 > Uptime: 1s > Cannot dump. No dump device defined. > Automatic reboot in 15 seconds - press a key on the console to abort > --> Press a key on the console to reboot, > --> or switch off the system now. > > > > > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel -- Regards Vladimir 'phcoder' Serbinenko ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 9:37 ` Joey Korkames 2009-04-13 9:43 ` phcoder @ 2009-04-13 10:05 ` phcoder 2009-04-13 21:36 ` Joey Korkames 1 sibling, 1 reply; 25+ messages in thread From: phcoder @ 2009-04-13 10:05 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 10136 bytes --] Try this Joey Korkames wrote: > phcoder writes: > >> Joey Korkames wrote: >>> Hmm, FreeBSD seems to choke when trying to load the grub-bootstrapped >>> mfsroot.gz (as the root device - haven't tried loading without >>> rooting from it)... > >> Thank you for the testing. Can you define "choke" more exactly? >>> > > Hmm, did my log attachment not make it? I'll inline it below. > > "md0: Preloaded image <mfsroot.gz> 11771904 bytes at 0x7380afd000" > I gunzipped the mfsroot.gz on my PXE server, this reported size matches > the uncompressed mfsroot file. > >>> >> Just run commands I gave you. You also need ruby to regenerate all >> these autogenerated files. > > All things Ruby (including the *.rmk files) purposefully try to escape > my attention ;-) > adding maintainer-clean before autogen in my build scripts fixed the > issue -thanks. > > > "Choking": > > Copyright (c) 1992-2009 The FreeBSD Project. > Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 > The Regents of the University of California. All rights reserved. > FreeBSD is a registered trademark of The FreeBSD Foundation. > FreeBSD 7.1-RELEASE #0: Thu Jan 1 08:58:24 UTC 2009 > root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC > Timecounter "i8254" frequency 1193182 Hz quality 0 > CPU: Intel(R) Xeon(R) CPU 5140 @ 2.33GHz (2333.35-MHz > K8-class CPU) > Origin = "GenuineIntel" Id = 0x6f6 Stepping = 6 > Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> > > Features2=0x4e3bd<SSE3,RSVD2,MON,DS_CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,DCA> > > AMD Features=0x20000800<SYSCALL,LM> > AMD Features2=0x1<LAHF> > Cores per package: 2 > usable memory = 17155354624 (16360 MB) > avail memory = 16608129024 (15838 MB) > ACPI APIC Table: <PTLTD APIC > > FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs > cpu0 (BSP): APIC ID: 0 > cpu1 (AP): APIC ID: 1 > ioapic0 <Version 2.0> irqs 0-23 on motherboard > ioapic1 <Version 2.0> irqs 24-47 on motherboard > kbd1 at kbdmux0 > ath_hal: 0.9.20.3 (AR5210, AR5211, AR5212, RF5111, RF5112, RF2413, RF5413) > acpi0: <PTLTD RSDT> on motherboard > acpi0: [ITHREAD] > acpi0: Power Button (fixed) > Timecounter "ACPI-safe" frequency 3579545 Hz quality 850 > acpi_timer0: <24-bit timer at 3.579545MHz> port 0x1008-0x100b on acpi0 > pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0 > pci0: <ACPI PCI bus> on pcib0 > pcib1: <ACPI PCI-PCI bridge> at device 2.0 on pci0 > pci1: <ACPI PCI bus> on pcib1 > pcib2: <ACPI PCI-PCI bridge> irq 16 at device 0.0 on pci1 > pci2: <ACPI PCI bus> on pcib2 > pcib3: <ACPI PCI-PCI bridge> irq 16 at device 0.0 on pci2 > pci3: <ACPI PCI bus> on pcib3 > pcib4: <ACPI PCI-PCI bridge> at device 0.0 on pci3 > pci4: <ACPI PCI bus> on pcib4 > ahd0: <Adaptec AIC7902 Ultra320 SCSI adapter> port > 0x2400-0x24ff,0x2000-0x20ff mem 0xc8200000-0xc8201fff irq 16 at device > 2.0 on pci4 > ahd0: [ITHREAD] > aic7902: Ultra320 Wide Channel A, SCSI Id=7, PCI-X 67-100Mhz, 512 SCBs > ahd1: <Adaptec AIC7902 Ultra320 SCSI adapter> port > 0x2c00-0x2cff,0x2800-0x28ff mem 0xc8202000-0xc8203fff irq 17 at device > 2.1 on pci4 > ahd1: [ITHREAD] > aic7902: Ultra320 Wide Channel B, SCSI Id=7, PCI-X 67-100Mhz, 512 SCBs > pcib5: <ACPI PCI-PCI bridge> at device 0.2 on pci3 > pci5: <ACPI PCI bus> on pcib5 > pcib6: <ACPI PCI-PCI bridge> irq 18 at device 2.0 on pci2 > pci6: <ACPI PCI bus> on pcib6 > em0: <Intel(R) PRO/1000 Network Connection 6.9.6> port 0x3000-0x301f mem > 0xc8300000-0xc831ffff irq 18 at device 0.0 on pci6 > em0: Using MSI interrupt > em0: [FILTER] > em0: Ethernet address: 00:30:48:31:6b:10 > em1: <Intel(R) PRO/1000 Network Connection 6.9.6> port 0x3020-0x303f mem > 0xc8320000-0xc833ffff irq 19 at device 0.1 on pci6 > em1: Using MSI interrupt > em1: [FILTER] > em1: Ethernet address: 00:30:48:31:6b:11 > pcib7: <ACPI PCI-PCI bridge> at device 0.3 on pci1 > pci7: <ACPI PCI bus> on pcib7 > mpt0: <LSILogic SAS/SATA Adapter> port 0x4000-0x40ff mem > 0xc8410000-0xc8413fff,0xc8400000-0xc840ffff irq 24 at device 1.0 on pci7 > mpt0: [ITHREAD] > mpt0: MPI Version=1.5.13.0 > mpt0: Capabilities: ( RAID-0 RAID-1E RAID-1 ) > mpt0: 0 Active Volumes (2 Max) > mpt0: 0 Hidden Drive Members (10 Max) > pcib8: <ACPI PCI-PCI bridge> at device 4.0 on pci0 > pci8: <ACPI PCI bus> on pcib8 > pcib9: <ACPI PCI-PCI bridge> at device 6.0 on pci0 > pci9: <ACPI PCI bus> on pcib9 > pci0: <base peripheral> at device 8.0 (no driver attached) > pcib10: <ACPI PCI-PCI bridge> irq 17 at device 28.0 on pci0 > pci10: <ACPI PCI bus> on pcib10 > uhci0: <Intel 631XESB/632XESB/3100 USB controller USB-1> port > 0x1800-0x181f irq 17 at device 29.0 on pci0 > uhci0: [GIANT-LOCKED] > uhci0: [ITHREAD] > usb0: <Intel 631XESB/632XESB/3100 USB controller USB-1> on uhci0 > usb0: USB revision 1.0 > uhub0: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb0 > uhub0: 2 ports with 2 removable, self powered > uhci1: <Intel 631XESB/632XESB/3100 USB controller USB-2> port > 0x1820-0x183f irq 19 at device 29.1 on pci0 > uhci1: [GIANT-LOCKED] > uhci1: [ITHREAD] > usb1: <Intel 631XESB/632XESB/3100 USB controller USB-2> on uhci1 > usb1: USB revision 1.0 > uhub1: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb1 > uhub1: 2 ports with 2 removable, self powered > uhci2: <Intel 631XESB/632XESB/3100 USB controller USB-3> port > 0x1840-0x185f irq 18 at device 29.2 on pci0 > uhci2: [GIANT-LOCKED] > uhci2: [ITHREAD] > usb2: <Intel 631XESB/632XESB/3100 USB controller USB-3> on uhci2 > usb2: USB revision 1.0 > uhub2: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb2 > uhub2: 2 ports with 2 removable, self powered > ehci0: <Intel 63XXESB USB 2.0 controller> mem 0xc8000000-0xc80003ff irq > 17 at device 29.7 on pci0 > ehci0: [GIANT-LOCKED] > ehci0: [ITHREAD] > usb3: EHCI version 1.0 > usb3: companion controllers, 2 ports each: usb0 usb1 usb2 > usb3: <Intel 63XXESB USB 2.0 controller> on ehci0 > usb3: USB revision 2.0 > uhub3: <Intel EHCI root hub, class 9/0, rev 2.00/1.00, addr 1> on usb3 > uhub3: 6 ports with 6 removable, self powered > pcib11: <ACPI PCI-PCI bridge> at device 30.0 on pci0 > pci11: <ACPI PCI bus> on pcib11 > vgapci0: <VGA-compatible display> port 0x5000-0x50ff mem > 0xd0000000-0xd7ffffff,0xc8500000-0xc850ffff irq 18 at device 1.0 on pci11 > isab0: <PCI-ISA bridge> at device 31.0 on pci0 > isa0: <ISA bus> on isab0 > atapci0: <Intel 63XXESB2 UDMA100 controller> port > 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0x1860-0x186f at device 31.1 on pci0 > ata0: <ATA channel 0> on atapci0 > ata0: [ITHREAD] > ata1: <ATA channel 1> on atapci0 > ata1: [ITHREAD] > pci0: <serial bus, SMBus> at device 31.3 (no driver attached) > acpi_button0: <Power Button> on acpi0 > atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0 > atkbd0: <AT Keyboard> irq 1 on atkbdc0 > kbd0 at atkbd0 > atkbd0: [GIANT-LOCKED] > atkbd0: [ITHREAD] > sio0: configured irq 4 not in bitmap of probed irqs 0 > sio0: port may not be enabled > sio0: configured irq 4 not in bitmap of probed irqs 0 > sio0: port may not be enabled > sio0: <16550A-compatible COM port> port 0x3f8-0x3ff irq 4 flags 0x10 on > acpi0 > sio0: type 16550A, console > sio0: [FILTER] > sio1: configured irq 3 not in bitmap of probed irqs 0 > sio1: port may not be enabled > sio1: configured irq 3 not in bitmap of probed irqs 0 > sio1: port may not be enabled > sio1: <16550A-compatible COM port> port 0x2f8-0x2ff irq 3 on acpi0 > sio1: type 16550A > sio1: [FILTER] > fdc0: <floppy drive controller> port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on acpi0 > fdc0: [FILTER] > ppc0: <Parallel port> port 0x378-0x37f,0x778-0x77f irq 7 drq 3 on acpi0 > ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode > ppc0: FIFO with 16/16/9 bytes threshold > ppbus0: <Parallel port bus> on ppc0 > ppbus0: [ITHREAD] > plip0: <PLIP network interface> on ppbus0 > plip0: WARNING: using obsoleted IFF_NEEDSGIANT flag > lpt0: <Printer> on ppbus0 > lpt0: Interrupt-driven port > ppi0: <Parallel I/O> on ppbus0 > ppc0: [GIANT-LOCKED] > ppc0: [ITHREAD] > cpu0: <ACPI CPU> on acpi0 > est0: <Enhanced SpeedStep Frequency Control> on cpu0 > est: CPU supports Enhanced Speedstep, but is not recognized. > est: cpu_vendor GenuineIntel, msr 728072806000728 > device_attach: est0 attach returned 6 > p4tcc0: <CPU Frequency Thermal Control> on cpu0 > cpu1: <ACPI CPU> on acpi0 > est1: <Enhanced SpeedStep Frequency Control> on cpu1 > est: CPU supports Enhanced Speedstep, but is not recognized. > est: cpu_vendor GenuineIntel, msr 728072806000728 > device_attach: est1 attach returned 6 > p4tcc1: <CPU Frequency Thermal Control> on cpu1 > orm0: <ISA Option ROMs> at iomem > 0xc0000-0xcafff,0xcb000-0xcbfff,0xcc000-0xcc7ff on isa0 > sc0: <System console> at flags 0x100 on isa0 > sc0: VGA <16 virtual consoles, flags=0x300> > vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 > Timecounters tick every 1.000 msec > md0: Preloaded image <mfsroot.gz> 11771904 bytes at 0x7380afd000 > > > Fatal trap 12: page fault while in kernel mode > cpuid = 0; apic id = 00 > fault virtual address = 0x7380afd000 > fault code = supervisor read data, page not present > instruction pointer = 0x8:0xffffffff80789636 > stack pointer = 0x10:0xffffffffaeee2bd0 > frame pointer = 0x10:0xffffff000420a800 > code segment = base 0x0, limit 0xfffff, type 0x1b > = DPL 0, pres 1, long 1, def32 0, gran 1 > processor eflags = interrupt enabled, resume, IOPL = 0 > current process = 47 (md0) > trap number = 12 > panic: page fault > cpuid = 0 > Uptime: 1s > Cannot dump. No dump device defined. > Automatic reboot in 15 seconds - press a key on the console to abort > --> Press a key on the console to reboot, > --> or switch off the system now. > > > > > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel -- Regards Vladimir 'phcoder' Serbinenko [-- Attachment #2: bsd64fix.diff --] [-- Type: text/x-diff, Size: 1267 bytes --] diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 8c59c1b..8e9bb17 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -219,11 +219,27 @@ grub_freebsd_add_meta_module (int is_kern, int argc, char **argv, ((is_64bit) ? FREEBSD_MODTYPE_KERNEL64 : FREEBSD_MODTYPE_KERNEL) : FREEBSD_MODTYPE_RAW); - if ((grub_freebsd_add_meta (FREEBSD_MODINFO_TYPE, type, + if (is_64bit) + { + grub_uint64_t addr64 = addr, size64 = size; + if ((grub_freebsd_add_meta (FREEBSD_MODINFO_TYPE, type, grub_strlen (type) + 1)) || - (grub_freebsd_add_meta (FREEBSD_MODINFO_ADDR, &addr, sizeof (addr))) || - (grub_freebsd_add_meta (FREEBSD_MODINFO_SIZE, &size, sizeof (size)))) - return grub_errno; + (grub_freebsd_add_meta (FREEBSD_MODINFO_ADDR, &addr64, + sizeof (addr64))) || + (grub_freebsd_add_meta (FREEBSD_MODINFO_SIZE, &size64, + sizeof (size64)))) + return grub_errno; + } + else + { + if ((grub_freebsd_add_meta (FREEBSD_MODINFO_TYPE, type, + grub_strlen (type) + 1)) || + (grub_freebsd_add_meta (FREEBSD_MODINFO_ADDR, &addr, + sizeof (addr))) || + (grub_freebsd_add_meta (FREEBSD_MODINFO_SIZE, &size, + sizeof (size)))) + return grub_errno; + } if (argc) { ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 10:05 ` phcoder @ 2009-04-13 21:36 ` Joey Korkames 2009-04-14 8:13 ` Chip Panarchy 0 siblings, 1 reply; 25+ messages in thread From: Joey Korkames @ 2009-04-13 21:36 UTC (permalink / raw) To: The development of GRUB 2 That did the trick - amd64 boots with a mfsroot now. thanks! -joey phcoder writes: > Try this > Joey Korkames wrote: >> phcoder writes: >> >>> Joey Korkames wrote: >>>> Hmm, FreeBSD seems to choke when trying to load the grub-bootstrapped >>>> mfsroot.gz (as the root device - haven't tried loading without >>>> rooting from it)... ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-13 21:36 ` Joey Korkames @ 2009-04-14 8:13 ` Chip Panarchy 2009-04-14 19:17 ` Joey Korkames 0 siblings, 1 reply; 25+ messages in thread From: Chip Panarchy @ 2009-04-14 8:13 UTC (permalink / raw) To: The development of GRUB 2 What's the advantage of booting with an mfsroot? Also, will it be advantageous to me? (FreeBSD installations contained within a UFS, UFS2 &/or ZFS logical partition) On Tue, Apr 14, 2009 at 7:36 AM, Joey Korkames <joey+lists@kidfixit.com> wrote: > That did the trick - amd64 boots with a mfsroot now. thanks! > > -joey > > phcoder writes: > >> Try this >> Joey Korkames wrote: >>> >>> phcoder writes: >>> >>>> Joey Korkames wrote: >>>>> >>>>> Hmm, FreeBSD seems to choke when trying to load the grub-bootstrapped >>>>> mfsroot.gz (as the root device - haven't tried loading without rooting from >>>>> it)... > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-14 8:13 ` Chip Panarchy @ 2009-04-14 19:17 ` Joey Korkames 2009-04-14 21:30 ` Chip Panarchy 0 siblings, 1 reply; 25+ messages in thread From: Joey Korkames @ 2009-04-14 19:17 UTC (permalink / raw) To: The development of GRUB 2 > What's the advantage of booting with an mfsroot? You can make a minimal fbsd system in the mfsroot that is smart enough to "init_chroot" from a SMB/NFS netmount, or from a cloop file stored a CD or http-sever (cached to a tmpfs (ramdisk)). Mine also unionfs-mounts a tmpfs to what ever root that is used so you can make changes in ram and not on the source root mount. This is also what Frenzy does - http://frenzy.org.ua/eng/ I don't know if HeX unionfs-mounts or not - http://www.rawpacket.org/projects/hex > > Also, will it be advantageous to me? > I find it useful for executing FreeBSD rescues and where I need to pkg_add tools that are not already on the rootfs. > (FreeBSD installations contained within a UFS, UFS2 &/or ZFS logical partition) > I didn't think of it at first, but the mfsroot could also have all the smarts contained in it for mounting and init_chroot'ing a ZFS root. You still have to load grub and the kernel/mfsroot from a grub-supported fs, but I was very pleased to hear that phcoder is working on that! -joey ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-14 19:17 ` Joey Korkames @ 2009-04-14 21:30 ` Chip Panarchy 0 siblings, 0 replies; 25+ messages in thread From: Chip Panarchy @ 2009-04-14 21:30 UTC (permalink / raw) To: The development of GRUB 2 Hi Great news! Thanks for your reply! Can't wait for PHcoder to finish his work! Panarchy On Wed, Apr 15, 2009 at 5:17 AM, Joey Korkames <joey+lists@kidfixit.com> wrote: >> What's the advantage of booting with an mfsroot? > > You can make a minimal fbsd system in the mfsroot that is smart enough to > "init_chroot" from a SMB/NFS netmount, or from a cloop file stored a CD or > http-sever (cached to a tmpfs (ramdisk)). Mine also unionfs-mounts a tmpfs > to what ever root that is used so you can make changes in ram and not on the > source root mount. > > This is also what Frenzy does - http://frenzy.org.ua/eng/ > > I don't know if HeX unionfs-mounts or not - > http://www.rawpacket.org/projects/hex > >> >> Also, will it be advantageous to me? >> > > I find it useful for executing FreeBSD rescues and where I need to pkg_add > tools that are not already on the rootfs. > >> (FreeBSD installations contained within a UFS, UFS2 &/or ZFS logical >> partition) >> > > I didn't think of it at first, but the mfsroot could also have all the > smarts contained in it for mounting and init_chroot'ing a ZFS root. > > You still have to load grub and the kernel/mfsroot from a grub-supported fs, > but I was very pleased to hear that phcoder is working on that! > > -joey > > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-12 19:19 [PATCH] FreeBSD 64-bit kernel support Bean 2009-04-12 19:26 ` phcoder 2009-04-13 1:27 ` phcoder @ 2009-04-21 21:10 ` Vladimir Serbinenko 2009-04-22 10:52 ` Chip Panarchy 2009-05-03 9:13 ` Vladimir 'phcoder' Serbinenko 3 siblings, 1 reply; 25+ messages in thread From: Vladimir Serbinenko @ 2009-04-21 21:10 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1.1: Type: text/plain, Size: 658 bytes --] Hello, here is the version with changelog, fix for freebsd_module and licencing corrections. If nobody objects I'll commit it soon Enjoy On Sun, Apr 12, 2009 at 9:19 PM, Bean <bean123ch@gmail.com> wrote: > Hi, > > This patch allows you to load amd64 freebsd kernel directly, here is an > example: > > set root=(hd0,1,a) > freebsd /boot/kernel/kernel > freebsd_loadenv /boot/device.hints > set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s1a > boot > > Test successfully on FreeBSD 7.1 amd64. > > -- > Bean > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > > [-- Attachment #1.2: Type: text/html, Size: 1136 bytes --] [-- Attachment #2: bsd64.diff --] [-- Type: text/x-diff, Size: 21750 bytes --] diff --git a/ChangeLog b/ChangeLog index ca0ab43..bd1776b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,40 @@ +2009-04-21 Bean <bean123ch@gmail.com> Vladimir Serbinenko <phcoder@gmail.com> + + FreeBSD 64-bit support + + * conf/i386-pc.rmk (bsd_mod_SOURCES): add loader/i386/bsd_helper.S + and loader/i386/bsd_trampoline.S + (bsd_mod_ASFLAGS): new variable + * include/grub/i386/bsd.h (FREEBSD_MODINFOMD_SMAP): new definition + (FREEBSD_MODTYPE_KERNEL64): likewise + (grub_bsd64_trampoline_start): likewise + (grub_bsd64_trampoline_end): likewise + (grub_bsd64_trampoline_selfjump): likewise + (grub_bsd64_trampoline_gdt): likewise + * include/grub/i386/loader.h (grub_unix_real_boot): moved from here ... + * include/grub/i386/bsd.h (grub_unix_real_boot): ... moved here + * kern/i386/loader.S (grub_unix_real_boot): moved from here ... + * loader/i386/bsd_helper.S (grub_unix_real_boot): moved here + * include/grub/gpt_partition.h (grub_gpt_partentry): Corrected the type + of "attrib" member + * loader/i386/bsd_pagetable.c: new file + * loader/i386/bsd_trampoline.S: likewise + * loader/i386/bsd.c (ALIGN_QWORD): new macro + (ALIGN_VAR): likewise + (entry_hi): new variable + (kern_end_mdofs): likewise + (is_64bit): likewise + (grub_freebsd_add_meta): use ALIGN_VAR + (grub_e820_mmap): new declaration + (grub_freebsd_add_mmap): new function + (grub_freebsd_add_meta_module): support 64 bit kernels + (grub_freebsd_list_modules): use ALIGN_VAR + (gdt_descriptor): new declaration + (grub_freebsd_boot): support 64 bit kernels + (grub_bsd_elf64_hook): new function + (grub_bsd_load_elf): support elf64 + + 2009-04-19 Vladimir Serbinenko <phcoder@gmail.com> Correct GPT definition diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 265b250..bf2516d 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -301,9 +301,10 @@ aout_mod_CFLAGS = $(COMMON_CFLAGS) aout_mod_LDFLAGS = $(COMMON_LDFLAGS) # For bsd.mod -bsd_mod_SOURCES = loader/i386/bsd.c +bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd_helper.S loader/i386/bsd_trampoline.S bsd_mod_CFLAGS = $(COMMON_CFLAGS) bsd_mod_LDFLAGS = $(COMMON_LDFLAGS) +bsd_mod_ASFLAGS = $(COMMON_ASFLAGS) # For usb.mod usb_mod_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c diff --git a/include/grub/i386/bsd.h b/include/grub/i386/bsd.h index f50f18e..3706f4d 100644 --- a/include/grub/i386/bsd.h +++ b/include/grub/i386/bsd.h @@ -80,9 +80,12 @@ #define FREEBSD_MODINFOMD_SHDR 0x0009 /* section header table */ #define FREEBSD_MODINFOMD_NOCOPY 0x8000 /* don't copy this metadata to the kernel */ +#define FREEBSD_MODINFOMD_SMAP 0x1001 + #define FREEBSD_MODINFOMD_DEPLIST (0x4001 | FREEBSD_MODINFOMD_NOCOPY) /* depends on */ #define FREEBSD_MODTYPE_KERNEL "elf kernel" +#define FREEBSD_MODTYPE_KERNEL64 "elf64 kernel" #define FREEBSD_MODTYPE_MODULE "elf module" #define FREEBSD_MODTYPE_RAW "raw" @@ -222,4 +225,11 @@ struct grub_netbsd_btinfo_bootdisk int partition; }; +void grub_unix_real_boot (grub_addr_t entry, ...) + __attribute__ ((cdecl,noreturn)); + +extern grub_uint8_t grub_bsd64_trampoline_start, grub_bsd64_trampoline_end; +extern grub_uint32_t grub_bsd64_trampoline_selfjump; +extern grub_uint32_t grub_bsd64_trampoline_gdt; + #endif /* ! GRUB_BSD_CPU_HEADER */ diff --git a/include/grub/i386/loader.h b/include/grub/i386/loader.h index afd3eb9..72a44d0 100644 --- a/include/grub/i386/loader.h +++ b/include/grub/i386/loader.h @@ -32,7 +32,4 @@ extern grub_size_t EXPORT_VAR(grub_os_area_size); grub_err_t EXPORT_FUNC(grub_linux16_boot) (void); -void EXPORT_FUNC(grub_unix_real_boot) (grub_addr_t entry, ...) - __attribute__ ((cdecl,noreturn)); - #endif /* ! GRUB_LOADER_CPU_HEADER */ diff --git a/kern/i386/loader.S b/kern/i386/loader.S index bbd2187..3e9c713 100644 --- a/kern/i386/loader.S +++ b/kern/i386/loader.S @@ -118,25 +118,3 @@ linux_setup_seg: .word 0 .code32 -/* - * Use cdecl calling convention for *BSD kernels. - */ - -FUNCTION(grub_unix_real_boot) - - call EXT_C(grub_dl_unload_all) - - /* Interrupts should be disabled. */ - cli - - /* Discard `grub_unix_real_boot' return address. */ - popl %eax - - /* Fetch `entry' address ... */ - popl %eax - - /* - * ... and put our return address in its place. The kernel will - * ignore it, but it expects %esp to point to it. - */ - call *%eax diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index 355cb3f..167cd0b 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. + * Copyright (C) 2008, 2009 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,17 +33,19 @@ #include <grub/command.h> #define ALIGN_DWORD(a) ALIGN_UP (a, 4) +#define ALIGN_QWORD(a) ALIGN_UP (a, 8) +#define ALIGN_VAR(a) ((is_64bit) ? (ALIGN_QWORD(a)) : (ALIGN_DWORD(a))) #define ALIGN_PAGE(a) ALIGN_UP (a, 4096) #define MOD_BUF_ALLOC_UNIT 4096 static int kernel_type; static grub_dl_t my_mod; -static grub_addr_t entry, kern_start, kern_end; +static grub_addr_t entry, entry_hi, kern_start, kern_end; static grub_uint32_t bootflags; static char *mod_buf; -static grub_uint32_t mod_buf_len, mod_buf_max; -static int is_elf_kernel; +static grub_uint32_t mod_buf_len, mod_buf_max, kern_end_mdofs; +static int is_elf_kernel, is_64bit; static const char freebsd_opts[] = "DhaCcdgmnpqrsv"; static const grub_uint32_t freebsd_flags[] = @@ -135,11 +137,58 @@ grub_freebsd_add_meta (grub_uint32_t type, void *data, grub_uint32_t len) if (len) grub_memcpy (mod_buf + mod_buf_len, data, len); - mod_buf_len = ALIGN_DWORD (mod_buf_len + len); + mod_buf_len = ALIGN_VAR (mod_buf_len + len); return GRUB_ERR_NONE; } +struct grub_e820_mmap +{ + grub_uint64_t addr; + grub_uint64_t size; + grub_uint32_t type; +} __attribute__((packed)); + +static grub_err_t +grub_freebsd_add_mmap (void) +{ + grub_size_t len = 0; + struct grub_e820_mmap *mmap = 0; + + auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t); + int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, + grub_uint32_t type) + { + if (mmap) + { + mmap->addr = addr; + mmap->size = size; + mmap->type = type; + mmap++; + } + else + len += sizeof (struct grub_e820_mmap); + + return 0; + } + + struct grub_e820_mmap *mmap_buf; + + grub_machine_mmap_iterate (hook); + mmap_buf = mmap = grub_malloc (len); + if (! mmap) + return grub_errno; + + grub_machine_mmap_iterate (hook); + + grub_freebsd_add_meta (FREEBSD_MODINFO_METADATA | + FREEBSD_MODINFOMD_SMAP, mmap_buf, len); + + grub_free (mmap_buf); + + return grub_errno; +} + static grub_err_t grub_freebsd_add_meta_module (int is_kern, int argc, char **argv, grub_addr_t addr, grub_uint32_t size) @@ -166,13 +215,31 @@ grub_freebsd_add_meta_module (int is_kern, int argc, char **argv, argv++; } else - type = (is_kern) ? FREEBSD_MODTYPE_KERNEL : FREEBSD_MODTYPE_RAW; + type = ((is_kern) ? + ((is_64bit) ? FREEBSD_MODTYPE_KERNEL64 : FREEBSD_MODTYPE_KERNEL) + : FREEBSD_MODTYPE_RAW); - if ((grub_freebsd_add_meta (FREEBSD_MODINFO_TYPE, type, + if (is_64bit) + { + grub_uint64_t addr64 = addr, size64 = size; + if ((grub_freebsd_add_meta (FREEBSD_MODINFO_TYPE, type, grub_strlen (type) + 1)) || - (grub_freebsd_add_meta (FREEBSD_MODINFO_ADDR, &addr, sizeof (addr))) || - (grub_freebsd_add_meta (FREEBSD_MODINFO_SIZE, &size, sizeof (size)))) - return grub_errno; + (grub_freebsd_add_meta (FREEBSD_MODINFO_ADDR, &addr64, + sizeof (addr64))) || + (grub_freebsd_add_meta (FREEBSD_MODINFO_SIZE, &size64, + sizeof (size64)))) + return grub_errno; + } + else + { + if ((grub_freebsd_add_meta (FREEBSD_MODINFO_TYPE, type, + grub_strlen (type) + 1)) || + (grub_freebsd_add_meta (FREEBSD_MODINFO_ADDR, &addr, + sizeof (addr))) || + (grub_freebsd_add_meta (FREEBSD_MODINFO_SIZE, &size, + sizeof (size)))) + return grub_errno; + } if (argc) { @@ -202,6 +269,23 @@ grub_freebsd_add_meta_module (int is_kern, int argc, char **argv, } } + if (is_kern) + { + int len = (is_64bit) ? 8 : 4; + grub_uint64_t data = 0; + + if ((grub_freebsd_add_meta (FREEBSD_MODINFO_METADATA | + FREEBSD_MODINFOMD_HOWTO, &data, 4)) || + (grub_freebsd_add_meta (FREEBSD_MODINFO_METADATA | + FREEBSD_MODINFOMD_ENVP, &data, len)) || + (grub_freebsd_add_meta (FREEBSD_MODINFO_METADATA | + FREEBSD_MODINFOMD_KERNEND, &data, len))) + return grub_errno; + kern_end_mdofs = mod_buf_len - len; + + return grub_freebsd_add_mmap (); + } + return GRUB_ERR_NONE; } @@ -241,10 +325,19 @@ grub_freebsd_list_modules (void) } } - pos = ALIGN_DWORD (pos + size); + pos = ALIGN_VAR (pos + size); } } +/* This function would be here but it's under different licence. */ +#include "bsd_pagetable.c" + +struct gdt_descriptor +{ + grub_uint16_t limit; + void *base; +} __attribute__ ((packed)); + static grub_err_t grub_freebsd_boot (void) { @@ -291,6 +384,9 @@ grub_freebsd_boot (void) if (is_elf_kernel) { + grub_addr_t md_ofs; + int ofs; + if (grub_freebsd_add_meta (FREEBSD_MODINFO_END, 0, 0)) return grub_errno; @@ -298,12 +394,70 @@ grub_freebsd_boot (void) bi.bi_modulep = kern_end; kern_end = ALIGN_PAGE (kern_end + mod_buf_len); + + if (is_64bit) + kern_end += 4096 * 4; + + md_ofs = bi.bi_modulep + kern_end_mdofs; + ofs = (is_64bit) ? 16 : 12; + *((grub_uint32_t *) md_ofs) = kern_end; + md_ofs -= ofs; + *((grub_uint32_t *) md_ofs) = bi.bi_envp; + md_ofs -= ofs; + *((grub_uint32_t *) md_ofs) = bootflags; } bi.bi_kernend = kern_end; - grub_unix_real_boot (entry, bootflags | FREEBSD_RB_BOOTINFO, bootdev, - 0, 0, 0, &bi, bi.bi_modulep, kern_end); + if (is_64bit) + { + grub_uint32_t *gdt; + grub_uint8_t *trampoline; + void (*launch_trampoline) (grub_addr_t entry, ...) + __attribute__ ((cdecl, regparm (0))); + grub_uint8_t *pagetable; + + struct gdt_descriptor *gdtdesc; + + pagetable = (grub_uint8_t *) (kern_end - 16384); + fill_bsd64_pagetable (pagetable); + + /* Create GDT. */ + gdt = (grub_uint32_t *) (kern_end - 4096); + gdt[0] = 0; + gdt[1] = 0; + gdt[2] = 0; + gdt[3] = 0x00209800; + gdt[4] = 0; + gdt[5] = 0x00008000; + + /* Create GDT descriptor. */ + gdtdesc = (struct gdt_descriptor *) (kern_end - 4096 + 24); + gdtdesc->limit = 24; + gdtdesc->base = gdt; + + /* Prepare trampoline. */ + trampoline = (grub_uint8_t *) (kern_end - 4096 + 24 + + sizeof (struct gdt_descriptor)); + launch_trampoline = (void __attribute__ ((cdecl, regparm (0))) + (*) (grub_addr_t entry, ...)) trampoline; + grub_bsd64_trampoline_gdt = (grub_uint32_t) gdtdesc; + grub_bsd64_trampoline_selfjump + = (grub_uint32_t) (trampoline + 6 + + ((grub_uint8_t *) &grub_bsd64_trampoline_selfjump + - &grub_bsd64_trampoline_start)); + + /* Copy trampoline. */ + grub_memcpy (trampoline, &grub_bsd64_trampoline_start, + &grub_bsd64_trampoline_end - &grub_bsd64_trampoline_start); + + /* Launch trampoline. */ + launch_trampoline (entry, entry_hi, pagetable, bi.bi_modulep, + kern_end); + } + else + grub_unix_real_boot (entry, bootflags | FREEBSD_RB_BOOTINFO, bootdev, + 0, 0, 0, &bi, bi.bi_modulep, kern_end); /* Not reached. */ return GRUB_ERR_NONE; @@ -478,6 +632,29 @@ grub_bsd_elf32_hook (Elf32_Phdr * phdr, grub_addr_t * addr) } static grub_err_t +grub_bsd_elf64_hook (Elf64_Phdr * phdr, grub_addr_t * addr) +{ + Elf64_Addr paddr; + + paddr = phdr->p_paddr & 0xffffff; + + if ((paddr < grub_os_area_addr) + || (paddr + phdr->p_memsz > grub_os_area_addr + grub_os_area_size)) + return grub_error (GRUB_ERR_OUT_OF_RANGE, "Address 0x%x is out of range", + paddr); + + if ((!kern_start) || (paddr < kern_start)) + kern_start = paddr; + + if (paddr + phdr->p_memsz > kern_end) + kern_end = paddr + phdr->p_memsz; + + *addr = paddr; + + return GRUB_ERR_NONE; +} + +static grub_err_t grub_bsd_load_elf (grub_elf_t elf) { kern_start = kern_end = 0; @@ -487,6 +664,13 @@ grub_bsd_load_elf (grub_elf_t elf) entry = elf->ehdr.ehdr32.e_entry & 0xFFFFFF; return grub_elf32_load (elf, grub_bsd_elf32_hook, 0, 0); } + else if (grub_elf_is_elf64 (elf)) + { + is_64bit = 1; + entry = elf->ehdr.ehdr64.e_entry & 0xffffffff; + entry_hi = (elf->ehdr.ehdr64.e_entry >> 32) & 0xffffffff; + return grub_elf64_load (elf, grub_bsd_elf64_hook, 0, 0); + } else return grub_error (GRUB_ERR_BAD_OS, "invalid elf"); } diff --git a/loader/i386/bsd_helper.S b/loader/i386/bsd_helper.S new file mode 100644 index 0000000..23c8610 --- /dev/null +++ b/loader/i386/bsd_helper.S @@ -0,0 +1,45 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2008, 2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <grub/symbol.h> + + .p2align 2 + + + .code32 + +/* + * Use cdecl calling convention for *BSD kernels. + */ + +FUNCTION(grub_unix_real_boot) + + /* Interrupts should be disabled. */ + cli + + /* Discard `grub_unix_real_boot' return address. */ + popl %eax + + /* Fetch `entry' address ... */ + popl %eax + + /* + * ... and put our return address in its place. The kernel will + * ignore it, but it expects %esp to point to it. + */ + call *%eax diff --git a/loader/i386/bsd_pagetable.c b/loader/i386/bsd_pagetable.c new file mode 100644 index 0000000..522a19c --- /dev/null +++ b/loader/i386/bsd_pagetable.c @@ -0,0 +1,84 @@ + +/*- + * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see <http://www.gnu.org/licenses/>. + */ + + +static void +fill_bsd64_pagetable (grub_uint8_t *target) +{ + grub_uint64_t *pt2, *pt3, *pt4; + int i; + +#define PG_V 0x001 +#define PG_RW 0x002 +#define PG_U 0x004 +#define PG_PS 0x080 + + pt4 = (grub_uint64_t *) target; + pt3 = (grub_uint64_t *) (target + 4096); + pt2 = (grub_uint64_t *) (target + 8192); + + grub_memset ((char *) target, 0, 4096 * 3); + + /* + * This is kinda brutal, but every single 1GB VM memory segment points to + * the same first 1GB of physical memory. But it is how BSD expects + * it to be. + */ + for (i = 0; i < 512; i++) + { + /* Each slot of the level 4 pages points to the same level 3 page */ + pt4[i] = (grub_addr_t) &pt3[0]; + pt4[i] |= PG_V | PG_RW | PG_U; + + /* Each slot of the level 3 pages points to the same level 2 page */ + pt3[i] = (grub_addr_t) &pt2[0]; + pt3[i] |= PG_V | PG_RW | PG_U; + + /* The level 2 page slots are mapped with 2MB pages for 1GB. */ + pt2[i] = i * (2 * 1024 * 1024); + pt2[i] |= PG_V | PG_RW | PG_PS | PG_U; + } +} diff --git a/loader/i386/bsd_trampoline.S b/loader/i386/bsd_trampoline.S new file mode 100644 index 0000000..b283a87 --- /dev/null +++ b/loader/i386/bsd_trampoline.S @@ -0,0 +1,121 @@ + +/*- + * Copyright (c) 2003 Peter Wemm <peter@FreeBSD.org> + * Copyright (C) 2009 Free Software Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see <http://www.gnu.org/licenses/>. + */ + + +#define MSR_EFER 0xc0000080 +#define EFER_LME 0x00000100 +#define CR4_PAE 0x00000020 +#define CR4_PSE 0x00000010 +#define CR0_PG 0x80000000 + +#include <grub/symbol.h> + + .p2align 2 + + .code32 + + +VARIABLE(grub_bsd64_trampoline_start) + + /* Discard `grub_unix_real_boot' return address. */ + popl %eax + + /* entry */ + popl %edi + + /* entry_hi */ + popl %esi + + cli + + /* Turn on EFER.LME. */ + movl $MSR_EFER, %ecx + rdmsr + orl $EFER_LME, %eax + wrmsr + + /* Turn on PAE. */ + movl %cr4, %eax + orl $(CR4_PAE | CR4_PSE), %eax + movl %eax, %cr4 + + /* Set %cr3 for PT4. */ + popl %eax + movl %eax, %cr3 + + /* Push a dummy return address. */ + pushl %eax + + /* Turn on paging (implicitly sets EFER.LMA). */ + movl %cr0, %eax + orl $CR0_PG, %eax + movl %eax, %cr0 + + /* Now we're in compatability mode. set %cs for long mode. */ + /* lgdt */ + .byte 0x0f + .byte 0x01 + .byte 0x15 +VARIABLE (grub_bsd64_trampoline_gdt) + .long 0x0 + + /* ljmp */ + .byte 0xea +VARIABLE (grub_bsd64_trampoline_selfjump) + .long 0x0 + .word 0x08 + + .code64 + +bsd64_longmode: + /* We're still running V=P, jump to entry point. */ + movl %esi, %eax + salq $32, %rax + orq %rdi, %rax + pushq %rax + ret +VARIABLE(grub_bsd64_trampoline_end) ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-21 21:10 ` Vladimir Serbinenko @ 2009-04-22 10:52 ` Chip Panarchy 2009-05-03 1:08 ` Chip Panarchy 0 siblings, 1 reply; 25+ messages in thread From: Chip Panarchy @ 2009-04-22 10:52 UTC (permalink / raw) To: The development of GRUB 2 Hi Thanks Great, I'll be waiting till it's committed! WOOT Panarchy On Wed, Apr 22, 2009 at 7:10 AM, Vladimir Serbinenko <phcoder@gmail.com> wrote: > Hello, here is the version with changelog, fix for freebsd_module and > licencing corrections. > If nobody objects I'll commit it soon > Enjoy > > > On Sun, Apr 12, 2009 at 9:19 PM, Bean <bean123ch@gmail.com> wrote: >> >> Hi, >> >> This patch allows you to load amd64 freebsd kernel directly, here is an >> example: >> >> set root=(hd0,1,a) >> freebsd /boot/kernel/kernel >> freebsd_loadenv /boot/device.hints >> set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s1a >> boot >> >> Test successfully on FreeBSD 7.1 amd64. >> >> -- >> Bean >> >> _______________________________________________ >> Grub-devel mailing list >> Grub-devel@gnu.org >> http://lists.gnu.org/mailman/listinfo/grub-devel >> > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-22 10:52 ` Chip Panarchy @ 2009-05-03 1:08 ` Chip Panarchy 0 siblings, 0 replies; 25+ messages in thread From: Chip Panarchy @ 2009-05-03 1:08 UTC (permalink / raw) To: The development of GRUB 2 Hello After 10-days, do you think it's read to be committed now? Thanks On Wed, Apr 22, 2009 at 8:52 PM, Chip Panarchy <forumanarchy@gmail.com> wrote: > > Hi > > Thanks > > Great, I'll be waiting till it's committed! > > WOOT > > Panarchy > > On Wed, Apr 22, 2009 at 7:10 AM, Vladimir Serbinenko <phcoder@gmail.com> wrote: > > Hello, here is the version with changelog, fix for freebsd_module and > > licencing corrections. > > If nobody objects I'll commit it soon > > Enjoy > > > > > > On Sun, Apr 12, 2009 at 9:19 PM, Bean <bean123ch@gmail.com> wrote: > >> > >> Hi, > >> > >> This patch allows you to load amd64 freebsd kernel directly, here is an > >> example: > >> > >> set root=(hd0,1,a) > >> freebsd /boot/kernel/kernel > >> freebsd_loadenv /boot/device.hints > >> set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s1a > >> boot > >> > >> Test successfully on FreeBSD 7.1 amd64. > >> > >> -- > >> Bean > >> > >> _______________________________________________ > >> Grub-devel mailing list > >> Grub-devel@gnu.org > >> http://lists.gnu.org/mailman/listinfo/grub-devel > >> > > > > > > _______________________________________________ > > Grub-devel mailing list > > Grub-devel@gnu.org > > http://lists.gnu.org/mailman/listinfo/grub-devel > > > > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-04-12 19:19 [PATCH] FreeBSD 64-bit kernel support Bean ` (2 preceding siblings ...) 2009-04-21 21:10 ` Vladimir Serbinenko @ 2009-05-03 9:13 ` Vladimir 'phcoder' Serbinenko 2009-05-03 9:55 ` Chip Panarchy 3 siblings, 1 reply; 25+ messages in thread From: Vladimir 'phcoder' Serbinenko @ 2009-05-03 9:13 UTC (permalink / raw) To: The development of GRUB 2 [-- Attachment #1: Type: text/plain, Size: 606 bytes --] Added code for mmap services and commited On Sun, Apr 12, 2009 at 9:19 PM, Bean <bean123ch@gmail.com> wrote: > Hi, > > This patch allows you to load amd64 freebsd kernel directly, here is an > example: > > set root=(hd0,1,a) > freebsd /boot/kernel/kernel > freebsd_loadenv /boot/device.hints > set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s1a > boot > > Test successfully on FreeBSD 7.1 amd64. > > -- > Bean > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > > -- Regards Vladimir 'phcoder' Serbinenko [-- Attachment #2: Type: text/html, Size: 1106 bytes --] ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] FreeBSD 64-bit kernel support 2009-05-03 9:13 ` Vladimir 'phcoder' Serbinenko @ 2009-05-03 9:55 ` Chip Panarchy 0 siblings, 0 replies; 25+ messages in thread From: Chip Panarchy @ 2009-05-03 9:55 UTC (permalink / raw) To: The development of GRUB 2 Beautiful! Thanks a heap for all your help phcoder & Bean! (& Joey for working out some bugs) Thanks once again guys, Chip D. Panarchy On Sun, May 3, 2009 at 7:13 PM, Vladimir 'phcoder' Serbinenko <phcoder@gmail.com> wrote: > Added code for mmap services and commited > > On Sun, Apr 12, 2009 at 9:19 PM, Bean <bean123ch@gmail.com> wrote: >> >> Hi, >> >> This patch allows you to load amd64 freebsd kernel directly, here is an >> example: >> >> set root=(hd0,1,a) >> freebsd /boot/kernel/kernel >> freebsd_loadenv /boot/device.hints >> set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s1a >> boot >> >> Test successfully on FreeBSD 7.1 amd64. >> >> -- >> Bean >> >> _______________________________________________ >> Grub-devel mailing list >> Grub-devel@gnu.org >> http://lists.gnu.org/mailman/listinfo/grub-devel >> > > > > -- > Regards > Vladimir 'phcoder' Serbinenko > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > > ^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2009-05-03 9:56 UTC | newest] Thread overview: 25+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-04-12 19:19 [PATCH] FreeBSD 64-bit kernel support Bean 2009-04-12 19:26 ` phcoder 2009-04-12 19:29 ` phcoder 2009-04-13 1:27 ` phcoder 2009-04-13 2:26 ` Chip Panarchy 2009-04-13 2:58 ` Chip Panarchy 2009-04-13 3:53 ` Bean 2009-04-13 5:26 ` Chip Panarchy 2009-04-13 5:33 ` Joey Korkames 2009-04-13 8:51 ` Joey Korkames 2009-04-13 9:03 ` phcoder 2009-04-13 9:10 ` Joey Korkames 2009-04-13 9:20 ` phcoder 2009-04-13 9:37 ` Joey Korkames 2009-04-13 9:43 ` phcoder 2009-04-13 10:05 ` phcoder 2009-04-13 21:36 ` Joey Korkames 2009-04-14 8:13 ` Chip Panarchy 2009-04-14 19:17 ` Joey Korkames 2009-04-14 21:30 ` Chip Panarchy 2009-04-21 21:10 ` Vladimir Serbinenko 2009-04-22 10:52 ` Chip Panarchy 2009-05-03 1:08 ` Chip Panarchy 2009-05-03 9:13 ` Vladimir 'phcoder' Serbinenko 2009-05-03 9:55 ` Chip Panarchy
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.