Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp197284imj; Thu, 14 Feb 2019 18:28:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IYHA1CwJcVGt/lA604AgnpAkfoqee5TlZj1K8Arrvwd2ssl4NpxDsq8D0kR+6A2XxqItVZe X-Received: by 2002:a62:3990:: with SMTP id u16mr7410573pfj.80.1550197727876; Thu, 14 Feb 2019 18:28:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550197727; cv=none; d=google.com; s=arc-20160816; b=ovp7vmupL3sChaMq6PqEoRvd436uglY/sVo85MgU45DaGNDymPk0mH5k2hktfSDVgk nQC/v3fmHphCkt3qG/r5J3WR8g9iDhCjtzc7x1+1I9LPlE3tLSt0keuE0eij5PVEKyVm xewitplfOSs/PK7R75VcKmpaa5xZrio2iG3llfShGuLQsptrBbvZfjjEjCV86uZKDG5N IjIWWfDhviO+anEcSAh5eJe4ztBd0wVO0wlVy3Di01wWdX+/4qqBo+WMYKz+WNY5XqOD itEHx2BqZOjdK21O1+Egywa8OiC+JOkrzKwdEQfQZoEkSAthyfb7n95bwxijF2OH8XTS 3b5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=3l6+V/BDZWODyI9BnxFoERRQbWFR5+4O02MuZU5pB7E=; b=BTXZQ+9eQTq/ASyet2FC0JNd4is5Sb5lY6Fwu0/PrPdkqIM1HF3AUOOBpnIHiZMujl sm8t9S2WEw66nU5aNeZg1N2wpGnd5QYdBELaGK5Rfh7iUvQfbBWTAK67Vs88r0i4C6Zt YuU7fNa1B1PI9hXFM36/en1S7bIRuv8fpcTAExRXFd9IpQzzECkh+Gotet+OWlUAT+YM 82/M9+yAdymxM8RQMQEX2xrQ/elOPICJJbV84bfEufcF00wg1tMLjKbBIDyyjnnA1YA6 mL4Jffpai91wuyM14aYGny2SR6qfbV0ytpxE2BqfZ75OEjl60XXIj7sgrrKg0XlpXmqb 5/2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si4176248pgg.279.2019.02.14.18.28.32; Thu, 14 Feb 2019 18:28:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731363AbfBOCBk convert rfc822-to-8bit (ORCPT + 99 others); Thu, 14 Feb 2019 21:01:40 -0500 Received: from szxga08-in.huawei.com ([45.249.212.255]:58334 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726435AbfBOCBj (ORCPT ); Thu, 14 Feb 2019 21:01:39 -0500 Received: from DGGEMA403-HUB.china.huawei.com (unknown [172.30.72.54]) by Forcepoint Email with ESMTP id 6625C6B72CD48228C24F; Fri, 15 Feb 2019 10:01:37 +0800 (CST) Received: from DGGEMA503-MBX.china.huawei.com ([169.254.1.64]) by DGGEMA403-HUB.china.huawei.com ([10.3.20.44]) with mapi id 14.03.0415.000; Fri, 15 Feb 2019 10:01:31 +0800 From: "chenzefeng (A)" To: "hjl.tools@gmail.com" , "jpoimboe@redhat.com" , "sjenning@redhat.com" , "jikos@kernel.org" , "vojtech@suse.com" , "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "gregkh@linuxfoundation.org" CC: "x86@kernel.org" , "live-patching@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "chengjian (D)" Subject: [PATCH] x86: livepatch: Treat R_X86_64_PLT32 as R_X86_64_PC32 Thread-Topic: [PATCH] x86: livepatch: Treat R_X86_64_PLT32 as R_X86_64_PC32 Thread-Index: AdTE0VS6YxuMC8nAT2u21pUoQUU8yw== Date: Fri, 15 Feb 2019 02:01:31 +0000 Message-ID: <79A62BFA453EFB42B7A4E40AD8F3A2264F2A872D@DGGEMA503-MBX.china.huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.57.50.95] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On x86-64, for 32-bit PC-relacive branches, we can generate PLT32 relocation, instead of PC32 relocation. and R_X86_64_PLT32 can be treated the same as R_X86_64_PC32 since linux kernel doesn't use PLT. In linux 4.4 commit b21ebf2fb4cd ("x86: Treat R_X86_64_PLT32 as R_X86_64_PC32") been fixed for the module loading, but not fixed for livepatch relocation, which will fail to load livepatch with the error message as follow: relocation failed for symbol at Signed-off-by: chenzefeng --- arch/x86/kernel/livepatch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kernel/livepatch.c b/arch/x86/kernel/livepatch.c index d1d35cc..579f8f8 100644 --- a/arch/x86/kernel/livepatch.c +++ b/arch/x86/kernel/livepatch.c @@ -58,6 +58,7 @@ int klp_write_module_reloc(struct module *mod, unsigned long type, val = (s32)value; break; case R_X86_64_PC32: + case R_X86_64_PLT32: val = (u32)(value - loc); break; default: -- 1.8.5.6