From owner-svn-src-all@freebsd.org Mon Aug 24 11:49:50 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A00053BB716; Mon, 24 Aug 2020 11:49:50 +0000 (UTC) (envelope-from grehan@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BZr5V3lPBz4dCG; Mon, 24 Aug 2020 11:49:50 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5F4F41809A; Mon, 24 Aug 2020 11:49:50 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 07OBnonW096834; Mon, 24 Aug 2020 11:49:50 GMT (envelope-from grehan@FreeBSD.org) Received: (from grehan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 07OBnodk096832; Mon, 24 Aug 2020 11:49:50 GMT (envelope-from grehan@FreeBSD.org) Message-Id: <202008241149.07OBnodk096832@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: grehan set sender to grehan@FreeBSD.org using -f From: Peter Grehan Date: Mon, 24 Aug 2020 11:49:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r364656 - in head/sys: amd64/amd64 i386/i386 X-SVN-Group: head X-SVN-Commit-Author: grehan X-SVN-Commit-Paths: in head/sys: amd64/amd64 i386/i386 X-SVN-Commit-Revision: 364656 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2020 11:49:50 -0000 Author: grehan Date: Mon Aug 24 11:49:49 2020 New Revision: 364656 URL: https://svnweb.freebsd.org/changeset/base/364656 Log: cpu_auxmsr: assert caller is preventing CPU migration. Submitted by: Adam Fenn (adam at fenn dot io) Requested by: kib Reviewed by: kib, grehan Approved by: kib MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D26166 Modified: head/sys/amd64/amd64/initcpu.c head/sys/i386/i386/initcpu.c Modified: head/sys/amd64/amd64/initcpu.c ============================================================================== --- head/sys/amd64/amd64/initcpu.c Mon Aug 24 11:44:20 2020 (r364655) +++ head/sys/amd64/amd64/initcpu.c Mon Aug 24 11:49:49 2020 (r364656) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -218,11 +219,14 @@ init_via(void) } /* - * The value for the TSC_AUX MSR and rdtscp/rdpid. + * The value for the TSC_AUX MSR and rdtscp/rdpid on the invoking CPU. + * + * Caller should prevent CPU migration. */ u_int cpu_auxmsr(void) { + KASSERT((read_rflags() & PSL_I) == 0, ("context switch possible")); return (PCPU_GET(cpuid)); } Modified: head/sys/i386/i386/initcpu.c ============================================================================== --- head/sys/i386/i386/initcpu.c Mon Aug 24 11:44:20 2020 (r364655) +++ head/sys/i386/i386/initcpu.c Mon Aug 24 11:49:49 2020 (r364656) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -628,11 +629,14 @@ init_transmeta(void) #endif /* - * The value for the TSC_AUX MSR and rdtscp/rdpid. + * The value for the TSC_AUX MSR and rdtscp/rdpid on the invoking CPU. + * + * Caller should prevent CPU migration. */ u_int cpu_auxmsr(void) { + KASSERT((read_eflags() & PSL_I) == 0, ("context switch possible")); return (PCPU_GET(cpuid)); }