Author: kib
Date: Thu May 24 11:59:33 2018
New Revision: 334150
URL: https://svnweb.freebsd.org/changeset/base/334150

Log:
  MFC r334003:
  Preserve other bits in IA32_SPEC_CTL MSR when changing the IBRS and
  STIBP states.
  
  Approved by:  re (gjb)

Modified:
  stable/11/sys/amd64/amd64/support.S
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/amd64/support.S
==============================================================================
--- stable/11/sys/amd64/amd64/support.S Thu May 24 11:02:21 2018        
(r334149)
+++ stable/11/sys/amd64/amd64/support.S Thu May 24 11:59:33 2018        
(r334150)
@@ -849,8 +849,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)
@@ -863,8 +864,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
@@ -878,8 +880,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
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to