xen/dom0: Fix latent dom0 construction bugs on all architectures
PATCH 1/1 xen/dom0: Fix latent dom0 construction bugs on all architectures
* x86 PV and ARM dom0's must not clear _VPF_down from v->pause_flags until all state is actually set up. As it currently stands, d0v0 is eligible for scheduling before its registers have been set. This is latent as we also hold a systemcontroller pause reference at the time which prevents d0 from being scheduled.
* x86 PVH dom0's must set v->is_initialised on d0v0, to prevent another vcpu being able to call VCPUOP_initialise and modify state under the feet of the running vcpu. This is latent as PVH dom0 construction don't yet function.
---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
--- xen/arch/arm/domain_build.c | 6 +++--- xen/arch/x86/dom0_build.c | 13 +++++++++++-- xen/arch/x86/hvm/dom0_build.c | 1 + xen/arch/x86/pv/dom0_build.c | 6 +++--- 4 files changed, 18 insertions(+), 8 deletions(-)
xen/arch/arm/domain_build.c +3 -3
@@ -2197,9 +2197,6 @@ int construct_dom0(struct domain *d)discard_initial_modules (); - v->is_initialised =1 ; -clear_bit (_VPF_down, &v->pause_flags); -memset (regs,0 ,sizeof (*regs)); regs->pc = (register_t )kinfo.entry;
@@ -2247,6 +2244,9 @@ int construct_dom0(struct domain *d)vcpu_switch_to_aarch64_mode (d->vcpu[i]); } + v->is_initialised =1 ; +clear_bit (_VPF_down, &v->pause_flags); +return 0 ; }
xen/arch/x86/dom0_build.c +11 -2
@@ -466,6 +466,8 @@ int __init construct_dom0(struct domain *d, const module_t *image,void *(*bootstrap_map)(const module_t *), char *cmdline) { + int rc; +/* Sanity! */ BUG_ON (d->domain_id !=0 );BUG_ON (d->vcpu[0 ] ==NULL );
@@ -481,8 +483,15 @@ int __init construct_dom0(struct domain *d, const module_t *image, }#endif -return (is_hvm_domain (d) ? dom0_construct_pvh : dom0_construct_pv) - (d, image, image_headroom, initrd,bootstrap_map, cmdline); + rc = (is_hvm_domain (d) ? dom0_construct_pvh : dom0_construct_pv) + (d, image, image_headroom, initrd, bootstrap_map, cmdline); +if ( rc ) +return rc; + +/* Sanity! */ +BUG_ON (!d->vcpu[0 ]->is_initialised); + +return 0 ; }/*
xen/arch/x86/hvm/dom0_build.c +1 -0
@@ -614,6 +614,7 @@ static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,update_domain_wallclock_time (d); + v->is_initialised =1 ;clear_bit (_VPF_down, &v->pause_flags);return 0 ;
xen/arch/x86/pv/dom0_build.c +3 -3
@@ -847,9 +847,6 @@ int __init dom0_construct_pv(struct domain *d,update_domain_wallclock_time (d); - v->is_initialised =1 ; -clear_bit (_VPF_down, &v->pause_flags); -/* * Initial register values: * DS,ES,FS,GS = FLAT_KERNEL_DS
@@ -883,6 +880,9 @@ int __init dom0_construct_pv(struct domain *d,if ( d->domain_id == hardware_domid )iommu_hwdom_init (d); + v->is_initialised =1 ; +clear_bit (_VPF_down, &v->pause_flags); +return 0 ; out:
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 10 lines · Andrew Cooper
* x86 PV and ARM dom0's must not clear
_VPF_downfromv->pause_flagsuntil all state is actually set up. As it currently stands, d0v0 is eligible for scheduling before its registers have been set. This is latent as we also hold a systemcontroller pause reference at the time which prevents d0 from being scheduled.* x86 PVH dom0's must set
v->is_initialisedon d0v0, to prevent another vcpu being able to callVCPUOP_initialiseand modify state under the feet of the running vcpu. This is latent as PVH dom0 construction don't yet function.
While I think this patch is a good idea, the above paragraph confuses
me: I did boot PVH Dom0 at one point so it did function; I also never triggered a bug like the one described here.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 7 lines · Wei Liu
Quoted 6 lines · Andrew Cooper
* x86 PV and ARM dom0's must not clear
_VPF_downfromv->pause_flagsuntil all state is actually set up. As it currently stands, d0v0 is eligible for scheduling before its registers have been set. This is latent as we also hold a systemcontroller pause reference at the time which prevents d0 from being scheduled.
Quoted 7 lines
Quoted 4 lines
* x86 PVH dom0's must set
v->is_initialisedon d0v0, to prevent another vcpu being able to callVCPUOP_initialiseand modify state under the feet of the running vcpu. This is latent as PVH dom0 construction don't yet function.While I think this patch is a good idea, the above paragraph confuses
me: I did boot PVH Dom0 at one point so it did function; I also never triggered a bug like the one described here.
Strictly speaking, this is the PVH v2 dom0 path, not the legacy PVH dom0 path.
The bottom of dom0_construct_pvh() currently has:
...
panic("Building a PVHv2 Dom0 is not yet supported."); return 0;
}
As for the v->is_initialised, a well behaved dom0 wouldn't hit the issue, because it wouldn't call VCPUOP_initialise against a running vcpu. Nevertheless, it is relevant to Xen's security that such an attempt doesn't get to the point of actually trying to edit the VMC{S,B} under a running vcpu.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 19 lines · Andrew Cooper
Quoted 7 lines · Wei Liu
Quoted 6 lines · Andrew Cooper
* x86 PV and ARM dom0's must not clear
_VPF_downfromv->pause_flagsuntil all state is actually set up. As it currently stands, d0v0 is eligible for scheduling before its registers have been set. This is latent as we also hold a systemcontroller pause reference at the time which prevents d0 from being scheduled.Quoted 7 lines
Quoted 4 lines
* x86 PVH dom0's must set
v->is_initialisedon d0v0, to prevent another vcpu being able to callVCPUOP_initialiseand modify state under the feet of the running vcpu. This is latent as PVH dom0 construction don't yet function.While I think this patch is a good idea, the above paragraph confuses
me: I did boot PVH Dom0 at one point so it did function; I also never triggered a bug like the one described here.Strictly speaking, this is the PVH v2 dom0 path, not the legacy PVH dom0 path.
Quoted 7 lines
The bottom of
dom0_construct_pvh()currently has:...
panic("Building a PVHv2 Dom0 is not yet supported."); return 0;
}
Oh yes, I was using a development branch.
Quoted 6 lines
As for the
v->is_initialised, a well behaved dom0 wouldn't hit the issue, because it wouldn't callVCPUOP_initialiseagainst a running vcpu. Nevertheless, it is relevant to Xen's security that such an attempt doesn't get to the point of actually trying to edit the VMC{S,B} under a running vcpu.
Right.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 31 lines
Quoted 1 line
Quoted 1 line · On 16.10.17 at 16:49, <[email protected]> wrote:
Quoted 3 lines · Wei Liu
Quoted 2 lines · Andrew Cooper
* x86 PV and ARM dom0's must not clear
_VPF_downfromv->pause_flagsuntil all state is actually set up. As it currently stands, d0v0 is eligiblefor
Quoted 2 lines
Quoted 2 lines
scheduling before its registers have been set. This is latent as we also hold a systemcontroller pause reference at the time which prevents d0
from
Quoted 4 lines
Quoted 4 lines
being scheduled.
* x86 PVH dom0's must set
v->is_initialisedon d0v0, to prevent another vcpu being able to callVCPUOP_initialiseand modify state under the feet ofthe
Quoted 1 line
Quoted 1 line
running vcpu. This is latent as PVH dom0 construction don't yet
function.
Quoted 4 lines
Quoted 1 line
While I think this patch is a good idea, the above paragraph confuses
me: I did boot PVH Dom0 at one point so it did function; I also never triggered a bug like the one described here.Strictly speaking, this is the PVH v2 dom0 path, not the legacy PVH dom0 path.
The bottom of
dom0_construct_pvh()currently has:...
panic("Building a PVHv2 Dom0 is not yet supported."); return 0; }
Quoted 5 lines
As for the
v->is_initialised, a well behaved dom0 wouldn't hit the issue, because it wouldn't callVCPUOP_initialiseagainst a running vcpu. Nevertheless, it is relevant to Xen's security that such an attempt doesn't get to the point of actually trying to edit the VMC{S,B} under a running vcpu.
I don't understand this reply of yours: The changes you make are for vCPU 0 only, and even there only for its initial state. Even if Dom0 decided to bring down and back up that vCPU, it would go through a different path.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 29 lines · Jan Beulich
Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 16.10.17 at 16:49, <[email protected]> wrote:
Quoted 3 lines · Wei Liu
Quoted 2 lines · Andrew Cooper
* x86 PV and ARM dom0's must not clear
_VPF_downfromv->pause_flagsuntil all state is actually set up. As it currently stands, d0v0 is eligiblefor
Quoted 2 lines
Quoted 2 lines
scheduling before its registers have been set. This is latent as we also hold a systemcontroller pause reference at the time which prevents d0
from
Quoted 4 lines
Quoted 4 lines
being scheduled.
* x86 PVH dom0's must set
v->is_initialisedon d0v0, to prevent another vcpu being able to callVCPUOP_initialiseand modify state under the feet ofthe
Quoted 1 line
Quoted 1 line
running vcpu. This is latent as PVH dom0 construction don't yet
function.
Quoted 3 lines
While I think this patch is a good idea, the above paragraph confuses
me: I did boot PVH Dom0 at one point so it did function; I also never triggered a bug like the one described here.Strictly speaking, this is the PVH v2 dom0 path, not the legacy PVH dom0 path.
The bottom of
dom0_construct_pvh()currently has:...
panic("Building a PVHv2 Dom0 is not yet supported."); return 0; }
Quoted 7 lines
Quoted 5 lines
As for the
v->is_initialised, a well behaved dom0 wouldn't hit the issue, because it wouldn't callVCPUOP_initialiseagainst a running vcpu. Nevertheless, it is relevant to Xen's security that such an attempt doesn't get to the point of actually trying to edit the VMC{S,B} under a running vcpu.I don't understand this reply of yours: The changes you make are for vCPU 0 only, and even there only for its initial state.
Correct.
Quoted 2 lines
Even if Dom0 decided to bring down and back up that vCPU, it would go through a different path.
Correct as well, but unrelated to the bug.
The bug is that, at the moment, d0v1 can make a blind VCPUOP_initialise call targeting d0v0, while d0v0 is running, and it will go and rewrite state. The problem is that d0v0 starts running in a way that VCPUOP_initialise believes it to be eligible for initialisation.
All other mechanisms of bringing a vcpu down and up cause there to be proper isolation between playing with a vcpus state, and it being unscheduled.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
xen/arch/x86/hvm/dom0_build.c static int __init pvh_setup_cpus(struct domain *d, paddr_t entry, · line 618
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.10.17 at 16:38, <[email protected]> wrote:
xen/arch/x86/hvm/dom0_build.c +1
-0@@ -614,6 +614,7 @@ static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,update_domain_wallclock_time (d); + v->is_initialised =1 ;clear_bit (_VPF_down, &v->pause_flags);
How come this has no counterpart of code being deleted?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 10 lines · Jan Beulich
xen/arch/x86/hvm/dom0_build.c static int __init pvh_setup_cpus(struct domain *d, paddr_t entry, · line 618
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.10.17 at 16:38, <[email protected]> wrote:
xen/arch/x86/hvm/dom0_build.c +1
-0@@ -614,6 +614,7 @@ static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,update_domain_wallclock_time (d); + v->is_initialised =1 ;clear_bit (_VPF_down, &v->pause_flags);How come this has no counterpart of code being deleted?
Because the bug is that it was never being set before.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Jan Beulich
Reviewed-byQuoted 7 lines
Quoted 1 line
Quoted 1 line · On 16.10.17 at 18:07, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 16.10.17 at 16:38, <[email protected]> wrote:
xen/arch/x86/hvm/dom0_build.c +0
-0@@ -614,6 +614,7 @@ static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,
Quoted 7 lines
Quoted 5 lines
xen/arch/x86/hvm/dom0_build.c static int __init pvh_setup_cpus(struct domain *d, paddr_t entry, · line 618
Quoted 4 lines
xen/arch/x86/hvm/dom0_build.c +1
-0update_domain_wallclock_time (d); + v->is_initialised =1 ;clear_bit (_VPF_down, &v->pause_flags);How come this has no counterpart of code being deleted?
Because the bug is that it was never being set before.
Oh, I see - I had read that part of the commit message in slightly a wrong way.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 16.10.17 at 18:07, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 16.10.17 at 16:38, <[email protected]> wrote:
xen/arch/x86/hvm/dom0_build.c +0
-0@@ -614,6 +614,7 @@ static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,update_domain_wallclock_time (d);
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
xen/arch/x86/hvm/dom0_build.c static int __init pvh_setup_cpus(struct domain *d, paddr_t entry, · line 618
Quoted 2 lines
xen/arch/x86/hvm/dom0_build.c +1
-0+ v->is_initialised =1 ;clear_bit (_VPF_down, &v->pause_flags);How come this has no counterpart of code being deleted?
Because the bug is that it was never being set before.
Oh, I see - I had read that part of the commit message in slightly a wrong way.
Reviewed-by Jan Beulich <[email protected]>
How about this for an adjusted commit message?
* x86 PVH previously was not setting v->is_initialised for d0v0, despite setting the vcpu running eventually. Therefore, a later VCPUOP_initialise hypercall will modify state under the feet of the running vcpu. This is latent as PVH dom0 construction don't yet function.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 17.10.17 at 12:38, <[email protected]> wrote:
Quoted 16 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 16.10.17 at 18:07, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 16.10.17 at 16:38, <[email protected]> wrote:
xen/arch/x86/hvm/dom0_build.c +0
-0@@ -614,6 +614,7 @@ static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,Quoted 6 lines
Quoted 5 lines
xen/arch/x86/hvm/dom0_build.c static int __init pvh_setup_cpus(struct domain *d, paddr_t entry, · line 618
Quoted 4 lines
xen/arch/x86/hvm/dom0_build.c +1
-0update_domain_wallclock_time (d); + v->is_initialised =1 ;clear_bit (_VPF_down, &v->pause_flags);How come this has no counterpart of code being deleted?
Because the bug is that it was never being set before.
Oh, I see - I had read that part of the commit message in slightly a wrong way.
Quoted 8 lines
Quoted 1 line
Reviewed-by Jan Beulich <[email protected]>How about this for an adjusted commit message?
* x86 PVH previously was not setting
v->is_initialisedfor d0v0, despite setting the vcpu running eventually. Therefore, a laterVCPUOP_initialisehypercall will modify state under the feet of the running vcpu. This is latent as PVH dom0 construction don't yet function.
Yes, thanks.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 11 lines · Andrew Cooper
* x86 PV and ARM dom0's must not clear
_VPF_downfromv->pause_flagsuntil all state is actually set up. As it currently stands, d0v0 is eligible for scheduling before its registers have been set. This is latent as we also hold a systemcontroller pause reference at the time which prevents d0 from being scheduled.* x86 PVH dom0's must set
v->is_initialisedon d0v0, to prevent another vcpu being able to callVCPUOP_initialiseand modify state under the feet of the running vcpu. This is latent as PVH dom0 construction don't yet function.Signed-off-by Andrew Cooper <[email protected]>
LGTM, just one question.
xen/arch/x86/hvm/dom0_build.c static int __init pvh_setup_cpus(struct domain *d, paddr_t entry, · line 618
Quoted 10 lines
xen/arch/x86/hvm/dom0_build.c +1
-0@@ -614,6 +614,7 @@ static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,update_domain_wallclock_time (d); + v->is_initialised =1 ;clear_bit (_VPF_down, &v->pause_flags);
Don't you want to move this to the end of dom0_construct_pvh? In any case, at this point the vCPU state is already setup correctly.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 20 lines · Roger Pau Monné
Quoted 11 lines · Andrew Cooper
* x86 PV and ARM dom0's must not clear
_VPF_downfromv->pause_flagsuntil all state is actually set up. As it currently stands, d0v0 is eligible for scheduling before its registers have been set. This is latent as we also hold a systemcontroller pause reference at the time which prevents d0 from being scheduled.* x86 PVH dom0's must set
v->is_initialisedon d0v0, to prevent another vcpu being able to callVCPUOP_initialiseand modify state under the feet of the running vcpu. This is latent as PVH dom0 construction don't yet function.Signed-off-by Andrew Cooper <[email protected]>LGTM, just one question.
Quoted 6 lines
xen/arch/x86/hvm/dom0_build.c +0
-0@@ -614,6 +614,7 @@ static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,
Quoted 6 lines
xen/arch/x86/hvm/dom0_build.c static int __init pvh_setup_cpus(struct domain *d, paddr_t entry, · line 618
Quoted 4 lines
xen/arch/x86/hvm/dom0_build.c +1
-0update_domain_wallclock_time (d); + v->is_initialised =1 ;clear_bit (_VPF_down, &v->pause_flags);Don't you want to move this to the end of
dom0_construct_pvh? In any case, at this point the vCPU state is already setup correctly.
I had considered that, but a) As you say, it only matters when the vcpu state is set up, and b) it would look odd being anywhere later.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 11 lines · Andrew Cooper
* x86 PV and ARM dom0's must not clear
_VPF_downfromv->pause_flagsuntil all state is actually set up. As it currently stands, d0v0 is eligible for scheduling before its registers have been set. This is latent as we also hold a systemcontroller pause reference at the time which prevents d0 from being scheduled.* x86 PVH dom0's must set
v->is_initialisedon d0v0, to prevent another vcpu being able to callVCPUOP_initialiseand modify state under the feet of the running vcpu. This is latent as PVH dom0 construction don't yet function.Signed-off-by Andrew Cooper <[email protected]>
ARM bits:
Quoted 107 lines
---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>--- xen/arch/arm/domain_build.c | 6 +++--- xen/arch/x86/dom0_build.c | 13 +++++++++++-- xen/arch/x86/hvm/dom0_build.c | 1 + xen/arch/x86/pv/dom0_build.c | 6 +++--- 4 files changed, 18 insertions(+), 8 deletions(-)xen/arch/arm/domain_build.c +3
-3@@ -2197,9 +2197,6 @@ int construct_dom0(struct domain *d)discard_initial_modules (); - v->is_initialised =1 ; -clear_bit (_VPF_down, &v->pause_flags); -memset (regs,0 ,sizeof (*regs)); regs->pc = (register_t )kinfo.entry;@@ -2247,6 +2244,9 @@ int construct_dom0(struct domain *d)vcpu_switch_to_aarch64_mode (d->vcpu[i]); } + v->is_initialised =1 ; +clear_bit (_VPF_down, &v->pause_flags); +return 0 ; }xen/arch/x86/dom0_build.c +11
-2@@ -466,6 +466,8 @@ int __init construct_dom0(struct domain *d, const module_t *image,void *(*bootstrap_map)(const module_t *), char *cmdline) { + int rc; +/* Sanity! */ BUG_ON (d->domain_id !=0 );BUG_ON (d->vcpu[0 ] ==NULL );@@ -481,8 +483,15 @@ int __init construct_dom0(struct domain *d, const module_t *image, }#endif -return (is_hvm_domain (d) ? dom0_construct_pvh : dom0_construct_pv) - (d, image, image_headroom, initrd,bootstrap_map, cmdline); + rc = (is_hvm_domain (d) ? dom0_construct_pvh : dom0_construct_pv) + (d, image, image_headroom, initrd, bootstrap_map, cmdline); +if ( rc ) +return rc; + +/* Sanity! */ +BUG_ON (!d->vcpu[0 ]->is_initialised); + +return 0 ; }/* xen/arch/x86/hvm/dom0_build.c +1
-0@@ -614,6 +614,7 @@ static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,update_domain_wallclock_time (d); + v->is_initialised =1 ;clear_bit (_VPF_down, &v->pause_flags);return 0 ;xen/arch/x86/pv/dom0_build.c +3
-3@@ -847,9 +847,6 @@ int __init dom0_construct_pv(struct domain *d,update_domain_wallclock_time (d); - v->is_initialised =1 ; -clear_bit (_VPF_down, &v->pause_flags); -/* * Initial register values: * DS,ES,FS,GS = FLAT_KERNEL_DS @@ -883,6 +880,9 @@ int __init dom0_construct_pv(struct domain *d,if ( d->domain_id == hardware_domid )iommu_hwdom_init (d); + v->is_initialised =1 ; +clear_bit (_VPF_down, &v->pause_flags); +return 0 ; out:Signature · 1 line
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 11 lines · Andrew Cooper
* x86 PV and ARM dom0's must not clear
_VPF_downfromv->pause_flagsuntil all state is actually set up. As it currently stands, d0v0 is eligible for scheduling before its registers have been set. This is latent as we also hold a systemcontroller pause reference at the time which prevents d0 from being scheduled.* x86 PVH dom0's must set
v->is_initialisedon d0v0, to prevent another vcpu being able to callVCPUOP_initialiseand modify state under the feet of the running vcpu. This is latent as PVH dom0 construction don't yet function.Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Hi Andrew,
Quoted 11 lines · Andrew Cooper
* x86 PV and ARM dom0's must not clear
_VPF_downfromv->pause_flagsuntil all state is actually set up. As it currently stands, d0v0 is eligible for scheduling before its registers have been set. This is latent as we also hold a systemcontroller pause reference at the time which prevents d0 from being scheduled.* x86 PVH dom0's must set
v->is_initialisedon d0v0, to prevent another vcpu being able to callVCPUOP_initialiseand modify state under the feet of the running vcpu. This is latent as PVH dom0 construction don't yet function.Signed-off-by Andrew Cooper <[email protected]>
Cheers,
Quoted 105 lines
---
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>--- xen/arch/arm/domain_build.c | 6 +++--- xen/arch/x86/dom0_build.c | 13 +++++++++++-- xen/arch/x86/hvm/dom0_build.c | 1 + xen/arch/x86/pv/dom0_build.c | 6 +++--- 4 files changed, 18 insertions(+), 8 deletions(-)xen/arch/arm/domain_build.c +3
-3@@ -2197,9 +2197,6 @@ int construct_dom0(struct domain *d)discard_initial_modules (); - v->is_initialised =1 ; -clear_bit (_VPF_down, &v->pause_flags); -memset (regs,0 ,sizeof (*regs)); regs->pc = (register_t )kinfo.entry;@@ -2247,6 +2244,9 @@ int construct_dom0(struct domain *d)vcpu_switch_to_aarch64_mode (d->vcpu[i]); } + v->is_initialised =1 ; +clear_bit (_VPF_down, &v->pause_flags); +return 0 ; }xen/arch/x86/dom0_build.c +11
-2@@ -466,6 +466,8 @@ int __init construct_dom0(struct domain *d, const module_t *image,void *(*bootstrap_map)(const module_t *), char *cmdline) { + int rc; +/* Sanity! */ BUG_ON (d->domain_id !=0 );BUG_ON (d->vcpu[0 ] ==NULL );@@ -481,8 +483,15 @@ int __init construct_dom0(struct domain *d, const module_t *image, }#endif -return (is_hvm_domain (d) ? dom0_construct_pvh : dom0_construct_pv) - (d, image, image_headroom, initrd,bootstrap_map, cmdline); + rc = (is_hvm_domain (d) ? dom0_construct_pvh : dom0_construct_pv) + (d, image, image_headroom, initrd, bootstrap_map, cmdline); +if ( rc ) +return rc; + +/* Sanity! */ +BUG_ON (!d->vcpu[0 ]->is_initialised); + +return 0 ; }/* xen/arch/x86/hvm/dom0_build.c +1
-0@@ -614,6 +614,7 @@ static int __init pvh_setup_cpus(struct domain *d, paddr_t entry,update_domain_wallclock_time (d); + v->is_initialised =1 ;clear_bit (_VPF_down, &v->pause_flags);return 0 ;xen/arch/x86/pv/dom0_build.c +3
-3@@ -847,9 +847,6 @@ int __init dom0_construct_pv(struct domain *d,update_domain_wallclock_time (d); - v->is_initialised =1 ; -clear_bit (_VPF_down, &v->pause_flags); -/* * Initial register values: * DS,ES,FS,GS = FLAT_KERNEL_DS @@ -883,6 +880,9 @@ int __init dom0_construct_pv(struct domain *d,if ( d->domain_id == hardware_domid )iommu_hwdom_init (d); + v->is_initialised =1 ; +clear_bit (_VPF_down, &v->pause_flags); +return 0 ; out:
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel