All of lore.kernel.org
 help / color / mirror / Atom feed
From: Janosch Frank <frankja@linux.ibm.com>
To: linux-s390@vger.kernel.org, kvm@vger.kernel.org
Subject: [kvm-unit-tests PATCH v6 05/11] s390x: Add BSS clearing for non ELF boot
Date: Fri, 18 Jan 2019 11:41:58 +0000	[thread overview]
Message-ID: <20190118114204.147868-6-frankja@linux.ibm.com> (raw)

When doing an IPL normal the memory will not be zeroed and hence the
BSS section can have any value. We need to clear it by ourselves.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
 s390x/cstart64.S | 22 ++++++++++++++++++++--
 s390x/flat.lds   |  2 ++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/s390x/cstart64.S b/s390x/cstart64.S
index 6622633..dedfe80 100644
--- a/s390x/cstart64.S
+++ b/s390x/cstart64.S
@@ -39,7 +39,22 @@ start:
 	/* setup initial PSW mask + control registers*/
 	larl	%r1, initial_psw
 	lpswe	0(%r1)
-init_psw_cont:
+clear_bss_start:
+	larl 	%r2, __bss_start
+	larl 	%r3, __bss_end
+	slgr 	%r3, %r2		# Get sizeof bss
+	aghi 	%r3,-1
+	srlg 	%r4,%r3,8		# Calc number of 256 byte chunks
+	ltgr 	%r4,%r4
+	lgr 	%r1,%r2
+	jz	clear_bss_remainder		# If none, clear remaining bytes
+clear_bss_loop:
+	xc	0(256,%r1), 0(%r1)	# Clear 256 byte chunks via xor
+	la	%r1, 256(%r1)
+	brctg 	%r4, clear_bss_loop
+clear_bss_remainder:
+	larl	%r2, memsetxc
+	ex 	%r3, 0(%r2)
 	/* setup pgm interrupt handler */
 	larl	%r1, pgm_int_psw
 	mvc	GEN_LC_PGM_NEW_PSW(16), 0(%r1)
@@ -71,6 +86,9 @@ init_psw_cont:
 	/* call exit() */
 	j exit
 
+memsetxc:
+	xc 0(1,%r1),0(%r1)
+
 	.macro SAVE_REGS
 	/* save grs 0-15 */
 	stmg	%r0, %r15, GEN_LC_SW_INT_GRS
@@ -159,7 +177,7 @@ svc_int:
 
 	.align	8
 initial_psw:
-	.quad	0x0000000180000000, init_psw_cont
+	.quad	0x0000000180000000, clear_bss_start
 pgm_int_psw:
 	.quad	0x0000000180000000, pgm_int
 ext_int_psw:
diff --git a/s390x/flat.lds b/s390x/flat.lds
index 977af7c..403d967 100644
--- a/s390x/flat.lds
+++ b/s390x/flat.lds
@@ -40,7 +40,9 @@ SECTIONS
 	. = ALIGN(16);
 	.rodata : { *(.rodata) *(.rodata.*) }
 	. = ALIGN(16);
+	__bss_start = .;
 	.bss : { *(.bss) }
+	__bss_end = .;
 	. = ALIGN(64K);
 	edata = .;
 	. += 64K;
-- 
2.14.3

                 reply	other threads:[~2019-01-18 11:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20190118114204.147868-6-frankja@linux.ibm.com \
    --to=frankja@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.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.