Skip to contentSkip to conversation

SetVirtualAddressMap() on Tiano EFI firmware

PATCH Bjorn Helgaas 3 participants 6 messages Sep 11, 2008 – Oct 5, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Has kexec been tested on x86 with EFI firmware?

I'm testing it on ia64 with Tiano-based EFI firmware, and I tripped over an issue with SetVirtualAddressMap(). I would expect a similar problem to happen on x86, but I don't see any code to deal with it.

The EFI SetVirtualAddressMap() interface is only supposed to be called once. Linux calls it once at boot-time, and if we kexec a new Linux kernel, the new kernel calls it again.

The EFI spec suggests that if it *is* called twice, SetVirtualAddressMap() should return EFI_UNSUPPORTED. But we go to great pains in purgatory (ia64_env_setup()) to patch the function descriptor so that the new kernel's call never even makes it to the EFI routine. I don't know whether this is because SetVirtualAddressMap() blows up if we call it again, or whether we just didn't want to change Linux to ignore an EFI_UNSUPPORTED return value.

On ia64, the SetVirtualAddressMap entry in the EFI Runtime Services Table points to a function descriptor, and ia64_env_setup() patches the code address in the descriptor so that when the new kernel thinks it's calling SetVirtualAddressMap(), it's instead calling a dummy function that immediately returns success.

In most current ia64 EFI implementations, SetVirtualAddressMap() converts all pointers in the EFI Runtime Services Table from physical to virtual, including the SetVirtualAddressMap pointer itself. ia64_env_setup() (running in physical mode) converts the SetVirtualAddressMap pointer from virtual to physical by subtracting PAGE_OFFSET.

But new Tiano-based EFI implementations do *not* convert the SetVirtualAddressMap pointer to virtual -- they leave it as physical. So when ia64_env_setup() subtracts PAGE_OFFSET from the physical address, it ends up with garbage, and patching the function descriptor causes an MCA.

The following patch makes kexec-tools work on either old or new firmware. Masking out the top nibble of either a physical address or a virtual address in region 7 results in a physical address.

purgatory/arch/ia64/purgatory-ia64.c +1 -1
index b2fe6d4..acacb56 100644
@@ -147,7 +147,7 @@ setup_arch(void)
 
 inline unsigned long PA(unsigned long addr)
 {
-	return addr - PAGE_OFFSET;
+	return addr & 0x0fffffffffffffffLL;
 }
 
 void

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#1 lore raw
Quoted 6 lines · Bjorn Helgaas

Has kexec been tested on x86 with EFI firmware?

I'm testing it on ia64 with Tiano-based EFI firmware, and I tripped over an issue with SetVirtualAddressMap(). I would expect a similar problem to happen on x86, but I don't see any code to deal with it.

Hmmm. I run on 32- and 64-bit kernels on a 32-bit IA EFI, and haven't seen this problem, including chains of kexec invocations.

I'll take a closer look at what's going on on my systems.

Signature · 7 lines
David N. Lombard, Intel, Irvine, CA
I do not speak for Intel Corporation; all comments are strictly my own.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#2 lore raw
Quoted 8 lines · David N
Quoted 6 lines · Bjorn Helgaas

Has kexec been tested on x86 with EFI firmware?

I'm testing it on ia64 with Tiano-based EFI firmware, and I tripped over an issue with SetVirtualAddressMap(). I would expect a similar problem to happen on x86, but I don't see any code to deal with it.

Quoted 4 lines

Hmmm. I run on 32- and 64-bit kernels on a 32-bit IA EFI, and haven't seen this problem, including chains of kexec invocations.

I'll take a closer look at what's going on on my systems.

Thanks. In case it wasn't clear, here's my confusion about x86:

I don't see anything in kexec-tools that touches SetVirtualAddressMap(). And I don't see anything in Linux that prevents x86 from calling SetVirtualAddressMap() in the new kernel.

If we do call SetVirtualAddressMap() in the new kernel, I would expect it to return EFI_UNSUPPORTED, which should cause Linux to panic.

Bjorn

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#3 lore raw
Quoted 9 lines · Bjorn Helgaas
Quoted 8 lines · David N
Quoted 6 lines · Bjorn Helgaas

Has kexec been tested on x86 with EFI firmware?

I'm testing it on ia64 with Tiano-based EFI firmware, and I tripped over an issue with SetVirtualAddressMap(). I would expect a similar problem to happen on x86, but I don't see any code to deal with it.

Quoted 4 lines
Quoted 4 lines

Hmmm. I run on 32- and 64-bit kernels on a 32-bit IA EFI, and haven't seen this problem, including chains of kexec invocations.

I'll take a closer look at what's going on on my systems.

Any news on this?

Quoted 9 lines

Thanks. In case it wasn't clear, here's my confusion about x86:

I don't see anything in kexec-tools that touches SetVirtualAddressMap(). And I don't see anything in Linux that prevents x86 from calling SetVirtualAddressMap() in the new kernel.

If we do call SetVirtualAddressMap() in the new kernel, I would expect it to return EFI_UNSUPPORTED, which should cause Linux to panic.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw
In reply to Bjorn Helgaas
Quoted 11 lines · Bjorn Helgaas

...
The following patch makes kexec-tools work on either old or new firmware. Masking out the top nibble of either a physical address or a virtual address in region 7 results in a physical address.

purgatory/arch/ia64/purgatory-ia64.c +0 -0
index b2fe6d4..acacb56 100644

purgatory/arch/ia64/purgatory-ia64.c setup_arch(void) · line 153

Quoted 8 lines
purgatory/arch/ia64/purgatory-ia64.c +1 -1
@@ -147,7 +147,7 @@ setup_arch(void)
 
 inline unsigned long PA(unsigned long addr)
 {
-	return addr - PAGE_OFFSET;
+	return addr & 0x0fffffffffffffffLL;
 }
 
 void

I haven't seen any activity on this.

Simon, if nobody objects to it, would you consider the patch above for kexec-tools?

Bjorn

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#5 lore raw
Quoted 18 lines · Bjorn Helgaas
Quoted 17 lines · Bjorn Helgaas

...
The following patch makes kexec-tools work on either old or new firmware. Masking out the top nibble of either a physical address or a virtual address in region 7 results in a physical address.

purgatory/arch/ia64/purgatory-ia64.c +1 -1
index b2fe6d4..acacb56 100644
@@ -147,7 +147,7 @@ setup_arch(void)
 
 inline unsigned long PA(unsigned long addr)
 {
-	return addr - PAGE_OFFSET;
+	return addr & 0x0fffffffffffffffLL;
 }
 
Quoted 7 lines

purgatory/arch/ia64/purgatory-ia64.c setup_arch(void) · line 153

Quoted 2 lines
purgatory/arch/ia64/purgatory-ia64.c +0 -0
 void

I haven't seen any activity on this.

Simon, if nobody objects to it, would you consider the patch above for kexec-tools?

Hi Bjorn,

That looks good to me. Could you provided a Signed-off-by line?

Signature · 9 lines
Simon Horman
  VA Linux Systems Japan K.K., Sydney, Australia Satellite Office
  H: www.vergenet.net/~horms/             W: www.valinux.co.jp/en


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec