From: Sean Christopherson <seanjc@google.com>
To: Mingwei Zhang <mizhang@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Maxim Levitsky <mlevitsk@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Oliver Upton <oupton@google.com>,
Jim Mattson <jmattson@google.com>
Subject: Re: [PATCH v2 3/4] KVM: selftests: Add support for posted interrupt handling in L2
Date: Mon, 29 Aug 2022 16:19:56 +0000 [thread overview]
Message-ID: <YwznLAqRb2i4lHiH@google.com> (raw)
In-Reply-To: <20220828222544.1964917-4-mizhang@google.com>
On Sun, Aug 28, 2022, Mingwei Zhang wrote:
> Add support for posted interrupt handling in L2. This is done by adding
> needed data structures in vmx_pages and APIs to allow an L2 receive posted
> interrupts.
>
> Cc: Jim Mattson <jmattson@google.com>
> Signed-off-by: Mingwei Zhang <mizhang@google.com>
> ---
> tools/testing/selftests/kvm/include/x86_64/vmx.h | 10 ++++++++++
> tools/testing/selftests/kvm/lib/x86_64/vmx.c | 14 ++++++++++++++
> 2 files changed, 24 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/include/x86_64/vmx.h b/tools/testing/selftests/kvm/include/x86_64/vmx.h
> index 99fa1410964c..69784fc71bce 100644
> --- a/tools/testing/selftests/kvm/include/x86_64/vmx.h
> +++ b/tools/testing/selftests/kvm/include/x86_64/vmx.h
> @@ -577,6 +577,14 @@ struct vmx_pages {
> void *apic_access_hva;
> uint64_t apic_access_gpa;
> void *apic_access;
> +
> + void *virtual_apic_hva;
> + uint64_t virtual_apic_gpa;
> + void *virtual_apic;
> +
> + void *posted_intr_desc_hva;
> + uint64_t posted_intr_desc_gpa;
> + void *posted_intr_desc;
Can you add a prep patch to dedup the absurd amount of copy-paste code related to
vmx_pages?
I.e. take this and give all the other triplets the same treatment.
---
tools/testing/selftests/kvm/include/x86_64/vmx.h | 10 +++++++---
tools/testing/selftests/kvm/lib/x86_64/vmx.c | 15 ++++++++++-----
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/kvm/include/x86_64/vmx.h b/tools/testing/selftests/kvm/include/x86_64/vmx.h
index 99fa1410964c..ecc66d65acc1 100644
--- a/tools/testing/selftests/kvm/include/x86_64/vmx.h
+++ b/tools/testing/selftests/kvm/include/x86_64/vmx.h
@@ -537,10 +537,14 @@ static inline uint32_t vmcs_revision(void)
return rdmsr(MSR_IA32_VMX_BASIC);
}
+struct vmx_page {
+ void *gva;
+ uint64_t gpa;
+ void *hva;
+};
+
struct vmx_pages {
- void *vmxon_hva;
- uint64_t vmxon_gpa;
- void *vmxon;
+ struct vmx_page vmxon;
void *vmcs_hva;
uint64_t vmcs_gpa;
diff --git a/tools/testing/selftests/kvm/lib/x86_64/vmx.c b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
index 80a568c439b8..e4eeab85741a 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/vmx.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
@@ -58,6 +58,13 @@ int vcpu_enable_evmcs(struct kvm_vcpu *vcpu)
return evmcs_ver;
}
+static void vcpu_alloc_vmx_page(struct kvm_vm *vm, struct vmx_page *page)
+{
+ page->gva = (void *)vm_vaddr_alloc_page(vm);
+ page->hva = addr_gva2hva(vm, (uintptr_t)page->gva);
+ page->gpa = addr_gva2gpa(vm, (uintptr_t)page->gva);
+}
+
/* Allocate memory regions for nested VMX tests.
*
* Input Args:
@@ -76,9 +83,7 @@ vcpu_alloc_vmx(struct kvm_vm *vm, vm_vaddr_t *p_vmx_gva)
struct vmx_pages *vmx = addr_gva2hva(vm, vmx_gva);
/* Setup of a region of guest memory for the vmxon region. */
- vmx->vmxon = (void *)vm_vaddr_alloc_page(vm);
- vmx->vmxon_hva = addr_gva2hva(vm, (uintptr_t)vmx->vmxon);
- vmx->vmxon_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->vmxon);
+ vcpu_alloc_vmx_page(vm, &vmx->vmxon);
/* Setup of a region of guest memory for a vmcs. */
vmx->vmcs = (void *)vm_vaddr_alloc_page(vm);
@@ -160,8 +165,8 @@ bool prepare_for_vmx_operation(struct vmx_pages *vmx)
wrmsr(MSR_IA32_FEAT_CTL, feature_control | required);
/* Enter VMX root operation. */
- *(uint32_t *)(vmx->vmxon) = vmcs_revision();
- if (vmxon(vmx->vmxon_gpa))
+ *(uint32_t *)(vmx->vmxon.gva) = vmcs_revision();
+ if (vmxon(vmx->vmxon.gpa))
return false;
return true;
base-commit: 372d07084593dc7a399bf9bee815711b1fb1bcf2
--
next prev parent reply other threads:[~2022-08-29 16:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-28 22:25 [PATCH v2 0/4] Fix a race between posted interrupt delivery and migration in a nested VM Mingwei Zhang
2022-08-28 22:25 ` [PATCH v2 1/4] KVM: x86: move the event handling of KVM_REQ_GET_VMCS12_PAGES into a common function Mingwei Zhang
2022-08-29 16:09 ` Sean Christopherson
2022-09-07 0:01 ` Mingwei Zhang
2022-09-07 2:50 ` Yuan Yao
2022-09-07 4:26 ` Mingwei Zhang
2022-09-07 5:35 ` Yuan Yao
2022-09-07 15:48 ` Sean Christopherson
2022-09-07 15:56 ` Sean Christopherson
2022-08-28 22:25 ` [PATCH v2 2/4] KVM: selftests: Save/restore vAPIC state in migration tests Mingwei Zhang
2022-08-28 22:25 ` [PATCH v2 3/4] KVM: selftests: Add support for posted interrupt handling in L2 Mingwei Zhang
2022-08-29 16:19 ` Sean Christopherson [this message]
2022-09-07 0:02 ` Mingwei Zhang
2022-08-28 22:25 ` [PATCH v2 4/4] KVM: selftests: Test if posted interrupt delivery race with migration Mingwei Zhang
2022-08-29 17:21 ` Sean Christopherson
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=YwznLAqRb2i4lHiH@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mizhang@google.com \
--cc=mlevitsk@redhat.com \
--cc=oupton@google.com \
--cc=pbonzini@redhat.com \
--cc=vkuznets@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;
as well as URLs for NNTP newsgroup(s).