[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v4 1/6] xen/arm: Skip initializing the BSS section when it is empty


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • Date: Mon, 28 Oct 2024 12:45:42 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZFcBkE/m8lBfaY/RDGSA74usJ37yqes+AbUBa2xX70A=; b=cAW06+L9ec1sN1DBh5vst50QR2DrE3Uj+TLRxNOL3TqBztiG880z8FekhYNs/cNakTGQD2eBkBfKJL10OkmM7TVz5qB9kAxJtPpDBB1qhcelbWn1TbFYBEVpgMBAMd/khyU0EiKoBAErKnvG73cIwUiCDWFSwAqdMZyaZqPOD0XBbVzhY5Ex3Xruw5mhx8Ugmy1//Tq27ua7g4vgsJNdTkkBWygcKZay0uJx1VPGszpR1i/HK9mwcXqkldYVasseQKtNXXgJsDrSd1+8rQ7mXVLykTAUo6mGVxwuJC2nmagxV4wrpdczgKk8RXZ+5t4F9B0abhKyVTHXUSmz1xxqdA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lwhqCnyLQKeD/i8x6y0clE+m+6lu3TAvl6ewlQyscDM6iDCyMhssZSmfWIfAkKD1cy8DZ2uRobAABiDD3bqyvRX2jNA5UzJpkpzsp/XPDgpBohoEYe4MEoxBZjCxLGEqz3MEKMNuaiIF3SHGDUbC5YOBzwEeSKpgOuW0JCy3WZqkJJ7718zP8FtJoavq9Ec6/gfDkJCg0fTQ8Jqh9QPvJxQzWV8RdVAmlWTVvT71pVVaoQzK6SaLKjRB2MyV9Cm9IFDsTowuBtTNuQZeS88T9oIL1LECIw+2e7LSszt6eyQCdHAwmAlXYhSQUTrgOgQvbscwrzdE7A97uu8VooZV8w==
  • Cc: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 28 Oct 2024 12:46:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxx>
---
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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.