Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp134685pxu; Tue, 6 Oct 2020 02:39:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvmssqoT5E2egsPKbDCxwy87DqBA6vT0DQqiwUtys+7fK10WRoY6/0cHdfXQq0Q1pDDMcR X-Received: by 2002:a17:906:c0d8:: with SMTP id bn24mr4158971ejb.480.1601977148523; Tue, 06 Oct 2020 02:39:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601977148; cv=none; d=google.com; s=arc-20160816; b=Gg8CVmjY2pRWCRDXVZyh1T6GSxha+cJbfrByw6hAozrH6inTweWI1X/IqLlACm4+lW 5dxCCi/xd5Vkl8ZM1tSpsNwucAwi9fjWqQPvoCxpo8l1qf6xRQfovfjw57I+x5oO/nO5 2/Sm/Ig7AAqI08CoCvFghiD9L5R3634ZNFf4FkcPZ0O4aD4tAIypIux6Bcf6Aq+R4xk1 N7HnIk0S6A12ihbq4ZFjOOv2H76puG+VLz0yxKEXLckqtJjw4ixcMgTsQdSeIAdeTASf UZlQzqClshPuKeO1Qr2WRY6YLj6ExGCxgADQ6jMDMS2I691/273wDf84FRgAq3rHuYyq BqQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=5D+7MRPOfT4+0ZmAqhlpTqQExQ9a6XzhkXx7em7pVDc=; b=PtyQzJfECfuVfuPvZY0po9A7vbVBQdYxLSmNHVM+eo6WtToLQQ7NRloLTc1eJxLYmO ZZBvhC8L0H8kg8cegxNGvQjGDs6WPa841ZYoBC7gxoF1QJA4LUUvhJ/GAiMEIwphz/iZ SJ2I/EtnbKJGpp89WKeKEimV2vcWN258A555TKkCJCk9WpEeLOjxpsToLqYl296afZjL ScJNvt07GtOyCd4SE/BKEJE3ExGJ+/q06UrOWPUlSb1mDIeLtDruTI+dPa9zvr0CQaIM QbFkc/BJ1kjdoXP/JJ0noudDgF5KkPBQT8jNS9GKuYmXlYiYRuuYUAqgw0V4iG3wA8xN j05Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q7si1667069ejd.647.2020.10.06.02.38.35; Tue, 06 Oct 2020 02:39:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725947AbgJFJiW (ORCPT + 99 others); Tue, 6 Oct 2020 05:38:22 -0400 Received: from foss.arm.com ([217.140.110.172]:43058 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbgJFJiW (ORCPT ); Tue, 6 Oct 2020 05:38:22 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2C931113E; Tue, 6 Oct 2020 02:38:22 -0700 (PDT) Received: from arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CC4E23F71F; Tue, 6 Oct 2020 02:38:20 -0700 (PDT) Date: Tue, 6 Oct 2020 10:38:17 +0100 From: Dave Martin To: Jeremy Linton Cc: Ard Biesheuvel , Herbert Xu , Catalin Marinas , Linux Kernel Mailing List , Mark Brown , Linux Crypto Mailing List , Will Deacon , "David S. Miller" , Linux ARM Subject: Re: [BUG][PATCH] arm64: bti: fix BTI to handle local indirect branches Message-ID: <20201006093817.GV6642@arm.com> References: <20201005181804.1331237-1-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Oct 05, 2020 at 02:24:47PM -0500, Jeremy Linton wrote: > Hi, > > On 10/5/20 1:54 PM, Ard Biesheuvel wrote: > >On Mon, 5 Oct 2020 at 20:18, Jeremy Linton wrote: > >> > >>The AES code uses a 'br x7' as part of a function called by > >>a macro, that ends up needing a BTI_J as a target. > > > >Could we instead just drop the tail call, i.e, replace it with a ret > >and do a 'bl' after it returns? The indirect call does not really > >serve a purpose here anyway > > Yes, that is an option, it adds an extra ret. Which probably doesn't mean > much in most cases. I assumed this code was optimized this way because it > mattered somewhere. Since this really does seem to be a tail-call and since x16 and x17 appear to be otherwise unused here, can we not just use x16 or x17 instead of x7? This relies on there being no other calls to veneered functions in the mix, but this code is all in a single section so that shouldn't be a concern. Due to the magic status of x16 and x17 in br instructions, the resulting jump should be compatible with BTI c. I think this matches how the compiler should typically compile tail-calls. Cheers ---Dave