Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1524536pxb; Thu, 28 Oct 2021 05:28:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNGCpLGgTnSE6ztZ/1kf74JI2roJNtqUEyLDU33IsVTp/ckZwLj4BumAWNWarR38pyR91N X-Received: by 2002:a17:906:4c58:: with SMTP id d24mr5063926ejw.510.1635424106287; Thu, 28 Oct 2021 05:28:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635424106; cv=none; d=google.com; s=arc-20160816; b=pAgQk80musYcwbmGXsnzAzFQzkbeypDjn5Iwr3QGpA1eH5mtlcXAX/3B3yl+QCo8zl +5ul71kg6E1R47jvmp0MoFoIH6t2YwprCgRvbLYGcRaA53hIJph40cY9cEpanvD8qYXo lFmztbcz0Js5cR+59saIpXe/92avHe/0PuIlBJOwaB1dOcdjWwZcXhP7u7F0RGUeMGtE JqEuewKqMiwhXetYSSr6U1qyXg3JqWhKs3wQt6kekmXtrpYCpvT4xbs0u0AUmMNe9FBX 4fnTUvi1/BZABlfTgu/GUnhSXEpf8kNCI7PUPB/mU8uoL00DQitx78l9NHfjo+iYXgD1 vXIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=FrR+m1iw115NT02gboYA69t8ZJW4Yg11QEuaP1SJIIU=; b=c7u+I9661IGamSDs8GNd00pzhM9DCz9y0+8I2vDiaKHIl1Jx2RQEHqs8CsZHW+A4Um 5ezBKbsAcAZbpAUeQuclAinHm4EcOrOjHD/4ktqBKjuQChSHOjeOHP/7c7R4eCq2a0D7 IWBC/lbxgyEGAccD0goS6WOEmn2UjtOJbXRm7QhARfwokVLQ7LmuQLFMW4rrycse2L4p jQQY++7zkgNlxn9Npo6odsStIhY6xm1M9EsTAyuObIATmbNDLNBwafl9N97yGd+4br89 koBpAimz+0k1nFmHdxbkM/6ucPxooW+TA3o1udQp4LtQevgj0C6eE3z4fYckRpbQicd9 dIUA== 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 a27si3762130edj.77.2021.10.28.05.28.00; Thu, 28 Oct 2021 05:28:26 -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 S230426AbhJ1M1P (ORCPT + 99 others); Thu, 28 Oct 2021 08:27:15 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:41035 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230443AbhJ1M1E (ORCPT ); Thu, 28 Oct 2021 08:27:04 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4Hg4Vp0qPfz9sT8; Thu, 28 Oct 2021 14:24:18 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KVrVmzDFwFyy; Thu, 28 Oct 2021 14:24:18 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4Hg4Vl5bTHz9sTB; Thu, 28 Oct 2021 14:24:15 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A97D78B792; Thu, 28 Oct 2021 14:24:15 +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 3C9KJWB6m9xI; Thu, 28 Oct 2021 14:24:15 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.232.214]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2C0858B78B; Thu, 28 Oct 2021 14:24:15 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.16.1/8.16.1) with ESMTPS id 19SCO7iC194388 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 28 Oct 2021 14:24:07 +0200 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.16.1/8.16.1/Submit) id 19SCO71X194387; Thu, 28 Oct 2021 14:24:07 +0200 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Steven Rostedt , Ingo Molnar , "Naveen N . Rao" Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, live-patching@vger.kernel.org Subject: [PATCH v1 1/5] livepatch: Fix build failure on 32 bits processors Date: Thu, 28 Oct 2021 14:24:01 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1635423843; l=2882; s=20211009; h=from:subject:message-id; bh=FaIgF0/d4y029q2RzpfnjkNI4436DlWb16kZwMjiL08=; b=60UPwEY+jJpBNO+sWMPCw8ZmljEVv4JoARyFsqpKbVO0yO6ogYby2zHYSEcMfy2bXZRyQ4thKT+u rq23saK8BfQ2Hk5PhSwmDbGSRjhqv67CqC9QOu1776WgwJdrzkC0 X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Trying to build livepatch on powerpc/32 results in: kernel/livepatch/core.c: In function 'klp_resolve_symbols': kernel/livepatch/core.c:221:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 221 | sym = (Elf64_Sym *)sechdrs[symndx].sh_addr + ELF_R_SYM(relas[i].r_info); | ^ kernel/livepatch/core.c:221:21: error: assignment to 'Elf32_Sym *' {aka 'struct elf32_sym *'} from incompatible pointer type 'Elf64_Sym *' {aka 'struct elf64_sym *'} [-Werror=incompatible-pointer-types] 221 | sym = (Elf64_Sym *)sechdrs[symndx].sh_addr + ELF_R_SYM(relas[i].r_info); | ^ kernel/livepatch/core.c: In function 'klp_apply_section_relocs': kernel/livepatch/core.c:312:35: error: passing argument 1 of 'klp_resolve_symbols' from incompatible pointer type [-Werror=incompatible-pointer-types] 312 | ret = klp_resolve_symbols(sechdrs, strtab, symndx, sec, sec_objname); | ^~~~~~~ | | | Elf32_Shdr * {aka struct elf32_shdr *} kernel/livepatch/core.c:193:44: note: expected 'Elf64_Shdr *' {aka 'struct elf64_shdr *'} but argument is of type 'Elf32_Shdr *' {aka 'struct elf32_shdr *'} 193 | static int klp_resolve_symbols(Elf64_Shdr *sechdrs, const char *strtab, | ~~~~~~~~~~~~^~~~~~~ Fix it by using the right types instead of forcing 64 bits types. Fixes: 7c8e2bdd5f0d ("livepatch: Apply vmlinux-specific KLP relocations early") Signed-off-by: Christophe Leroy --- kernel/livepatch/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 335d988bd811..c0789383807b 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -190,7 +190,7 @@ static int klp_find_object_symbol(const char *objname, const char *name, return -EINVAL; } -static int klp_resolve_symbols(Elf64_Shdr *sechdrs, const char *strtab, +static int klp_resolve_symbols(Elf_Shdr *sechdrs, const char *strtab, unsigned int symndx, Elf_Shdr *relasec, const char *sec_objname) { @@ -218,7 +218,7 @@ static int klp_resolve_symbols(Elf64_Shdr *sechdrs, const char *strtab, relas = (Elf_Rela *) relasec->sh_addr; /* For each rela in this klp relocation section */ for (i = 0; i < relasec->sh_size / sizeof(Elf_Rela); i++) { - sym = (Elf64_Sym *)sechdrs[symndx].sh_addr + ELF_R_SYM(relas[i].r_info); + sym = (Elf_Sym *)sechdrs[symndx].sh_addr + ELF_R_SYM(relas[i].r_info); if (sym->st_shndx != SHN_LIVEPATCH) { pr_err("symbol %s is not marked as a livepatch symbol\n", strtab + sym->st_name); -- 2.31.1