From patchwork Thu Aug 25 13:37:29 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: 9299367 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 5EC29608A7 for ; Thu, 25 Aug 2016 13:40:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5046829332 for ; Thu, 25 Aug 2016 13:40:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4494F29335; Thu, 25 Aug 2016 13:40:24 +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 3F67E29332 for ; Thu, 25 Aug 2016 13:40:23 +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 1bcur8-0000vo-Ef; Thu, 25 Aug 2016 13:38:06 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcur6-0000s3-Dl for xen-devel@lists.xenproject.org; Thu, 25 Aug 2016 13:38:04 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id 7A/C5-15404-CB4FEB75; Thu, 25 Aug 2016 13:38:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsXSO6nOVXf3l33 hBh3vtS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyuyX+YCw4qVKyaFN/AeFOii5GLQ0hgMpPE ufObWCCcv4wS1x7/ZOpi5ARyNjJKPGqOgEhMY5Q4sn8WYxcjBwebgInEm1WOIHERgT5GicNHN zGDNDCDOPtOg9nCAkESLafOsYHYLAKqEmeWH2IEsXkF3CUWzetmBpkjISAv8ex2PUiYEyj8u2 EzG8ReN4nvlzpYQGwJAWOJ9rcX2SYw8i1gZFjFqFGcWlSWWqRraK6XVJSZnlGSm5iZo2toYKa Xm1pcnJiempOYVKyXnJ+7iREYJgxAsIPx9saAQ4ySHExKorzaK/aFC/El5adUZiQWZ8QXleak Fh9ilOHgUJLgnfIZKCdYlJqeWpGWmQMMWJi0BAePkgivGUiat7ggMbc4Mx0idYpRUUqctwokI QCSyCjNg2uDRcklRlkpYV5GoEOEeApSi3IzS1DlXzGKczAqCfNWg0zhycwrgZv+CmgxE9Dilv u7QRaXJCKkpBoYWZlarJSUJubpLU+IbbvcJNlrf/+qvd/3mOhFYX5fP2apn99xR8y8/f/n1qA 7ljN2PFjxIFe8XbHjeMiaTxK8hat3dr5ICvnzXS884ZPXgwsel5wVnh69vUOTV+tuxJGtBUIt 3r6q99ZYbhRfkjR191/JrtiK5C3z/m4o1FF/p/KncEKryK4wJZbijERDLeai4kQAy8bza40CA AA= X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1472132282!2907985!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 60749 invoked from network); 25 Aug 2016 13:38:03 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-15.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 Aug 2016 13:38:03 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u7PDbupm006219 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Aug 2016 13:37:56 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id u7PDbuvN009499 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Aug 2016 13:37:56 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u7PDburw020824; Thu, 25 Aug 2016 13:37:56 GMT Received: from localhost.event.rightround.com (/75.98.193.200) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 25 Aug 2016 06:37:55 -0700 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, konrad@kernel.org, ross.lagerwall@citrix.com, sstabellini@kernel.org, julien.grall@arm.com Date: Thu, 25 Aug 2016 09:37:29 -0400 Message-Id: <1472132255-23470-15-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1472132255-23470-1-git-send-email-konrad.wilk@oracle.com> References: <1472132255-23470-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: Andrew Cooper , Jan Beulich , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v2 14/20] livepatch: ARM 32|64: Ignore mapping symbols: $[d, a, x, t] 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. 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. --- xen/arch/arm/livepatch.c | 32 ++++++++++++++++++++++++++++++++ xen/arch/x86/livepatch.c | 7 +++++++ xen/common/livepatch.c | 2 +- xen/include/xen/livepatch.h | 2 ++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/livepatch.c b/xen/arch/arm/livepatch.c index f49e347..c290602 100644 --- a/xen/arch/arm/livepatch.c +++ b/xen/arch/arm/livepatch.c @@ -82,6 +82,38 @@ void arch_livepatch_unmask(void) local_abort_enable(); } +int arch_is_payload_symbol(const struct livepatch_elf *elf, + const struct livepatch_elf_sym *sym) +{ + /* + * - Mapping symbols - denote the "start of a sequence of bytes of the + * appropiate type" to mark certain features - such as start of region + * containing data ($d); ARM ($a), A64 ($x), or Thumb instructions ($t). + * + * 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' || p == 't' +#else + p == 'x' +#endif + ) + return 0; + } + } + return 1; +} + 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 5491c09..f45eccf 100644 --- a/xen/arch/x86/livepatch.c +++ b/xen/arch/x86/livepatch.c @@ -130,6 +130,13 @@ int arch_livepatch_verify_elf(const struct livepatch_elf *elf) return 0; } +int arch_is_payload_symbol(const struct livepatch_elf *elf, + const struct livepatch_elf_sym *sym) +{ + /* No special checks on x86. */ + return 1; +} + 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 7d21326..d5f069e 100644 --- a/xen/common/livepatch.c +++ b/xen/common/livepatch.c @@ -779,7 +779,7 @@ static bool_t is_payload_symbol(const struct livepatch_elf *elf, !strncmp(sym->name, ".L", 2) ) return 0; - return 1; + return arch_is_payload_symbol(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 6f30c0d..d94155f 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_verify_insn_length(unsigned long len); int arch_livepatch_verify_elf(const struct livepatch_elf *elf); +int arch_is_payload_symbol(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);