From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Jim Mattson <jmattson@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Joerg Roedel <joro@8bytes.org>, kvm list <kvm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] KVM: nVMX: Tweak handling of failure code for nested VM-Enter failure
Date: Tue, 28 Apr 2020 09:17:40 -0700 [thread overview]
Message-ID: <20200428161740.GE12735@linux.intel.com> (raw)
In-Reply-To: <CALMp9eRG=L_dQfS_qpYhJ_86B-yyfYYg+pwcixQOfWT4hwCa1Q@mail.gmail.com>
On Fri, Apr 24, 2020 at 10:47:04AM -0700, Jim Mattson wrote:
> On Fri, Apr 24, 2020 at 10:19 AM Sean Christopherson
> <sean.j.christopherson@intel.com> wrote:
> > if (from_vmentry) {
> > exit_reason = EXIT_REASON_MSR_LOAD_FAIL;
> > - exit_qual = nested_vmx_load_msr(vcpu,
> > - vmcs12->vm_entry_msr_load_addr,
> > - vmcs12->vm_entry_msr_load_count);
> > - if (exit_qual)
> > + failed_msr = nested_vmx_load_msr(vcpu,
> > + vmcs12->vm_entry_msr_load_addr,
> > + vmcs12->vm_entry_msr_load_count);
> > + if (failed_msr) {
> > + entry_failure_code = failed_msr;
>
> This assignment is a bit dodgy from a type perspective, and suggests
> that perhaps a better type for the local variable is an
> undiscriminated union of the enumerated type and a sufficiently large
> unsigned integer type. But I won't be a stickler if you add a comment.
> :-)
This is a bit ugly. A union doesn't work well because writing the enum
field isn't guaranteed to write the full width of the union, i.e. could
lead to uninitialized variable usage without additional initialization
of the union. The reverse is true as well, e.g. if the compiler sizes the
enum to be larger than an unisigned int.
Rather than use a common local variable, I think it's best to set vmcs12
directly. That also provides an opportunity to set exit_reason on demand
instead of speculatively setting it, which has always bugged me.
v2 incoming.
next prev parent reply other threads:[~2020-04-28 16:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 17:19 [PATCH] KVM: nVMX: Tweak handling of failure code for nested VM-Enter failure Sean Christopherson
2020-04-24 17:47 ` Jim Mattson
2020-04-28 16:17 ` Sean Christopherson [this message]
2020-05-04 16:43 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200428161740.GE12735@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.