diff mbox series

[v2,2/2] xen/riscv: add explicit check that .got{.plt} is empty

Message ID 7c066d6dcc0618749df04785b34b93819148087d.1678970065.git.oleksii.kurochko@gmail.com (mailing list archive)
State New, archived
Headers show
Series deal with GOT stuff for RISC-V | expand

Commit Message

Oleksii Kurochko March 16, 2023, 1:22 p.m. UTC
The GOT sections usage should be avoided in the hypervisor
so to catch such use cases earlier when GOT things are
produced the patch introduces .got and .got.plt sections
and adds asserts that they're empty.

The sections won't be created until they remain
empty otherwise the asserts would cause early failure.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
Changes in V2:
 * the patch was introduced in patch series v2.
---
 xen/arch/riscv/xen.lds.S | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Jan Beulich March 16, 2023, 1:56 p.m. UTC | #1
On 16.03.2023 14:22, Oleksii Kurochko wrote:
> The GOT sections usage should be avoided in the hypervisor
> so to catch such use cases earlier when GOT things are
> produced the patch introduces .got and .got.plt sections
> and adds asserts that they're empty.
> 
> The sections won't be created until they remain
> empty otherwise the asserts would cause early failure.
> 
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

And again a Suggested-by to Andrew perhaps.

Jan
Alistair Francis April 18, 2023, 2:17 a.m. UTC | #2
On Thu, Mar 16, 2023 at 11:22 PM Oleksii Kurochko
<oleksii.kurochko@gmail.com> wrote:
>
> The GOT sections usage should be avoided in the hypervisor
> so to catch such use cases earlier when GOT things are
> produced the patch introduces .got and .got.plt sections
> and adds asserts that they're empty.
>
> The sections won't be created until they remain
> empty otherwise the asserts would cause early failure.
>
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>

Acked-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
> Changes in V2:
>  * the patch was introduced in patch series v2.
> ---
>  xen/arch/riscv/xen.lds.S | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S
> index ca57cce75c..f299ea8422 100644
> --- a/xen/arch/riscv/xen.lds.S
> +++ b/xen/arch/riscv/xen.lds.S
> @@ -1,3 +1,4 @@
> +#include <xen/lib.h>
>  #include <xen/xen.lds.h>
>
>  #undef ENTRY
> @@ -123,6 +124,15 @@ SECTIONS
>          *(SORT(.init_array.*))
>          __ctors_end = .;
>      } :text
> +
> +    .got : {
> +        *(.got)
> +    } : text
> +
> +    .got.plt : {
> +        *(.got.plt)
> +    } : text
> +
>      . = ALIGN(POINTER_ALIGN);
>      __init_end = .;
>
> @@ -156,3 +166,6 @@ SECTIONS
>
>      ELF_DETAILS_SECTIONS
>  }
> +
> +ASSERT(!SIZEOF(.got),      ".got non-empty")
> +ASSERT(!SIZEOF(.got.plt),  ".got.plt non-empty")
> --
> 2.39.2
>
>
diff mbox series

Patch

diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S
index ca57cce75c..f299ea8422 100644
--- a/xen/arch/riscv/xen.lds.S
+++ b/xen/arch/riscv/xen.lds.S
@@ -1,3 +1,4 @@ 
+#include <xen/lib.h>
 #include <xen/xen.lds.h>
 
 #undef ENTRY
@@ -123,6 +124,15 @@  SECTIONS
         *(SORT(.init_array.*))
         __ctors_end = .;
     } :text
+
+    .got : {
+        *(.got)
+    } : text
+
+    .got.plt : {
+        *(.got.plt)
+    } : text
+
     . = ALIGN(POINTER_ALIGN);
     __init_end = .;
 
@@ -156,3 +166,6 @@  SECTIONS
 
     ELF_DETAILS_SECTIONS
 }
+
+ASSERT(!SIZEOF(.got),      ".got non-empty")
+ASSERT(!SIZEOF(.got.plt),  ".got.plt non-empty")