KVM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] KVM: VMX: eVMCS: make evmcs_sanitize_exec_ctrls() work again
@ 2020-10-14 10:06 Vitaly Kuznetsov
  2020-10-14 14:01 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Vitaly Kuznetsov @ 2020-10-14 10:06 UTC (permalink / raw)
  To: kvm, Paolo Bonzini
  Cc: Sean Christopherson, Wanpeng Li, Jim Mattson, Yang Weijiang,
	linux-kernel

It was noticed that evmcs_sanitize_exec_ctrls() is not being executed
nowadays despite the code checking 'enable_evmcs' static key looking
correct. Turns out, static key magic doesn't work in '__init' section
(and it is unclear when things changed) but setup_vmcs_config() is called
only once per CPU so we don't really need it to. Switch to checking
'enlightened_vmcs' instead, it is supposed to be in sync with
'enable_evmcs'.

Opportunistically make evmcs_sanitize_exec_ctrls '__init' and drop unneeded
extra newline from it.

Reported-by: Yang Weijiang <weijiang.yang@intel.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 arch/x86/kvm/vmx/evmcs.c | 3 +--
 arch/x86/kvm/vmx/evmcs.h | 2 +-
 arch/x86/kvm/vmx/vmx.c   | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/vmx/evmcs.c b/arch/x86/kvm/vmx/evmcs.c
index e5325bd0f304..f3199bb02f22 100644
--- a/arch/x86/kvm/vmx/evmcs.c
+++ b/arch/x86/kvm/vmx/evmcs.c
@@ -297,14 +297,13 @@ const struct evmcs_field vmcs_field_to_evmcs_1[] = {
 };
 const unsigned int nr_evmcs_1_fields = ARRAY_SIZE(vmcs_field_to_evmcs_1);
 
-void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf)
+__init void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf)
 {
 	vmcs_conf->pin_based_exec_ctrl &= ~EVMCS1_UNSUPPORTED_PINCTRL;
 	vmcs_conf->cpu_based_2nd_exec_ctrl &= ~EVMCS1_UNSUPPORTED_2NDEXEC;
 
 	vmcs_conf->vmexit_ctrl &= ~EVMCS1_UNSUPPORTED_VMEXIT_CTRL;
 	vmcs_conf->vmentry_ctrl &= ~EVMCS1_UNSUPPORTED_VMENTRY_CTRL;
-
 }
 #endif
 
diff --git a/arch/x86/kvm/vmx/evmcs.h b/arch/x86/kvm/vmx/evmcs.h
index e5f7a7ebf27d..3333326b3702 100644
--- a/arch/x86/kvm/vmx/evmcs.h
+++ b/arch/x86/kvm/vmx/evmcs.h
@@ -185,7 +185,7 @@ static inline void evmcs_load(u64 phys_addr)
 	vp_ap->enlighten_vmentry = 1;
 }
 
-void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf);
+__init void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf);
 #else /* !IS_ENABLED(CONFIG_HYPERV) */
 static inline void evmcs_write64(unsigned long field, u64 value) {}
 static inline void evmcs_write32(unsigned long field, u32 value) {}
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 96979c09ebd1..d529349d9b33 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -2607,7 +2607,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
 	vmcs_conf->vmexit_ctrl         = _vmexit_control;
 	vmcs_conf->vmentry_ctrl        = _vmentry_control;
 
-	if (static_branch_unlikely(&enable_evmcs))
+	if (enlightened_vmcs)
 		evmcs_sanitize_exec_ctrls(vmcs_conf);
 
 	return 0;
-- 
2.25.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: VMX: eVMCS: make evmcs_sanitize_exec_ctrls() work again
  2020-10-14 10:06 [PATCH] KVM: VMX: eVMCS: make evmcs_sanitize_exec_ctrls() work again Vitaly Kuznetsov
@ 2020-10-14 14:01 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2020-10-14 14:01 UTC (permalink / raw)
  To: Vitaly Kuznetsov, kvm, Paolo Bonzini
  Cc: kbuild-all, Sean Christopherson, Wanpeng Li, Jim Mattson,
	Yang Weijiang, linux-kernel


[-- Attachment #1: Type: text/plain, Size: 2695 bytes --]

Hi Vitaly,

I love your patch! Yet something to improve:

[auto build test ERROR on kvm/linux-next]
[also build test ERROR on vhost/linux-next linus/master linux/master v5.9 next-20201013]
[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/Vitaly-Kuznetsov/KVM-VMX-eVMCS-make-evmcs_sanitize_exec_ctrls-work-again/20201014-180828
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next
config: i386-randconfig-r015-20201014 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/d17b759596aa18f05176cee4695968b88977f6a4
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Vitaly-Kuznetsov/KVM-VMX-eVMCS-make-evmcs_sanitize_exec_ctrls-work-again/20201014-180828
        git checkout d17b759596aa18f05176cee4695968b88977f6a4
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

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

All errors (new ones prefixed by >>):

   arch/x86/kvm/vmx/vmx.c: In function 'setup_vmcs_config':
>> arch/x86/kvm/vmx/vmx.c:2595:6: error: 'enlightened_vmcs' undeclared (first use in this function); did you mean 'hv_enlightened_vmcs'?
    2595 |  if (enlightened_vmcs)
         |      ^~~~~~~~~~~~~~~~
         |      hv_enlightened_vmcs
   arch/x86/kvm/vmx/vmx.c:2595:6: note: each undeclared identifier is reported only once for each function it appears in

vim +2595 arch/x86/kvm/vmx/vmx.c

  2578	
  2579		/* Require Write-Back (WB) memory type for VMCS accesses. */
  2580		if (((vmx_msr_high >> 18) & 15) != 6)
  2581			return -EIO;
  2582	
  2583		vmcs_conf->size = vmx_msr_high & 0x1fff;
  2584		vmcs_conf->order = get_order(vmcs_conf->size);
  2585		vmcs_conf->basic_cap = vmx_msr_high & ~0x1fff;
  2586	
  2587		vmcs_conf->revision_id = vmx_msr_low;
  2588	
  2589		vmcs_conf->pin_based_exec_ctrl = _pin_based_exec_control;
  2590		vmcs_conf->cpu_based_exec_ctrl = _cpu_based_exec_control;
  2591		vmcs_conf->cpu_based_2nd_exec_ctrl = _cpu_based_2nd_exec_control;
  2592		vmcs_conf->vmexit_ctrl         = _vmexit_control;
  2593		vmcs_conf->vmentry_ctrl        = _vmentry_control;
  2594	
> 2595		if (enlightened_vmcs)
  2596			evmcs_sanitize_exec_ctrls(vmcs_conf);
  2597	
  2598		return 0;
  2599	}
  2600	

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 39827 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-14 10:06 [PATCH] KVM: VMX: eVMCS: make evmcs_sanitize_exec_ctrls() work again Vitaly Kuznetsov
2020-10-14 14:01 ` kernel test robot

KVM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kvm/0 kvm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kvm kvm/ https://lore.kernel.org/kvm \
		kvm@vger.kernel.org
	public-inbox-index kvm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.kvm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git