From: Fu Wei <fu.wei(a)linaro.org>
This patch adds a has_xsm_magic helper function for detecting XSM
from the second unknown module.
If Xen can't get the kind of module from compatible, we guess the kind of
these unknowns respectively:
(1) The first unknown must be kernel.
(2) Detect the XSM Magic from the 2nd unknown:
a. If it's XSM, set the kind as XSM, and that also means we
won't load ramdisk;
b. if it's not XSM, set the kind as ramdisk.
So if user want to load ramdisk, it must be the 2nd unknown.
We also detect the XSM Magic for the following unknowns, then set its kind
according to the return value of has_xsm_magic.
By this way, arm64 behavior can be compatible to x86 and can simplify
multi-arch bootloader such as GRUB.
Signed-off-by: Fu Wei <fu.wei(a)linaro.org>
---
Changelog:
v4: Fix some code style and comments problems.
Only check the Magic number.
Re-order the code in process_multiboot_node to get the base address
first, then the XSM Magic checking function only need to check if the
Magic number is valid.
Factor the XSM Magic checking code into an helper and re-use it
in xsm_dt_policy_init.
v3: http://lists.xen.org/archives/html/xen-devel/2016-03/msg03564.html
Using memcmp instead of strncmp.
Using "return 0;" instead of panic();
Improve some comments.
v2: http://lists.xen.org/archives/html/xen-devel/2016-03/msg03543.html
Using XEN_MAGIC macro instead of 0xf97cff8c :
uint32_t selinux_magic = 0xf97cff8c; --> uint32_t xen_magic = XEN_MAGIC;
Comment out the code(return 0 directly), if CONFIG_FLASK is not set.
v1: http://lists.xen.org/archives/html/xen-devel/2016-03/msg02430.html
The first upstream patch to xen-devel mailing lists.
xen/arch/arm/bootfdt.c | 37 +++++++++++++++++++++++++------------
xen/include/xsm/xsm.h | 8 +++++++-
xen/xsm/xsm_core.c | 21 +++++++++++++++++++++
xen/xsm/xsm_policy.c | 8 ++------
4 files changed, 55 insertions(+), 19 deletions(-)
diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
index 8a14015..d130633 100644
--- a/xen/arch/arm/bootfdt.c
+++ b/xen/arch/arm/bootfdt.c
@@ -14,6 +14,7 @@
#include <xen/init.h>
#include <xen/device_tree.h>
#include <xen/libfdt/libfdt.h>
+#include <xsm/xsm.h>
#include <asm/setup.h>
static bool_t __init device_tree_node_matches(const void *fdt, int node,
@@ -175,6 +176,17 @@ static void __init process_multiboot_node(const void *fdt, int node,
const char *cmdline;
int len;
+ prop = fdt_get_property(fdt, node, "reg", &len);
+ if ( !prop )
+ panic("node %s missing `reg' property\n", name);
+
+ if ( len < dt_cells_to_size(address_cells + size_cells) )
+ panic("fdt: node `%s': `reg` property length is too short\n",
+ name);
+
+ cell = (const __be32 *)prop->data;
+ device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
+
if ( fdt_node_check_compatible(fdt, node, "xen,linux-zimage") == 0 ||
fdt_node_check_compatible(fdt, node, "multiboot,kernel") == 0 )
kind = BOOTMOD_KERNEL;
@@ -186,7 +198,17 @@ static void __init process_multiboot_node(const void *fdt, int node,
else
kind = BOOTMOD_UNKNOWN;
- /* Guess that first two unknown are kernel and ramdisk respectively. */
+ /**
+ * Guess the kind of these first two unknowns respectively:
+ * (1) The first unknown must be kernel.
+ * (2) Detect the XSM Magic from the 2nd unknown:
+ * a. If it's XSM, set the kind as XSM, and that also means we
+ * won't load ramdisk;
+ * b. if it's not XSM, set the kind as ramdisk.
+ * So if user want to load ramdisk, it must be the 2nd unknown.
+ * We also detect the XSM Magic for the following unknowns,
+ * then set its kind according to the return value of has_xsm_magic.
+ */
if ( kind == BOOTMOD_UNKNOWN )
{
switch ( kind_guess++ )
@@ -195,19 +217,10 @@ static void __init process_multiboot_node(const void *fdt, int node,
case 1: kind = BOOTMOD_RAMDISK; break;
default: break;
}
+ if ( kind_guess > 1 && has_xsm_magic(start) )
+ kind = BOOTMOD_XSM;
}
- prop = fdt_get_property(fdt, node, "reg", &len);
- if ( !prop )
- panic("node %s missing `reg' property\n", name);
-
- if ( len < dt_cells_to_size(address_cells + size_cells) )
- panic("fdt: node `%s': `reg` property length is too short\n",
- name);
-
- cell = (const __be32 *)prop->data;
- device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
-
prop = fdt_get_property(fdt, node, "bootargs", &len);
if ( prop )
{
diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
index 3afed70..803c7ea 100644
--- a/xen/include/xsm/xsm.h
+++ b/xen/include/xsm/xsm.h
@@ -745,6 +745,7 @@ extern int xsm_multiboot_policy_init(unsigned long *module_map,
#ifdef CONFIG_HAS_DEVICE_TREE
extern int xsm_dt_init(void);
extern int xsm_dt_policy_init(void);
+extern bool has_xsm_magic(paddr_t);
#endif
extern int register_xsm(struct xsm_operations *ops);
@@ -771,7 +772,12 @@ static inline int xsm_dt_init(void)
{
return 0;
}
-#endif
+
+static inline bool has_xsm_magic(paddr_t start)
+{
+ return false;
+}
+#endif /* CONFIG_HAS_DEVICE_TREE */
#endif /* CONFIG_XSM */
diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c
index 5e432de..bdb06c5 100644
--- a/xen/xsm/xsm_core.c
+++ b/xen/xsm/xsm_core.c
@@ -19,6 +19,8 @@
#ifdef CONFIG_XSM
+#include <asm/setup.h>
+
#define XSM_FRAMEWORK_VERSION "1.0.0"
struct xsm_operations *xsm_ops;
@@ -109,6 +111,25 @@ int __init xsm_dt_init(void)
return ret;
}
+
+/**
+ * has_xsm_magic - Check XSM Magic of the module header by phy address
+ * A XSM module has a special header
+ * ------------------------------------------------
+ * uint magic | uint target_len | uchar target[8] |
+ * 0xf97cff8c | 8 | "XenFlask" |
+ * ------------------------------------------------
+ * 0xf97cff8c is policy magic number (XSM_MAGIC).
+ * Here we only check the "magic" of the module.
+ */
+bool __init has_xsm_magic(paddr_t start)
+{
+ xsm_magic_t magic;
+
+ copy_from_paddr(&magic, start, sizeof(magic) );
+
+ return ( XSM_MAGIC && magic == XSM_MAGIC );
+}
#endif
int register_xsm(struct xsm_operations *ops)
diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c
index b60d822..bde8015 100644
--- a/xen/xsm/xsm_policy.c
+++ b/xen/xsm/xsm_policy.c
@@ -79,7 +79,6 @@ int __init xsm_dt_policy_init(void)
{
struct bootmodule *mod = boot_module_find_by_kind(BOOTMOD_XSM);
paddr_t paddr, len;
- xsm_magic_t magic;
if ( !mod || !mod->size )
return 0;
@@ -87,12 +86,9 @@ int __init xsm_dt_policy_init(void)
paddr = mod->start;
len = mod->size;
- copy_from_paddr(&magic, paddr, sizeof(magic));
-
- if ( magic != XSM_MAGIC )
+ if ( !has_xsm_magic(paddr) )
{
- printk(XENLOG_ERR "xsm: Invalid magic for XSM blob got 0x%x "
- "expected 0x%x\n", magic, XSM_MAGIC);
+ printk(XENLOG_ERR "xsm: Invalid magic for XSM blob\n");
return -EINVAL;
}
--
2.5.5
From: Fu Wei <fu.wei(a)linaro.org>
This patch add a check_xsm_signature static function for detecting XSM
from the second unknown module.
If Xen can't get the kind of module from compatible, we guess the kind of
these first two unknown respectively:
(1) The first unknown must be kernel;
(2) The second unknown is ramdisk, only if we have ramdisk;
(3) Start from the 2nd unknown, detect the XSM binary signature;
(4) If we got XSM in the 2nd unknown, that means we don't load initrd.
Signed-off-by: Fu Wei <fu.wei(a)linaro.org>
---
Changelog:
v3: Using memcmp instead of strncmp.
Using "return 0;" instead of panic();
Improve some comments.
v2: http://lists.xen.org/archives/html/xen-devel/2016-03/msg03543.html
Using XEN_MAGIC macro instead of 0xf97cff8c :
uint32_t selinux_magic = 0xf97cff8c; --> uint32_t xen_magic = XEN_MAGIC;
Comment out the code(return 0 directly), if CONFIG_FLASK is not set.
v1: http://lists.xen.org/archives/html/xen-devel/2016-03/msg02430.html
The first upstream patch to xen-devel mailing lists.
xen/arch/arm/bootfdt.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
index 8a14015..10d3382 100644
--- a/xen/arch/arm/bootfdt.c
+++ b/xen/arch/arm/bootfdt.c
@@ -163,6 +163,49 @@ static void __init process_memory_node(const void *fdt, int node,
}
}
+/**
+ * check_xsm_signature - Check XSM Magic and Signature of the module header
+ * A XSM module has a special header
+ * ------------------------------------------------
+ * uint magic | uint target_len | uchar target[8] |
+ * 0xf97cff8c | 8 | "XenFlask" |
+ * ------------------------------------------------
+ * 0xf97cff8c is policy magic number (XSM_MAGIC).
+ * So we only read the first 16 bytes of the module, then check these three
+ * parts. This checking (memcmp) assumes little-endian byte order.
+ */
+static bool __init check_xsm_signature(const void *fdt, int node,
+ const char *name,
+ u32 address_cells, u32 size_cells)
+{
+#ifdef CONFIG_FLASK
+ u32 xen_magic = XSM_MAGIC, target_len = 8;
+ const struct fdt_property *prop;
+ unsigned char buff[16];
+ paddr_t start, size;
+ const __be32 *cell;
+ int len;
+
+ prop = fdt_get_property(fdt, node, "reg", &len);
+ if ( !prop || len < dt_cells_to_size(address_cells + size_cells))
+ return 0;
+
+ cell = (const __be32 *)prop->data;
+ device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
+
+ copy_from_paddr(buff, start, sizeof(buff));
+
+ if (memcmp(buff, (void *) &xen_magic, sizeof(u32)) ||
+ memcmp(buff + sizeof(u32), (void *) &target_len, sizeof(u32)) ||
+ memcmp(buff + sizeof(u32) * 2, "XenFlask", target_len))
+ return 0;
+
+ return 1;
+#else
+ return 0;
+#endif
+}
+
static void __init process_multiboot_node(const void *fdt, int node,
const char *name,
u32 address_cells, u32 size_cells)
@@ -186,7 +229,13 @@ static void __init process_multiboot_node(const void *fdt, int node,
else
kind = BOOTMOD_UNKNOWN;
- /* Guess that first two unknown are kernel and ramdisk respectively. */
+ /**
+ * Guess the kind of these first two unknown respectively:
+ * (1) The first unknown must be kernel;
+ * (2) The second unknown is ramdisk, only if we have ramdisk;
+ * (3) Start from the 2nd unknown, detect the XSM binary signature;
+ * (4) If we got XSM in the 2nd unknown, that means we have not initrd.
+ */
if ( kind == BOOTMOD_UNKNOWN )
{
switch ( kind_guess++ )
@@ -195,6 +244,9 @@ static void __init process_multiboot_node(const void *fdt, int node,
case 1: kind = BOOTMOD_RAMDISK; break;
default: break;
}
+ if (kind_guess > 1 && check_xsm_signature(fdt, node, name,
+ address_cells, size_cells))
+ kind = BOOTMOD_XSM;
}
prop = fdt_get_property(fdt, node, "reg", &len);
--
2.5.0
From: Dandan Bi <dandan.bi(a)intel.com>
Dandan submitted this patch to the EDK2 Mailing list for review before
FVP was moved to OpenPlatformPkg:
https://www.mail-archive.com/edk2-devel@lists.01.org/msg07113.html
His original commit message:
ArmPlatformPkg: Add FileExplorerLib.inf to the dsc file
V3: Add FileExplorerLib when SECURE_BOOT_ENABLE == TRUE, so
when to use FileExplorerLib is clear.
Because SecureBootConfigDxe use FileExplorerLib now, but
FileExplorerLib is not in the dsc file of the package
that use SecureBootConfigDxe. Now add it to pass build.
Cc: Leif Lindholm <leif.lindholm(a)linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel(a)linaro.org>
Cc: Ryan.Harkin <ryan.harkin(a)linaro.org>
Cc: Eric Dong <eric.dong(a)intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi(a)intel.com>
Reviewed-by: Ryan Harkin <ryan.har...(a)linaro.org>
---
Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc b/Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc
index 265c5d7..78330d6 100644
--- a/Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc
+++ b/Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc
@@ -54,6 +54,9 @@ [LibraryClasses.common]
# Virtio Support
VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
+!if $(SECURE_BOOT_ENABLE) == TRUE
+ FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
+!endif
[LibraryClasses.common.SEC]
ArmLib|ArmPkg/Library/ArmLib/AArch64/AArch64LibSec.inf
--
2.5.0
The upstream code uses a PCD to set the FIFO depth:
f423d76 2016-03-17 MdeModulePkg/SerialDxe: Set FIFO depth with PCD
Add a sensible default for the PCD before the code becomes more widely
used.
The PL011UartInitializePort function in the PL011 driver expects the
receive FIFO depth to be set to a sane value or zero to use the
appropriate default for the version of PL011 present on the device.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ryan Harkin <ryan.harkin(a)linaro.org>
---
Platforms/ARM/Juno/ArmJuno.dsc | 1 +
Platforms/ARM/VExpress/ArmVExpress-CTA15-A7.dsc | 1 +
Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc | 1 +
3 files changed, 3 insertions(+)
diff --git a/Platforms/ARM/Juno/ArmJuno.dsc b/Platforms/ARM/Juno/ArmJuno.dsc
index 8cf0ada..7f030a7 100644
--- a/Platforms/ARM/Juno/ArmJuno.dsc
+++ b/Platforms/ARM/Juno/ArmJuno.dsc
@@ -121,6 +121,7 @@ [PcdsFixedAtBuild.common]
## PL011 - Serial Terminal
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x7FF80000
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0
gArmPlatformTokenSpaceGuid.PL011UartInteger|4
gArmPlatformTokenSpaceGuid.PL011UartFractional|0
diff --git a/Platforms/ARM/VExpress/ArmVExpress-CTA15-A7.dsc b/Platforms/ARM/VExpress/ArmVExpress-CTA15-A7.dsc
index 44e2105..c6d0b13 100644
--- a/Platforms/ARM/VExpress/ArmVExpress-CTA15-A7.dsc
+++ b/Platforms/ARM/VExpress/ArmVExpress-CTA15-A7.dsc
@@ -139,6 +139,7 @@ [PcdsFixedAtBuild.common]
## PL011 - Serial Terminal
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x1C090000
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|38400
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0
## PL031 RealTimeClock
gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x1C170000
diff --git a/Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc b/Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc
index fffbf28..78330d6 100644
--- a/Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc
+++ b/Platforms/ARM/VExpress/ArmVExpress-FVP-AArch64.dsc
@@ -145,6 +145,7 @@ [PcdsFixedAtBuild.common]
## PL011 - Serial Terminal
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x1c090000
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0
## PL031 RealTimeClock
gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x1C170000
--
2.5.0
The FACS table does not expose anything meaningful on AArch64, and since
the Tianocore ACPI table handling code insists on locating FACS below 4 GB,
which may fail since since AArch64 platforms may not have any system RAM
below 4 GB to begin with.
The reason for this behavior is to ensure that a 32-bit PEI can access the
FACS table on an otherwise 64-bit system, but this is a concern that does not
apply to AArch64, since PEI always runs in 64-bit mode in that case. The PI
spec currently does not provide any means for PEI to convey its bitness or
how much system RAM it can access, so a permanent fix requires a spec update
first.
So simply remove the FACS table until the PIWG clarifies the spec in this
regard.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel(a)linaro.org>
---
Platforms/ARM/Juno/AcpiTables/AcpiTables.inf | 1 -
Platforms/ARM/Juno/AcpiTables/Facs.aslc | 62 ----------------------------
2 files changed, 63 deletions(-)
delete mode 100644 Platforms/ARM/Juno/AcpiTables/Facs.aslc
diff --git a/Platforms/ARM/Juno/AcpiTables/AcpiTables.inf b/Platforms/ARM/Juno/AcpiTables/AcpiTables.inf
index 3159d7d37c4a..039cff0a743a 100644
--- a/Platforms/ARM/Juno/AcpiTables/AcpiTables.inf
+++ b/Platforms/ARM/Juno/AcpiTables/AcpiTables.inf
@@ -25,7 +25,6 @@
Dsdt.asl
Dbg2.asl
Spcr.asl
- Facs.aslc
Fadt.aslc
Gtdt.aslc
Madt.aslc
diff --git a/Platforms/ARM/Juno/AcpiTables/Facs.aslc b/Platforms/ARM/Juno/AcpiTables/Facs.aslc
deleted file mode 100644
index 137ead77c199..000000000000
--- a/Platforms/ARM/Juno/AcpiTables/Facs.aslc
+++ /dev/null
@@ -1,62 +0,0 @@
-/** @file
-* Firmware ACPI Control Structure (FACS)
-*
-* Copyright (c) 2012 - 2014, ARM Limited. All rights reserved.
-*
-* This program and the accompanying materials
-* are licensed and made available under the terms and conditions of the BSD License
-* which accompanies this distribution. The full text of the license may be found at
-* http://opensource.org/licenses/bsd-license.php
-*
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-*
-**/
-
-#include <IndustryStandard/Acpi.h>
-
-EFI_ACPI_5_0_FIRMWARE_ACPI_CONTROL_STRUCTURE Facs = {
- EFI_ACPI_5_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE, // UINT32 Signature
- sizeof (EFI_ACPI_5_0_FIRMWARE_ACPI_CONTROL_STRUCTURE), // UINT32 Length
- 0xA152, // UINT32 HardwareSignature
- 0, // UINT32 FirmwareWakingVector
- 0, // UINT32 GlobalLock
- 0, // UINT32 Flags
- 0, // UINT64 XFirmwareWakingVector
- EFI_ACPI_5_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION, // UINT8 Version;
- { EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved0[0]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved0[1]
- EFI_ACPI_RESERVED_BYTE }, // UINT8 Reserved0[2]
- 0, // UINT32 OspmFlags "Platform firmware must
- // initialize this field to zero."
- { EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[0]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[1]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[2]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[3]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[4]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[5]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[6]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[7]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[8]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[9]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[10]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[11]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[12]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[13]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[14]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[15]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[16]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[17]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[18]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[19]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[20]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[21]
- EFI_ACPI_RESERVED_BYTE, // UINT8 Reserved1[22]
- EFI_ACPI_RESERVED_BYTE }, // UINT8 Reserved1[23]
-};
-
-//
-// Reference the table being generated to prevent the optimizer from removing the
-// data structure from the executable
-//
-VOID* CONST ReferenceAcpiTable = &Facs;
--
2.5.0
From: Fu Wei <fu.wei(a)linaro.org>
This patch add a check_xsm_signature static function for detecting XSM
from the second unknown module.
If xen can't get the kind of module from compatible, we guess the kind of
these first two unknown respectively:
(1) The first unknown must be kernel;
(2) The second unknown is ramdisk, only if we have ramdisk;
(3) Start from the 2nd unknown, detect the XSM binary signature;
(4) If we got XSM in the 2nd unknown, that means we don't load initrd.
Signed-off-by: Fu Wei <fu.wei(a)linaro.org>
---
v2: Using XEN_MAGIC macro instead of 0xf97cff8c :
uint32_t selinux_magic = 0xf97cff8c; --> uint32_t xen_magic = XEN_MAGIC;
Comment out the code(return 0 directly), if CONFIG_FLASK is not set.
v1: http://lists.xen.org/archives/html/xen-devel/2016-03/msg02430.html
The first upstream patch to xen-devel mailing lists.
xen/arch/arm/bootfdt.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
index 8a14015..322f17f 100644
--- a/xen/arch/arm/bootfdt.c
+++ b/xen/arch/arm/bootfdt.c
@@ -163,6 +163,52 @@ static void __init process_memory_node(const void *fdt, int node,
}
}
+/**
+ * check_xsm_signature - Check XSM Magic and Signature of the module header
+ * A XSM module has a special header
+ * ------------------------------------------------
+ * uint magic | uint target_len | uchar target[8] |
+ * 0xf97cff8c | 8 | "XenFlask" |
+ * ------------------------------------------------
+ * 0xf97cff8c is policy magic number.
+ * So we only read the first 16 Bytes of the module, then check these three
+ * parts.
+ */
+static bool __init check_xsm_signature(const void *fdt, int node,
+ const char *name,
+ u32 address_cells, u32 size_cells)
+{
+#ifdef CONFIG_FLASK
+ u32 xen_magic = XSM_MAGIC, target_len = 8;
+ const struct fdt_property *prop;
+ paddr_t start, size;
+ const __be32 *cell;
+ char buff[16];
+ int len;
+
+ prop = fdt_get_property(fdt, node, "reg", &len);
+ if ( !prop )
+ panic("node %s missing `reg' property\n", name);
+
+ if ( len < dt_cells_to_size(address_cells + size_cells) )
+ panic("fdt: node `%s': `reg` property length is too short\n", name);
+
+ cell = (const __be32 *)prop->data;
+ device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
+
+ copy_from_paddr(buff, start, sizeof(buff));
+
+ if (strncmp(buff, (char *) &xen_magic, sizeof(u32)) ||
+ strncmp(buff + sizeof(u32), (char *) &target_len, sizeof(u32)) ||
+ strncmp(buff + sizeof(u32) * 2, "XenFlask", target_len))
+ return 0;
+
+ return 1;
+#else
+ return 0;
+#endif
+}
+
static void __init process_multiboot_node(const void *fdt, int node,
const char *name,
u32 address_cells, u32 size_cells)
@@ -186,7 +232,13 @@ static void __init process_multiboot_node(const void *fdt, int node,
else
kind = BOOTMOD_UNKNOWN;
- /* Guess that first two unknown are kernel and ramdisk respectively. */
+ /**
+ * Guess the kind of these first two unknown respectively:
+ * (1) The first unknown must be kernel;
+ * (2) The second unknown is ramdisk, only if we have ramdisk;
+ * (3) Start from the 2nd unknown, detect the XSM binary signature;
+ * (4) If we got XSM in the 2nd unknown, that means we have not initrd.
+ */
if ( kind == BOOTMOD_UNKNOWN )
{
switch ( kind_guess++ )
@@ -195,6 +247,9 @@ static void __init process_multiboot_node(const void *fdt, int node,
case 1: kind = BOOTMOD_RAMDISK; break;
default: break;
}
+ if (kind_guess > 1 && check_xsm_signature(fdt, node, name,
+ address_cells, size_cells))
+ kind = BOOTMOD_XSM;
}
prop = fdt_get_property(fdt, node, "reg", &len);
--
2.5.0
From: Fu Wei <fu.wei(a)linaro.org>
This patch add a check_xsm_signature static function for detecting XSM
from the second unknown module.
If xen can't get the kind of module from compatible, we guess the kind of
these first two unknown respectively:
(1) The first unknown must be kernel;
(2) The second unknown is ramdisk, only if we have ramdisk;
(3) Start from the 2nd unknown, detect the XSM binary signature;
(4) If we got XSM in the 2nd unknown, that means we don't load initrd.
Signed-off-by: Fu Wei <fu.wei(a)linaro.org>
---
ChangeLog:
v1: This patch - the first upstream patch to xen-devel mailing lists.
xen/arch/arm/bootfdt.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
index 8a14015..1a74ecf 100644
--- a/xen/arch/arm/bootfdt.c
+++ b/xen/arch/arm/bootfdt.c
@@ -163,6 +163,36 @@ static void __init process_memory_node(const void *fdt, int node,
}
}
+static bool __init check_xsm_signature(const void *fdt, int node,
+ const char *name,
+ u32 address_cells, u32 size_cells)
+{
+ uint32_t selinux_magic = 0xf97cff8c;
+ const struct fdt_property *prop;
+ paddr_t start, size;
+ const __be32 *cell;
+ /* 16 == sizeof(uint32_t) * 2 + sizeof("XenFlask") - 1 */
+ char magic[16];
+ int len;
+
+ prop = fdt_get_property(fdt, node, "reg", &len);
+ if ( !prop )
+ panic("node %s missing `reg' property\n", name);
+
+ if ( len < dt_cells_to_size(address_cells + size_cells) )
+ panic("fdt: node `%s': `reg` property length is too short\n", name);
+
+ cell = (const __be32 *)prop->data;
+ device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
+
+ copy_from_paddr(magic, start, 16);
+ if (strncmp(magic, (char *) &selinux_magic, sizeof(uint32_t)) ||
+ strncmp(magic + sizeof(uint32_t) * 2, "XenFlask", 8))
+ return 0;
+
+ return 1;
+}
+
static void __init process_multiboot_node(const void *fdt, int node,
const char *name,
u32 address_cells, u32 size_cells)
@@ -186,7 +216,13 @@ static void __init process_multiboot_node(const void *fdt, int node,
else
kind = BOOTMOD_UNKNOWN;
- /* Guess that first two unknown are kernel and ramdisk respectively. */
+ /**
+ * Guess the kind of these first two unknown respectively:
+ * (1) The first unknown must be kernel;
+ * (2) The second unknown is ramdisk, only if we have ramdisk;
+ * (3) Start from the 2nd unknown, detect the XSM binary signature;
+ * (4) If we got XSM in the 2nd unknown, that means we have not initrd.
+ */
if ( kind == BOOTMOD_UNKNOWN )
{
switch ( kind_guess++ )
@@ -195,6 +231,9 @@ static void __init process_multiboot_node(const void *fdt, int node,
case 1: kind = BOOTMOD_RAMDISK; break;
default: break;
}
+ if (kind_guess > 1 && check_xsm_signature(fdt, node, name,
+ address_cells, size_cells))
+ kind = BOOTMOD_XSM;
}
prop = fdt_get_property(fdt, node, "reg", &len);
--
2.5.0
From: Sami Mujawar <sami.mujawar(a)arm.com>
The wrong type name is used in the definition of the GTDT, causing the
header to have an incorrect size value.
EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE is changed to
EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES to rectify this.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Evan Lloyd <evan.lloyd(a)arm.com>
---
Platforms/ARM/Juno/AcpiTables/Gtdt.aslc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Platforms/ARM/Juno/AcpiTables/Gtdt.aslc b/Platforms/ARM/Juno/AcpiTables/Gtdt.aslc
index c0e3f5f..1c258fc 100644
--- a/Platforms/ARM/Juno/AcpiTables/Gtdt.aslc
+++ b/Platforms/ARM/Juno/AcpiTables/Gtdt.aslc
@@ -1,7 +1,7 @@
/** @file
* Generic Timer Description Table (GTDT)
*
-* Copyright (c) 2012 - 2014, ARM Limited. All rights reserved.
+* Copyright (c) 2012 - 2016, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -70,7 +70,7 @@
{
ARM_ACPI_HEADER(
EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
- EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE,
+ EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES,
EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION
),
SYSTEM_TIMER_BASE_ADDRESS, // UINT64 PhysicalAddress
--
2.7.0
The CpuExceptionHandlerLib LibraryClass dependency is trivially satisfied
on most ARM systems by the null implementation, i.e., an implementation
that does absolutely nothing.
The upstream implementation of ARM's CpuDxe will be refactored to delegate
the registration and dispatch of exceptions to CpuExceptionHandlerLib, of
which an ARM implementation (both AArch32 and AArch64) has been contributed
by Eugene Cohen. This means all current users of ARM's CpuDxe will need to
upgrade. Please refer to the attached patches #2 and #3 for an example.
Ard Biesheuvel (3):
Chips/TI/Omap35xx: drop CpuExceptionHandlerLib library class
resolution
Platforms/TI/BeagleBoard: move to ARM version of
CpuExceptionHandlerLib
Platforms/VExpress: move to ARM version of CpuExceptionHandlerLib
Chips/TexasInstruments/Omap35xx/Omap35xxPkg.dsc | 1 -
Platforms/ARM/VExpress/ArmVExpress.dsc.inc | 2 +-
Platforms/TexasInstruments/BeagleBoard/BeagleBoardPkg.dsc | 2 +-
3 files changed, 2 insertions(+), 3 deletions(-)
--
2.5.0