x86/viridian: EOI MSR should always happen in affected vCPU context
PATCH 1/1 x86/viridian: EOI MSR should always happen in affected vCPU context
The HV_X64_MSR_EOI wrmsr should always happen with the target vCPU as current, as there's no support for EOI'ing interrupts on a remote vCPU.
While there also turn the unconditional assert at the top of the function into an error on non-debug builds.
No functional change intended.
--- xen/arch/x86/hvm/viridian/synic.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
xen/arch/x86/hvm/viridian/synic.c +10 -1
@@ -79,11 +79,20 @@ int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val)struct viridian_vcpu *vv = v->arch.hvm.viridian;struct domain *d = v->domain; -ASSERT (v == current || !v->is_running); +if ( v != current && v->is_running ) + { +ASSERT_UNREACHABLE (); +return X86EMUL_EXCEPTION ; + }switch ( idx ) {case HV_X64_MSR_EOI : +if ( v != current ) + { +ASSERT_UNREACHABLE (); +return X86EMUL_EXCEPTION ; + }vlapic_EOI_set (vcpu_vlapic (v));break ;
Signature · 1 line
2.30.1
Quoted 11 lines · Roger Pau Monne
The
HV_X64_MSR_EOIwrmsr should always happen with the target vCPU as current, as there's no support for EOI'ing interrupts on a remote vCPU.While there also turn the unconditional assert at the top of the function into an error on non-debug builds.
No functional change intended.
Requested-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>
Quoted 31 lines
--- xen/arch/x86/hvm/viridian/synic.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)xen/arch/x86/hvm/viridian/synic.c +10
-1@@ -79,11 +79,20 @@ int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val)struct viridian_vcpu *vv = v->arch.hvm.viridian;struct domain *d = v->domain; -ASSERT (v == current || !v->is_running); +if ( v != current && v->is_running ) + { +ASSERT_UNREACHABLE (); +return X86EMUL_EXCEPTION ; + }switch ( idx ) {case HV_X64_MSR_EOI : +if ( v != current ) + { +ASSERT_UNREACHABLE (); +return X86EMUL_EXCEPTION ; + }vlapic_EOI_set (vcpu_vlapic (v));break ;
Quoted 8 lines · Paul Durrant
Quoted 7 lines · Roger Pau Monne
The
HV_X64_MSR_EOIwrmsr should always happen with the target vCPU as current, as there's no support for EOI'ing interrupts on a remote vCPU.While there also turn the unconditional assert at the top of the function into an error on non-debug builds.
Quoted 6 lines
Quoted 4 lines
No functional change intended.
Requested-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>Reviewed-by Paul Durrant <[email protected]>
Andrew,
can you please clarify whether your concern was addressed and this can go in as-is, or (if not) reply to what Roger and I have said in response?
Thanks, Jan
Quoted 14 lines · Jan Beulich
Quoted 13 lines · Paul Durrant
Quoted 11 lines · Roger Pau Monne
The
HV_X64_MSR_EOIwrmsr should always happen with the target vCPU as current, as there's no support for EOI'ing interrupts on a remote vCPU.While there also turn the unconditional assert at the top of the function into an error on non-debug builds.
No functional change intended.
Requested-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>
Quoted 6 lines
Quoted 1 line
Reviewed-by Paul Durrant <[email protected]>Andrew,
can you please clarify whether your concern was addressed and this can go in as-is, or (if not) reply to what Roger and I have said in response?
This continues to be pending. I guess I'll consider ongoing silence as an indication of your concerns having been addressed, committing the patch perhaps early next week.
Jan
Quoted 11 lines · Roger Pau Monne
The
HV_X64_MSR_EOIwrmsr should always happen with the target vCPU as current, as there's no support for EOI'ing interrupts on a remote vCPU.While there also turn the unconditional assert at the top of the function into an error on non-debug builds.
No functional change intended.
Requested-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>
Quoted 12 lines
xen/arch/x86/hvm/viridian/synic.c +5
-1@@ -79,11 +79,20 @@ int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val)struct viridian_vcpu *vv = v->arch.hvm.viridian;struct domain *d = v->domain; -ASSERT (v == current || !v->is_running); +if ( v != current && v->is_running ) + { +ASSERT_UNREACHABLE (); +return X86EMUL_EXCEPTION ; + }
xen/arch/x86/hvm/viridian/synic.c int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val) · line 96
Quoted 10 lines
xen/arch/x86/hvm/viridian/synic.c +5
-0switch ( idx ) {case HV_X64_MSR_EOI : +if ( v != current ) + { +ASSERT_UNREACHABLE (); +return X86EMUL_EXCEPTION ; + }vlapic_EOI_set (vcpu_vlapic (v));
I suppose this function then also wants to lose its parameter. But I'll reply to patch 1 of the other series again as well.
Jan
Quoted 20 lines · Roger Pau Monne
The
HV_X64_MSR_EOIwrmsr should always happen with the target vCPU as current, as there's no support for EOI'ing interrupts on a remote vCPU.While there also turn the unconditional assert at the top of the function into an error on non-debug builds.
No functional change intended.
Requested-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>--- xen/arch/x86/hvm/viridian/synic.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)xen/arch/x86/hvm/viridian/synic.c +0
-0
xen/arch/x86/hvm/viridian/synic.c int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val) · line 86
Quoted 9 lines
xen/arch/x86/hvm/viridian/synic.c +5
-1@@ -79,11 +79,20 @@ int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val)struct viridian_vcpu *vv = v->arch.hvm.viridian;struct domain *d = v->domain; -ASSERT (v == current || !v->is_running); +if ( v != current && v->is_running ) + { +ASSERT_UNREACHABLE (); +return X86EMUL_EXCEPTION ; + }
The original ASSERT() was correct - both of these are easily reachable in control domain context.
If you want EOI to not be used, you need to raise #GP from it, but that in principle breaks introspection which really does write MSRs on the guests behalf.
It's perhaps fine in principle to leave that problem to whomever first wants to poke this MSR from introspection context, but the ASSERT_UNREACHABLE()s need dropping whatever the introspection angle.
~Andrew
Quoted 34 lines · Andrew Cooper
Quoted 20 lines · Roger Pau Monne
The
HV_X64_MSR_EOIwrmsr should always happen with the target vCPU as current, as there's no support for EOI'ing interrupts on a remote vCPU.While there also turn the unconditional assert at the top of the function into an error on non-debug builds.
No functional change intended.
Requested-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>--- xen/arch/x86/hvm/viridian/synic.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)xen/arch/x86/hvm/viridian/synic.c +0
-0xen/arch/x86/hvm/viridian/synic.c int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val) · line 86
Quoted 9 lines
xen/arch/x86/hvm/viridian/synic.c +5
-1@@ -79,11 +79,20 @@ int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val)struct viridian_vcpu *vv = v->arch.hvm.viridian;struct domain *d = v->domain; -ASSERT (v == current || !v->is_running); +if ( v != current && v->is_running ) + { +ASSERT_UNREACHABLE (); +return X86EMUL_EXCEPTION ; + }The original
ASSERT()was correct - both of these are easily reachable in control domain context.
Quoted 7 lines
If you want EOI to not be used, you need to raise #GP from it, but that in principle breaks introspection which really does write MSRs on the guests behalf.
It's perhaps fine in principle to leave that problem to whomever first wants to poke this MSR from introspection context, but the ASSERT_UNREACHABLE()s need dropping whatever the introspection angle.
But if the original ASSERT() was correct, how can the ASSERT_UNREACHABLE() above need dropping? Are you perhaps only talking about the other one?
Jan
Quoted 24 lines · Andrew Cooper
Quoted 23 lines · Roger Pau Monne
The
HV_X64_MSR_EOIwrmsr should always happen with the target vCPU as current, as there's no support for EOI'ing interrupts on a remote vCPU.While there also turn the unconditional assert at the top of the function into an error on non-debug builds.
No functional change intended.
Requested-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>--- xen/arch/x86/hvm/viridian/synic.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)xen/arch/x86/hvm/viridian/synic.c +0
-0@@ -79,11 +79,20 @@ int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val)struct viridian_vcpu *vv = v->arch.hvm.viridian;struct domain *d = v->domain;
Quoted 9 lines
xen/arch/x86/hvm/viridian/synic.c int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val) · line 86
Quoted 6 lines
xen/arch/x86/hvm/viridian/synic.c +5
-1-ASSERT (v == current || !v->is_running); +if ( v != current && v->is_running ) + { +ASSERT_UNREACHABLE (); +return X86EMUL_EXCEPTION ; + }The original
ASSERT()was correct - both of these are easily reachable in control domain context.
I'm confused, if it's reachable from control domain context then it shouldn't be an assert?
Quoted 3 lines
If you want EOI to not be used, you need to raise #GP from it, but that in principle breaks introspection which really does write MSRs on the guests behalf.
Looking at hvm_msr_write_intercept I see that indeed introspection can monitor an MSR and defer a write, but AFAICT the postponed write will be performed in guest vcpu context as part of hvm_vm_event_do_resume?
Also AFAICT there's no way for a control domain to write to this MSR ATM, as the allowed list in hvm_load_cpu_msrs doesn't contain HV_X64_MSR_EOI.
Thanks, Roger.