[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220819174659.2427983-4-vannapurve@google.com>
Date: Fri, 19 Aug 2022 17:46:56 +0000
From: Vishal Annapurve <vannapurve@...gle.com>
To: x86@...nel.org, kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org
Cc: pbonzini@...hat.com, vkuznets@...hat.com, wanpengli@...cent.com,
jmattson@...gle.com, joro@...tes.org, tglx@...utronix.de,
mingo@...hat.com, bp@...en8.de, dave.hansen@...ux.intel.com,
hpa@...or.com, shuah@...nel.org, yang.zhong@...el.com,
drjones@...hat.com, ricarkol@...gle.com, aaronlewis@...gle.com,
wei.w.wang@...el.com, kirill.shutemov@...ux.intel.com,
corbet@....net, hughd@...gle.com, jlayton@...nel.org,
bfields@...ldses.org, akpm@...ux-foundation.org,
chao.p.peng@...ux.intel.com, yu.c.zhang@...ux.intel.com,
jun.nakajima@...el.com, dave.hansen@...el.com,
michael.roth@....com, qperret@...gle.com, steven.price@....com,
ak@...ux.intel.com, david@...hat.com, luto@...nel.org,
vbabka@...e.cz, marcorr@...gle.com, erdemaktas@...gle.com,
pgonda@...gle.com, nikunj@....com, seanjc@...gle.com,
diviness@...gle.com, maz@...nel.org, dmatlack@...gle.com,
axelrasmussen@...gle.com, maciej.szmigiero@...cle.com,
mizhang@...gle.com, bgardon@...gle.com,
Vishal Annapurve <vannapurve@...gle.com>
Subject: [RFC V3 PATCH 3/6] selftests: kvm: ucall: Allow querying ucall pool gpa
Add a helper to query guest physical address for ucall pool
so that guest can mark the page as accessed shared or private.
Signed-off-by: Vishal Annapurve <vannapurve@...gle.com>
---
tools/testing/selftests/kvm/include/ucall_common.h | 2 ++
tools/testing/selftests/kvm/lib/ucall_common.c | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/tools/testing/selftests/kvm/include/ucall_common.h b/tools/testing/selftests/kvm/include/ucall_common.h
index 279bbab011c7..2c6e5c4df012 100644
--- a/tools/testing/selftests/kvm/include/ucall_common.h
+++ b/tools/testing/selftests/kvm/include/ucall_common.h
@@ -31,6 +31,8 @@ void ucall_arch_uninit(struct kvm_vm *vm);
void ucall_arch_do_ucall(vm_vaddr_t uc);
void *ucall_arch_get_ucall(struct kvm_vcpu *vcpu);
+vm_paddr_t get_ucall_pool_paddr(void);
+
void ucall(uint64_t cmd, int nargs, ...);
uint64_t get_ucall(struct kvm_vcpu *vcpu, struct ucall *uc);
diff --git a/tools/testing/selftests/kvm/lib/ucall_common.c b/tools/testing/selftests/kvm/lib/ucall_common.c
index 5a15fa39cd51..4d2abef8ee77 100644
--- a/tools/testing/selftests/kvm/lib/ucall_common.c
+++ b/tools/testing/selftests/kvm/lib/ucall_common.c
@@ -11,6 +11,7 @@ struct ucall_header {
static bool use_ucall_pool;
static struct ucall_header *ucall_pool;
+static vm_paddr_t ucall_page_paddr;
void ucall_init(struct kvm_vm *vm, void *arg)
{
@@ -35,7 +36,10 @@ void ucall_init(struct kvm_vm *vm, void *arg)
}
ucall_pool = (struct ucall_header *)vaddr;
+ ucall_page_paddr = addr_gva2gpa(vm, vaddr);
sync_global_to_guest(vm, ucall_pool);
+ sync_global_to_guest(vm, ucall_page_paddr);
+ printf("ucall_page_paddr 0x%lx\n", ucall_page_paddr);
out:
ucall_arch_init(vm, arg);
@@ -54,6 +58,14 @@ void ucall_uninit(struct kvm_vm *vm)
ucall_arch_uninit(vm);
}
+vm_paddr_t get_ucall_pool_paddr(void)
+{
+ if (!use_ucall_pool)
+ return 0;
+
+ return ucall_page_paddr;
+}
+
static struct ucall *ucall_alloc(void)
{
struct ucall *uc = NULL;
--
2.37.1.595.g718a3a8f04-goog
Powered by blists - more mailing lists