x86/vcpu: relax VCPUOP_initialise restriction for non-PV vCPUs
PATCH 1/1 x86/vcpu: relax VCPUOP_initialise restriction for non-PV vCPUs
There's no reason to force HVM guests to have a valid vcpu_info area when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement for vcpu_info to be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use of vcpu_info.
Restrict the check against dummy_vcpu_info to only apply to PV guests.
--- xen/common/compat/domain.c | 2 +- xen/common/domain.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
xen/common/compat/domain.c +1 -1
@@ -49,7 +49,7 @@ int compat_common_vcpu_op(int cmd, struct vcpu *v, {case VCPUOP_initialise: { -if ( v->vcpu_info_area.map == &dummy_vcpu_info ) +if (is_pv_domain (d) && v->vcpu_info_area.map == &dummy_vcpu_info )return -EINVAL ;#ifdef CONFIG_HVM
xen/common/domain.c +1 -1
@@ -1817,7 +1817,7 @@ long common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg)switch ( cmd ) {case VCPUOP_initialise: -if ( v->vcpu_info_area.map == &dummy_vcpu_info ) +if (is_pv_domain (d) && v->vcpu_info_area.map == &dummy_vcpu_info )return -EINVAL ; rc =arch_initialise_vcpu (v, arg);
Signature · 1 line
2.44.0
Quoted 10 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.Restrict the check against
dummy_vcpu_infoto only apply to PV guests.Fixes 192df6f9122d ('x86: allow HVM guests to use hypercalls to bring up vCPUs')Signed-off-by Roger Pau Monné <[email protected]>
Thanks for looking into this. But, do we actually need to force this on PV either?
The only interesting user of dummy_vcpu_info now is vcpu_info_populate() which can cope with any arbitrary vCPU.
I have a suspicion that we can (now) delete these two checks, delete the dummy_vcpu_info object, and use a regular NULL pointer in vcpu_info_{populate,reset}(), and in doing so, remove one of the bigger pieces of PV-absurdity from Xen.
I can entirely believe that this is only safe to do with Jan's physical registration changes in place.
~Andrew
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.
Quoted 7 lines
Quoted 4 lines
Restrict the check against
dummy_vcpu_infoto only apply to PV guests.Fixes 192df6f9122d ('x86: allow HVM guests to use hypercalls to bring up vCPUs')Signed-off-by Roger Pau Monné <[email protected]>Thanks for looking into this. But, do we actually need to force this on PV either?
Possibly, having now taken a look at the users it does seem they could cope with unpopulated vcpu_info_area.
Part of my understanding was that this was some kind of courtesy to PV guests in order to prevent starting them without a vcpu_info, which strictly speaking is not mandatory, but otherwise the guest vCPU won't be able to receive interrupts, not even IPIs.
Quoted 7 lines
The only interesting user of
dummy_vcpu_infonow isvcpu_info_populate()which can cope with any arbitrary vCPU.I have a suspicion that we can (now) delete these two checks, delete the
dummy_vcpu_infoobject, and use a regular NULL pointer in vcpu_info_{populate,reset}(), and in doing so, remove one of the bigger pieces of PV-absurdity from Xen.
I was expecting this to be something we can backport. OTOH removing the check completely (or even getting rid of dummy_vcpu_info) is not something that we would want to backport.
I would rather do the removal of dummy_vcpu_info as followup work.
Quoted 2 lines
I can entirely believe that this is only safe to do with Jan's physical registration changes in place.
Quite possible.
Thanks, Roger.
Quoted 14 lines · Roger Pau Monné
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.Quoted 6 lines
Quoted 4 lines
Restrict the check against
dummy_vcpu_infoto only apply to PV guests.Fixes 192df6f9122d ('x86: allow HVM guests to use hypercalls to bring up vCPUs')Signed-off-by Roger Pau Monné <[email protected]>Thanks for looking into this. But, do we actually need to force this on PV either?
Quoted 7 lines
Possibly, having now taken a look at the users it does seem they could cope with unpopulated
vcpu_info_area.Part of my understanding was that this was some kind of courtesy to PV guests in order to prevent starting them without a
vcpu_info, which strictly speaking is not mandatory, but otherwise the guest vCPU won't be able to receive interrupts, not even IPIs.
That's more of a stick than a carrot... "you must set up the area of a CPU before you can bring it online". Except as we've seen, HVM has been fine all along without it.
Quoted 7 lines
Quoted 7 lines
The only interesting user of
dummy_vcpu_infonow isvcpu_info_populate()which can cope with any arbitrary vCPU.I have a suspicion that we can (now) delete these two checks, delete the
dummy_vcpu_infoobject, and use a regular NULL pointer in vcpu_info_{populate,reset}(), and in doing so, remove one of the bigger pieces of PV-absurdity from Xen.
Quoted 5 lines
I was expecting this to be something we can backport. OTOH removing the check completely (or even getting rid of
dummy_vcpu_info) is not something that we would want to backport.I would rather do the removal of
dummy_vcpu_infoas followup work.
I was worried about ARM with your patch, because it's spelt HVM there, rather than PV.
However, I'd forgotten that ARM's do_vcpu_op() filters ops down to just VCPUOP_register_{vcpu_info,runstate_memory_area} so VCPUOP_initialise isn't reachable.
Therefore, Reviewed-by: Andrew Cooper <[email protected]>
It also means ARM can't use any of the PHYS registration yet...
~Andrew
Hi Andrew,
Quoted 42 lines · Andrew Cooper
Quoted 14 lines · Roger Pau Monné
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.Quoted 6 lines
Quoted 4 lines
Restrict the check against
dummy_vcpu_infoto only apply to PV guests.Fixes 192df6f9122d ('x86: allow HVM guests to use hypercalls to bring up vCPUs')Signed-off-by Roger Pau Monné <[email protected]>Thanks for looking into this. But, do we actually need to force this on PV either?
Quoted 7 lines
Possibly, having now taken a look at the users it does seem they could cope with unpopulated
vcpu_info_area.Part of my understanding was that this was some kind of courtesy to PV guests in order to prevent starting them without a
vcpu_info, which strictly speaking is not mandatory, but otherwise the guest vCPU won't be able to receive interrupts, not even IPIs.That's more of a stick than a carrot... "you must set up the area of a CPU before you can bring it online". Except as we've seen, HVM has been fine all along without it.
Quoted 7 lines
Quoted 7 lines
The only interesting user of
dummy_vcpu_infonow isvcpu_info_populate()which can cope with any arbitrary vCPU.I have a suspicion that we can (now) delete these two checks, delete the
dummy_vcpu_infoobject, and use a regular NULL pointer in vcpu_info_{populate,reset}(), and in doing so, remove one of the bigger pieces of PV-absurdity from Xen.Quoted 5 lines
I was expecting this to be something we can backport. OTOH removing the check completely (or even getting rid of
dummy_vcpu_info) is not something that we would want to backport.I would rather do the removal of
dummy_vcpu_infoas followup work.I was worried about ARM with your patch, because it's spelt HVM there, rather than PV.
Quoted 7 lines
However, I'd forgotten that ARM's
do_vcpu_op()filters ops down to just VCPUOP_register_{vcpu_info,runstate_memory_area} soVCPUOP_initialiseisn't reachable.Therefore, Reviewed-by: Andrew Cooper <[email protected]>
It also means ARM can't use any of the PHYS registration yet...
Whoops. I don't think this was intended. Jan, I don't seem to find any use in Linux. Do you have any patches you could share? I would like to give a try on Arm before sending a patch?
Cheers,
Signature · 1 line
Julien Grall
Quoted 49 lines · Julien Grall
Hi Andrew,
Quoted 46 lines · Andrew Cooper
Quoted 14 lines · Roger Pau Monné
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.Quoted 6 lines
Quoted 4 lines
Restrict the check against
dummy_vcpu_infoto only apply to PV guests.Fixes 192df6f9122d ('x86: allow HVM guests to use hypercalls to bring up vCPUs')Signed-off-by Roger Pau Monné <[email protected]>Thanks for looking into this. But, do we actually need to force this on PV either?
Quoted 7 lines
Possibly, having now taken a look at the users it does seem they could cope with unpopulated
vcpu_info_area.Part of my understanding was that this was some kind of courtesy to PV guests in order to prevent starting them without a
vcpu_info, which strictly speaking is not mandatory, but otherwise the guest vCPU won't be able to receive interrupts, not even IPIs.That's more of a stick than a carrot... "you must set up the area of a CPU before you can bring it online". Except as we've seen, HVM has been fine all along without it.
Quoted 7 lines
Quoted 7 lines
The only interesting user of
dummy_vcpu_infonow isvcpu_info_populate()which can cope with any arbitrary vCPU.I have a suspicion that we can (now) delete these two checks, delete the
dummy_vcpu_infoobject, and use a regular NULL pointer in vcpu_info_{populate,reset}(), and in doing so, remove one of the bigger pieces of PV-absurdity from Xen.Quoted 5 lines
I was expecting this to be something we can backport. OTOH removing the check completely (or even getting rid of
dummy_vcpu_info) is not something that we would want to backport.I would rather do the removal of
dummy_vcpu_infoas followup work.I was worried about ARM with your patch, because it's spelt HVM there, rather than PV.
However, I'd forgotten that ARM's
do_vcpu_op()filters ops down to just VCPUOP_register_{vcpu_info,runstate_memory_area} soVCPUOP_initialiseisn't reachable.
Quoted 6 lines
Quoted 3 lines
Therefore, Reviewed-by: Andrew Cooper <[email protected]>
It also means ARM can't use any of the PHYS registration yet...
Whoops. I don't think this was intended. Jan, I don't seem to find any use in Linux. Do you have any patches you could share?
No, I don't. I did all development with hacked up XTF tests, and I was expecting Linux folks to be looking into making use of the new subops.
Jan
Quoted 5 lines
I would like to
give a try on Arm before sending a patch?Cheers,
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.Restrict the check against
dummy_vcpu_infoto only apply to PV guests.
Quoted 8 lines
Quoted 2 lines
Fixes 192df6f9122d ('x86: allow HVM guests to use hypercalls to bring up vCPUs')Signed-off-by Roger Pau Monné <[email protected]>Thanks for looking into this. But, do we actually need to force this on PV either?
The only interesting user of
dummy_vcpu_infonow isvcpu_info_populate()which can cope with any arbitrary vCPU.
Why would that be the only interesting user? If we were to ...
Quoted 4 lines
I have a suspicion that we can (now) delete these two checks, delete the
dummy_vcpu_infoobject, and use a regular NULL pointer in vcpu_info_{populate,reset}(), and in doing so, remove one of the bigger pieces of PV-absurdity from Xen.
... use NULL pointers instead, we'd need to audit all Xen's vcpu_info accesses for properly avoiding to de-reference that NULL. The dummy struct instance was really meant as a safety belt (besides also acting as a sentinel).
Quoted 2 lines
I can entirely believe that this is only safe to do with Jan's physical registration changes in place.
Which nobody uses just yet, afaik.
Jan
Quoted 5 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.
While I'd agree if you started with "There's no real need to force ...", I still think there is a reason: If one wants to use paravirt interfaces (i.e. hypercalls), they would better do so consistently. After all there's also no need to use VCPUOP_initialise, yet you're not disabling its use.
As said in reply to Andrew's reply, besides acting as a sentinel that structure instance also acts as a sink for Xen accesses to a vCPU's vcpu_info. By removing the check, you switch that from being a safeguard to being something that actually has to be expected to be accessed. Unless you've audited all uses to prove that no such access exists.
Jan
Quoted 10 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.While I'd agree if you started with "There's no real need to force ...", I still think there is a reason: If one wants to use paravirt interfaces (i.e. hypercalls), they would better do so consistently. After all there's also no need to use
VCPUOP_initialise, yet you're not disabling its use.
I firmly disagree.
There are good reasons to use VCPUOP_initialise over INIT-SIPI-SIPI (like avoiding 16bit mode - in the case we want it here, to fix APIC_ID enumeration in a way that doesn't involve putting more complexity into HVMLoader), and forcing us to set up a useless structure before we can boot vCPU number 32 is just wrong.
It was dumb to design a hypercall like this in the first place for PV guests, and it definitely isn't OK to keep guests broken because of it.
~Andrew
Quoted 12 lines · Andrew Cooper
Quoted 10 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.While I'd agree if you started with "There's no real need to force ...", I still think there is a reason: If one wants to use paravirt interfaces (i.e. hypercalls), they would better do so consistently. After all there's also no need to use
VCPUOP_initialise, yet you're not disabling its use.
Quoted 7 lines
I firmly disagree.
There are good reasons to use
VCPUOP_initialiseover INIT-SIPI-SIPI (like avoiding 16bit mode - in the case we want it here, to fixAPIC_IDenumeration in a way that doesn't involve putting more complexity into HVMLoader), and forcing us to set up a useless structure before we can boot vCPU number 32 is just wrong.
Just to mention it: I can certainly accept this as one possible valid viewpoint, and my looking at it differently is not an objection to the patch. It's just that the other aspect mentioned needs sorting (perhaps by just extending the patch description).
Quoted 2 lines
It was dumb to design a hypercall like this in the first place for PV guests, and it definitely isn't OK to keep guests broken because of it.
And again just to mention it: Originally, with a vCPU limit of 32, all vCPU-s would reliably have had vcpu_info (by way of that being embedded in shared_info). When raising the limit, the goal was to not chance overlooking any vcpu_info access in Xen. Hence why, instead of putting a NULL pointer there (or perhaps some non-canonical sentinel), the dummy approach was chosen. It then seemed quite desirable to prevent vCPU-s coming online without them first being detached from that dummy structure. And I think this firmly needs to continue to hold for PV.
Jan
Quoted 12 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.While I'd agree if you started with "There's no real need to force ...", I still think there is a reason: If one wants to use paravirt interfaces (i.e. hypercalls), they would better do so consistently. After all there's also no need to use
VCPUOP_initialise, yet you're not disabling its use.
Quoted 5 lines
As said in reply to Andrew's reply, besides acting as a sentinel that structure instance also acts as a sink for Xen accesses to a vCPU's
vcpu_info. By removing the check, you switch that from being a safeguard to being something that actually has to be expected to be accessed. Unless you've audited all uses to prove that no such access exists.
I'm kind of lost in this last paragraph, how is that different than what currently happens when an HVM vCPU >= 32 is brought up using the lapic and has no vpcu_info mapped?
Also, from a quick look it seems like sites do check whether vcpu_info == dummy_vcpu_info, otherwise we would already be in trouble.
Thanks, Roger.
Quoted 19 lines · Roger Pau Monné
Quoted 12 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.While I'd agree if you started with "There's no real need to force ...", I still think there is a reason: If one wants to use paravirt interfaces (i.e. hypercalls), they would better do so consistently. After all there's also no need to use
VCPUOP_initialise, yet you're not disabling its use.Quoted 5 lines
As said in reply to Andrew's reply, besides acting as a sentinel that structure instance also acts as a sink for Xen accesses to a vCPU's
vcpu_info. By removing the check, you switch that from being a safeguard to being something that actually has to be expected to be accessed. Unless you've audited all uses to prove that no such access exists.
Quoted 3 lines
I'm kind of lost in this last paragraph, how is that different than what currently happens when an HVM vCPU >= 32 is brought up using the lapic and has no
vpcu_infomapped?
I think this aspect was simply missed back at the time. And I think it wants mentioning explicitly to justify the change.
As said in reply to Andrew, I don't think the dummy structure can be got rid of. Nor can the checks here be (easily) removed altogether, i.e. your change cannot (easily) be extended to PV as well. Even conditional removal of the structure in !PV builds would first require all vcpu_info accesses to gain a suitable conditional. Which may be undesirable, as some of these may be deemed fast paths.
Quoted 2 lines
Also, from a quick look it seems like sites do check whether
vcpu_info==dummy_vcpu_info, otherwise we would already be in trouble.
Such checks exist in code managing vcpu_info, but not - afaics - in places actually accessing it.
Jan
Quoted 20 lines · Jan Beulich
Quoted 19 lines · Roger Pau Monné
Quoted 17 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.While I'd agree if you started with "There's no real need to force ...", I still think there is a reason: If one wants to use paravirt interfaces (i.e. hypercalls), they would better do so consistently. After all there's also no need to use
VCPUOP_initialise, yet you're not disabling its use.As said in reply to Andrew's reply, besides acting as a sentinel that structure instance also acts as a sink for Xen accesses to a vCPU's
vcpu_info. By removing the check, you switch that from being a safeguard to being something that actually has to be expected to be accessed. Unless you've audited all uses to prove that no such access exists.
Quoted 6 lines
Quoted 3 lines
I'm kind of lost in this last paragraph, how is that different than what currently happens when an HVM vCPU >= 32 is brought up using the lapic and has no
vpcu_infomapped?I think this aspect was simply missed back at the time. And I think it wants mentioning explicitly to justify the change.
OK, I can add to the commit message:
"Note an HVM vCPU can operate normally without making use of vcpu_info, and in fact does so when brought up from the local APIC."
Quoted 6 lines
As said in reply to Andrew, I don't think the dummy structure can be got rid of. Nor can the checks here be (easily) removed altogether, i.e. your change cannot (easily) be extended to PV as well. Even conditional removal of the structure in !PV builds would first require all
vcpu_infoaccesses to gain a suitable conditional. Which may be undesirable, as some of these may be deemed fast paths.
I didn't intended to do this here, as replied to Andrew. If we want to get rid of the check for PV also it needs to be done in a different patch, and with a different justification and analysis.
Quoted 5 lines
Quoted 2 lines
Also, from a quick look it seems like sites do check whether
vcpu_info==dummy_vcpu_info, otherwise we would already be in trouble.Such checks exist in code managing
vcpu_info, but not - afaics - in places actually accessing it.
Quite possibly, I didn't look that close TBH, since my intention was not to remove dummy_vcpu_info. I've noticed however that __update_vcpu_system_time() checks for v->vcpu_info_area.map == NULL, which is fine, but shouldn't it also check for v->vcpu_info_area.map == &dummy_vcpu_info, as it's pointless to update the vcpu system time if pointing to the dummy_vcpu_info?
Thanks, Roger.
Quoted 25 lines · Roger Pau Monné
Quoted 24 lines · Jan Beulich
Quoted 22 lines · Roger Pau Monné
Quoted 12 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.While I'd agree if you started with "There's no real need to force ...", I still think there is a reason: If one wants to use paravirt interfaces (i.e. hypercalls), they would better do so consistently. After all there's also no need to use
VCPUOP_initialise, yet you're not disabling its use.Quoted 5 lines
As said in reply to Andrew's reply, besides acting as a sentinel that structure instance also acts as a sink for Xen accesses to a vCPU's
vcpu_info. By removing the check, you switch that from being a safeguard to being something that actually has to be expected to be accessed. Unless you've audited all uses to prove that no such access exists.I'm kind of lost in this last paragraph, how is that different than what currently happens when an HVM vCPU >= 32 is brought up using the lapic and has no
vpcu_infomapped?
Quoted 7 lines
Quoted 2 lines
I think this aspect was simply missed back at the time. And I think it wants mentioning explicitly to justify the change.
OK, I can add to the commit message:
"Note an HVM vCPU can operate normally without making use of
vcpu_info, and in fact does so when brought up from the local APIC."
I'd be fine adding this (or having this added) while committing.
Quoted 17 lines
Quoted 6 lines
As said in reply to Andrew, I don't think the dummy structure can be got rid of. Nor can the checks here be (easily) removed altogether, i.e. your change cannot (easily) be extended to PV as well. Even conditional removal of the structure in !PV builds would first require all
vcpu_infoaccesses to gain a suitable conditional. Which may be undesirable, as some of these may be deemed fast paths.I didn't intended to do this here, as replied to Andrew. If we want to get rid of the check for PV also it needs to be done in a different patch, and with a different justification and analysis.
Quoted 5 lines
Quoted 2 lines
Also, from a quick look it seems like sites do check whether
vcpu_info==dummy_vcpu_info, otherwise we would already be in trouble.Such checks exist in code managing
vcpu_info, but not - afaics - in places actually accessing it.
Quoted 6 lines
Quite possibly, I didn't look that close TBH, since my intention was not to remove
dummy_vcpu_info. I've noticed however that__update_vcpu_system_time()checks forv->vcpu_info_area.map== NULL, which is fine, but shouldn't it also check forv->vcpu_info_area.map==&dummy_vcpu_info, as it's pointless to update the vcpu system time if pointing to thedummy_vcpu_info?
The check is there to guard against NULL deref. As said, the aspect of a vCPU being brought up the "native" way yet then still using its vCPU info was, by mistake, neglected earlier on. So yes, such a check could be added here, but it isn't strictly necessary as long as we don't avoid accessing the dummy structure uniformly everywhere (which, as said, I'm not sure we want to do).
Jan
Quoted 29 lines · Jan Beulich
Quoted 28 lines · Roger Pau Monné
Quoted 26 lines · Jan Beulich
Quoted 19 lines · Roger Pau Monné
Quoted 12 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.While I'd agree if you started with "There's no real need to force ...", I still think there is a reason: If one wants to use paravirt interfaces (i.e. hypercalls), they would better do so consistently. After all there's also no need to use
VCPUOP_initialise, yet you're not disabling its use.Quoted 5 lines
As said in reply to Andrew's reply, besides acting as a sentinel that structure instance also acts as a sink for Xen accesses to a vCPU's
vcpu_info. By removing the check, you switch that from being a safeguard to being something that actually has to be expected to be accessed. Unless you've audited all uses to prove that no such access exists.Quoted 3 lines
I'm kind of lost in this last paragraph, how is that different than what currently happens when an HVM vCPU >= 32 is brought up using the lapic and has no
vpcu_infomapped?I think this aspect was simply missed back at the time. And I think it wants mentioning explicitly to justify the change.
Quoted 23 lines
Quoted 4 lines
OK, I can add to the commit message:
"Note an HVM vCPU can operate normally without making use of
vcpu_info, and in fact does so when brought up from the local APIC."I'd be fine adding this (or having this added) while committing.
Quoted 16 lines
Quoted 6 lines
As said in reply to Andrew, I don't think the dummy structure can be got rid of. Nor can the checks here be (easily) removed altogether, i.e. your change cannot (easily) be extended to PV as well. Even conditional removal of the structure in !PV builds would first require all
vcpu_infoaccesses to gain a suitable conditional. Which may be undesirable, as some of these may be deemed fast paths.I didn't intended to do this here, as replied to Andrew. If we want to get rid of the check for PV also it needs to be done in a different patch, and with a different justification and analysis.
Quoted 5 lines
Quoted 2 lines
Also, from a quick look it seems like sites do check whether
vcpu_info==dummy_vcpu_info, otherwise we would already be in trouble.Such checks exist in code managing
vcpu_info, but not - afaics - in places actually accessing it.
Is there anything else that needs adjusting then, or are you happy to pick this up and adjust the commit message?
Quoted 7 lines
Quoted 6 lines
Quite possibly, I didn't look that close TBH, since my intention was not to remove
dummy_vcpu_info. I've noticed however that__update_vcpu_system_time()checks forv->vcpu_info_area.map== NULL, which is fine, but shouldn't it also check forv->vcpu_info_area.map==&dummy_vcpu_info, as it's pointless to update the vcpu system time if pointing to thedummy_vcpu_info?
Quoted 6 lines
The check is there to guard against NULL deref. As said, the aspect of a vCPU being brought up the "native" way yet then still using its vCPU info was, by mistake, neglected earlier on. So yes, such a check could be added here, but it isn't strictly necessary as long as we don't avoid accessing the dummy structure uniformly everywhere (which, as said, I'm not sure we want to do).
I could add such a check in a separate patch, my main concern with this is not correctness, it's just that we waste cycles updating the contents of dummy_vcpu_info which is useless.
Thanks, Roger.
Quoted 48 lines · Roger Pau Monné
Quoted 47 lines · Jan Beulich
Quoted 25 lines · Roger Pau Monné
Quoted 24 lines · Jan Beulich
Quoted 22 lines · Roger Pau Monné
Quoted 12 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.While I'd agree if you started with "There's no real need to force ...", I still think there is a reason: If one wants to use paravirt interfaces (i.e. hypercalls), they would better do so consistently. After all there's also no need to use
VCPUOP_initialise, yet you're not disabling its use.Quoted 5 lines
As said in reply to Andrew's reply, besides acting as a sentinel that structure instance also acts as a sink for Xen accesses to a vCPU's
vcpu_info. By removing the check, you switch that from being a safeguard to being something that actually has to be expected to be accessed. Unless you've audited all uses to prove that no such access exists.I'm kind of lost in this last paragraph, how is that different than what currently happens when an HVM vCPU >= 32 is brought up using the lapic and has no
vpcu_infomapped?Quoted 7 lines
Quoted 2 lines
I think this aspect was simply missed back at the time. And I think it wants mentioning explicitly to justify the change.
OK, I can add to the commit message:
"Note an HVM vCPU can operate normally without making use of
vcpu_info, and in fact does so when brought up from the local APIC."I'd be fine adding this (or having this added) while committing.
Quoted 11 lines
Quoted 6 lines
As said in reply to Andrew, I don't think the dummy structure can be got rid of. Nor can the checks here be (easily) removed altogether, i.e. your change cannot (easily) be extended to PV as well. Even conditional removal of the structure in !PV builds would first require all
vcpu_infoaccesses to gain a suitable conditional. Which may be undesirable, as some of these may be deemed fast paths.I didn't intended to do this here, as replied to Andrew. If we want to get rid of the check for PV also it needs to be done in a different patch, and with a different justification and analysis.
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Also, from a quick look it seems like sites do check whether
vcpu_info==dummy_vcpu_info, otherwise we would already be in trouble.Such checks exist in code managing
vcpu_info, but not - afaics - in places actually accessing it.Is there anything else that needs adjusting then, or are you happy to pick this up and adjust the commit message?
I'll pick this up and adjust (unless Andrew beats me).
Jan
Quoted 10 lines · Roger Pau Monne
There's no reason to force HVM guests to have a valid
vcpu_infoarea when initializing a vCPU, as the vCPU can also be brought online using the local APIC, and on that path there's no requirement forvcpu_infoto be setup ahead of the bring up. Note an HVM vCPU can operate normally without making use ofvcpu_info.Restrict the check against
dummy_vcpu_infoto only apply to PV guests.Fixes 192df6f9122d ('x86: allow HVM guests to use hypercalls to bring up vCPUs')Signed-off-by Roger Pau Monné <[email protected]>
Despite the Fixes: tag I have to admit I'm uncertain of backporting here. HVM guests need to be prepared anyway that they may be denied use of this sub-op without first setting up vCPU info.
Jan