Re: [Xen-devel] [PATCH v3 2/2] efi: Avoid calling boot services after ExitBootServices()

2015-06-01 Thread Andrew Cooper
On 01/06/15 11:17, Ross Lagerwall wrote:
 After the first call to ExitBootServices(), avoid calling any boot
 services by setting setting efi_bs to NULL and entering an infinite loop
 in blexit().

 Signed-off-by: Ross Lagerwall ross.lagerw...@citrix.com
 ---
  xen/common/efi/boot.c | 16 +---
  1 file changed, 13 insertions(+), 3 deletions(-)

 diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
 index 60c1b8d..5c5c158 100644
 --- a/xen/common/efi/boot.c
 +++ b/xen/common/efi/boot.c
 @@ -216,6 +216,12 @@ static void __init noreturn blexit(const CHAR16 *str)
  PrintStr((CHAR16 *)str);
  PrintStr(newline);
  
 +if ( !efi_bs )
 +{
 +for ( ; ; )
 +;

At the very least this should be halt() to avoid spinning in a busy
loop, and probably with a local_irq_disable() ahead of the for.

~Andrew

 +}
 +
  if ( cfg.addr )
  efi_bs-FreePages(cfg.addr, PFN_UP(cfg.size));
  if ( kernel.addr )
 @@ -1063,8 +1069,10 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE 
 *SystemTable)
  for ( retry = 0; ; retry = 1 )
  {
  efi_memmap_size = map_alloc_size;
 -status = efi_bs-GetMemoryMap(efi_memmap_size, efi_memmap, map_key,
 -  efi_mdesc_size, mdesc_ver);
 +status = SystemTable-BootServices-GetMemoryMap(efi_memmap_size,
 + efi_memmap, 
 map_key,
 + efi_mdesc_size,
 + mdesc_ver);
  if ( EFI_ERROR(status) )
  PrintErrMesg(LCannot obtain memory map, status);
  
 @@ -1073,7 +1081,9 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE 
 *SystemTable)
  
  efi_arch_pre_exit_boot();
  
 -status = efi_bs-ExitBootServices(ImageHandle, map_key);
 +status = SystemTable-BootServices-ExitBootServices(ImageHandle,
 + map_key);
 +efi_bs = NULL;
  if ( status != EFI_INVALID_PARAMETER || retry )
  break;
  }


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v3 2/2] efi: Avoid calling boot services after ExitBootServices()

2015-06-01 Thread Jan Beulich
 On 01.06.15 at 12:26, andrew.coop...@citrix.com wrote:
 On 01/06/15 11:17, Ross Lagerwall wrote:
 --- a/xen/common/efi/boot.c
 +++ b/xen/common/efi/boot.c
 @@ -216,6 +216,12 @@ static void __init noreturn blexit(const CHAR16 *str)
  PrintStr((CHAR16 *)str);
  PrintStr(newline);
  
 +if ( !efi_bs )
 +{
 +for ( ; ; )
 +;
 
 At the very least this should be halt() to avoid spinning in a busy
 loop, and probably with a local_irq_disable() ahead of the for.

Suitably abstracted, yes: ARM has no halt(), and I don't think we
should assume local_irq_disable() can be used here in a completely
arch-independent fashion. I.e. perhaps the whole body of the if()
should become a new arch hook.

Jan


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v3 2/2] efi: Avoid calling boot services after ExitBootServices()

2015-06-01 Thread Ross Lagerwall
After the first call to ExitBootServices(), avoid calling any boot
services by setting setting efi_bs to NULL and entering an infinite loop
in blexit().

Signed-off-by: Ross Lagerwall ross.lagerw...@citrix.com
---
 xen/common/efi/boot.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 60c1b8d..5c5c158 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -216,6 +216,12 @@ static void __init noreturn blexit(const CHAR16 *str)
 PrintStr((CHAR16 *)str);
 PrintStr(newline);
 
+if ( !efi_bs )
+{
+for ( ; ; )
+;
+}
+
 if ( cfg.addr )
 efi_bs-FreePages(cfg.addr, PFN_UP(cfg.size));
 if ( kernel.addr )
@@ -1063,8 +1069,10 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE 
*SystemTable)
 for ( retry = 0; ; retry = 1 )
 {
 efi_memmap_size = map_alloc_size;
-status = efi_bs-GetMemoryMap(efi_memmap_size, efi_memmap, map_key,
-  efi_mdesc_size, mdesc_ver);
+status = SystemTable-BootServices-GetMemoryMap(efi_memmap_size,
+ efi_memmap, map_key,
+ efi_mdesc_size,
+ mdesc_ver);
 if ( EFI_ERROR(status) )
 PrintErrMesg(LCannot obtain memory map, status);
 
@@ -1073,7 +1081,9 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE 
*SystemTable)
 
 efi_arch_pre_exit_boot();
 
-status = efi_bs-ExitBootServices(ImageHandle, map_key);
+status = SystemTable-BootServices-ExitBootServices(ImageHandle,
+ map_key);
+efi_bs = NULL;
 if ( status != EFI_INVALID_PARAMETER || retry )
 break;
 }
-- 
2.1.0


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel