From: Krish Sadhukhan <krish.sadhukhan@oracle.com> To: Jim Mattson <jmattson@google.com> Cc: "kvm list" <kvm@vger.kernel.org>, "Paolo Bonzini" <pbonzini@redhat.com>, "Radim Krčmář" <rkrcmar@redhat.com> Subject: Re: [PATCH 6/8][KVM nVMX]: Load IA32_PERF_GLOBAL_CTRL MSR on vmentry of nested guests Date: Wed, 21 Aug 2019 16:05:04 -0700 Message-ID: <6d0a81be-1546-2a02-92b3-6b94468de9c6@oracle.com> (raw) In-Reply-To: <CALMp9eR8u6qPF5Gv-UEXSmB9NX=H=AGb4jh4d=mEm7jyTqBfWg@mail.gmail.com> On 8/15/19 3:44 PM, Jim Mattson wrote: > On Wed, Apr 24, 2019 at 4:43 PM Krish Sadhukhan > <krish.sadhukhan@oracle.com> wrote: >> According to section "Loading Guest State" in Intel SDM vol 3C, the >> IA32_PERF_GLOBAL_CTRL MSR is loaded on vmentry of nested guests: >> >> "If the “load IA32_PERF_GLOBAL_CTRL” VM-entry control is 1, the >> IA32_PERF_GLOBAL_CTRL MSR is loaded from the IA32_PERF_GLOBAL_CTRL >> field." >> >> Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com> >> Suggested-by: Jim Mattson <jmattson@google.com> >> Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> >> --- >> arch/x86/kvm/vmx/nested.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c >> index a7bf19eaa70b..8177374886a9 100644 >> --- a/arch/x86/kvm/vmx/nested.c >> +++ b/arch/x86/kvm/vmx/nested.c >> @@ -2300,6 +2300,10 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, >> vcpu->arch.cr0_guest_owned_bits &= ~vmcs12->cr0_guest_host_mask; >> vmcs_writel(CR0_GUEST_HOST_MASK, ~vcpu->arch.cr0_guest_owned_bits); >> >> + if (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL) >> + vmcs_write64(GUEST_IA32_PERF_GLOBAL_CTRL, >> + vmcs12->guest_ia32_perf_global_ctrl); >> + >> if (vmx->nested.nested_run_pending && >> (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_PAT)) { >> vmcs_write64(GUEST_IA32_PAT, vmcs12->guest_ia32_pat); >> -- >> 2.17.2 >> > This isn't quite right. The GUEST_IA32_PERF_GLOBAL_CTRL value is just > going to get overwritten later by atomic_switch_perf_msrs(). atomic_switch_perf_msrs() gest called from vmx_vcpu_run() which I thought was executing before handle_vmlaunch() stuff that lead to prepare_vmcs02(). Did I miss something in the call-chain ? > Instead of writing the vmcs12 value directly into the vmcs02, you > should call kvm_set_msr(), exactly as it would have been called if > MSR_CORE_PERF_GLOBAL_CTRL had been in the vmcs12 > VM-entry MSR-load list. Then, atomic_switch_perf_msrs() will > automatically do the right thing.
next prev parent reply index Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-24 23:17 [KVM nVMX]: Check "load IA32_PERF_GLOBAL_CTRL" " Krish Sadhukhan 2019-04-24 23:17 ` [PATCH 1/8][KVMnVMX]: Enable "load IA32_PERF_GLOBAL_CTRL" VM-exit control for " Krish Sadhukhan 2019-05-13 18:49 ` Sean Christopherson 2019-05-13 22:08 ` Krish Sadhukhan 2019-04-24 23:17 ` [PATCH 2/8][KVM nVMX]: Enable "load IA32_PERF_GLOBAL_CTRL" VM-entry " Krish Sadhukhan 2019-05-13 18:49 ` Sean Christopherson 2019-04-24 23:17 ` [PATCH 3/8][KVM VMX]: Add a function to check reserved bits in MSR_CORE_PERF_GLOBAL_CTRL Krish Sadhukhan 2019-05-13 18:57 ` Sean Christopherson 2019-08-15 22:29 ` Jim Mattson 2019-04-24 23:17 ` [PATCH 4/8][KVM nVMX]: Check "load IA32_PERF_GLOBAL_CTRL" VM-exit control on vmentry of nested guests Krish Sadhukhan 2019-05-13 19:00 ` Sean Christopherson 2019-05-16 22:07 ` Krish Sadhukhan 2019-05-17 20:34 ` Sean Christopherson 2019-08-15 22:54 ` Jim Mattson 2019-04-24 23:17 ` [PATCH 5/8][KVM nVMX]: Check "load IA32_PERF_GLOBAL_CTRL" VM-entry " Krish Sadhukhan 2019-08-15 22:36 ` Jim Mattson 2019-04-24 23:17 ` [PATCH 6/8][KVM nVMX]: Load IA32_PERF_GLOBAL_CTRL MSR " Krish Sadhukhan 2019-08-15 22:44 ` Jim Mattson 2019-08-21 23:05 ` Krish Sadhukhan [this message] 2019-08-21 23:10 ` Jim Mattson 2019-08-23 5:29 ` Krish Sadhukhan 2019-08-23 15:57 ` Jim Mattson 2019-04-24 23:17 ` [PATCH 7/8][KVM nVMX]: Enable "load IA32_PERF_GLOBAL_CTRL VM-{entry,exit} controls Krish Sadhukhan 2019-05-13 19:12 ` Sean Christopherson 2019-08-15 23:02 ` Jim Mattson 2019-04-24 23:17 ` [PATCH 8/8][KVM nVMX]: Test "load IA32_PERF_GLOBAL_CTRL" controls on vmentry of nested guests Krish Sadhukhan 2019-05-13 18:46 ` [KVM nVMX]: Check "load IA32_PERF_GLOBAL_CTRL" " Sean Christopherson
Reply instructions: You may reply publically 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=6d0a81be-1546-2a02-92b3-6b94468de9c6@oracle.com \ --to=krish.sadhukhan@oracle.com \ --cc=jmattson@google.com \ --cc=kvm@vger.kernel.org \ --cc=pbonzini@redhat.com \ --cc=rkrcmar@redhat.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
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