From nobody Mon Nov 25 21:08:48 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XxyxD751Fz5fCVq; Mon, 25 Nov 2024 21:08:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XxyxD4ygCz4v6X; Mon, 25 Nov 2024 21:08:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732568928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=J9UzCvBgD48oIAJMgxhp3KfWY11wFrl6zZ8mXFpPFxU=; b=vovIfm60422BDzaEtYjUuYTh+J91Bgs+noJOtULXLQkVgArIyBM/gELO8GZTIKN8jpX9QG JHOlNrZ718ouB/Qlh131taGTwlUNKQ1dm+zGZtOMEeFFa7IJQP9msFACsRxTp1GMM67WCz 1LoytFTN1c13H7kvxQ260F74Xqetx1Xu1NyrgS7ID1YbolPdDQZM1CAuEn70CrUb2uFwo7 5epbo2Ctb9lelSAL9KBSH26hA0hGnSThTu1bTqVnyqnv+BEeStugutQxU0LF8gzjKrBDs6 6lrS+r3joa+wuWD81UFF0p5/c3YIACmO2skpa9qZGYJdSHpPWcLTABOmNProgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732568928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=J9UzCvBgD48oIAJMgxhp3KfWY11wFrl6zZ8mXFpPFxU=; b=Nx9oZ1xQmWWv3qsXcxbcGuSGkoE31S8YnCfvhbk97KAlXH4kwELafaaIccPVMKhVIqdqb9 RpkShYRDIpbgt5lRJGAKFnFloPvwZ4kkcrGg8O1pk9aEXmVmLE7Bnjd8EIiViYDCH/J9w8 8HkojMKuQxye4xeQ1Qc1eZF/aD1h1U5JhzJIhI5thG9TBJOGL3eEM9vblrHJlNBZVP8/Gt z3f+AlMwA24cRZHsYxmzrYcYx6nOssdQMSGa+vVLWxlChPApaeeO3GzIt1nxAoqfNonWPN oLiHjL3L5qEZ3zxwN2UewIdPhR5PtX31/VWBJmL8jB9xipCRiwudLvmSpyB1gA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732568928; a=rsa-sha256; cv=none; b=Syz+0y9n+MZhw+3rcYvjgYh3JwkF0Eb4XzwBCnw7BlZOo38SG7Q/0KguIxggNNAsqs1dZN Sa2ktgCnfFvdVBB+rjCCDAEre7oKe4ceBaTUgY6g/xOEugqcHQ3zRQbBKdRId6lmYvmc6O hteI3bFlsE2Yp77X550QXnaPfXj+fumENoyAc2iHz4I89RdDXT8bfEkoocsERbh8G4o6jF NNBTi08w0P3OX1+wsKpaxVk+mNcLKpwtRyuQM0wPfNNv8x4lb2+StDvrL6jFWfSf+LGIZH Wfj2Vi5yQAX6/6gBa4GXRU+DsyKEqAKh61xW/VKLpytqQJxNchX/FPfzgcTL+w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XxyxD4Z6czwbp; Mon, 25 Nov 2024 21:08:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4APL8mqU011509; Mon, 25 Nov 2024 21:08:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4APL8ma0011506; Mon, 25 Nov 2024 21:08:48 GMT (envelope-from git) Date: Mon, 25 Nov 2024 21:08:48 GMT Message-Id: <202411252108.4APL8ma0011506@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: c7fa232e9b70 - main - locore.S: stash boot arguments in saved registers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c7fa232e9b7065e7c02eb31baf3f7cb250b8d1cc Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=c7fa232e9b7065e7c02eb31baf3f7cb250b8d1cc commit c7fa232e9b7065e7c02eb31baf3f7cb250b8d1cc Author: Mitchell Horne AuthorDate: 2024-11-21 18:12:23 +0000 Commit: Mitchell Horne CommitDate: 2024-11-25 21:08:04 +0000 locore.S: stash boot arguments in saved registers Switch the boot argument registers to the unused s3 and s4. This ensures the values will not be clobbered by SBI or function calls; they are consumed late in the assembly routine. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47457 --- sys/riscv/riscv/locore.S | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/sys/riscv/riscv/locore.S b/sys/riscv/riscv/locore.S index f7363fd025a7..5c0ade6e66ca 100644 --- a/sys/riscv/riscv/locore.S +++ b/sys/riscv/riscv/locore.S @@ -83,8 +83,12 @@ _alt_start: lla t0, boot_hart sw a0, 0(t0) - /* Load zero as modulep */ - mv a0, zero + /* + * Stash the DTB pointer in the callee-saved register s4, and zero s3 + * to indicate that we have no loader metadata. + */ + mv s4, a1 + mv s3, zero j pagetables /* @@ -104,10 +108,12 @@ _start: .option pop /* - * Zero a1 to indicate that we have no DTB pointer. It is already - * included in the loader(8) metadata. + * Stash modulep in the callee-saved register s3, and zero s4 to + * indicate that we have no DTB pointer. It is already included in the + * loader(8) metadata. */ - mv a1, zero + mv s3, a0 + mv s4, zero /* * Set up page tables: Our goal is to enable virtual memory, doing the @@ -128,8 +134,8 @@ _start: * here and will conditionally enable Sv48 (or higher) later. * * We arrive here with: - * a0 - modulep or zero - * a1 - zero or dtbp + * s3 - modulep or zero + * s4 - zero or dtbp */ pagetables: /* Get the kernel's load address (kernstart) in s9 */ @@ -244,8 +250,8 @@ va: la t0, initstack sd t0, RISCV_BOOTPARAMS_KERN_STACK(sp) - sd a1, RISCV_BOOTPARAMS_DTBP_PHYS(sp) - sd a0, RISCV_BOOTPARAMS_MODULEP(sp) + sd s4, RISCV_BOOTPARAMS_DTBP_PHYS(sp) + sd s3, RISCV_BOOTPARAMS_MODULEP(sp) mv a0, sp call _C_LABEL(initriscv) /* Off we go */