From nobody Thu Oct 26 19:07:47 2023 X-Original-To: dev-commits-src-branches@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 4SGb0N2G5vz4y9nC; Thu, 26 Oct 2023 19:07: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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SGb0N1M2rz3Lqc; Thu, 26 Oct 2023 19:07:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698347268; 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=Z7NzxqD6Gy2gyo2NkAt/eVcL7XHiLbFcp1B2Kpbz79I=; b=htcEPeM0xszcFF62VEjPFKtl6TyI/vskHBFHuN1SDFiiyQf0c5PWhQHFrVS0ateC8sLfej fWiWex6/d4lFU2lM0aORHncdFEhQDZUamRAE+7L7ARapWrYJoE0wyKNFZmMyHbc/UthVKM EA1O399MLC/2Tb6aCMPuMonV65ghXuy6Ydj024ORBszifFPAEnq1HmtTaiJblhvlSlsKcF s4HjgjGxY24Y6+DKUbba/TiESxkK0oj7XdGYjpciD1IuYePDlrkdIi3bOOhX3/gks6Lyt4 ScheXOr30KVkYUxkYHVh8u0jYiO7HuWaxdHbAzr6D5CIT9dexfd3OlbuK4oYuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698347268; 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=Z7NzxqD6Gy2gyo2NkAt/eVcL7XHiLbFcp1B2Kpbz79I=; b=VsWZnR1Ln4LxYL1kGkvUTCwekEYKguODSo+iXg4u2wO/oSbdoFotgWWwsDa+U5lSXgieKJ xvX0AAtbjuo1GuU7w3BjfnT+MEHtioC5ZSQSZcbQsCyMSvNRVJgB1s8i8aUr7iJBJo+HVZ y5jw2CQc3AkSpSXXcd1oH2OpUHEno8sGujUUWJK5wI8QUoLBIuXTYSUJCueF57EmFE0awu oQ2waeOoT4qsHvKCX4gSewnISqjdcD3yCkOJzBtFX6H8Nql362yB6zqs/bZFwFXYo5TcH+ PUtKLkdtypVkVKF+n/4lG4wTGvH8kPja+Pj7XR/cb3TNH7/aGBiKV49PAck46g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698347268; a=rsa-sha256; cv=none; b=rLt94ZHUW7sZadJqgfpRJ/W9yQenvPoqLtF1yGaPAyGvV//nmyw2OxheykABf6bfJx7v1S sPMN5Bi3R1foKhs1u7udigr0SHpacDqF4w7hHN9u1BwVz5QH3bSKnrFC/om1kVVdXQLzz3 EccozykYgMTqdpNVEQ5RH7Aew9Esptd91/jhsyWrkTGjJs525hlPZ7mREkwOcGzHY4phyw GIyd33LhpNqEaJmKWUah322gsGdEtr9do/g+2r6HqIQK/usy/BsPaQuuH6Ud+gbWFAriPv ygrKjgppJWvmlG/h2+kbp8gJyyQsQNZEIyVFHFmGLJ/LA+PlCuE+eS8jU2z7ZQ== 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 4SGb0N0BxxzjwC; Thu, 26 Oct 2023 19:07:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39QJ7lPq041060; Thu, 26 Oct 2023 19:07:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39QJ7lHw041057; Thu, 26 Oct 2023 19:07:47 GMT (envelope-from git) Date: Thu, 26 Oct 2023 19:07:47 GMT Message-Id: <202310261907.39QJ7lHw041057@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: ef71fbf692af - stable/13 - Add cpu_sync_core() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: ef71fbf692af963b1a4fa072e88d0d1256f1f897 Auto-Submitted: auto-generated The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ef71fbf692af963b1a4fa072e88d0d1256f1f897 commit ef71fbf692af963b1a4fa072e88d0d1256f1f897 Author: Konstantin Belousov AuthorDate: 2021-10-07 21:57:55 +0000 Commit: Konstantin Belousov CommitDate: 2023-10-26 04:07:29 +0000 Add cpu_sync_core() (cherry picked from commit 74ccb8ecf6c115a79f008bc32d4981f1126b63a8) --- sys/amd64/amd64/support.S | 21 +++++++++++++++++++++ sys/arm/arm/vm_machdep.c | 5 +++++ sys/arm64/arm64/vm_machdep.c | 11 +++++++++++ sys/i386/i386/support.s | 8 ++++++++ sys/powerpc/powerpc/vm_machdep.c | 10 ++++++++++ sys/riscv/riscv/vm_machdep.c | 7 +++++++ sys/sys/proc.h | 1 + 7 files changed, 63 insertions(+) diff --git a/sys/amd64/amd64/support.S b/sys/amd64/amd64/support.S index f070973913a0..936065a78879 100644 --- a/sys/amd64/amd64/support.S +++ b/sys/amd64/amd64/support.S @@ -1970,3 +1970,24 @@ ENTRY(mds_handler_silvermont) popq %rax retq END(mds_handler_silvermont) + +/* + * Do the same as Linux and execute IRET explicitly, despite IPI + * return does it as well. + */ +ENTRY(cpu_sync_core) +/* + * Can utilize SERIALIZE when instruction is moved from + * 'future extensions' to SDM. + */ + movq (%rsp), %rdx + movl %ss, %eax + pushq %rax + pushq %rsp + addq $16, (%rsp) + pushfq + movl %cs, %eax + pushq %rax + pushq %rdx + iretq +END(cpu_sync_core) diff --git a/sys/arm/arm/vm_machdep.c b/sys/arm/arm/vm_machdep.c index 2dcd0158fd93..03816df5760f 100644 --- a/sys/arm/arm/vm_machdep.c +++ b/sys/arm/arm/vm_machdep.c @@ -305,3 +305,8 @@ cpu_procctl(struct thread *td __unused, int idtype __unused, id_t id __unused, return (EINVAL); } + +void +cpu_sync_core(void) +{ +} diff --git a/sys/arm64/arm64/vm_machdep.c b/sys/arm64/arm64/vm_machdep.c index f1ff0742418a..ea8e88b7201d 100644 --- a/sys/arm64/arm64/vm_machdep.c +++ b/sys/arm64/arm64/vm_machdep.c @@ -302,3 +302,14 @@ cpu_procctl(struct thread *td __unused, int idtype __unused, id_t id __unused, return (EINVAL); } + +void +cpu_sync_core(void) +{ + /* + * Do nothing. According to ARM ARMv8 D1.11 Exception return + * If FEAT_ExS is not implemented, or if FEAT_ExS is + * implemented and the SCTLR_ELx.EOS field is set, exception + * return from ELx is a context synchronization event. + */ +} diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index e017e67d0fa7..2995469405df 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -634,3 +634,11 @@ ENTRY(mds_handler_silvermont) movl %eax, %cr0 3: ret END(mds_handler_silvermont) + +ENTRY(cpu_sync_core) + popl %eax + pushfl + pushl %cs + pushl %eax + iretl +END(cpu_sync_core) diff --git a/sys/powerpc/powerpc/vm_machdep.c b/sys/powerpc/powerpc/vm_machdep.c index 47a4dd0d4c4a..c99748149f39 100644 --- a/sys/powerpc/powerpc/vm_machdep.c +++ b/sys/powerpc/powerpc/vm_machdep.c @@ -234,3 +234,13 @@ cpu_procctl(struct thread *td __unused, int idtype __unused, id_t id __unused, return (EINVAL); } + +void +cpu_sync_core(void) +{ + /* + * Linux performs "rfi" there. Our rendezvous IPI handler on + * the target cpu does "rfi" before and lwsync/sync after the + * action, which is stronger than required. + */ +} diff --git a/sys/riscv/riscv/vm_machdep.c b/sys/riscv/riscv/vm_machdep.c index 3b2553996bb8..58acf5df9e14 100644 --- a/sys/riscv/riscv/vm_machdep.c +++ b/sys/riscv/riscv/vm_machdep.c @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -267,3 +268,9 @@ cpu_procctl(struct thread *td __unused, int idtype __unused, id_t id __unused, return (EINVAL); } + +void +cpu_sync_core(void) +{ + fence_i(); +} diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 0e8156e308b6..369bc607e9c7 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1162,6 +1162,7 @@ void cpu_idle(int); int cpu_idle_wakeup(int); extern void (*cpu_idle_hook)(sbintime_t); /* Hook to machdep CPU idler. */ void cpu_switch(struct thread *, struct thread *, struct mtx *); +void cpu_sync_core(void); void cpu_throw(struct thread *, struct thread *) __dead2; bool curproc_sigkilled(void); void userret(struct thread *, struct trapframe *);