svn commit: r334003 - head/sys/amd64/amd64
Konstantin Belousov
kib at FreeBSD.org
Mon May 21 21:05:56 UTC 2018
Author: kib
Date: Mon May 21 21:05:55 2018
New Revision: 334003
URL: https://svnweb.freebsd.org/changeset/base/334003
Log:
Preserve other bits in IA32_SPEC_CTL MSR when changing the IBRS and
STIBP states.
Tested by: emaste (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Modified:
head/sys/amd64/amd64/support.S
Modified: head/sys/amd64/amd64/support.S
==============================================================================
--- head/sys/amd64/amd64/support.S Mon May 21 21:04:31 2018 (r334002)
+++ head/sys/amd64/amd64/support.S Mon May 21 21:05:55 2018 (r334003)
@@ -958,8 +958,9 @@ ENTRY(handle_ibrs_entry)
cmpb $0,hw_ibrs_active(%rip)
je 1f
movl $MSR_IA32_SPEC_CTRL,%ecx
- movl $(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
- movl $(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32,%edx
+ rdmsr
+ orl $(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
+ orl $(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32,%edx
wrmsr
movb $1,PCPU(IBPB_SET)
testl $CPUID_STDEXT_SMEP,cpu_stdext_feature(%rip)
@@ -972,8 +973,9 @@ ENTRY(handle_ibrs_exit)
cmpb $0,PCPU(IBPB_SET)
je 1f
movl $MSR_IA32_SPEC_CTRL,%ecx
- xorl %eax,%eax
- xorl %edx,%edx
+ rdmsr
+ andl $~(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
+ andl $~((IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32),%edx
wrmsr
movb $0,PCPU(IBPB_SET)
1: ret
@@ -987,8 +989,9 @@ ENTRY(handle_ibrs_exit_rs)
pushq %rdx
pushq %rcx
movl $MSR_IA32_SPEC_CTRL,%ecx
- xorl %eax,%eax
- xorl %edx,%edx
+ rdmsr
+ andl $~(IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP),%eax
+ andl $~((IA32_SPEC_CTRL_IBRS|IA32_SPEC_CTRL_STIBP)>>32),%edx
wrmsr
popq %rcx
popq %rdx
More information about the svn-src-all
mailing list