* [PATCH] x86 UEFI: Fix broken build for UEFI
@ 2022-02-10 9:20 Zhenzhong Duan
2022-02-10 16:30 ` Sean Christopherson
2022-02-14 11:14 ` Alexandru Elisei
0 siblings, 2 replies; 5+ messages in thread
From: Zhenzhong Duan @ 2022-02-10 9:20 UTC (permalink / raw)
To: kvm; +Cc: pbonzini, seanjc
UEFI loads EFI applications to dynamic runtime addresses, so it requires
all applications to be compiled as PIC (position independent code).
The new introduced single-step #DB tests series bring some compile time
absolute address, fixed it with RIP relative address.
Fixes: 9734b4236294 ("x86/debug: Add framework for single-step #DB tests")
Fixes: 6bfb9572ec04 ("x86/debug: Test IN instead of RDMSR for single-step #DB emulation test")
Fixes: bc0dd8bdc627 ("x86/debug: Add single-step #DB + STI/MOVSS blocking tests")
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
x86/debug.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/x86/debug.c b/x86/debug.c
index 20ff8ebacc16..13d1f9629e1d 100644
--- a/x86/debug.c
+++ b/x86/debug.c
@@ -145,7 +145,7 @@ static unsigned long singlestep_basic(void)
"and $~(1<<8),%%rax\n\t"
"1:push %%rax\n\t"
"popf\n\t"
- "lea 1b, %0\n\t"
+ "lea 1b(%%rip), %0\n\t"
: "=r" (start) : : "rax"
);
return start;
@@ -186,7 +186,7 @@ static unsigned long singlestep_emulated_instructions(void)
"movl $0x3fd, %%edx\n\t"
"inb %%dx, %%al\n\t"
"popf\n\t"
- "lea 1b,%0\n\t"
+ "lea 1b(%%rip),%0\n\t"
: "=r" (start) : : "rax", "ebx", "ecx", "edx"
);
return start;
@@ -223,7 +223,7 @@ static unsigned long singlestep_with_sti_blocking(void)
"1:and $~(1<<8),%%rax\n\t"
"push %%rax\n\t"
"popf\n\t"
- "lea 1b,%0\n\t"
+ "lea 1b(%%rip),%0\n\t"
: "=r" (start_rip) : : "rax"
);
return start_rip;
@@ -259,7 +259,7 @@ static unsigned long singlestep_with_movss_blocking(void)
"and $~(1<<8),%%rax\n\t"
"1: push %%rax\n\t"
"popf\n\t"
- "lea 1b,%0\n\t"
+ "lea 1b(%%rip),%0\n\t"
: "=r" (start_rip) : : "rax"
);
return start_rip;
@@ -302,7 +302,7 @@ static unsigned long singlestep_with_movss_blocking_and_icebp(void)
"1:and $~(1<<8),%%rax\n\t"
"push %%rax\n\t"
"popf\n\t"
- "lea 1b,%0\n\t"
+ "lea 1b(%%rip),%0\n\t"
: "=r" (start) : : "rax"
);
return start;
@@ -346,7 +346,7 @@ static unsigned long singlestep_with_movss_blocking_and_dr7_gd(void)
"and $~(1<<8),%%rax\n\t"
"push %%rax\n\t"
"popf\n\t"
- "lea 1b,%0\n\t"
+ "lea 1b(%%rip),%0\n\t"
: "=r" (start_rip) : : "rax"
);
return start_rip;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] x86 UEFI: Fix broken build for UEFI
2022-02-10 9:20 [PATCH] x86 UEFI: Fix broken build for UEFI Zhenzhong Duan
@ 2022-02-10 16:30 ` Sean Christopherson
2022-02-11 3:07 ` Duan, Zhenzhong
2022-02-14 11:14 ` Alexandru Elisei
1 sibling, 1 reply; 5+ messages in thread
From: Sean Christopherson @ 2022-02-10 16:30 UTC (permalink / raw)
To: Zhenzhong Duan; +Cc: kvm, pbonzini
On Thu, Feb 10, 2022, Zhenzhong Duan wrote:
> UEFI loads EFI applications to dynamic runtime addresses, so it requires
> all applications to be compiled as PIC (position independent code).
>
> The new introduced single-step #DB tests series bring some compile time
> absolute address, fixed it with RIP relative address.
>
> Fixes: 9734b4236294 ("x86/debug: Add framework for single-step #DB tests")
> Fixes: 6bfb9572ec04 ("x86/debug: Test IN instead of RDMSR for single-step #DB emulation test")
> Fixes: bc0dd8bdc627 ("x86/debug: Add single-step #DB + STI/MOVSS blocking tests")
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> ---
Hrm. It would be nice if we could enabled -fPIC by default for tests that support
it, having to compile twice is going to be annoying...
Reviewed-and-tested-by: Sean Christopherson <seanjc@google.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: [PATCH] x86 UEFI: Fix broken build for UEFI
2022-02-10 16:30 ` Sean Christopherson
@ 2022-02-11 3:07 ` Duan, Zhenzhong
0 siblings, 0 replies; 5+ messages in thread
From: Duan, Zhenzhong @ 2022-02-11 3:07 UTC (permalink / raw)
To: Christopherson,, Sean; +Cc: kvm@vger.kernel.org, pbonzini@redhat.com
>-----Original Message-----
>From: Sean Christopherson <seanjc@google.com>
>Sent: Friday, February 11, 2022 12:31 AM
>To: Duan, Zhenzhong <zhenzhong.duan@intel.com>
>Cc: kvm@vger.kernel.org; pbonzini@redhat.com
>Subject: Re: [PATCH] x86 UEFI: Fix broken build for UEFI
>
>On Thu, Feb 10, 2022, Zhenzhong Duan wrote:
>> UEFI loads EFI applications to dynamic runtime addresses, so it
>> requires all applications to be compiled as PIC (position independent code).
>>
>> The new introduced single-step #DB tests series bring some compile
>> time absolute address, fixed it with RIP relative address.
>>
>> Fixes: 9734b4236294 ("x86/debug: Add framework for single-step #DB
>> tests")
>> Fixes: 6bfb9572ec04 ("x86/debug: Test IN instead of RDMSR for
>> single-step #DB emulation test")
>> Fixes: bc0dd8bdc627 ("x86/debug: Add single-step #DB + STI/MOVSS
>> blocking tests")
>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>> ---
>
>Hrm. It would be nice if we could enabled -fPIC by default for tests that
>support it, having to compile twice is going to be annoying...
Agree it's annoying, but enable -fPIC for non-UEFI build may not help find
this build error, because the error happen in link stage to generate xxx.so,
while non-UEFI build will not generate xxx.so.
Thanks
Zhenzhong
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86 UEFI: Fix broken build for UEFI
2022-02-10 9:20 [PATCH] x86 UEFI: Fix broken build for UEFI Zhenzhong Duan
2022-02-10 16:30 ` Sean Christopherson
@ 2022-02-14 11:14 ` Alexandru Elisei
2022-02-14 12:42 ` Paolo Bonzini
1 sibling, 1 reply; 5+ messages in thread
From: Alexandru Elisei @ 2022-02-14 11:14 UTC (permalink / raw)
To: Zhenzhong Duan; +Cc: kvm, pbonzini, seanjc
Hi,
On Thu, Feb 10, 2022 at 05:20:44PM +0800, Zhenzhong Duan wrote:
> UEFI loads EFI applications to dynamic runtime addresses, so it requires
> all applications to be compiled as PIC (position independent code).
>
> The new introduced single-step #DB tests series bring some compile time
> absolute address, fixed it with RIP relative address.
With this patch the error:
ld: x86/debug.o: relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC
disappears and I can now build kvm-unit-tests for x86_64 when configured
with --target-efi:
Tested-by: Alexandru Elisei <alexandru.elisei@arm.com>
Thanks,
Alex
>
> Fixes: 9734b4236294 ("x86/debug: Add framework for single-step #DB tests")
> Fixes: 6bfb9572ec04 ("x86/debug: Test IN instead of RDMSR for single-step #DB emulation test")
> Fixes: bc0dd8bdc627 ("x86/debug: Add single-step #DB + STI/MOVSS blocking tests")
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> ---
> x86/debug.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/x86/debug.c b/x86/debug.c
> index 20ff8ebacc16..13d1f9629e1d 100644
> --- a/x86/debug.c
> +++ b/x86/debug.c
> @@ -145,7 +145,7 @@ static unsigned long singlestep_basic(void)
> "and $~(1<<8),%%rax\n\t"
> "1:push %%rax\n\t"
> "popf\n\t"
> - "lea 1b, %0\n\t"
> + "lea 1b(%%rip), %0\n\t"
> : "=r" (start) : : "rax"
> );
> return start;
> @@ -186,7 +186,7 @@ static unsigned long singlestep_emulated_instructions(void)
> "movl $0x3fd, %%edx\n\t"
> "inb %%dx, %%al\n\t"
> "popf\n\t"
> - "lea 1b,%0\n\t"
> + "lea 1b(%%rip),%0\n\t"
> : "=r" (start) : : "rax", "ebx", "ecx", "edx"
> );
> return start;
> @@ -223,7 +223,7 @@ static unsigned long singlestep_with_sti_blocking(void)
> "1:and $~(1<<8),%%rax\n\t"
> "push %%rax\n\t"
> "popf\n\t"
> - "lea 1b,%0\n\t"
> + "lea 1b(%%rip),%0\n\t"
> : "=r" (start_rip) : : "rax"
> );
> return start_rip;
> @@ -259,7 +259,7 @@ static unsigned long singlestep_with_movss_blocking(void)
> "and $~(1<<8),%%rax\n\t"
> "1: push %%rax\n\t"
> "popf\n\t"
> - "lea 1b,%0\n\t"
> + "lea 1b(%%rip),%0\n\t"
> : "=r" (start_rip) : : "rax"
> );
> return start_rip;
> @@ -302,7 +302,7 @@ static unsigned long singlestep_with_movss_blocking_and_icebp(void)
> "1:and $~(1<<8),%%rax\n\t"
> "push %%rax\n\t"
> "popf\n\t"
> - "lea 1b,%0\n\t"
> + "lea 1b(%%rip),%0\n\t"
> : "=r" (start) : : "rax"
> );
> return start;
> @@ -346,7 +346,7 @@ static unsigned long singlestep_with_movss_blocking_and_dr7_gd(void)
> "and $~(1<<8),%%rax\n\t"
> "push %%rax\n\t"
> "popf\n\t"
> - "lea 1b,%0\n\t"
> + "lea 1b(%%rip),%0\n\t"
> : "=r" (start_rip) : : "rax"
> );
> return start_rip;
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] x86 UEFI: Fix broken build for UEFI
2022-02-14 11:14 ` Alexandru Elisei
@ 2022-02-14 12:42 ` Paolo Bonzini
0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2022-02-14 12:42 UTC (permalink / raw)
To: Alexandru Elisei, Zhenzhong Duan; +Cc: kvm, seanjc
On 2/14/22 12:14, Alexandru Elisei wrote:
> Hi,
>
> On Thu, Feb 10, 2022 at 05:20:44PM +0800, Zhenzhong Duan wrote:
>> UEFI loads EFI applications to dynamic runtime addresses, so it requires
>> all applications to be compiled as PIC (position independent code).
>>
>> The new introduced single-step #DB tests series bring some compile time
>> absolute address, fixed it with RIP relative address.
>
> With this patch the error:
>
> ld: x86/debug.o: relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC
>
> disappears and I can now build kvm-unit-tests for x86_64 when configured
> with --target-efi:
>
> Tested-by: Alexandru Elisei <alexandru.elisei@arm.com>
Applied, thanks.
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-14 12:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-10 9:20 [PATCH] x86 UEFI: Fix broken build for UEFI Zhenzhong Duan
2022-02-10 16:30 ` Sean Christopherson
2022-02-11 3:07 ` Duan, Zhenzhong
2022-02-14 11:14 ` Alexandru Elisei
2022-02-14 12:42 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox