[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/4] livepatch: differentiate between old and new build systems


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Thu, 10 Mar 2022 18:01:48 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dutXrCMyPCT3EF4xQMJwBzi2O1s157h9DnmoUvOyd7o=; b=hRFmy6YCzdutdgcdtlvhtAnbltcvSH7wuypivjicnSuzvU8bNEV/B2VRzO5ijb1DseNQdWKHJ/NvxL/tsRl7Ds0KZyrSSJgYPOFSdRbzy4/z/6gM5aZzIE7bLBmc1EerSfXIRCmL3NrR0wN4+EabT3rq8cFdRjUGrfAFUUYG+5jx+7Y1KwwM4S/3i1gK2vXjDzklj85WSbOvqapzrwHnmhuVQ6SsT8/ZGH/+FqiKg60LP6DR86MSD6tvjYYR/rsNGoIGfJDkBoOG2xm0LRc83Oofha/JNMBA4BeRw7sM4d671SJ3BovvGmSS3ewrfAmbYlz2CxZngUx/5yJrI5wb8w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KFAb8lapqIwu5xEZYQPrNOxkNZwypVvDfG9s4a59SrdLZktIAEZE910Ivm0upUl27UV97brZLZMUtp94B8+C5WDoEl+epO+oUcVwCUFhT2BP0aABOLuRiCfpWUQfw/zzAZUuVDOTkFdKOSdY27aw1KKob/YT86Gh7ix28rrgB9CWgvN5bta6hXh3ZdeXgANyhGYKwAbU33CvINZh76qD+PDFL1qKO1i7kC0BCghHCabX5Ts1rsO0YL5rYjWk/JE9HStiUduykf6SlWSCP2MNeN79ViuTyM/6cgApoKoNBB6aoOWbdG+uTkqYoVAwdUm6m2siGjDDDzJeu3o2lnMDZw==
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Ross Lagerwall" <ross.lagerwall@xxxxxxxxxx>, "konrad.wilk@xxxxxxxxxx" <konrad.wilk@xxxxxxxxxx>, "doebel@xxxxxxxxx" <doebel@xxxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>
  • Delivery-date: Thu, 10 Mar 2022 18:02:01 +0000
  • Ironport-data: A9a23:/ra2DK/u2it8Cx4nlOPfDrUDtn6TJUtcMsCJ2f8bNWPcYEJGY0x3y TEWCmyAaanfZGrwL9okPdnk80wHuZGDzt8wHgI6+yg8E34SpcT7XtnIdU2Y0wF+jyHgoOCLy +1EN7Es+ehtFie0Si+Fa+Sn9T8mvU2xbuKU5NTsY0idfic5DnZ54f5fs7Rh2NQw2oHhW1nlV e7a+KUzBnf0g1aYDUpMg06zgEsHUCPa4W5wUvQWPJinjXeG/5UnJMt3yZKZdhMUdrJ8DO+iL 9sv+Znilo/vE7XBPfv++lrzWhVirrc/pmFigFIOM0SpqkAqSiDfTs/XnRfTAKtao2zhojx/9 DlCnay+UgsMEKCWobQyAgV3S3lzHo1kw6CSdBBTseTLp6HHW37lwvEoB0AqJ4wIvO1wBAmi9 9RBdmpLNErawbvrnvTrEYGAhex6RCXvFKoZtmtt0nfyCvE+TIqYa67L+cVZzHE7gcUm8fP2O ZdINGMwPU6ojxtneRAYLJ83kdqToXThMCN/pmKSroYo7D2GpOB2+Oe0a4eEEjCQfu1ZmUuSq 2bu9mHwEBYcctCSoRKH73ati+nnjS79HoU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w66p2EvnvUUiGEaWYwCaKVJpYha509NFowcdRiKqbzPv9 MeR/00ycwmPm9yVUqp8FWHAebcFEgbD1ODWAwPq8aV2z9ZkDRwyFYZ3tUWmjMF+IgmQ5dJ6u zYOuAw/Ys+DfM+fOZ4HqMMUMG3AmvCTVbFN3+TO03uEOUCN2jWo5D67b0p7KWheYAOzpE1hJ PdOWko9VIaagbrE4mDzZdL+hfCTCG0Wins0NhX49xjtrj1VNPQQGG+oZAV4oadStkkc4Tmsq yISeRr6tfYXCPTJbo=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYLkHgSrb/iAL0mEi291/GjB3zE6y1l+sAgAAD5ACAA1l+gA==
  • Thread-topic: [PATCH 4/4] livepatch: differentiate between old and new build systems

On 08/03/2022 14:52, Roger Pau Monne wrote:
> On Tue, Mar 08, 2022 at 02:38:47PM +0000, Andrew Cooper wrote:
>> On 02/03/2022 14:27, Roger Pau Monne wrote:
>>> diff --git a/livepatch-build b/livepatch-build
>>> index 38a92be..656cdac 100755
>>> --- a/livepatch-build
>>> +++ b/livepatch-build
>>> @@ -98,14 +98,20 @@ function build_special()
>>>  
>>>      # Build with special GCC flags
>>>      cd "${SRCDIR}/xen" || die
>>> -    sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc -ffunction-sections 
>>> -fdata-sections/' Rules.mk
>>> -    cp -p arch/x86/Makefile arch/x86/Makefile.bak
>>> -    sed -i 's/--section-alignment=0x200000/--section-alignment=0x1000/' 
>>> arch/x86/Makefile
>>> -    # Restore timestamps to prevent spurious rebuilding
>>> -    touch --reference=arch/x86/Makefile.bak arch/x86/Makefile
>>> -    make "-j$CPUS" $XEN_DEBUG &> "${OUTPUT}/build_${name}_compile.log" || 
>>> die
>>> -    sed -i 's/CFLAGS += -nostdinc -ffunction-sections 
>>> -fdata-sections/CFLAGS += -nostdinc/' Rules.mk
>>> -    mv -f arch/x86/Makefile.bak arch/x86/Makefile
>>> +    if grep -q 'nostdinc' Rules.mk; then
>>> +         # Support for old build system, attempt to set 
>>> -f{function,data}-sections and rebuild
>>> +        sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc 
>>> -ffunction-sections -fdata-sections/' Rules.mk
>>> +        cp -p arch/x86/Makefile arch/x86/Makefile.bak
>>> +        sed -i 
>>> 's/--section-alignment=0x200000/--section-alignment=0x1000/' 
>>> arch/x86/Makefile
>>> +        # Restore timestamps to prevent spurious rebuilding
>>> +        touch --reference=arch/x86/Makefile.bak arch/x86/Makefile
>>> +        make "-j$CPUS" $XEN_DEBUG &> "${OUTPUT}/build_${name}_compile.log" 
>>> || die
>>> +        sed -i 's/CFLAGS += -nostdinc -ffunction-sections 
>>> -fdata-sections/CFLAGS += -nostdinc/' Rules.mk
>>> +        mv -f arch/x86/Makefile.bak arch/x86/Makefile
>>> +    else
>>> +        # -f{function,data}-sections set by CONFIG_LIVEPATCH
>>> +        make "-j$CPUS" $XEN_DEBUG &> "${OUTPUT}/build_${name}_compile.log" 
>>> || die
>>> +    fi
>> This really ought to be the other way around, by spotting the thing we
>> know is good, and then falling back to the heuristics.  In light of the
>> updates to the Xen side, something like:
> I'm not sure I agree. I do prefer to spot the 'bad' one, and just
> fallback to expecting Xen to correctly set -f{function,data}-sections
> otherwise.
>
>> if grep -q CC_SPLIT_SECTIONS Kconfig; then
> Because this logic ties us to not moving CC_SPLIT_SECTIONS from being
> defined in xen/Kconfig (or even changing it's name), and gain ties the
> livepatch tools to internal details about the Xen build system.

It doesn't particularly matter which way around the if/else is.  It does
matter that we're choosing based on something relevant.

nostdinc in Rules.mk has exactly the same amount of "magic string in
magic file" as CC_SPLIT_SECTIONS in Kconfig, but has absolutely nothing
to do with the property we actually care about.

Really what you actually want is

if grep -q CC_SPLIT_SECTIONS Kconfig; then
    # Xen behaves sensibly
elif grep -q 'nostdinc' Rules.mk; then
    # Legacy mess with Rules.mk
else
    die "Help with build system divination"
fi

The "behaves sensibly" case is unlikely to change name and unlikely to
move locations, but each are easy to cope with via `grep -e FOO -e BAR
file1 file2`, and this approach avoids the problem of blindly (and
falsely) assuming that anything which is 4.14 and later splits sections
correctly, and that this will remain true even when someone adds "# use
to have -nostdinc here" to Rules.mk.

~Andrew

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.