Re: [PATCH] x86/entry/64: Disallow RDPID in paranoid entry if KVM is enabled

From: kernel test robot
Date: Fri Aug 21 2020 - 04:57:29 EST


Hi Sean,

I love your patch! Yet something to improve:

[auto build test ERROR on tip/auto-latest]
[also build test ERROR on v5.9-rc1 next-20200821]
[cannot apply to tip/x86/asm luto/next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Sean-Christopherson/x86-entry-64-Disallow-RDPID-in-paranoid-entry-if-KVM-is-enabled/20200821-105339
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git a9bd3a91d6e49ebd2d7d8ace91d4cc339c382a31
config: x86_64-randconfig-a005-20200820 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project b587ca93be114d07ec3bf654add97d7872325281)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

arch/x86/entry/entry_64.S: Assembler messages:
>> arch/x86/entry/entry_64.S:851: Error: too many positional arguments
clang-12: error: assembler command failed with exit code 1 (use -v to see invocation)

# https://github.com/0day-ci/linux/commit/bebb51882f9c18938e44b6a7b66fdf0452eea142
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Sean-Christopherson/x86-entry-64-Disallow-RDPID-in-paranoid-entry-if-KVM-is-enabled/20200821-105339
git checkout bebb51882f9c18938e44b6a7b66fdf0452eea142
vim +851 arch/x86/entry/entry_64.S

794
795 /*
796 * Save all registers in pt_regs. Return GSBASE related information
797 * in EBX depending on the availability of the FSGSBASE instructions:
798 *
799 * FSGSBASE R/EBX
800 * N 0 -> SWAPGS on exit
801 * 1 -> no SWAPGS on exit
802 *
803 * Y GSBASE value at entry, must be restored in paranoid_exit
804 */
805 SYM_CODE_START_LOCAL(paranoid_entry)
806 UNWIND_HINT_FUNC
807 cld
808 PUSH_AND_CLEAR_REGS save_ret=1
809 ENCODE_FRAME_POINTER 8
810
811 /*
812 * Always stash CR3 in %r14. This value will be restored,
813 * verbatim, at exit. Needed if paranoid_entry interrupted
814 * another entry that already switched to the user CR3 value
815 * but has not yet returned to userspace.
816 *
817 * This is also why CS (stashed in the "iret frame" by the
818 * hardware at entry) can not be used: this may be a return
819 * to kernel code, but with a user CR3 value.
820 *
821 * Switching CR3 does not depend on kernel GSBASE so it can
822 * be done before switching to the kernel GSBASE. This is
823 * required for FSGSBASE because the kernel GSBASE has to
824 * be retrieved from a kernel internal table.
825 */
826 SAVE_AND_SWITCH_TO_KERNEL_CR3 scratch_reg=%rax save_reg=%r14
827
828 /*
829 * Handling GSBASE depends on the availability of FSGSBASE.
830 *
831 * Without FSGSBASE the kernel enforces that negative GSBASE
832 * values indicate kernel GSBASE. With FSGSBASE no assumptions
833 * can be made about the GSBASE value when entering from user
834 * space.
835 */
836 ALTERNATIVE "jmp .Lparanoid_entry_checkgs", "", X86_FEATURE_FSGSBASE
837
838 /*
839 * Read the current GSBASE and store it in %rbx unconditionally,
840 * retrieve and set the current CPUs kernel GSBASE. The stored value
841 * has to be restored in paranoid_exit unconditionally.
842 *
843 * The MSR write ensures that no subsequent load is based on a
844 * mispredicted GSBASE. No extra FENCE required.
845 *
846 * Disallow RDPID if KVM is enabled as it may consume a guest's TSC_AUX
847 * if an NMI arrives in KVM's run loop. KVM loads guest's TSC_AUX on
848 * VM-Enter and may not restore the host's value until the CPU returns
849 * to userspace, i.e. KVM depends on the kernel not using TSC_AUX.
850 */
> 851 SAVE_AND_SET_GSBASE scratch_reg=%rax save_reg=%rbx no_rdpid=IS_ENABLED(CONFIG_KVM)
852 ret
853

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip