Re: [edk2] OVMF Xen ACPI tables

Subject: Re: [edk2] OVMF Xen ACPI tables

From: Bei Guan <>

To: Jordan Justen <>

Date: 2011-07-21 04:18:33

Hi Jordan,

Can I use the assembly instruction "call <mem_address>" in C code file of edk2?
Is the usage of "call" in the following piece code right for edk2? (See the red part)

#define __STR(x) #x
#define STR(x) __STR(x)
#define hypercall_pa STR(0x1F7FF000)

#define _hypercall2(type, name, a1, a2) \
({ \
__asm__ __volatile__ ("call "hypercall_pa :::"memory"); \
(type)0; \

When I build the code, error occurs like this

GenFw: ERROR 3000: Invalid
/root/src/edk2/Build/OvmfIa32/DEBUG_GCC44/IA32/OvmfPkg/PlatformPei/PlatformPei/DEBUG/PlatformPei.dll bad symbol definition.
make: *** [/root/src/edk2/Build/OvmfIa32/DEBUG_GCC44/IA32/OvmfPkg/PlatformPei/PlatformPei/DEBUG/PlatformPei.efi] Error 2

Is there any instruction on how to use assembly instruction in edk2?


2011/7/20 Bei Guan <>

2011/7/20 Andrei Warkentin <>
On Tue, Jul 19, 2011 at 9:45 AM, Bei Guan <> wrote:
> Hi Andrei,
> I want to call a hypercall in OVMF to make a simple testing. But, I don't
> know how to convert the following code from Xen to the code of edk2 style.
> (From:
> 67 #define _hypercall2(type, name, a1, a2) \
> 68 ({ \
> 69 long __res, __ign1, __ign2; \
> 70 asm volatile ( \
> 71 "call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32) \
> 72 : "=a" (__res), "=b" (__ign1), "=c" (__ign2) \
> 73 : "1" ((long)(a1)), "2" ((long)(a2)) \
> 74 : "memory" ); \
> 75 (type)__res; \
> 76 })
> I have made the replacement
> "asm volatile" => "__asm__ __volatile__"
> "long" => "INT32"
> (I find that "INT64" equals to "long int" or "long" in edk2, but there is an
> error of "cast the variable". So, I use the "INT32" to replace it.)

Careful... this code is going to be different for IA-32 and for X64.
Yes, I know. But, I am not sure what is the equivalentcode for IA-32 and for X64 in edk2.

> But, an error come out as this (The above code is called at
> OvmfPkg/PlatformPei/Platform.c by a hypercall
> HYPERVISOR_xen_version(XENVER_version, 0);)

Did you define hypercall_pa? That's probably the issue.
Yes, I have defined this variable. The error is the same.

> ------
> GenFw: ERROR 3000: Invalid
> /root/src/edk2/Build/OvmfIa32/DEBUG_GCC44/IA32/OvmfPkg/PlatformPei/PlatformPei/DEBUG/PlatformPei.dll
> bad symbol definition.
> make: ***
> [/root/src/edk2/Build/OvmfIa32/DEBUG_GCC44/IA32/OvmfPkg/PlatformPei/PlatformPei/DEBUG/PlatformPei.efi]
> Error 2
> : error 7000: Failed to execute command
> make tbuild
> [/root/src/edk2/Build/OvmfIa32/DEBUG_GCC44/IA32/OvmfPkg/PlatformPei/PlatformPei]
> ------
> Why this error occurs? What's the likely reason? What's the "bad symbol"?
> Another question.
> In xen hvmloader, the hypercall page is at the address "#define
> HYPERCALL_PHYSICAL_ADDRESS 0x00080000". Maybe we cannot access this address
> to get the hypercall page in UEFI. Is it?
> In your previous patch for OvmfPkg/PlatformPei/Platform.c, you have
> allocated a new address for the hypercall page. (See the following code.)
> So, can we just assign the new address "mXenInfo.HyperPages" of hypercall
> page to the variable "hypercall_pa" in the xen code (line 71) I list above?

hypercall_pa = mXenInfo.HyperPages

By the way, what are your latest patches to apply to a clean Xen tree?
I want to build what you have now in order to better answer your
The latest Xen hvmloader's code has changed so much compared with the version which ourpreviouspatches can be applied to, such as the data structure bios_config in hvmloader/config.h. So, our previous patches for Xen hvmloader cannot be applied to the latest Xen-unstable. If necessary, I willrefactorour patches after finishing our project. My Xen code version information is

root@gavin-desktop:~/Xen/xen-4.2-unstable# hg tip
changeset: 23220:56a3b9c7367f
tag: tip
user: Stephen Smalley <>
date: Tue Apr 12 14:55:25 2011 +0100
summary: xsm: Fix xsm_mmu_* and xsm_update_va_mapping hooks

The latest patches for this Xen version is here
And, the ovmf firmware