Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1899619

Summary: QEMU 5.2 is built with PIC objects instead of PIE
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Paolo Bonzini <pbonzini>
Component: qemu-kvmAssignee: Paolo Bonzini <pbonzini>
qemu-kvm sub component: General QA Contact: jingzhao <jinzhao>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: high CC: coli, jinzhao, juzhang, knoel, pbonzini, virt-maint
Version: 8.4Keywords: Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.4   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-5.2.0-3.module+el8.4.0+9499+42e58f08 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-25 06:45:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1899620    
Bug Blocks:    

Description Paolo Bonzini 2020-11-19 17:08:27 UTC
QEMU uses lots of static libraries to group parts of the build.  Unless those libraries are compiled as position-independent executable (PIE) code and not position-independent shared library (PIC) code, there will be a substantial performance hit.

In theory, b_staticpic is meant for libraries that are never installed and only linked to executables.  However, Meson right now uses position-*dependent* code unconditionally if b_staticpic=false, even if b_pie=true.  Therefore we first need to backport a patch from Meson 0.56 in order to fix this case.  Once we do that, we can compile QEMU with b_staticpic=false.

To verify, check that the build.log has -fPIC only for module files and -fPIE for almost everything.

The patch is very simple:

--- a/configure
+++ b/configure
@@ -6490,7 +6490,7 @@ mv $cross config-meson.cross
 rm -rf meson-private meson-info meson-logs
 unset staticpic
 if ! version_ge "$($meson --version)" 0.56.0; then
-  staticpic=$(if test "$pie" = yes; then echo true; else echo false; fi)
+  staticpic=false
 fi
 NINJA=$ninja $meson setup \
         --prefix "$prefix" \

Comment 1 Paolo Bonzini 2020-12-02 13:46:24 UTC
Fedora is now building using Meson 0.56, so this change is already effective in Fedora.

Comment 2 Paolo Bonzini 2020-12-16 17:55:10 UTC
Patch posted.  Danilo, before moving to ON_QA/MODIFIED please let me take a look at the build log, as I couldn't do the appropriate brew build without Meson 0.55.3-3.el8 in the build root.

Comment 11 Paolo Bonzini 2021-01-21 13:03:40 UTC
[pbonzini@virtlab701 qemu]$ grep -c fPIC build.log
44
[pbonzini@virtlab701 qemu]$ grep -c fPIE build.log
3462

Yes, it's okay (I also looked at the individual -fPIC lines and they are as expected).

Comment 14 errata-xmlrpc 2021-05-25 06:45:10 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (virt:av bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:2098