From patchwork Thu Feb 24 10:14:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12758312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69B70C433EF for ; Thu, 24 Feb 2022 10:15:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.278064.475160 (Exim 4.92) (envelope-from ) id 1nNB8v-0007f9-La; Thu, 24 Feb 2022 10:14:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 278064.475160; Thu, 24 Feb 2022 10:14:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nNB8v-0007f2-HA; Thu, 24 Feb 2022 10:14:37 +0000 Received: by outflank-mailman (input) for mailman id 278064; Thu, 24 Feb 2022 10:14:36 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nNB8u-0007ew-GZ for xen-devel@lists.xenproject.org; Thu, 24 Feb 2022 10:14:36 +0000 Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 90173fa3-955a-11ec-8539-5f4723681683; Thu, 24 Feb 2022 11:14:34 +0100 (CET) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2113.outbound.protection.outlook.com [104.47.18.113]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-28-qneMBb3ROPuLRAaKgdR9LQ-1; Thu, 24 Feb 2022 11:14:32 +0100 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by AM6PR0402MB3333.eurprd04.prod.outlook.com (2603:10a6:209:5::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16; Thu, 24 Feb 2022 10:14:31 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5017.024; Thu, 24 Feb 2022 10:14:31 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 90173fa3-955a-11ec-8539-5f4723681683 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1645697673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zhkz7XUOfkbAUL6lSDSMSMGj4W9BquadB21UquNDilc=; b=i+5BeWil7q53c6DoocXePIWaAkTQk4CQdXMBrdBOl7Eeru6w1MTNKEZ3kc0GchqS8PTKAd MKwEQ5vyY9QdMwVxTn1aGnQbTKGGcawAKXpDO4RE3GCoO85KU4M7GM3XcEGRTSmhvREdoC cfj3JHJNQIaWG8Tr4Fn3kEj6bPrxy30= X-MC-Unique: qneMBb3ROPuLRAaKgdR9LQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a78V4y121wmd+tF3k8ppQNxQn/Vh6NTmEKb7uWB+le14cSgoljhI/GF4Pf3OcpNhkkY7bLrxw2p1WpaklySNmeGg0WHXSDfAIcIRg0Zm2i/4uYEyT1H4MzQEVOFsfOX1rxlbwloa310c37NdsXhTr4VR9Cn6TJ2qsKwxxH+540yQ+PRNURIxZDWunRkfR/o42XXbS0VJZNWNG5OQvPN8YfquFpq6w8d0Wm+ej7I/SGXBdjGCvqycfCk2K7YHUc7OcfIr6fd2JP+k/5+CniNogoheaoKGD7HoNG54LkvMZcu4xV066nLgIrf86qrZchFAj9u6GNG+g+tEA9Ain7RFmg== 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=zhkz7XUOfkbAUL6lSDSMSMGj4W9BquadB21UquNDilc=; b=Tf8k2IZfk1B+UshpGS9g+W8J9EcS9onXa0Tn1J6IHEfKWWfuf4bhWxCZN7NwbjCvIXx7gg1ip0LDLPIc0WBjdhrIcVT86fggi8Meb2LzpoMv1xg4tcs38nEsxXIc6dph65G4flxwKJg0u81xvdInD7fM1VYXN+nFucyds++LDDgZWWyjHA6vZd85I7AMmoCgtbzBcthehxvx4X3JnfipNLDJGfpy+Y8CCMkbvXGGDA1bjHUq603Emj033xQyN5D1UzBinXNdV7fbwibluOw6BfG49lQiHxBSV2SpOm3OlSMKld4nTiL9jhL/l7QDgbnrKQwJTAzQq/Q6Yhjwygv44w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Thu, 24 Feb 2022 11:14:28 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Content-Language: en-US To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= From: Jan Beulich Subject: [PATCH] x86: make embedded endbr64 check compatible with older GNU grep X-ClientProxiedBy: AM6P191CA0023.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8b::36) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 37c28d98-85a2-4853-c663-08d9f77e728d X-MS-TrafficTypeDiagnostic: AM6PR0402MB3333:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BNME5yBQb56fm5pKl0OqFZsmARUVQLmrDI/XbnHzWS9aHzEFsXyXUXWzcxEMFtz7ABoPBhPE2ZgDcrX0jYeIb9eWekXBOF/JMioETt/MR9aieK4oLGD+BFg+P+RwrB8WT0g8OBtgi5Hu4qcWhLil6UZ3DiMLQ8BpAeWMGpi1CingWlJdByaidbcpqzJ3+TW1N47uQ/yVJijqYenrYWRb5ixRl08Cgu/vlUDF+o+y9Urzhyj0nhyFoVYOejS93jKJxbZaG0JWuBFiLa73GX/E67KeythbhWmTgk+yiCZs7lD2FV5Adu261QfXYnyhMACcl1O2xHTRr6+tA0r7JB3M3T78DsLX6A21HMZflfe48zngrA5Ry26DllAJnkrhKXo1PVmm3N1MLc/KAWqCocnaiu9NNlI4fFPxJ3EkABoxMwnMH5v+cSjX7YvpAGb5ij851CovDLS6ZjSg7jo0o2a7y9/nP71REFZ25kn37K1YNFlBwH9A2FMpx32uGr/Lo+pg4tnEiBWI234ZSCVFjzc3j9XhKSrTZdenMWw2jwtMS9pv/5b+nDRmHqY093BrpQRlerrd1n/Dbe0Y6IUVy5kCW0+RHmhHgM5/hFDSwhVogHeICWyK/hAOUmoNPmc/s0jYt3fOQSr2yjxaACakUw01uSn7Alo2Ovz7Fkq2X66iACPmzfyHc2Mx9BLIXR8earMwUaPwzHop6Yca1/+hF6dMA1n6UjoPpur6t36We8ZxRF0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(2616005)(66476007)(36756003)(186003)(508600001)(31686004)(8936002)(83380400001)(6666004)(2906002)(6486002)(31696002)(6512007)(5660300002)(6916009)(66556008)(38100700002)(54906003)(316002)(4326008)(66946007)(8676002)(86362001)(26005)(6506007)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?/vR9mpBD/7y55voCyPtKo/fqOC1D?= =?utf-8?q?LVOP4giaEvdDFRtHzdPBZz58TxiMkzeRhJos+xSEOAaECZmSEiEyEnB0E85LcBxDP?= =?utf-8?q?f8PE7u9EBl75ePrgtm3qZTfzgLR2krgg8OhqVvfnRP4FziBntgXCt8w10XdIAPJvz?= =?utf-8?q?WAP9KGI9m6Ibq2vYaGDqiTTAeLO/hLtdjI3Gbv8oGva9DN1eIBPf/h45ptvQm7Ey4?= =?utf-8?q?Syc0hK9Doqd71PsvT7ucXp+Nl+ZTLuzE0R6xyFzyuAzhImyVRsPi+oQAzseLUuQ2q?= =?utf-8?q?/quSl0fJCVwTXC99QdV0qZZ3J7FB59A2SnKsP1lAfxAvKloD7WHdS6frDtlF4SHSc?= =?utf-8?q?A+0iVDPYFULWPwyWWa77ZlGbh7h1hDL/RbVAX9LgYBm2AaQiKZkjdqm3g1YHIBz1u?= =?utf-8?q?spXSPmMf/zkyNXft8xddZbFnK+7NEtiuIdLvC+ZLAi96Qwff0dsO1WyQnIHHe8STU?= =?utf-8?q?QaytJfdN6xrdrsJelNwkitua8BebD8gY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HBFUfj1hlvR/jiPrhxCXKy6L3vxcqg7?= =?utf-8?q?hCav/9bM/cWRGsBgKo1WphRnwC897tGWz/3L4l+WEGg1pnWbyrzNQiaTTvHvyzkov?= =?utf-8?q?x4QzrKrwPRvNT1D62pXZuzcxTOd9OnTK6NhATHuMI2wXYZzEO+S0Wo5yuEoRIzPCw?= =?utf-8?q?TcfTyWIg50Y9jvH+SU1s3mIskXTzz7/wNjy5IKioMHi0bWwkPfjTu4o=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37c28d98-85a2-4853-c663-08d9f77e728d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Feb 2022 10:14:31.0719 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gCMby4O4FQSbL1+dmus2rPXuQ8CCPmoAH7Doh3yIpTWCj7QQAxkaJA7NJjbEfp61z+sdBdATfB1QKAR3fRhj5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0402MB3333 With version 2.7 I'm observing support for binary searches, but unreliable results: Only a subset of the supposed matches is actually reported; for our pattern I've never observed any match. This same version works fine when handing it a Perl regexp using hex or octal escapes. Probe for support of -P and prefer that over the original approach. Fixes: 4d037425dccf ("x86: Build check for embedded endbr64 instructions") Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- If we were to fear -P having a different meaning elsewhere, we may need to switch to the respective long option (--perl-regexp). --- a/xen/tools/check-endbr.sh +++ b/xen/tools/check-endbr.sh @@ -24,6 +24,11 @@ BAD=$D/bad-addrs echo "X" | grep -aob "X" -q 2>/dev/null || { echo "$MSG_PFX Warning: grep can't do binary searches" >&2; exit 0; } +# Check whether grep supports Perl regexps. Older GNU grep doesn't reliably +# find binary patterns otherwise. +perl_re=true +echo "X" | grep -aobP "\130" -q 2>/dev/null || perl_re=false + # # First, look for all the valid endbr64 instructions. # A worst-case disassembly, viewed through cat -A, may look like: @@ -60,8 +65,12 @@ eval $(${OBJDUMP} -j .text $1 -h | awk '$2 == ".text" {printf "vma_hi=%s\nvma_lo=%s\n", substr($4, 1, 8), substr($4, 9, 16)}') ${OBJCOPY} -j .text $1 -O binary $TEXT_BIN -grep -aob "$(printf '\363\17\36\372')" $TEXT_BIN | - awk -F':' '{printf "%s%x\n", "'$vma_hi'", int(0x'$vma_lo') + $1}' > $ALL +if $perl_re +then + LC_ALL=C grep -aobP '\363\17\36\372' $TEXT_BIN +else + grep -aob "$(printf '\363\17\36\372')" $TEXT_BIN +fi | awk -F':' '{printf "%s%x\n", "'$vma_hi'", int(0x'$vma_lo') + $1}' > $ALL # Wait for $VALID to become complete wait