Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3852304pxj; Mon, 7 Jun 2021 23:34:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz533mPq8DbU5GKTgUKvIo/vNjccAHCdv2Dm1Sr44eZcL/gbKnxkWwJGO5UEjN9dfkoc/ac X-Received: by 2002:a17:906:a293:: with SMTP id i19mr21015214ejz.311.1623134087874; Mon, 07 Jun 2021 23:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623134087; cv=none; d=google.com; s=arc-20160816; b=dtRA5UFxwXwOcLWlVppSkphxJJ8++yYvX1otyA8zp6OOuOUTxls1x4pPOG16aivwG+ ONljeMbnpnsv3qWNb0ZAxJKRGVcQFf4X1+SEpNIQV4chveNwQRq808TQCySStmbUaSbO PFLGTtXCFYitHl1EVj65w0g9bI5whCYXFWT5ZpW1FBuweYFryb/SfJD1ntj/O8iF08bw yxVP/Tnq/g7lHskS0jRuN46QZiYAZCPzpf2h8yAwSZqR6H+i740ZE8LggMHFUIRnXW0d 2YGiDEniw/kB3hB2QZ2vTNm28iRG6uBdPOfE5Z3oVsdXFZZlqd1zt7UDmsQkMSD1+Dt3 7ucw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=lZbW+jdwEJ0df0XlFQH0fRXjTgHOqcYAGdShHUjC4Oc=; b=Uw5DxA1iruAivbHYgTgfQIqiXGPltl+bdSUFnL06NzxlUgG1pDEbZCJQN+rwKrzGON bvVLbeJL9pekos7aM/kB01i97a5NoDaodNAcLgm+QNhSdhDy243046Ffa2Ha+xMaUT14 mu82G8AIvEfltNYOce9dE9OvzD0HygB+emP2WOBTB6UUUy6IRGfpsQCo1PXWOYFpEfB3 vQRlMWtmh/iDon/bpOnN7qCC+fWidrpGIqcwZ3aEio4O8sl2Qi/ACmRO4F6TFsQZZCPN ABy+gvyw/Np7NGuPtsNkC3B4Ulklj3NNEzvLyb65SrRaSeWmF2SZ6iePbina5K0xFrnp NHaA== 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 j25si14939112edq.489.2021.06.07.23.34.25; Mon, 07 Jun 2021 23:34:47 -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 S230212AbhFHGfZ (ORCPT + 99 others); Tue, 8 Jun 2021 02:35:25 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:5282 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbhFHGfZ (ORCPT ); Tue, 8 Jun 2021 02:35:25 -0400 Received: from dggeme755-chm.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4FzgKw3RSMz1BK3W; Tue, 8 Jun 2021 14:28:36 +0800 (CST) Received: from [10.67.110.136] (10.67.110.136) by dggeme755-chm.china.huawei.com (10.3.19.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 8 Jun 2021 14:33:26 +0800 Subject: Re: [PATCH] powerpc: Fix kernel-jump address for ppc64 wrapper boot To: Oliver O'Halloran CC: Linux Kernel Mailing List , Nathan Chancellor , Paul Mackerras , linuxppc-dev References: <20210604092228.199588-1-heying24@huawei.com> From: He Ying Message-ID: <9dc8b323-7846-0975-16f0-6e3e447383a4@huawei.com> Date: Tue, 8 Jun 2021 14:33:26 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.110.136] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggeme755-chm.china.huawei.com (10.3.19.101) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, 在 2021/6/8 13:26, Oliver O'Halloran 写道: > On Fri, Jun 4, 2021 at 7:39 PM He Ying wrote: >> 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. > How have you tested this? I tested ppc64-elf big-endian. I changed the Kconfig so that ppc64 big-endian selects PPC64_WRAPPER_BOOT. I used qemu to run the cuImage and found the problem. It made me confused. By applying this patch, I found it works. I thought it works for ppc64le too. So I upstream this patch. > > IIRC the 64bit wrapper is only used for ppc64le builds. For that case > the current code is work because the LE ABI (ABIv2) doesn't use > function descriptors. I think even for a BE kernel we need the current > behaviour because the vmlinux's entry point is screwed up (i.e. > doesn't point a descriptor) and tools in the wild (probably kexec) > expect it to be screwed up. Yes, you're right. PPC64_WRAPPER_BOOT is only used for ppc64le builds currently. LE ABI (ABI v2) doesn't use function descriptors. Is that right? I don't test that. If so, this patch should be dropped. But why does ppc64 have different ABIs? So strange. If the wrapper is built to ppc64be, my patch is tested right. The entry point in the ELF header is always right so you can assign the header->e_entry to the function pointer and then jump to the entry by calling the function. But in the ppc  wrapper, the address is intialized to 0 or malloced to be an address later. In this situation, I think my patch should be right for ppc64be. > > ABIv2 (LE) reference: > https://openpowerfoundation.org/?resource_lib=64-bit-elf-v2-abi-specification-power-architecture > .