* [PATCH] Move translate_gpa() initialization for the nested context into init_kvm_nested_mmu()
@ 2013-12-31 1:22 Zhihui Zhang
2014-01-08 21:09 ` Marcelo Tosatti
0 siblings, 1 reply; 2+ messages in thread
From: Zhihui Zhang @ 2013-12-31 1:22 UTC (permalink / raw)
To: gleb, pbonzini, hpa; +Cc: kvm
This is the right place to set the function pointer. In addition, change function name
from translate_nested_gpa() to translate_gpa_nested() to match the naming convention of
other functions (e.g., paging64_gva_to_gpa_nested()).
Signed-off-by: Zhihui Zhang <zzhsuny@gmail.com>
---
arch/x86/include/asm/kvm_host.h | 2 +-
arch/x86/kvm/mmu.c | 2 +-
arch/x86/kvm/x86.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index ae5d783..a38be84 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -916,7 +916,7 @@ void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
int kvm_mmu_load(struct kvm_vcpu *vcpu);
void kvm_mmu_unload(struct kvm_vcpu *vcpu);
void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu);
-gpa_t translate_nested_gpa(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access);
+gpa_t translate_gpa_nested(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access);
gpa_t kvm_mmu_gva_to_gpa_read(struct kvm_vcpu *vcpu, gva_t gva,
struct x86_exception *exception);
gpa_t kvm_mmu_gva_to_gpa_fetch(struct kvm_vcpu *vcpu, gva_t gva,
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 40772ef..8bd6a5f 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3804,6 +3804,7 @@ static void init_kvm_nested_mmu(struct kvm_vcpu *vcpu)
g_context->get_cr3 = get_cr3;
g_context->get_pdptr = kvm_pdptr_read;
g_context->inject_page_fault = kvm_inject_page_fault;
+ g_context->translate_gpa = translate_gpa_nested;
/*
* Note that arch.mmu.gva_to_gpa translates l2_gva to l1_gpa. The
@@ -4230,7 +4231,6 @@ int kvm_mmu_create(struct kvm_vcpu *vcpu)
vcpu->arch.walk_mmu = &vcpu->arch.mmu;
vcpu->arch.mmu.root_hpa = INVALID_PAGE;
vcpu->arch.mmu.translate_gpa = translate_gpa;
- vcpu->arch.nested_mmu.translate_gpa = translate_nested_gpa;
return alloc_mmu_pages(vcpu);
}
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 5d004da..f5cc306 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3938,7 +3938,7 @@ void kvm_get_segment(struct kvm_vcpu *vcpu,
kvm_x86_ops->get_segment(vcpu, var, seg);
}
-gpa_t translate_nested_gpa(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access)
+gpa_t translate_gpa_nested(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access)
{
gpa_t t_gpa;
struct x86_exception exception;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Move translate_gpa() initialization for the nested context into init_kvm_nested_mmu()
2013-12-31 1:22 [PATCH] Move translate_gpa() initialization for the nested context into init_kvm_nested_mmu() Zhihui Zhang
@ 2014-01-08 21:09 ` Marcelo Tosatti
0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2014-01-08 21:09 UTC (permalink / raw)
To: Zhihui Zhang; +Cc: gleb, pbonzini, hpa, kvm
On Mon, Dec 30, 2013 at 08:22:21PM -0500, Zhihui Zhang wrote:
> This is the right place to set the function pointer. In addition, change function name
> from translate_nested_gpa() to translate_gpa_nested() to match the naming convention of
> other functions (e.g., paging64_gva_to_gpa_nested()).
>
> Signed-off-by: Zhihui Zhang <zzhsuny@gmail.com>
Why is it the right place? The assignment was executed once per
VM-creation, now its executed once per kvm_mmu_reset_context
(which is a downside). Another downside is that
vcpu->arch.mmu.translate_gpa = translate_gpa;
vcpu->arch.nested_mmu.translate_gpa = translate_nested_gpa;
You lose this proximity.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-08 21:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-31 1:22 [PATCH] Move translate_gpa() initialization for the nested context into init_kvm_nested_mmu() Zhihui Zhang
2014-01-08 21:09 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox