From: David Hildenbrand <david@redhat.com>
To: Bandan Das <bsd@redhat.com>, kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com, jmattson@google.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] KVM: nVMX: Emulate EPTP switching for the L1 hypervisor
Date: Thu, 3 Aug 2017 13:39:30 +0200 [thread overview]
Message-ID: <56d21524-1a08-8281-fb01-950fb7c10b2f@redhat.com> (raw)
In-Reply-To: <20170801232433.31749-4-bsd@redhat.com>
>
> +static bool valid_ept_address(struct kvm_vcpu *vcpu, u64 address)
> +{
> + struct vcpu_vmx *vmx = to_vmx(vcpu);
> + u64 mask = address & 0x7;
> + int maxphyaddr = cpuid_maxphyaddr(vcpu);
> +
> + /* Check for memory type validity */
> + switch (mask) {
> + case 0:
> + if (!(vmx->nested.nested_vmx_ept_caps & VMX_EPTP_UC_BIT))
> + return false;
> + break;
> + case 6:
> + if (!(vmx->nested.nested_vmx_ept_caps & VMX_EPTP_WB_BIT))
> + return false;
> + break;
> + default:
> + return false;
> + }
> +
> + /* Bits 5:3 must be 3 */
> + if (((address >> VMX_EPT_GAW_EPTP_SHIFT) & 0x7) != VMX_EPT_DEFAULT_GAW)
> + return false;
> +
> + /* Reserved bits should not be set */
> + if (address >> maxphyaddr || ((address >> 7) & 0x1f))
> + return false;
> +
> + /* AD, if set, should be supported */
> + if ((address & VMX_EPT_AD_ENABLE_BIT)) {
> + if (!enable_ept_ad_bits)
> + return false;
In theory (I guess) we would have to check here if
(vmx->nested.nested_vmx_ept_caps & VMX_EPT_AD_BIT)
But I am no expert on this.
> + }
> +
> + return true;
> +}
> +
> +static int nested_vmx_eptp_switching(struct kvm_vcpu *vcpu,
> + struct vmcs12 *vmcs12)
> +{
> + u32 index = vcpu->arch.regs[VCPU_REGS_RCX];
> + u64 *l1_eptp_list, address;
> + struct page *page;
> + bool accessed_dirty;
> + struct kvm_mmu *mmu = vcpu->arch.walk_mmu;
> +
> + if (!nested_cpu_has_eptp_switching(vmcs12) ||
> + !nested_cpu_has_ept(vmcs12))
> + return 1;
> +
> + if (index >= VMFUNC_EPTP_ENTRIES)
> + return 1;
> +
> + page = nested_get_page(vcpu, vmcs12->eptp_list_address);
> + if (!page)
> + return 1;
> +
> + l1_eptp_list = kmap(page);
> + address = l1_eptp_list[index];
> + accessed_dirty = !!(address & VMX_EPT_AD_ENABLE_BIT);
Minor nit: Can't you directly do
kunmap(page);
nested_release_page_clean(page);
at this point?
We can fix this up later.
We could even later factor this out into sth. like "nested_vmx_read_guest".
--
Thanks,
David
next prev parent reply other threads:[~2017-08-03 11:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-01 23:24 [PATCH v6 0/3] Expose VMFUNC to the nested hypervisor Bandan Das
2017-08-01 23:24 ` [PATCH v6 1/3] KVM: vmx: Enable VMFUNCs Bandan Das
2017-08-01 23:24 ` [PATCH v6 2/3] KVM: nVMX: Enable VMFUNC for the L1 hypervisor Bandan Das
2017-08-01 23:24 ` [PATCH 3/3] KVM: nVMX: Emulate EPTP switching " Bandan Das
2017-08-03 11:39 ` David Hildenbrand [this message]
2017-08-03 12:41 ` Paolo Bonzini
2017-08-03 12:47 ` David Hildenbrand
2017-08-03 19:55 ` Bandan Das
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=56d21524-1a08-8281-fb01-950fb7c10b2f@redhat.com \
--to=david@redhat.com \
--cc=bsd@redhat.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®