From patchwork Thu Mar 19 13:03:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 11447201 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 385821667 for ; Thu, 19 Mar 2020 13:28:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1871F208D6 for ; Thu, 19 Mar 2020 13:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584624532; bh=5iPR7XCLsazQnaDrcx+zT2BH4J3il51Isf+Aw05JtG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Zi+vZ6XdVHnB3QbgTmJ7JlVHncCNQ97cX22FE5uU1/QH+mR7k+8ZVAI6vnZMyB8jE baH6L0MSt5TYXWlg/RorHYpJ8ZuSEJQvixLZS9/BAkMyh94YKiATMX4VCDRIR4sOvc pIC9t5ROWPadD98UCCSLgr/v1lRl3qG5Eoc3M2Ds= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730709AbgCSNZ6 (ORCPT ); Thu, 19 Mar 2020 09:25:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:53740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730515AbgCSNZ5 (ORCPT ); Thu, 19 Mar 2020 09:25:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 578FD2080C; Thu, 19 Mar 2020 13:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584624355; bh=5iPR7XCLsazQnaDrcx+zT2BH4J3il51Isf+Aw05JtG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V00+g1ReQ5ZN/S2LQRGaxu6CjECtb2pY2qLqmqQStO9M/zo7vl+bjuSiQdu8A32yP ZGoB69yUYBSPk0Dcc97B8VUPv/G949VaOvPGrXMgx4DVltRdhHD6ZAoEJoeMFYZjXw cHNJ+xcNquBqNGl77AlhtjEDZ7XaSmsMXL6aZJeg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Victor Kamensky , Paul Burton , linux-mips@vger.kernel.org, Ralf Baechle , James Hogan , Vincenzo Frascino , bruce.ashfield@gmail.com, richard.purdie@linuxfoundation.org, Sasha Levin Subject: [PATCH 5.5 15/65] mips: vdso: add build time check that no jalr t9 calls left Date: Thu, 19 Mar 2020 14:03:57 +0100 Message-Id: <20200319123931.264495151@linuxfoundation.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200319123926.466988514@linuxfoundation.org> References: <20200319123926.466988514@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org From: Victor Kamensky [ Upstream commit 976c23af3ee5bd3447a7bfb6c356ceb4acf264a6 ] vdso shared object cannot have GOT based PIC 'jalr t9' calls because nobody set GOT table in vdso. Contributing into vdso .o files are compiled in PIC mode and as result for internal static functions calls compiler will generate 'jalr t9' instructions. Those are supposed to be converted into PC relative 'bal' calls by linker when relocation are processed. Mips global GOT entries do have dynamic relocations and they will be caught by cmd_vdso_check Makefile rule. Static PIC calls go through mips local GOT entries that do not have dynamic relocations. For those 'jalr t9' calls could be present but without dynamic relocations and they need to be converted to 'bal' calls by linker. Add additional build time check to make sure that no 'jalr t9' slip through because of some toolchain misconfiguration that prevents 'jalr t9' to 'bal' conversion. Signed-off-by: Victor Kamensky Signed-off-by: Paul Burton Cc: linux-mips@vger.kernel.org Cc: Ralf Baechle Cc: James Hogan Cc: Vincenzo Frascino Cc: bruce.ashfield@gmail.com Cc: richard.purdie@linuxfoundation.org Signed-off-by: Sasha Levin --- arch/mips/vdso/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile index e8585a22b925c..bfb65b2d57c7f 100644 --- a/arch/mips/vdso/Makefile +++ b/arch/mips/vdso/Makefile @@ -93,12 +93,18 @@ GCOV_PROFILE := n UBSAN_SANITIZE := n KCOV_INSTRUMENT := n +# Check that we don't have PIC 'jalr t9' calls left +quiet_cmd_vdso_mips_check = VDSOCHK $@ + cmd_vdso_mips_check = if $(OBJDUMP) --disassemble $@ | egrep -h "jalr.*t9" > /dev/null; \ + then (echo >&2 "$@: PIC 'jalr t9' calls are not supported"; \ + rm -f $@; /bin/false); fi + # # Shared build commands. # quiet_cmd_vdsold_and_vdso_check = LD $@ - cmd_vdsold_and_vdso_check = $(cmd_vdsold); $(cmd_vdso_check) + cmd_vdsold_and_vdso_check = $(cmd_vdsold); $(cmd_vdso_check); $(cmd_vdso_mips_check) quiet_cmd_vdsold = VDSO $@ cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \