From nobody Mon Aug 08 16:44:38 2022 X-Original-To: dev-commits-src-main@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 4M1hr71RgDz4YTdq; Mon, 8 Aug 2022 16:44:39 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M1hr70Y70z3LrP; Mon, 8 Aug 2022 16:44:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659977079; 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=b1x70Y1Cr/uO5tJ9XYlrWTcaOYl8fWJhgDb3ZhQPUNM=; b=SyYZKPBLPBmJIF4/QWk1BDuIPupxGRyG4MZddosi+9zhRog1Y8Jok5woTKr2k9dyzqPK8V CzFYc70k4PBRV2oxhogvHObrEWKqnjHwl8YzEU1YgT2clpvj0GEHUiTQOFQIPcousf4Q3A CS9bx7THdkdwqt1OAWhwu3vl4NQhaiTSvYH2rdBpLQBNPZHHThcuumO8D/rgrapjMLgL8D CnCk7mXpdIMhOrcGkf0p6sOmXZhX5rgiJZTPlzA1CNpyqAaM8mRwUw4sEM2y/ikoTE21QP WkwXjeo51f8ZxqyWJojksui6U81/lSTTiOgWnTV6yxd/fBEpWuAowLZJlEJ8Vg== 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 4M1hr66jBTzyWD; Mon, 8 Aug 2022 16:44:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 278GicPm005270; Mon, 8 Aug 2022 16:44:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 278GicWD005269; Mon, 8 Aug 2022 16:44:38 GMT (envelope-from git) Date: Mon, 8 Aug 2022 16:44:38 GMT Message-Id: <202208081644.278GicWD005269@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 1b0a4974c500 - main - thread_create(): call cpu_copy_thread() after td_pflags is zeroed List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1b0a4974c5004216daf4a2ac4375074ce56bc55b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659977079; 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=b1x70Y1Cr/uO5tJ9XYlrWTcaOYl8fWJhgDb3ZhQPUNM=; b=tcA9sgvNmo/GYsHg4k/vuyjfLOeZPTZl13eaySdRuVSOy98WEo4faiql/dZlwPq4VgRXvL /8N+Q3Rp1S7GY81iB+pYV/2/5Wsf3QbN05Hyle3UkklN/qL8WERooNBv1wJMi/4biTaDIU +zO1MFzNBttKMHDOP43dF8Uuw/yzatxvPzoPT8DjKHRIAgR0/deirvfzFhjX2gdQyJQEJ8 ci/2ZIUnH83JX3oryw3RmqWv9H8fwa3ypffiT1NH689vVeVGFKAfsh5pLS8/2r+gtB1MNQ b2cgskvBR43MXduVCr075kyU8wTaypAn1rDrk8ELhhTfleDBtcj59CxDhwlkSw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659977079; a=rsa-sha256; cv=none; b=QagvKs3tNncJ6c4a+PZkk0aaP4lubn7txFiTgS2Lc1gRRgqp872OXP1jm94C4e3EeEKXp2 4AoDDLYkAPqy3Yh1khjP+QfvyP9cDB1oeGJR2Y5/IAk+2V4qIXaNUQb7ozODu0u3QsEK5s qFmT4S0ar5tPNeDCjyCzJtgqfcdFTNyhu+SP2jLeCd04SEozSI+QT/IMtt0VaaLZCYrMuf 5Ikl9iPRrJ0UD3a6VivuRKNgFVVsiHKF19tOAZqRFPF7opS16atjaI4qaLRO8Xwp3nqs5i 7bBAay92FTLxFZLMuHh4fzPfSFKFArsHO0JFrHpyY88s4CU1RW5DFuidEYmPpg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1b0a4974c5004216daf4a2ac4375074ce56bc55b commit 1b0a4974c5004216daf4a2ac4375074ce56bc55b Author: Konstantin Belousov AuthorDate: 2022-08-07 17:00:02 +0000 Commit: Konstantin Belousov CommitDate: 2022-08-08 16:44:17 +0000 thread_create(): call cpu_copy_thread() after td_pflags is zeroed By calling the function too early we might still have the td_pflags value cached from the previous struct thread use. cpu_copy_thread() depends on correct value for TDP_KTHREAD at least on x86. Reported, bisected, and tested by: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D36069 --- sys/compat/linux/linux_fork.c | 4 ++-- sys/kern/kern_thr.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c index 31d8344ce032..7654e447f878 100644 --- a/sys/compat/linux/linux_fork.c +++ b/sys/compat/linux/linux_fork.c @@ -280,8 +280,6 @@ linux_clone_thread(struct thread *td, struct l_clone_args *args) if (error) goto fail; - cpu_copy_thread(newtd, td); - bzero(&newtd->td_startzero, __rangeof(struct thread, td_startzero, td_endzero)); bcopy(&td->td_startcopy, &newtd->td_startcopy, @@ -290,6 +288,8 @@ linux_clone_thread(struct thread *td, struct l_clone_args *args) newtd->td_proc = p; thread_cow_get(newtd, td); + cpu_copy_thread(newtd, td); + /* create the emuldata */ linux_proc_init(td, newtd, true); diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index 2f44c5304471..4c0cfe06f1b4 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -231,8 +231,6 @@ thread_create(struct thread *td, struct rtprio *rtp, if (error) goto fail; - cpu_copy_thread(newtd, td); - bzero(&newtd->td_startzero, __rangeof(struct thread, td_startzero, td_endzero)); bcopy(&td->td_startcopy, &newtd->td_startcopy, @@ -241,6 +239,8 @@ thread_create(struct thread *td, struct rtprio *rtp, newtd->td_rb_list = newtd->td_rbp_list = newtd->td_rb_inact = 0; thread_cow_get(newtd, td); + cpu_copy_thread(newtd, td); + error = initialize_thread(newtd, thunk); if (error != 0) { thread_cow_free(newtd);