Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3803053pxj; Mon, 7 Jun 2021 22:00:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDMzp40jdcwDwljt94SJkjrCc653vyiRmSQ15NVx8xYuV8K6Od+/xI1avf+/kI3BYpaBin X-Received: by 2002:aa7:cb45:: with SMTP id w5mr3834445edt.170.1623128404816; Mon, 07 Jun 2021 22:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623128404; cv=none; d=google.com; s=arc-20160816; b=MuE7YE1RCJIyVgAVFpv0rDbrdd8/CAs/NDZKuJhaimf5vNZf5yMCGsVXv/QWFNmAbh HPYRsnfnoe6GLPYgMZRiuaShpP6Zr8NVVuyIRyYmTNg5ZfGQcHijob+HguLETck9rA+m v9BQ9WotDdu+IgiXw+o0DaVQLO4Yhj+8s/KqXAQ0uC4vokwm8c8z3DDUxHZ8BEVbCOLL y2FP/Pv09uY8/Mjy74SVCXnz8GZON/powzd1BeYU9ys9zobZWsR4mxtuQUoJY7tSrlsi xVP9Y6eDDJzLCd0APEg9CpBjcbbKMkApEqbWHpgauvC0txF1gqqzFD2ocday3x+0LiGE IuXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=iU096LnmLG4hCM1naf3LgXs+zjYdHUqSE8nuDht0QaY=; b=yNxvPI07dQ377N1uvvJtS7anysQLiW37ku3JYNEodi6STALAQe/cA28Yxnp5ASrmtQ aj+OrHS6Su8nMbiIrUK893s1tIhlt3sLbUPy42V0KOmjuaumpkC+iJHkr3p/ZQkkq4mY 0zhqT0q2e61O4EuvDxUcL+nFtefakmrCnRi5Q8/L+3myxDCxxuKdDjaZRIclDZE0b2Ey pMzjqt2Mb+74cEdXsPzYMrDe7onBoJwkBdNY94ZuVnyiPlFeUE+cdcd5+enDZKhke5Pm /RelH8YnfcY89DBh2FMzHrYoZECHtMeUTIuydIwPCgDwMWhimrphxRZMY9WfuuaDOEpG DiZw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o3si1988547edc.246.2021.06.07.21.59.41; Mon, 07 Jun 2021 22:00:04 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbhFHE5g (ORCPT + 99 others); Tue, 8 Jun 2021 00:57:36 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:59892 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbhFHE5g (ORCPT ); Tue, 8 Jun 2021 00:57:36 -0400 Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4FzdGk0tclzBDHZ; Tue, 8 Jun 2021 06:55:42 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OXJV5l2ukwIg; Tue, 8 Jun 2021 06:55:42 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4FzdGj61yXzBDHG; Tue, 8 Jun 2021 06:55:41 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C59B88B7A8; Tue, 8 Jun 2021 06:55:41 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 46y0R86zWyBd; Tue, 8 Jun 2021 06:55:41 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4924B8B767; Tue, 8 Jun 2021 06:55:41 +0200 (CEST) Subject: Re: [PATCH] powerpc: Fix kernel-jump address for ppc64 wrapper boot To: He Ying , mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, nathan@kernel.org Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20210604092228.199588-1-heying24@huawei.com> From: Christophe Leroy Message-ID: Date: Tue, 8 Jun 2021 06:55:35 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210604092228.199588-1-heying24@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 04/06/2021 à 11:22, He Ying a écrit : > 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 This kind of need doesn't desserve a #ifdef, see https://www.kernel.org/doc/html/latest/process/coding-style.html#conditional-compilation You can do: kentry = (kernel_entry_t)(IS_ENABLED(CONFIG_PPC64_BOOT_WRAPPER) ? &vmlinux.addr : vmlinux.addr); Or, if you prefer something less compact: if (IS_ENABLED(CONFIG_PPC64_BOOT_WRAPPER)) kentry = (kernel_entry_t) &vmlinux.addr; else kentry = (kernel_entry_t) vmlinux.addr; > + /* > + * 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); >