From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FB0C1547F3; Mon, 14 Oct 2024 14:26:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728915971; cv=none; b=jTSqPLdV4iDsggUb3d2myc3tn8fL3ugm+oPBtiiDbhiE5AXwEMNsAlnHK9Mt3vZP4xa5Yx8Co9h+uIShyVjMn9Lyrs4EbXzB6l9VQjkkTeEjhEa31CzpoMvEJCISLut3YxoY0FhmM6Z59ji9JEEyFxEEFiZXdWslScVyizynKRE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728915971; c=relaxed/simple; bh=YPO5gM7VZopvrEV5Q6IrPa5LpqVgI7Z2wHxslr3hUXs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EfyoaGqqQTIxWdlQkqoG+6MZm9q4iJ6ZUabdXx71DA89t9nq9Avo2i98UHc2Sl9aYTw3flrw9jncgOumgAEMXyz2whc05rd26aMQu0+4nS1+iYFl9y8Q0SbBv5vCuRjWGwsQLfwU08jEz8KiM2pIsBV/JEiSfL7bbRgViaImsk8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rwH18iwa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rwH18iwa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A38F5C4CEC3; Mon, 14 Oct 2024 14:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728915971; bh=YPO5gM7VZopvrEV5Q6IrPa5LpqVgI7Z2wHxslr3hUXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rwH18iwaJMi/EOBJP6fbOodzHo3AOjNmW0Fx48AKIb6SbvjNq7fsfUrAuwXvDP0eT 40RZmEsauBjISDRcGYb7kLS06zFvZ0XOWXG6xWd4Eky6seCiVSj0lXQFHj6beTNEji 1sHd3FGz+ZxRIJEaz1i4l/wTZmPAoPjbuk1xzOY4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Petr Tesarik , Ying Sun , Andrew Jones , Palmer Dabbelt , Sasha Levin Subject: [PATCH 6.11 050/214] riscv/kexec_file: Fix relocation type R_RISCV_ADD16 and R_RISCV_SUB16 unknown Date: Mon, 14 Oct 2024 16:18:33 +0200 Message-ID: <20241014141046.943776620@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241014141044.974962104@linuxfoundation.org> References: <20241014141044.974962104@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.11-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ying Sun [ Upstream commit c6ebf2c528470a09be77d0d9df2c6617ea037ac5 ] Runs on the kernel with CONFIG_RISCV_ALTERNATIVE enabled: kexec -sl vmlinux Error: kexec_image: Unknown rela relocation: 34 kexec_image: Error loading purgatory ret=-8 and kexec_image: Unknown rela relocation: 38 kexec_image: Error loading purgatory ret=-8 The purgatory code uses the 16-bit addition and subtraction relocation type, but not handled, resulting in kexec_file_load failure. So add handle to arch_kexec_apply_relocations_add(). Tested on RISC-V64 Qemu-virt, issue fixed. Co-developed-by: Petr Tesarik Signed-off-by: Petr Tesarik Signed-off-by: Ying Sun Reviewed-by: Andrew Jones Link: https://lore.kernel.org/r/20240711083236.2859632-1-sunying@isrc.iscas.ac.cn Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin --- arch/riscv/kernel/elf_kexec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c index 11c0d2e0becfe..3c37661801f95 100644 --- a/arch/riscv/kernel/elf_kexec.c +++ b/arch/riscv/kernel/elf_kexec.c @@ -451,6 +451,12 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi, *(u32 *)loc = CLEAN_IMM(CJTYPE, *(u32 *)loc) | ENCODE_CJTYPE_IMM(val - addr); break; + case R_RISCV_ADD16: + *(u16 *)loc += val; + break; + case R_RISCV_SUB16: + *(u16 *)loc -= val; + break; case R_RISCV_ADD32: *(u32 *)loc += val; break; -- 2.43.0