Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp955659pxj; Fri, 4 Jun 2021 02:24:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIukVjsyJgL1/1SJ2xRaivKEtgK4LnkAbUM3AbiyRL6dE6Oxn+5Q16/lTAchmYW0MAgWcw X-Received: by 2002:a17:906:6d43:: with SMTP id a3mr3353127ejt.142.1622798654237; Fri, 04 Jun 2021 02:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622798654; cv=none; d=google.com; s=arc-20160816; b=aFniQjZ2GSRpZhcpbJFjEw6RvVRMtT7tB0lUsA1N5Kph9LTKBNBK+qt6/kd8p70HA5 qgdw0GJ5gLh/2hiX0FVIP2Hf0TgGqEkGi2p2zIeMY1mIef2KHfLtSXQYp2OK0uigbJkm PPfHS0mPcLgGSRjDo+sLESTu2bh2FzgbUj6b1YPvzRKNXHjysoNbidHd6Y3cOgSwogS1 +fzsQQw6nJiDvCsg2+sNRJJhYPmqFzhhbLdME0RHQwoTvs2QSy3gfz50aa3DkYLwX1Eh 7YVw+6w+Ima3WoO5Mn4f8BURuOOi3Yg2DXfR9nQgL95fWwKWlU7cYLXKU9Iqjxz4uRHP yIRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=hElgLzGizjliXjcjSH8Wd/b7I1/rAQDblEeWHZOBIUg=; b=hJalyMbzWuMnZZFIJE0RWwYhCgCw/S4fi6/oZMDZsBCtTakiwe/xHh9PromTGZ3kD5 yBDp2NqvrOV36mXm6htCi+ar4a53STgrzRJVrtu9B7SwegCm86NnLBrg+DlCLwfeehwR O7BND4D3rKEPd+h9jlKFXYuGquL8D02gH9EDDXxBb6zNsot+9oFTTo+v7IrlsHV1RHnY D/56fiYTtBrX46r+kZlcQubz6yyMTuHUmggcoV0nkO3XKD86PpBvPxWbBK7rQLcqn2eq rm1XuBAr1LW7QvdjsHKBmPMxB1kYrjMY2RXCEi5oM1gLUoD8bJgpaXnexudCJdLrPGJf HPcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n1si4092889ejx.353.2021.06.04.02.23.49; Fri, 04 Jun 2021 02:24:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230193AbhFDJXg (ORCPT + 99 others); Fri, 4 Jun 2021 05:23:36 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:3060 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbhFDJXg (ORCPT ); Fri, 4 Jun 2021 05:23:36 -0400 Received: from dggeme758-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4FxHG50cc6zWpSp; Fri, 4 Jun 2021 17:17:01 +0800 (CST) Received: from huawei.com (10.67.174.47) by dggeme758-chm.china.huawei.com (10.3.19.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 4 Jun 2021 17:21:46 +0800 From: He Ying To: , , , CC: , , Subject: [PATCH] powerpc: Fix kernel-jump address for ppc64 wrapper boot Date: Fri, 4 Jun 2021 05:22:28 -0400 Message-ID: <20210604092228.199588-1-heying24@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.47] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggeme758-chm.china.huawei.com (10.3.19.104) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From "64-bit PowerPC ELF Application Binary Interface Supplement 1.9", we know that the value of a function pointer in a language like C is the address of the function descriptor and the first doubleword of the function descriptor contains the address of the entry point of the function. So, when we want to jump to an address (e.g. addr) to execute for PPC-elf64abi, we should assign the address of addr *NOT* addr itself to the function pointer or system will jump to the wrong address. Link: https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUNC-DES Signed-off-by: He Ying --- arch/powerpc/boot/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c index cae31a6e8f02..50fd7f11b642 100644 --- a/arch/powerpc/boot/main.c +++ b/arch/powerpc/boot/main.c @@ -268,7 +268,16 @@ void start(void) if (console_ops.close) console_ops.close(); +#ifdef CONFIG_PPC64_BOOT_WRAPPER + /* + * For PPC-elf64abi, the value of a function pointer is the address + * of the function descriptor. And the first doubleword of a function + * descriptor contains the address of the entry point of the function. + */ + kentry = (kernel_entry_t) &vmlinux.addr; +#else kentry = (kernel_entry_t) vmlinux.addr; +#endif if (ft_addr) { if(platform_ops.kentry) platform_ops.kentry(ft_addr, vmlinux.addr); -- 2.17.1