All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
To: <xen-devel@lists.xenproject.org>
Cc: Ayan Kumar Halder <ayan.kumar.halder@amd.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Michal Orzel <michal.orzel@amd.com>,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>
Subject: [PATCH v4 1/6] xen/arm: Skip initializing the BSS section when it is empty
Date: Mon, 28 Oct 2024 12:45:42 +0000	[thread overview]
Message-ID: <20241028124547.1371867-2-ayan.kumar.halder@amd.com> (raw)
In-Reply-To: <20241028124547.1371867-1-ayan.kumar.halder@amd.com>

If the BSS section is empty, then the function should return.
If one does not check whether the BSS section is empty or not, then there is a
risk of writing 0s outside of BSS section (which may contain critical data).

Fixes: dac84b66cc9a ("xen: arm64: initial build + config changes, start of day code")
Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
---
Changes from :-

v1..v2 - New patch introduced in v3.

v3 - 1. Update the check in arm32 as well.
2. Drop the R-bs.

 xen/arch/arm/arm32/head.S | 3 +++
 xen/arch/arm/arm64/head.S | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
index a96d5d3503..4ff5c220bc 100644
--- a/xen/arch/arm/arm32/head.S
+++ b/xen/arch/arm/arm32/head.S
@@ -185,12 +185,15 @@ zero_bss:
         PRINT("- Zero BSS -\r\n")
         mov_w r0, __bss_start        /* r0 := vaddr(__bss_start) */
         mov_w r1, __bss_end          /* r1 := vaddr(__bss_end)   */
+        cmp   r1, r0
+        beq   skip_bss
 
         mov   r2, #0
 1:      str   r2, [r0], #4
         cmp   r0, r1
         blo   1b
 
+skip_bss:
         mov   pc, lr
 ENDPROC(zero_bss)
 
diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index 14c3720d80..72c7b24498 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -346,6 +346,8 @@ FUNC_LOCAL(zero_bss)
         PRINT("- Zero BSS -\r\n")
         ldr   x0, =__bss_start       /* x0 := vaddr(__bss_start) */
         ldr   x1, =__bss_end         /* x1 := vaddr(__bss_end)   */
+        cmp   x1, x0
+        beq   skip_bss
 
 1:      str   xzr, [x0], #8
         cmp   x0, x1
-- 
2.25.1



  reply	other threads:[~2024-10-28 12:46 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-28 12:45 [PATCH v4 0/6] Enable early bootup of AArch64 MPU systems Ayan Kumar Halder
2024-10-28 12:45 ` Ayan Kumar Halder [this message]
2024-10-28 14:45   ` [PATCH v4 1/6] xen/arm: Skip initializing the BSS section when it is empty Luca Fancellu
2024-11-01 13:55   ` Julien Grall
2024-10-28 12:45 ` [PATCH v4 2/6] xen/arm: mpu: Introduce choice between MMU and MPU Ayan Kumar Halder
2024-10-29  9:53   ` Andrew Cooper
2024-10-29 16:49     ` oleksii.kurochko
2024-10-28 12:45 ` [PATCH v4 3/6] xen/arm: mpu: Define Xen start address for MPU systems Ayan Kumar Halder
2024-10-28 14:53   ` Luca Fancellu
2024-11-01 13:57   ` Julien Grall
2024-10-28 12:45 ` [PATCH v4 4/6] xen/arm: mpu: Create boot-time MPU protection regions Ayan Kumar Halder
2024-10-28 15:14   ` Luca Fancellu
2024-10-28 15:37     ` Luca Fancellu
2024-10-29 16:20     ` Ayan Kumar Halder
2024-10-29 16:25   ` Luca Fancellu
2024-10-30  9:16   ` Luca Fancellu
2024-10-30  9:52     ` Julien Grall
2024-10-30 10:08       ` Luca Fancellu
2024-10-30 10:32         ` Julien Grall
2024-10-30 10:51           ` Luca Fancellu
2024-10-31 16:16             ` Ayan Kumar Halder
2024-11-01 14:11   ` Julien Grall
2024-11-01 17:08     ` Ayan Kumar Halder
2024-11-01 17:11       ` Ayan Kumar Halder
2024-10-28 12:45 ` [PATCH v4 5/6] xen/arm: mpu: Enable MPU Ayan Kumar Halder
2024-10-28 15:39   ` Luca Fancellu
2024-11-01 14:19   ` Julien Grall
2024-10-28 12:45 ` [PATCH v4 6/6] xen/arm: mpu: Implement a dummy enable_secondary_cpu_mm Ayan Kumar Halder
2024-10-28 12:55   ` Jan Beulich
2024-10-28 14:39     ` Ayan Kumar Halder
2024-10-28 15:01       ` Jan Beulich
2024-10-28 17:38         ` Ayan Kumar Halder
2024-10-29  8:08           ` Jan Beulich
2024-10-29  9:30             ` Luca Fancellu
2024-10-29  9:41               ` Jan Beulich
2024-10-29  9:58                 ` Luca Fancellu
2024-11-01 14:22 ` [PATCH v4 0/6] Enable early bootup of AArch64 MPU systems Julien Grall

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=20241028124547.1371867-2-ayan.kumar.halder@amd.com \
    --to=ayan.kumar.halder@amd.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=bertrand.marquis@arm.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=sstabellini@kernel.org \
    --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.