From nobody Wed Aug 23 00:07:36 2023 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 4RVmkK2DZNz4qfbf; Wed, 23 Aug 2023 00:07:37 +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 4RVmkK1PWdz4ZVk; Wed, 23 Aug 2023 00:07:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692749257; 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=sAEy/rrwfz6MQp1twMd5r7ICLZI9gW0h64/81kQJdh4=; b=aBRzPhSklgS4hohB241DG0Ooy9TFqe7YXqMZzcRvzPPa5/whZMUqN0fhy5ZPkWOm0Tr2hk bttSwDNguBaeXFq4zQ+Dfd0p0AXGKsIdCcTCXNkjQyYuF/IsNKnn3ewE+Vm4WkZaXN7kyZ cFOh6NgiqbagK8iflZskJQeUO8Bi9by7U2ChLQ7MGp5qXczqg8kFahN2O57RgzWSHCQMPn iCLB0cNNhEFwJ0LzlRBueff8HiWgmNavxuPQkRrJXe/KEDch7jCOD5LsYfjoHCV9WgPfyv zUMwpbMz/5VH2KOjlHHJlxYWQXo94Uw6cOt5j0gibcB46LdqDs/QId5tH36DxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692749257; 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=sAEy/rrwfz6MQp1twMd5r7ICLZI9gW0h64/81kQJdh4=; b=N/dE7vMSCJ3IfgHrbUfuUniTG78CGMRk5RBRcV/DPOqBNxahNhxGX2ZVA0Wsl1zSaDakGi 7yrTHSW44it7ojO+Mmj3Gn93+IDCevDTPCRPl6EquABA3mSarN6nyU/72FJUeb7N5M1f30 YerqzH4QBcsdn1MOblkfCbHGoboL2BOQec8QuFENwZ3ivrWPOTF+DB4vlC+JpYXqFsTCKs m3bzlm7rRfNcihx2BnHEklWT7Xj3r/F1Cb1PfPFJl9GM8rOUOvTmytW+Rq6LHUHsDqtnAy kNLB96Ki7LgWdXSU463/Q4yWxmOfnJgNyHW78Wqto6Tyt0Ofc/6wOjl4ymP3Hg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692749257; a=rsa-sha256; cv=none; b=P5SVeNMCadfTuHsk70jDXTI8vJGM3UprAxw80vOoQf7IO51xQzbn8MoCSO3hmTDJgEosWL zi5KPTcjXBzYnFu5/kYwctVcvF3zpIRHPIyRQgp997gqMvq7IDqbaZTU664FlaVXBiGJUv yPj3V/yzVWSi2tEYJIAHVmzPNacJm4kBpCDoc3N5pktqDT8jfqdd68ENEb8ql8LdN15iqZ CkR7/lCyHxhkdWaeZj1F+WOH7GiIFzXsQm0PLvPyjpnc5uu1MkhYK5I8wjSc4CKhGvYqPk DyJ4KSzLdMgFO/9hDHoyw72BEP4F5OCDoXNcWULYQBHCTAi4UR1fW2kGzPq5nw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4RVmkK0T9gz8DD; Wed, 23 Aug 2023 00:07:37 +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 37N07bmc082869; Wed, 23 Aug 2023 00:07:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37N07acf082866; Wed, 23 Aug 2023 00:07:36 GMT (envelope-from git) Date: Wed, 23 Aug 2023 00:07:36 GMT Message-Id: <202308230007.37N07acf082866@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: 74ccb8ecf6c1 - main - Add cpu_sync_core() 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: 74ccb8ecf6c115a79f008bc32d4981f1126b63a8 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=74ccb8ecf6c115a79f008bc32d4981f1126b63a8 commit 74ccb8ecf6c115a79f008bc32d4981f1126b63a8 Author: Konstantin Belousov AuthorDate: 2021-10-07 21:57:55 +0000 Commit: Konstantin Belousov CommitDate: 2023-08-23 00:02:21 +0000 Add cpu_sync_core() Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32360 --- 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 ae2793aa7584..6e541b75cdae 100644 --- a/sys/amd64/amd64/support.S +++ b/sys/amd64/amd64/support.S @@ -1969,3 +1969,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 ace6b4ce668b..b7c08cd4e97f 100644 --- a/sys/arm/arm/vm_machdep.c +++ b/sys/arm/arm/vm_machdep.c @@ -311,3 +311,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 06e063d916f1..5e45b45dc320 100644 --- a/sys/arm64/arm64/vm_machdep.c +++ b/sys/arm64/arm64/vm_machdep.c @@ -310,3 +310,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 58c01f37a3fc..982108a0b968 100644 --- a/sys/i386/i386/support.S +++ b/sys/i386/i386/support.S @@ -578,3 +578,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 b53da3dd04fa..1a31959b278b 100644 --- a/sys/powerpc/powerpc/vm_machdep.c +++ b/sys/powerpc/powerpc/vm_machdep.c @@ -239,3 +239,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 a35446690526..05ab914af409 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1229,6 +1229,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 *);