Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Mar 2023 13:55:10 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: a54370f4abb6 - main - arm64: Ensure that thread0's PCB flags are initialized
Message-ID:  <202303311355.32VDtAFq083100@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=a54370f4abb6bc4e3ef25da97adb3262bacb5a4b

commit a54370f4abb6bc4e3ef25da97adb3262bacb5a4b
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-03-31 13:50:34 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-03-31 13:50:34 +0000

    arm64: Ensure that thread0's PCB flags are initialized
    
    On arm64, the PCB is stored at the top of the thread stack.  For thread0
    this comes from the static "initstack" region, which is placed in the
    .init_pagetable section, which is not part of the BSS and thus doesn't
    get zeroed by locore.  (See the comment in ldscript.arm64.)  It is thus
    possible for the pcb_flags field to be uninitialized, which can result
    in PCB_SINGLE_STEP being set.
    
    Fix this by simply initializing the field.  A separate commit will move
    initstack out of the .init_pagetable section, since it has no reason to
    be there, but it is preferable to explicitly initialize PCB fields
    anyway.  In particular, regular kernel stacks are not zeroed upon
    allocation, so we should be consistent here.
    
    Reviewed by:    andrew
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Sponsored by:   Juniper Networks
    Differential Revision:  https://reviews.freebsd.org/D39343
---
 sys/arm64/arm64/machdep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index b87c635048de..d9ea06952c54 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -380,6 +380,7 @@ init_proc0(vm_offset_t kstack)
 #endif
 	thread0.td_pcb = (struct pcb *)(thread0.td_kstack +
 	    thread0.td_kstack_pages * PAGE_SIZE) - 1;
+	thread0.td_pcb->pcb_flags = 0;
 	thread0.td_pcb->pcb_fpflags = 0;
 	thread0.td_pcb->pcb_fpusaved = &thread0.td_pcb->pcb_fpustate;
 	thread0.td_pcb->pcb_vfpcpu = UINT_MAX;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202303311355.32VDtAFq083100>