Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1685335

Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor

From Radim Krčmář <rkrcmar@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor
Date 2017-07-11 22:50 +0200
Message-ID <u2agx-73x-11@gated-at.bofh.it> (permalink)
References (4 earlier) <u2853-5KF-9@gated-at.bofh.it> <u29aN-6ru-7@gated-at.bofh.it> <u29u9-6y9-9@gated-at.bofh.it> <u29Xb-6WM-7@gated-at.bofh.it> <u2a6R-6ZW-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


2017-07-11 16:34-0400, Bandan Das:
> Radim Krčmář <rkrcmar@redhat.com> writes:
> 
> > 2017-07-11 15:50-0400, Bandan Das:
> >> Radim Krčmář <rkrcmar@redhat.com> writes:
> >> > 2017-07-11 14:24-0400, Bandan Das:
> >> >> Bandan Das <bsd@redhat.com> writes:
> >> >> > If there's a triple fault, I think it's a good idea to inject it
> >> >> > back. Basically, there's no need to take care of damage control
> >> >> > that L1 is intentionally doing.
> >> >> >
> >> >> >>> +			goto fail;
> >> >> >>> +		kvm_mmu_unload(vcpu);
> >> >> >>> +		vmcs12->ept_pointer = address;
> >> >> >>> +		kvm_mmu_reload(vcpu);
> >> >> >>
> >> >> >> I was thinking about something like this:
> >> >> >>
> >> >> >> kvm_mmu_unload(vcpu);
> >> >> >> old = vmcs12->ept_pointer;
> >> >> >> vmcs12->ept_pointer = address;
> >> >> >> if (kvm_mmu_reload(vcpu)) {
> >> >> >> 	/* pointer invalid, restore previous state */
> >> >> >> 	kvm_clear_request(KVM_REQ_TRIPLE_FAULT, vcpu);
> >> >> >> 	vmcs12->ept_pointer = old;
> >> >> >> 	kvm_mmu_reload(vcpu);
> >> >> >> 	goto fail;
> >> >> >> }
> >> >> >>
> >> >> >> The you can inherit the checks from mmu_check_root().
> >> >> 
> >> >> Actually, thinking about this a bit more, I agree with you. Any fault
> >> >> with a vmfunc operation should end with a vmfunc vmexit, so this
> >> >> is a good thing to have. Thank you for this idea! :)
> >> >
> >> > SDM says
> >> >
> >> >   IF tent_EPTP is not a valid EPTP value (would cause VM entry to fail
> >> >   if in EPTP) THEN VMexit;
> >> 
> >> This section here:
> >> As noted in Section 25.5.5.2, an execution of the
> >> EPTP-switching VM function that causes a VM exit (as specified
> >> above), uses the basic exit reason 59, indicating “VMFUNC”.
> >> The length of the VMFUNC instruction is saved into the
> >> VM-exit instruction-length field. No additional VM-exit
> >> information is provided.
> >> 
> >> Although, it adds (as specified above), from testing, any vmexit that
> >> happens as a result of the execution of the vmfunc instruction always
> >> has exit reason 59.
> >> 
> >> IMO, the case David pointed out comes under "as a result of the
> >> execution of the vmfunc instruction", so I would prefer exiting
> >> with reason 59.
> >
> > Right, the exit reason is 59 for reasons that trigger a VM exit
> > (i.e. invalid EPTP value, the four below), but kvm_mmu_reload() checks
> > unrelated stuff.
> >
> > If the EPTP value is correct, then the switch should succeed.
> > If the EPTP is correct, but bogus, then the guest should get
> > EPT_MISCONFIG VM exit on its first access (when reading the
> > instruction).  Source: I added
> 
> My point is that we are using kvm_mmu_reload() to emulate eptp
> switching. If that emulation of vmfunc fails, it should exit with reason
> 59.

Yeah, we just disagree on what is a vmfunc failure.

> >   vmcs_write64(EPT_POINTER, vmcs_read64(EPT_POINTER) | (1ULL << 40));
> >
> > shortly before a VMLAUNCH on L0. :)
> 
> What happens if this ept pointer is actually in the eptp list and the guest
> switches to it using vmfunc ? I think it will exit with reason 59.

I think otherwise, because it doesn't cause a VM entry failure on
bare-metal (and SDM says that we get a VM exit only if there would be a
VM entry failure).
I expect the vmfunc to succeed and to get a EPT_MISCONFIG right after.
(Experiment pending :])

> > I think that we might be emulating this case incorrectly and throwing
> > triple faults when it should be VM exits in vcpu_run().
> 
> No, I agree with not throwing a triple fault. We should clear it out.
> But we should emulate a vmfunc vmexit back to L1 when kvm_mmu_load fails.

Here we disagree.  I think that it's a bug do the VM exit, so we can
just keep the original bug -- we want to eventually fix it and it's no
worse till then.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4 0/3] Expose VMFUNC to the nested hypervisor Bandan Das <bsd@redhat.com> - 2017-07-10 23:00 +0200
  [PATCH v4 2/3] KVM: nVMX: Enable VMFUNC for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-10 23:00 +0200
  [PATCH v4 1/3] KVM: vmx: Enable VMFUNCs Bandan Das <bsd@redhat.com> - 2017-07-10 23:00 +0200
  [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-10 23:00 +0200
    Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1  hypervisor David Hildenbrand <david@redhat.com> - 2017-07-11 10:00 +0200
      Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1  hypervisor Paolo Bonzini <pbonzini@redhat.com> - 2017-07-11 10:50 +0200
      Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1  hypervisor Radim Krčmář <rkrcmar@redhat.com> - 2017-07-11 16:00 +0200
        Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-11 20:10 +0200
          Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1  hypervisor Radim Krčmář <rkrcmar@redhat.com> - 2017-07-11 21:20 +0200
            Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-11 21:40 +0200
      Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-11 20:00 +0200
        Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-11 20:30 +0200
          Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1  hypervisor Radim Krčmář <rkrcmar@redhat.com> - 2017-07-11 21:40 +0200
            Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-11 22:00 +0200
              Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1  hypervisor Radim Krčmář <rkrcmar@redhat.com> - 2017-07-11 22:30 +0200
                Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-11 22:40 +0200
                Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1  hypervisor Radim Krčmář <rkrcmar@redhat.com> - 2017-07-11 22:50 +0200
                Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-11 23:10 +0200
                Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1  hypervisor Radim Krčmář <rkrcmar@redhat.com> - 2017-07-12 15:30 +0200
                Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-12 20:20 +0200
                Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1  hypervisor Radim Krčmář <rkrcmar@redhat.com> - 2017-07-12 21:20 +0200
                Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-17 20:00 +0200
        Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Jim Mattson <jmattson@google.com> - 2017-07-11 20:30 +0200
          Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-11 20:40 +0200
            Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1  hypervisor Radim Krčmář <rkrcmar@redhat.com> - 2017-07-11 21:20 +0200
              Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-11 21:40 +0200
                Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1  hypervisor Radim Krčmář <rkrcmar@redhat.com> - 2017-07-11 22:30 +0200
                Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-11 22:50 +0200
                Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1  hypervisor Radim Krčmář <rkrcmar@redhat.com> - 2017-07-12 15:50 +0200
                Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-12 20:10 +0200
        Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1  hypervisor David Hildenbrand <david@redhat.com> - 2017-07-13 17:50 +0200
          Re: [PATCH v4 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor Bandan Das <bsd@redhat.com> - 2017-07-13 19:10 +0200

csiph-web