x86/hvm: Drop more remains of the PVHv1 implementation
PATCH 1/1 x86/hvm: Drop more remains of the PVHv1 implementation
These functions don't need is_hvm_{vcpu,domain}() predicates.
hvmop_set_evtchn_upcall_vector() does need the predicate to prevent a PV caller accessing the hvm union, but swap the copy_from_guest() and is_hvm_domain() predicate to avoid reading the hypercall parameter if we not going to use it.
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Paul Durrant <[email protected]>
CC: Roger Pau Monné <[email protected]>
--- xen/arch/x86/hvm/hvm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
xen/arch/x86/hvm/hvm.c +6 -9
@@ -506,8 +506,7 @@ void hvm_do_resume(struct vcpu *v) {check_wakeup_from_wait (); -if (is_hvm_domain (v->domain) ) -pt_restore_timer (v); +pt_restore_timer (v);if ( !handle_hvm_io_completion (v) )return ;
@@ -1544,8 +1543,7 @@ void hvm_vcpu_destroy(struct vcpu *v)tasklet_kill (&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet); hvm_funcs.vcpu_destroy (v); -if (is_hvm_vcpu (v) ) -vlapic_destroy (v); +vlapic_destroy (v);hvm_vcpu_cacheattr_destroy (v); }
@@ -1711,7 +1709,6 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,* - newer Windows (like Server 2012) for HPET accesses. */ if ( !nestedhvm_vcpu_in_guestmode (curr) - &&is_hvm_domain (currd) &&hvm_mmio_internal (gpa) ) {if ( !handle_mmio_with_translation (gla, gpa >>PAGE_SHIFT , npfec) )
@@ -3139,7 +3136,7 @@ static enum hvm_copy_result __hvm_copy(* - 32-bit WinXP (& older Windows) on AMD CPUs for LAPIC accesses, * - newer Windows (like Server 2012) for HPET accesses. */ -if ( v == current &&is_hvm_vcpu (v) +if ( v == current && !nestedhvm_vcpu_in_guestmode (v) &&hvm_mmio_internal (gpa) )return HVMCOPY_bad_gfn_to_mfn;
@@ -3971,12 +3968,12 @@ static int hvmop_set_evtchn_upcall_vector(struct domain *d = current->domain;struct vcpu *v; -if (copy_from_guest (&op, uop,1 ) ) -return -EFAULT ; -if ( !is_hvm_domain (d) )return -EINVAL ; +if (copy_from_guest (&op, uop,1 ) ) +return -EFAULT ; +if ( op.vector <0x10 )return -EINVAL ;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 12 lines
-----Original Message-----
From: Andrew Cooper [mailto:[email protected]]
Sent: 19 July 2017 14:28
To: Xen-devel <[email protected]>
Cc: Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Jan Beulich <[email protected]>; Wei Liu <[email protected]>; Paul Durrant <[email protected]>; Roger Pau Monne <[email protected]>
Subject: [PATCH] x86/hvm: Drop more remains of the PVHv1 implementationThese functions don't need is_hvm_{vcpu,domain}() predicates.
Quoted 8 lines
hvmop_set_evtchn_upcall_vector()does need the predicate to prevent a PV
caller accessing the hvm union, but swap thecopy_from_guest()andis_hvm_domain()predicate to avoid reading the hypercall parameter if we not
going to use it.Signed-off-by Andrew Cooper <[email protected]>
Quoted 69 lines
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Paul Durrant <[email protected]>
CC: Roger Pau Monné <[email protected]>--- xen/arch/x86/hvm/hvm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)xen/arch/x86/hvm/hvm.c +2
-5@@ -506,8 +506,7 @@ void hvm_do_resume(struct vcpu *v) {check_wakeup_from_wait (); -if (is_hvm_domain (v->domain) ) -pt_restore_timer (v); +pt_restore_timer (v);if ( !handle_hvm_io_completion (v) )return ;@@ -1544,8 +1543,7 @@ void hvm_vcpu_destroy(struct vcpu *v)tasklet_kill (&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet); hvm_funcs.vcpu_destroy (v); -if (is_hvm_vcpu (v) ) -vlapic_destroy (v); +vlapic_destroy (v);hvm_vcpu_cacheattr_destroy (v); }@@ -1711,7 +1709,6 @@ int hvm_hap_nested_page_fault(paddr_t gpa,unsigned long gla, * - newer Windows (like Server 2012) for HPET accesses. */ if ( !nestedhvm_vcpu_in_guestmode (curr) - &&is_hvm_domain (currd) &&hvm_mmio_internal (gpa) ) {if ( !handle_mmio_with_translation(gla, gpa >>
PAGE_SHIFT, npfec) )xen/arch/x86/hvm/hvm.c +4
-5@@ -3139,7 +3136,7 @@ static enum hvm_copy_result __hvm_copy(* - 32-bit WinXP (& older Windows) on AMD CPUs for LAPIC accesses, * - newer Windows (like Server 2012) for HPET accesses. */ -if ( v == current &&is_hvm_vcpu (v) +if ( v == current && !nestedhvm_vcpu_in_guestmode (v) &&hvm_mmio_internal (gpa) )return HVMCOPY_bad_gfn_to_mfn;@@ -3971,12 +3968,12 @@ static int hvmop_set_evtchn_upcall_vector(struct domain *d = current->domain;struct vcpu *v; -if (copy_from_guest (&op, uop,1 ) ) -return -EFAULT ; -if ( !is_hvm_domain (d) )return -EINVAL ; +if (copy_from_guest (&op, uop,1 ) ) +return -EFAULT ; +if ( op.vector <0x10 )return -EINVAL ; --
Quoted 1 line
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 8 lines · Andrew Cooper
These functions don't need is_hvm_{vcpu,domain}() predicates.
hvmop_set_evtchn_upcall_vector()does need the predicate to prevent a PV caller accessing the hvm union, but swap thecopy_from_guest()andis_hvm_domain()predicate to avoid reading the hypercall parameter if we not going to use it.Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 6 lines · Andrew Cooper
These functions don't need is_hvm_{vcpu,domain}() predicates.
hvmop_set_evtchn_upcall_vector()does need the predicate to prevent a PV caller accessing the hvm union, but swap thecopy_from_guest()andis_hvm_domain()predicate to avoid reading the hypercall parameter if we not going to use it.
IC, certain HVMOPs are available to PV guests (ie: the control domain).
Quoted 2 lines
Signed-off-by Andrew Cooper <[email protected]>
Thanks. Just one style nit.
Quoted 34 lines
CC George Dunlap <[email protected]>CC Jan Beulich <[email protected]>CC Wei Liu <[email protected]>CC Paul Durrant <[email protected]>CC Roger Pau Monné <[email protected]>--- xen/arch/x86/hvm/hvm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)xen/arch/x86/hvm/hvm.c +2
-4@@ -506,8 +506,7 @@ void hvm_do_resume(struct vcpu *v) {check_wakeup_from_wait (); -if (is_hvm_domain (v->domain) ) -pt_restore_timer (v); +pt_restore_timer (v);if ( !handle_hvm_io_completion (v) )return ;@@ -1544,8 +1543,7 @@ void hvm_vcpu_destroy(struct vcpu *v)tasklet_kill (&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet); hvm_funcs.vcpu_destroy (v); -if (is_hvm_vcpu (v) ) -vlapic_destroy (v); +vlapic_destroy (v);hvm_vcpu_cacheattr_destroy (v); }
xen/arch/x86/hvm/hvm.c int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla, · line 1712
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +0
-1@@ -1711,7 +1709,6 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,* - newer Windows (like Server 2012) for HPET accesses. */ if ( !nestedhvm_vcpu_in_guestmode (curr) - &&is_hvm_domain (currd) &&hvm_mmio_internal (gpa) )
Can this be moved to the previous line?
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Andrew Cooper
These functions don't need is_hvm_{vcpu,domain}() predicates.
hvmop_set_evtchn_upcall_vector()does need the predicate to prevent a PV caller accessing the hvm union, but swap thecopy_from_guest()andis_hvm_domain()predicate to avoid reading the hypercall parameter if we not going to use it.IC, certain HVMOPs are available to PV guests (ie: the control domain).
At the very least, the control domain needs to use HVMOP_getparam for construction and migration purposes. As a result, PV guests have always had blanket reign on HVMOPs.
Quoted 37 lines
Quoted 2 lines
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Roger Pau Monné <[email protected]>Thanks. Just one style nit.
Quoted 31 lines
CC George Dunlap <[email protected]>CC Jan Beulich <[email protected]>CC Wei Liu <[email protected]>CC Paul Durrant <[email protected]>CC Roger Pau Monné <[email protected]>--- xen/arch/x86/hvm/hvm.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)xen/arch/x86/hvm/hvm.c +2
-4@@ -506,8 +506,7 @@ void hvm_do_resume(struct vcpu *v) {check_wakeup_from_wait (); -if (is_hvm_domain (v->domain) ) -pt_restore_timer (v); +pt_restore_timer (v);if ( !handle_hvm_io_completion (v) )return ;@@ -1544,8 +1543,7 @@ void hvm_vcpu_destroy(struct vcpu *v)tasklet_kill (&v->arch.hvm_vcpu.assert_evtchn_irq_tasklet); hvm_funcs.vcpu_destroy (v); -if (is_hvm_vcpu (v) ) -vlapic_destroy (v); +vlapic_destroy (v);
Quoted 9 lines
xen/arch/x86/hvm/hvm.c int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla, · line 1712
Quoted 8 lines
xen/arch/x86/hvm/hvm.c +0
-1hvm_vcpu_cacheattr_destroy (v); }@@ -1711,7 +1709,6 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,* - newer Windows (like Server 2012) for HPET accesses. */ if ( !nestedhvm_vcpu_in_guestmode (curr) - &&is_hvm_domain (currd) &&hvm_mmio_internal (gpa) )Can this be moved to the previous line?
Will fix on commit.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel