linux_dsm_epyc7002/arch/x86/kernel/cpu
Borislav Petkov 31ac34ca56 x86/cpu: Fix MSR value truncation issue
So sparse rightfully complains that the u64 MSR value we're
writing into the STAR MSR, i.e. 0xc0000081, is being truncated:

./arch/x86/include/asm/msr.h:193:36: warning: cast truncates
bits from constant value (23001000000000 becomes 0)

because the actual value doesn't fit into the unsigned 32-bit
quantity which are the @low and @high wrmsrl() parameters.

This is not a problem, practically, because gcc is actually
being smart enough here and does the right thing:

  .loc 3 87 0
  xorl    %esi, %esi		# we needz a 32-bit zero
  movl    $2293776, %edx	# 0x00230010 == (__USER32_CS << 16) | __KERNEL_CS go into the high bits
  movl    $-1073741695, %ecx	# MSR_STAR, i.e., 0xc0000081
  movl    %esi, %eax		# low order 32 bits in the MSR which are 0
  #APP
  # 87 "./arch/x86/include/asm/msr.h" 1
          wrmsr

More specifically, MSR_STAR[31:0] is being set to 0. That field
is reserved on Intel and on AMD it is 32-bit SYSCALL Target EIP.

I'd strongly guess because Intel doesn't have SYSCALL in
compat/legacy mode and we're using SYSENTER and INT80 there. And
for compat syscalls in long mode we use CSTAR.

So let's fix the sparse warning by writing SYSRET and SYSCALL CS
and SS into the high 32-bit half of STAR and 0 in the low half
explicitly.

 [ Actually, if we had to be precise, we would have to read what's in
   STAR[31:0] and write it back unchanged on Intel and write 0 on AMD. I
   guess the current writing to 0 is still ok since Intel can apparently
   stomach it. ]

The resulting code is identical to what we have above:

  .loc 3 87 0
  xorl    %esi, %esi      # tmp104
  movl    $2293776, %eax  #, tmp103
  movl    $-1073741695, %ecx      #, tmp102
  movl    %esi, %edx      # tmp104, tmp104

  ...

        wrmsr

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1448273546-2567-6-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-11-24 09:15:55 +01:00
..
mcheck x86/mce: Add a default case to the switch in __mcheck_cpu_ancient_init() 2015-11-01 11:26:14 +01:00
microcode x86/cpu: Unify CPU family, model, stepping calculation 2015-11-24 09:15:54 +01:00
mtrr x86/mm/mtrr: Remove kernel internal MTRR interfaces: unexport mtrr_add() and mtrr_del() 2015-08-28 10:09:28 +02:00
.gitignore
amd.c x86/cpu/amd, kvm: Satisfy guest kernel reads of IC_CFG MSR 2015-11-24 09:15:54 +01:00
bugs_64.c
bugs.c x86/fpu: Move various internal function prototypes to fpu/internal.h 2015-05-19 15:47:48 +02:00
centaur.c
common.c x86/cpu: Fix MSR value truncation issue 2015-11-24 09:15:55 +01:00
cpu.h x86/cpu: Restore MSR_IA32_ENERGY_PERF_BIAS after resume 2015-07-21 07:51:38 +02:00
cyrix.c
hypervisor.c hypervisor/x86/xen: Unset X86_BUG_SYSRET_SS_ATTRS on Xen PV guests 2015-05-05 18:27:43 +01:00
intel_cacheinfo.c perf/core, perf/x86: Change needlessly global functions and a variable to static 2015-09-28 08:09:52 +02:00
intel_pt.h perf/x86/intel/pt: Clean up files of Intel Processor Trace 2015-08-12 11:43:22 +02:00
intel.c x86/cpu/intel: Enable X86_FEATURE_NONSTOP_TSC_S3 for Merrifield 2015-11-07 10:37:30 +01:00
Makefile perf/x86: Add Intel cstate PMUs support 2015-10-06 17:31:51 +02:00
match.c
mkcapflags.sh x86/build: Fix mkcapflags.sh bash-ism 2015-02-19 02:21:00 +01:00
mshyperv.c x86/hyperv: Fix the build in the !CONFIG_KEXEC_CORE case 2015-09-30 07:44:15 +02:00
perf_event_amd_ibs.c perf/x86/amd/ibs: Convert force_ibs_eilvt_setup() to void 2015-02-18 17:01:46 +01:00
perf_event_amd_iommu.c cpumask: factor out show_cpumap into separate helper function 2014-11-07 11:45:00 -08:00
perf_event_amd_iommu.h
perf_event_amd_uncore.c cpumask: factor out show_cpumap into separate helper function 2014-11-07 11:45:00 -08:00
perf_event_amd.c perf/x86: Add 'index' param to get_event_constraint() callback 2015-04-02 17:33:10 +02:00
perf_event_intel_bts.c perf/x86/intel/bts: Disallow use by unprivileged users on paranoid systems 2015-09-13 11:27:22 +02:00
perf_event_intel_cqm.c perf/x86/intel/cqm: Do not access cpu_data() from CPU_UP_PREPARE handler 2015-08-12 11:37:23 +02:00
perf_event_intel_cstate.c perf/x86: Add Intel cstate PMUs support 2015-10-06 17:31:51 +02:00
perf_event_intel_ds.c perf/x86/intel/ds: Work around BTS leaking kernel addresses 2015-09-13 11:27:21 +02:00
perf_event_intel_lbr.c perf/x86: Add support for PERF_SAMPLE_BRANCH_CALL 2015-10-20 10:30:53 +02:00
perf_event_intel_pt.c perf/x86/intel/pt: Fix KVM warning due to doing rdmsr() before the CPUID test 2015-09-13 11:27:23 +02:00
perf_event_intel_rapl.c perf/x86/intel/rapl: Remove the unused RAPL_EVENT_DESC() macro 2015-11-12 09:44:25 +01:00
perf_event_intel_uncore_nhmex.c perf/x86/uncore: Fix coccinelle warnings 2014-08-13 07:51:09 +02:00
perf_event_intel_uncore_snb.c perf/x86/intel/uncore: Fix multi-segment problem of perf_event_intel_uncore 2015-10-06 17:31:51 +02:00
perf_event_intel_uncore_snbep.c perf/x86/intel/uncore: Fix multi-segment problem of perf_event_intel_uncore 2015-10-06 17:31:51 +02:00
perf_event_intel_uncore.c perf/x86/intel/uncore: Fix multi-segment problem of perf_event_intel_uncore 2015-10-06 17:31:51 +02:00
perf_event_intel_uncore.h perf/x86/intel/uncore: Fix multi-segment problem of perf_event_intel_uncore 2015-10-06 17:31:51 +02:00
perf_event_intel.c perf/x86/intel: Fix Skylake FRONTEND MSR extrareg mask 2015-09-18 09:20:23 +02:00
perf_event_knc.c x86: Replace __get_cpu_var uses 2014-08-26 13:45:49 -04:00
perf_event_msr.c arch/x86/kernel/cpu/perf_event_msr.c: use sign_extend64() for sign extension 2015-11-06 17:50:42 -08:00
perf_event_p4.c x86: Replace __get_cpu_var uses 2014-08-26 13:45:49 -04:00
perf_event_p6.c
perf_event.c perf/core: Drop PERF_EVENT_TXN 2015-09-13 11:27:30 +02:00
perf_event.h Merge branch 'perf/urgent' into perf/core, to pick up fixes before applying new changes 2015-09-18 09:24:01 +02:00
perfctr-watchdog.c
powerflags.c
proc.c x86: Replace cpu_**_mask() with topology_**_cpumask() 2015-05-27 15:22:17 +02:00
rdrand.c x86, rdrand: When nordrand is specified, disable RDSEED as well 2014-05-11 20:25:20 -07:00
scattered.c x86/cpufeatures: Correct spelling of the HWP_NOTIFY flag 2015-09-23 09:57:24 +02:00
topology.c
transmeta.c
umc.c
vmware.c