Date: Mon, 24 Aug 2020 11:49:50 +0000 (UTC) From: Peter Grehan <grehan@FreeBSD.org> 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 Message-ID: <202008241149.07OBnodk096832@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <machine/cputypes.h> #include <machine/md_var.h> +#include <machine/psl.h> #include <machine/specialreg.h> #include <vm/vm.h> @@ -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 <machine/cputypes.h> #include <machine/md_var.h> +#include <machine/psl.h> #include <machine/specialreg.h> #include <vm/vm.h> @@ -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)); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008241149.07OBnodk096832>