From patchwork Sun Sep 11 20:35:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 9325591 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 195196048B for ; Sun, 11 Sep 2016 20:38:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 092E8284EF for ; Sun, 11 Sep 2016 20:38:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F213428AB5; Sun, 11 Sep 2016 20:38:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 884D4284EF for ; Sun, 11 Sep 2016 20:38:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjBTm-0001x9-H9; Sun, 11 Sep 2016 20:35:54 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjBTk-0001uS-VJ for xen-devel@lists.xenproject.org; Sun, 11 Sep 2016 20:35:53 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 79/2A-29563-820C5D75; Sun, 11 Sep 2016 20:35:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsXSO6nOVVf9wNV wg683LS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ox3s9rZCx4oVTzo2MPewLhNqouRi0NIoI1J 4mLDCtYuRk4g5xujxKJ3hhD2RkaJM180IIomMEo8ab/E3sXIwcEmYCLxZpUjSFxEoI1R4tuJr ewgDcwCZRIPFz8BGyQsECCx418fC4jNIqAqMXfNPTYQm1fATeLs5GdsIHMkBOQlnt2uBwlzCr hLbJzzngUkLARUcqLHGCQsIWAocfrhNsYJjHwLGBlWMaoXpxaVpRbpmuklFWWmZ5TkJmbm6Bo amOnlphYXJ6an5iQmFesl5+duYgSGCAMQ7GCcd8L/EKMkB5OSKK//gqvhQnxJ+SmVGYnFGfFF pTmpxYcYZTg4lCR4TfYD5QSLUtNTK9Iyc4DBCpOW4OBREuG1BUnzFhck5hZnpkOkTjEqSonzf tkHlBAASWSU5sG1wSLkEqOslDAvI9AhQjwFqUW5mSWo8q8YxTkYlYR5HUDG82TmlcBNfwW0mA lo8dOtl0EWlyQipKQaGFffW6Jp/H12gNyKOn2jxuXc+lcDX01dGnArZiWnxGlXo6gqb1+VC7v COq7VBVh9O31nx6FabwfhaTfmKrzQ0F6ffzBX4HOOywaJ8/mNmwtSelUOvGie5n2xltuNM86y 17XrSJLq7/ms7Pf3ME+WvHavV8Wm0NzYbkdLV8By/YfyigvZvt1NUGIpzkg01GIuKk4EAInjW CuLAgAA X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1473626149!32656190!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2122 invoked from network); 11 Sep 2016 20:35:51 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-5.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Sep 2016 20:35:51 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8BKZhix004824 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 11 Sep 2016 20:35:43 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u8BKZgat029104 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 11 Sep 2016 20:35:43 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u8BKZfQW030385; Sun, 11 Sep 2016 20:35:42 GMT Received: from localhost.localdomain.com (/209.6.196.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 11 Sep 2016 13:35:41 -0700 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, konrad@kernel.org, julien.grall@arm.com, sstabellini@kernel.org, ross.lagerwall@citrix.com Date: Sun, 11 Sep 2016 16:35:15 -0400 Message-Id: <1473626125-13683-9-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1473626125-13683-1-git-send-email-konrad.wilk@oracle.com> References: <1473626125-13683-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: andrew.cooper3@citrix.com, Jan Beulich , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v3 08/18] livepatch: ARM 32|64: Ignore mapping symbols: $[d, a, x] X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Those symbols are used to help final linkers to replace insn. The ARM ELF specification mandates that they are present to denote the start of certain CPU features. There are two variants of it - short and long format. Either way - we can ignore these symbols. Reviewed-by: Andrew Cooper [x86 bits] Signed-off-by: Konrad Rzeszutek Wilk --- Cc: Konrad Rzeszutek Wilk Cc: Ross Lagerwall Cc: Stefano Stabellini Cc: Julien Grall Cc: Andrew Cooper v1: First submission v2: Update the order of symbols, fix title Add {} in after the first if - per Jan's recommendation. v3: Add Andrew's Review tag Make the function return an bool_t. Skip check for '$t' Fix spelling of comments. s/arch_is_payload_symbol/arch_livepatch_symbol_ok/ --- xen/arch/arm/livepatch.c | 33 +++++++++++++++++++++++++++++++++ xen/arch/x86/livepatch.c | 7 +++++++ xen/common/livepatch.c | 2 +- xen/include/xen/livepatch.h | 2 ++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/livepatch.c b/xen/arch/arm/livepatch.c index 7a3e2f7..d2ae128 100644 --- a/xen/arch/arm/livepatch.c +++ b/xen/arch/arm/livepatch.c @@ -84,6 +84,39 @@ void arch_livepatch_unmask(void) local_abort_enable(); } +bool_t arch_livepatch_symbol_ok(const struct livepatch_elf *elf, + const struct livepatch_elf_sym *sym) +{ + /* + * - Mapping symbols - denote the "start of a sequence of bytes of the + * appropriate type" to mark certain features - such as start of region + * containing data ($d); ARM ($a), or A64 ($x) instructions. + * We ignore Thumb instructions ($t) as we shouldn't have them. + * + * The format is either short: '$x' or long: '$x.'. We do not + * need this and more importantly - each payload will contain this + * resulting in symbol collisions. + */ + if ( *sym->name == '$' && sym->name[1] != '\0' ) + { + char p = sym->name[1]; + size_t len = strlen(sym->name); + + if ( (len >= 3 && ( sym->name[2] == '.' )) || (len == 2) ) + { + if ( p == 'd' || +#ifdef CONFIG_ARM_32 + p == 'a' +#else + p == 'x' +#endif + ) + return false; + } + } + return true; +} + int arch_livepatch_perform_rel(struct livepatch_elf *elf, const struct livepatch_elf_sec *base, const struct livepatch_elf_sec *rela) diff --git a/xen/arch/x86/livepatch.c b/xen/arch/x86/livepatch.c index cf3eb22..bbcb5fe 100644 --- a/xen/arch/x86/livepatch.c +++ b/xen/arch/x86/livepatch.c @@ -118,6 +118,13 @@ int arch_livepatch_verify_elf(const struct livepatch_elf *elf) return 0; } +bool_t arch_livepatch_symbol_ok(const struct livepatch_elf *elf, + const struct livepatch_elf_sym *sym) +{ + /* No special checks on x86. */ + return true; +} + int arch_livepatch_perform_rel(struct livepatch_elf *elf, const struct livepatch_elf_sec *base, const struct livepatch_elf_sec *rela) diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c index 4f156c2..3c726a4 100644 --- a/xen/common/livepatch.c +++ b/xen/common/livepatch.c @@ -734,7 +734,7 @@ static bool_t is_payload_symbol(const struct livepatch_elf *elf, !strncmp(sym->name, ".L", 2) ) return 0; - return 1; + return arch_livepatch_symbol_ok(elf, sym); } static int build_symbol_table(struct payload *payload, diff --git a/xen/include/xen/livepatch.h b/xen/include/xen/livepatch.h index 904785a..c67b02c 100644 --- a/xen/include/xen/livepatch.h +++ b/xen/include/xen/livepatch.h @@ -46,6 +46,8 @@ bool_t is_patch(const void *addr); /* Arch hooks. */ int arch_livepatch_verify_elf(const struct livepatch_elf *elf); +bool_t arch_livepatch_symbol_ok(const struct livepatch_elf *elf, + const struct livepatch_elf_sym *sym); int arch_livepatch_perform_rel(struct livepatch_elf *elf, const struct livepatch_elf_sec *base, const struct livepatch_elf_sec *rela);