All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <stefanos@xilinx.com>,
	julien.grall@arm.com, sstabellini@kernel.org
Subject: [PATCH 3/4] xen: introduce __symbol
Date: Mon, 15 Oct 2018 02:56:06 -0700	[thread overview]
Message-ID: <1539597367-25807-3-git-send-email-sstabellini@kernel.org> (raw)
In-Reply-To: <alpine.DEB.2.10.1810142125100.4859@sstabellini-ThinkPad-X260>

Introduce a macro, __symbol, which is a simple wrapper around RELOC_HIDE
to be used everywhere symbols such as _stext and _etext are used in the
code.

RELOC_HIDE is needed when accessing symbols such as _stext and _etext
because the C standard forbids comparisons between pointers pointing to
different objects. _stext, _etext, etc. are all pointers to different
objects from ANCI C point of view.

To work around potential C compiler issues (which have actually
been found, see the comment on top of RELOC_HIDE in Linux), and to help
with certifications, let's introduce some syntactic sugar to be used in
following patches.

Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
---
 xen/include/asm-arm/mm.h   | 6 ++++++
 xen/include/asm-x86/page.h | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
index 940b74b..02ce05a 100644
--- a/xen/include/asm-arm/mm.h
+++ b/xen/include/asm-arm/mm.h
@@ -284,6 +284,12 @@ static inline uint64_t gvirt_to_maddr(vaddr_t va, paddr_t *pa,
 #define __mfn_to_virt(mfn) (maddr_to_virt((paddr_t)(mfn) << PAGE_SHIFT))
 
 /*
+ * Use RELOC_HIDE with symbols such as _stext and _etext to avoid errors
+ * on comparing pointers to different objects
+ */
+#define __symbol(x)         ((char *)RELOC_HIDE((unsigned long)(x), 0))
+
+/*
  * We define non-underscored wrappers for above conversion functions.
  * These are overriden in various source files while underscored version
  * remain intact.
diff --git a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h
index c1e9293..3f1592b 100644
--- a/xen/include/asm-x86/page.h
+++ b/xen/include/asm-x86/page.h
@@ -274,6 +274,12 @@ void copy_page_sse2(void *, const void *);
 #define vmap_to_mfn(va)     _mfn(l1e_get_pfn(*virt_to_xen_l1e((unsigned long)(va))))
 #define vmap_to_page(va)    mfn_to_page(vmap_to_mfn(va))
 
+/*
+ * Use RELOC_HIDE with symbols such as _stext and _etext to avoid errors
+ * on comparing pointers to different objects
+ */
+#define __symbol(x)         ((char *)RELOC_HIDE((unsigned long)(x), 0))
+
 #endif /* !defined(__ASSEMBLY__) */
 
 /* Where to find each level of the linear mapping */
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-10-15  9:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-15  9:55 [PATCH 0/4] misc safety certification fixes Stefano Stabellini
2018-10-15  9:56 ` [PATCH 1/4] xen/arm: initialize target Stefano Stabellini
2018-10-15 13:07   ` Julien Grall
2018-10-15  9:56 ` [PATCH 2/4] xen/arm: initialize access Stefano Stabellini
2018-10-15 13:08   ` Julien Grall
2018-10-15 15:15   ` Tamas K Lengyel
2018-10-16  1:14     ` Stefano Stabellini
2018-10-16 15:24       ` Tamas K Lengyel
2018-10-17 13:53         ` Stefano Stabellini
2018-10-15  9:56 ` Stefano Stabellini [this message]
2018-10-15 12:20   ` [PATCH 3/4] xen: introduce __symbol Andrew Cooper
2018-10-15 13:20   ` Julien Grall
2018-10-16  1:34     ` Stefano Stabellini
2018-10-16 10:06       ` Andrew Cooper
2018-10-16 13:01         ` Stefano Stabellini
2018-10-25 10:37   ` Jan Beulich
2018-10-15  9:56 ` [PATCH 4/4] xen: use __symbol everywhere Stefano Stabellini
2018-10-25 10:39   ` Jan Beulich
2018-11-06 21:47     ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1539597367-25807-3-git-send-email-sstabellini@kernel.org \
    --to=sstabellini@kernel.org \
    --cc=julien.grall@arm.com \
    --cc=stefanos@xilinx.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.