lkml.org 
[lkml]   [2022]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] KVM: nVMX: WARN on any attempt to allocate shadow VMCS for vmcs02
From
On 1/26/22 16:56, Vitaly Kuznetsov wrote:
>> - WARN_ON(loaded_vmcs == &vmx->vmcs01 && loaded_vmcs->shadow_vmcs);
>> + if (WARN_ON(loaded_vmcs != &vmx->vmcs01 || loaded_vmcs->shadow_vmcs))
>> + return loaded_vmcs->shadow_vmcs;
> Stupid question: why do we want to care about 'loaded_vmcs' at all,
> i.e. why can't we hardcode 'vmx->vmcs01' in alloc_shadow_vmcs()? The
> only caller is enter_vmx_operation() and AFAIU 'loaded_vmcs' will always
> be pointing to 'vmx->vmcs01' (as enter_vmx_operation() allocates
> &vmx->nested.vmcs02 so 'loaded_vmcs' can't point there!).
>

Well, that's why the WARN never happens. The idea is that if shadow
VMCS _virtualization_ (not emulation, i.e. running L2 VMREAD/VMWRITE
without even a vmexit to L0) was supported, then you would need a
non-NULL shadow_vmcs in vmx->vmcs02.

Regarding the patch, the old WARN was messy but it was also trying to
avoid a NULL pointer dereference in the caller.

What about:

if (WARN_ON(loaded_vmcs->shadow_vmcs))
return loaded_vmcs->shadow_vmcs;

/* Go ahead anyway. */
WARN_ON(loaded_vmcs != &vmx->vmcs01);

?

Paolo

\
 
 \ /
  Last update: 2022-01-26 17:05    [W:0.416 / U:0.544 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site