[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[2627] 2009-10-09 Robert Millan <address@hidden>
From: |
Robert Millan |
Subject: |
[2627] 2009-10-09 Robert Millan <address@hidden> |
Date: |
Fri, 09 Oct 2009 17:57:04 +0000 |
Revision: 2627
http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2627
Author: robertmh
Date: 2009-10-09 17:57:02 +0000 (Fri, 09 Oct 2009)
Log Message:
-----------
2009-10-09 Robert Millan <address@hidden>
Fail gracefuly when attempting to load 64-bit kFreeBSD on IA32 CPU.
* include/grub/i386/cpuid.h: New file.
* commands/i386/cpuid.c: Include `<grub/i386/cpuid.h>'.
(has_longmode): Rename to ...
(grub_cpuid_has_longmode): ... this. Update all users. Remove
`static' attribute.
* loader/i386/bsd.c: Include `<grub/i386/cpuid.h>'.
(grub_bsd_load_elf): Fail if load of 64-bit kernel was requested
on a CPU that doesn't implement AMD64 instruction set.
Modified Paths:
--------------
trunk/grub2/ChangeLog
trunk/grub2/commands/i386/cpuid.c
trunk/grub2/loader/i386/bsd.c
Added Paths:
-----------
trunk/grub2/include/grub/i386/cpuid.h
Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog 2009-10-06 00:04:32 UTC (rev 2626)
+++ trunk/grub2/ChangeLog 2009-10-09 17:57:02 UTC (rev 2627)
@@ -1,3 +1,16 @@
+2009-10-09 Robert Millan <address@hidden>
+
+ Fail gracefuly when attempting to load 64-bit kFreeBSD on IA32 CPU.
+
+ * include/grub/i386/cpuid.h: New file.
+ * commands/i386/cpuid.c: Include `<grub/i386/cpuid.h>'.
+ (has_longmode): Rename to ...
+ (grub_cpuid_has_longmode): ... this. Update all users. Remove
+ `static' attribute.
+ * loader/i386/bsd.c: Include `<grub/i386/cpuid.h>'.
+ (grub_bsd_load_elf): Fail if load of 64-bit kernel was requested
+ on a CPU that doesn't implement AMD64 instruction set.
+
2009-10-06 Colin Watson <address@hidden>
* Makefile.in (docs/stamp-vti): Depend on configure.ac as well, so
Modified: trunk/grub2/commands/i386/cpuid.c
===================================================================
--- trunk/grub2/commands/i386/cpuid.c 2009-10-06 00:04:32 UTC (rev 2626)
+++ trunk/grub2/commands/i386/cpuid.c 2009-10-09 17:57:02 UTC (rev 2627)
@@ -1,7 +1,7 @@
/* cpuid.c - test for CPU features */
/*
* GRUB -- GRand Unified Bootloader
- * Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+ * Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
* Based on gcc/gcc/config/i386/driver-i386.c
*
* GRUB is free software: you can redistribute it and/or modify
@@ -24,6 +24,7 @@
#include <grub/env.h>
#include <grub/command.h>
#include <grub/extcmd.h>
+#include <grub/i386/cpuid.h>
#define cpuid(num,a,b,c,d) \
asm volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1" \
@@ -38,14 +39,14 @@
#define bit_LM (1 << 29)
-static unsigned char has_longmode = 0;
+unsigned char grub_cpuid_has_longmode = 0;
static grub_err_t
grub_cmd_cpuid (grub_extcmd_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
- return has_longmode ? GRUB_ERR_NONE
+ return grub_cpuid_has_longmode ? GRUB_ERR_NONE
: grub_error (GRUB_ERR_TEST_FAILURE, "false");
}
@@ -55,7 +56,7 @@
{
#ifdef __x86_64__
/* grub-emu */
- has_longmode = 1;
+ grub_cpuid_has_longmode = 1;
#else
unsigned int eax, ebx, ecx, edx;
unsigned int max_level;
@@ -82,7 +83,7 @@
goto done;
cpuid (0x80000001, eax, ebx, ecx, edx);
- has_longmode = !!(edx & bit_LM);
+ grub_cpuid_has_longmode = !!(edx & bit_LM);
done:
#endif
Added: trunk/grub2/include/grub/i386/cpuid.h
===================================================================
--- trunk/grub2/include/grub/i386/cpuid.h (rev 0)
+++ trunk/grub2/include/grub/i386/cpuid.h 2009-10-09 17:57:02 UTC (rev
2627)
@@ -0,0 +1,19 @@
+/*
+ * 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/>.
+ */
+
+extern unsigned char grub_cpuid_has_longmode;
Modified: trunk/grub2/loader/i386/bsd.c
===================================================================
--- trunk/grub2/loader/i386/bsd.c 2009-10-06 00:04:32 UTC (rev 2626)
+++ trunk/grub2/loader/i386/bsd.c 2009-10-09 17:57:02 UTC (rev 2627)
@@ -19,6 +19,7 @@
#include <grub/loader.h>
#include <grub/cpu/loader.h>
#include <grub/cpu/bsd.h>
+#include <grub/i386/cpuid.h>
#include <grub/machine/init.h>
#include <grub/machine/memory.h>
#include <grub/memory.h>
@@ -871,6 +872,9 @@
{
is_64bit = 1;
+ if (! grub_cpuid_has_longmode)
+ return grub_error (GRUB_ERR_BAD_OS, "Your CPU does not implement AMD64
architecture.");
+
/* FreeBSD has 64-bit entry point. */
if (kernel_type == KERNEL_TYPE_FREEBSD)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [2627] 2009-10-09 Robert Millan <address@hidden>,
Robert Millan <=