* [PATCH] x86/domain: restrict context switch hooks for the idle domain
@ 2026-10-01 14:27 Roger Pau Monne
2026-10-01 15:17 ` Juergen Gross
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Roger Pau Monne @ 2026-10-01 14:27 UTC (permalink / raw)
To: xen-devel
Cc: Grygorii Strashko, Jan Beulich, Andrew Cooper,
Roger Pau Monné, Teddy Astie
From: Grygorii Strashko <grygorii_strashko@epam.com>
The arch_init_idle_domain() initializes struct arch_csw idle_csw as:
static const struct arch_csw idle_csw = {
.from = paravirt_ctxt_switch_from,
.to = paravirt_ctxt_switch_to,
.tail = idle_loop,
};
but only place where d->arch.ctxt_switch->{to,from}() are used is
__context_switch() where they are both guarded by !is_idle_domain(pd)
which makes the callbacks in idle_csw unreachable.
Drop to/from() callbacks initialization in idle_csw.
Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com>
Signed-off-by: Roger Pau Monné <roger@xenproject.org>
---
I don't think there's a suitable Fixes candidate here. The idle domain
hooks used to piggyback on the PV ones, and commit ab914e04a6272 split
those out into it's own structure. At that point the to/from hooks could
have been left zeroed, but that wasn't the point of that commit anyway.
---
xen/arch/x86/domain.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 996b50af7a17..464ca6f39026 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -813,8 +813,6 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
void __init arch_init_idle_domain(struct domain *d)
{
static const struct arch_csw idle_csw = {
- .from = paravirt_ctxt_switch_from,
- .to = paravirt_ctxt_switch_to,
.tail = idle_loop,
};
--
2.55.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH] x86/domain: restrict context switch hooks for the idle domain 2026-10-01 14:27 [PATCH] x86/domain: restrict context switch hooks for the idle domain Roger Pau Monne @ 2026-10-01 15:17 ` Juergen Gross 2026-10-01 17:23 ` Jason Andryuk 2026-10-02 5:45 ` Jan Beulich 2 siblings, 0 replies; 12+ messages in thread From: Juergen Gross @ 2026-10-01 15:17 UTC (permalink / raw) To: Roger Pau Monne, xen-devel Cc: Grygorii Strashko, Jan Beulich, Andrew Cooper, Teddy Astie [-- Attachment #1.1.1: Type: text/plain, Size: 811 bytes --] On 01.10.26 16:27, Roger Pau Monne wrote: > From: Grygorii Strashko <grygorii_strashko@epam.com> > > The arch_init_idle_domain() initializes struct arch_csw idle_csw as: > > static const struct arch_csw idle_csw = { > .from = paravirt_ctxt_switch_from, > .to = paravirt_ctxt_switch_to, > .tail = idle_loop, > }; > > but only place where d->arch.ctxt_switch->{to,from}() are used is > __context_switch() where they are both guarded by !is_idle_domain(pd) > which makes the callbacks in idle_csw unreachable. > > Drop to/from() callbacks initialization in idle_csw. > > Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com> > Signed-off-by: Roger Pau Monné <roger@xenproject.org> Reviewed-by: Juergen Gross <jgross@suse.com> Juergen [-- Attachment #1.1.2: OpenPGP public key --] [-- Type: application/pgp-keys, Size: 3743 bytes --] [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 495 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] x86/domain: restrict context switch hooks for the idle domain 2026-10-01 14:27 [PATCH] x86/domain: restrict context switch hooks for the idle domain Roger Pau Monne 2026-10-01 15:17 ` Juergen Gross @ 2026-10-01 17:23 ` Jason Andryuk 2026-10-02 5:45 ` Jan Beulich 2 siblings, 0 replies; 12+ messages in thread From: Jason Andryuk @ 2026-10-01 17:23 UTC (permalink / raw) To: Roger Pau Monne, xen-devel Cc: Grygorii Strashko, Jan Beulich, Andrew Cooper, Teddy Astie On 2026-10-01 10:27, Roger Pau Monne wrote: > From: Grygorii Strashko <grygorii_strashko@epam.com> > > The arch_init_idle_domain() initializes struct arch_csw idle_csw as: > > static const struct arch_csw idle_csw = { > .from = paravirt_ctxt_switch_from, > .to = paravirt_ctxt_switch_to, > .tail = idle_loop, > }; > > but only place where d->arch.ctxt_switch->{to,from}() are used is > __context_switch() where they are both guarded by !is_idle_domain(pd) > which makes the callbacks in idle_csw unreachable. > > Drop to/from() callbacks initialization in idle_csw. > > Signed-off-by: Grygorii Strashko <grygorii_strashko@epam.com> > Signed-off-by: Roger Pau Monné <roger@xenproject.org> Reviewed-by: Jason Andryuk <jason.andryuk@amd.com> Thanks, Jason ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] x86/domain: restrict context switch hooks for the idle domain 2026-10-01 14:27 [PATCH] x86/domain: restrict context switch hooks for the idle domain Roger Pau Monne 2026-10-01 15:17 ` Juergen Gross 2026-10-01 17:23 ` Jason Andryuk @ 2026-10-02 5:45 ` Jan Beulich 2026-10-02 7:48 ` Roger Pau Monné 2 siblings, 1 reply; 12+ messages in thread From: Jan Beulich @ 2026-10-02 5:45 UTC (permalink / raw) To: Roger Pau Monne; +Cc: Grygorii Strashko, Andrew Cooper, Teddy Astie, xen-devel On 01.10.2026 16:27, Roger Pau Monne wrote: > --- a/xen/arch/x86/domain.c > +++ b/xen/arch/x86/domain.c > @@ -813,8 +813,6 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) > void __init arch_init_idle_domain(struct domain *d) > { > static const struct arch_csw idle_csw = { > - .from = paravirt_ctxt_switch_from, > - .to = paravirt_ctxt_switch_to, > .tail = idle_loop, > }; Leaving NULL pointers around isn't a good thing, though. May I suggest to at least poison the pointers then? Jan ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] x86/domain: restrict context switch hooks for the idle domain 2026-10-02 5:45 ` Jan Beulich @ 2026-10-02 7:48 ` Roger Pau Monné 2026-10-02 7:55 ` Jan Beulich 0 siblings, 1 reply; 12+ messages in thread From: Roger Pau Monné @ 2026-10-02 7:48 UTC (permalink / raw) To: Jan Beulich; +Cc: Grygorii Strashko, Andrew Cooper, Teddy Astie, xen-devel On Fri, Oct 02, 2026 at 07:45:07AM +0200, Jan Beulich wrote: > On 01.10.2026 16:27, Roger Pau Monne wrote: > > --- a/xen/arch/x86/domain.c > > +++ b/xen/arch/x86/domain.c > > @@ -813,8 +813,6 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) > > void __init arch_init_idle_domain(struct domain *d) > > { > > static const struct arch_csw idle_csw = { > > - .from = paravirt_ctxt_switch_from, > > - .to = paravirt_ctxt_switch_to, > > .tail = idle_loop, > > }; > > Leaving NULL pointers around isn't a good thing, though. May I suggest to > at least poison the pointers then? I don't mind doing so, but I don't think we usually do that for other hook structures, ie: hvm_function_table for example doesn't poison unset hooks (and it possibly can't, because there are .hook != NULL checks). TBH I'm missing a benefit of the poisoning here. Using NULL or a poisoned value will both trigger a page-fault, and NULL has the benefit of callers easily checking whether the hook is set. Thanks, Roger. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] x86/domain: restrict context switch hooks for the idle domain 2026-10-02 7:48 ` Roger Pau Monné @ 2026-10-02 7:55 ` Jan Beulich 2026-10-02 8:05 ` Roger Pau Monné 0 siblings, 1 reply; 12+ messages in thread From: Jan Beulich @ 2026-10-02 7:55 UTC (permalink / raw) To: Roger Pau Monné Cc: Grygorii Strashko, Andrew Cooper, Teddy Astie, xen-devel On 02.10.2026 09:48, Roger Pau Monné wrote: > On Fri, Oct 02, 2026 at 07:45:07AM +0200, Jan Beulich wrote: >> On 01.10.2026 16:27, Roger Pau Monne wrote: >>> --- a/xen/arch/x86/domain.c >>> +++ b/xen/arch/x86/domain.c >>> @@ -813,8 +813,6 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) >>> void __init arch_init_idle_domain(struct domain *d) >>> { >>> static const struct arch_csw idle_csw = { >>> - .from = paravirt_ctxt_switch_from, >>> - .to = paravirt_ctxt_switch_to, >>> .tail = idle_loop, >>> }; >> >> Leaving NULL pointers around isn't a good thing, though. May I suggest to >> at least poison the pointers then? > > I don't mind doing so, but I don't think we usually do that for other > hook structures, ie: hvm_function_table for example doesn't poison > unset hooks (and it possibly can't, because there are .hook != NULL > checks). > > TBH I'm missing a benefit of the poisoning here. Using NULL or a > poisoned value will both trigger a page-fault, and NULL has the > benefit of callers easily checking whether the hook is set. NULL in the context of a HVM vCPU will #PF. NULL in the context of a PV one may not, depending on what the guest may have put there. Jan ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] x86/domain: restrict context switch hooks for the idle domain 2026-10-02 7:55 ` Jan Beulich @ 2026-10-02 8:05 ` Roger Pau Monné 2026-10-02 8:09 ` Jan Beulich 0 siblings, 1 reply; 12+ messages in thread From: Roger Pau Monné @ 2026-10-02 8:05 UTC (permalink / raw) To: Jan Beulich; +Cc: Grygorii Strashko, Andrew Cooper, Teddy Astie, xen-devel On Fri, Oct 02, 2026 at 09:55:09AM +0200, Jan Beulich wrote: > On 02.10.2026 09:48, Roger Pau Monné wrote: > > On Fri, Oct 02, 2026 at 07:45:07AM +0200, Jan Beulich wrote: > >> On 01.10.2026 16:27, Roger Pau Monne wrote: > >>> --- a/xen/arch/x86/domain.c > >>> +++ b/xen/arch/x86/domain.c > >>> @@ -813,8 +813,6 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) > >>> void __init arch_init_idle_domain(struct domain *d) > >>> { > >>> static const struct arch_csw idle_csw = { > >>> - .from = paravirt_ctxt_switch_from, > >>> - .to = paravirt_ctxt_switch_to, > >>> .tail = idle_loop, > >>> }; > >> > >> Leaving NULL pointers around isn't a good thing, though. May I suggest to > >> at least poison the pointers then? > > > > I don't mind doing so, but I don't think we usually do that for other > > hook structures, ie: hvm_function_table for example doesn't poison > > unset hooks (and it possibly can't, because there are .hook != NULL > > checks). > > > > TBH I'm missing a benefit of the poisoning here. Using NULL or a > > poisoned value will both trigger a page-fault, and NULL has the > > benefit of callers easily checking whether the hook is set. > > NULL in the context of a HVM vCPU will #PF. NULL in the context of a PV > one may not, depending on what the guest may have put there. It still feels a bit arbitrary to do here but not in other places, but never mind, I will adjust and send v2. Thanks, Roger. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] x86/domain: restrict context switch hooks for the idle domain 2026-10-02 8:05 ` Roger Pau Monné @ 2026-10-02 8:09 ` Jan Beulich 2026-10-02 9:23 ` Roger Pau Monné 0 siblings, 1 reply; 12+ messages in thread From: Jan Beulich @ 2026-10-02 8:09 UTC (permalink / raw) To: Roger Pau Monné Cc: Grygorii Strashko, Andrew Cooper, Teddy Astie, xen-devel On 02.10.2026 10:05, Roger Pau Monné wrote: > On Fri, Oct 02, 2026 at 09:55:09AM +0200, Jan Beulich wrote: >> On 02.10.2026 09:48, Roger Pau Monné wrote: >>> On Fri, Oct 02, 2026 at 07:45:07AM +0200, Jan Beulich wrote: >>>> On 01.10.2026 16:27, Roger Pau Monne wrote: >>>>> --- a/xen/arch/x86/domain.c >>>>> +++ b/xen/arch/x86/domain.c >>>>> @@ -813,8 +813,6 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) >>>>> void __init arch_init_idle_domain(struct domain *d) >>>>> { >>>>> static const struct arch_csw idle_csw = { >>>>> - .from = paravirt_ctxt_switch_from, >>>>> - .to = paravirt_ctxt_switch_to, >>>>> .tail = idle_loop, >>>>> }; >>>> >>>> Leaving NULL pointers around isn't a good thing, though. May I suggest to >>>> at least poison the pointers then? >>> >>> I don't mind doing so, but I don't think we usually do that for other >>> hook structures, ie: hvm_function_table for example doesn't poison >>> unset hooks (and it possibly can't, because there are .hook != NULL >>> checks). >>> >>> TBH I'm missing a benefit of the poisoning here. Using NULL or a >>> poisoned value will both trigger a page-fault, and NULL has the >>> benefit of callers easily checking whether the hook is set. >> >> NULL in the context of a HVM vCPU will #PF. NULL in the context of a PV >> one may not, depending on what the guest may have put there. > > It still feels a bit arbitrary to do here but not in other places, We should imo resolve this by replacing NULLs wherever hooks could, due to other issues, end up "in sight" on paths reachable for PV guests. This would then also cover potential speculation along such paths. > but never mind, I will adjust and send v2. Thanks. Jan ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] x86/domain: restrict context switch hooks for the idle domain 2026-10-02 8:09 ` Jan Beulich @ 2026-10-02 9:23 ` Roger Pau Monné 2026-10-02 9:29 ` Roger Pau Monné 0 siblings, 1 reply; 12+ messages in thread From: Roger Pau Monné @ 2026-10-02 9:23 UTC (permalink / raw) To: Jan Beulich; +Cc: Grygorii Strashko, Andrew Cooper, Teddy Astie, xen-devel On Fri, Oct 02, 2026 at 10:09:02AM +0200, Jan Beulich wrote: > On 02.10.2026 10:05, Roger Pau Monné wrote: > > On Fri, Oct 02, 2026 at 09:55:09AM +0200, Jan Beulich wrote: > >> On 02.10.2026 09:48, Roger Pau Monné wrote: > >>> On Fri, Oct 02, 2026 at 07:45:07AM +0200, Jan Beulich wrote: > >>>> On 01.10.2026 16:27, Roger Pau Monne wrote: > >>>>> --- a/xen/arch/x86/domain.c > >>>>> +++ b/xen/arch/x86/domain.c > >>>>> @@ -813,8 +813,6 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) > >>>>> void __init arch_init_idle_domain(struct domain *d) > >>>>> { > >>>>> static const struct arch_csw idle_csw = { > >>>>> - .from = paravirt_ctxt_switch_from, > >>>>> - .to = paravirt_ctxt_switch_to, > >>>>> .tail = idle_loop, > >>>>> }; > >>>> > >>>> Leaving NULL pointers around isn't a good thing, though. May I suggest to > >>>> at least poison the pointers then? > >>> > >>> I don't mind doing so, but I don't think we usually do that for other > >>> hook structures, ie: hvm_function_table for example doesn't poison > >>> unset hooks (and it possibly can't, because there are .hook != NULL > >>> checks). > >>> > >>> TBH I'm missing a benefit of the poisoning here. Using NULL or a > >>> poisoned value will both trigger a page-fault, and NULL has the > >>> benefit of callers easily checking whether the hook is set. > >> > >> NULL in the context of a HVM vCPU will #PF. NULL in the context of a PV > >> one may not, depending on what the guest may have put there. > > > > It still feels a bit arbitrary to do here but not in other places, > > We should imo resolve this by replacing NULLs wherever hooks could, due > to other issues, end up "in sight" on paths reachable for PV guests. This > would then also cover potential speculation along such paths. FTAOD, I plan to introduce a poison value using a non-canonical address, ie: #define POINTER_POISON ((void *)0xDEAD0000DEAD0000UL) in asm/config.h. Would that be acceptable? Thanks, Roger. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] x86/domain: restrict context switch hooks for the idle domain 2026-10-02 9:23 ` Roger Pau Monné @ 2026-10-02 9:29 ` Roger Pau Monné 2026-10-02 9:35 ` Jan Beulich 0 siblings, 1 reply; 12+ messages in thread From: Roger Pau Monné @ 2026-10-02 9:29 UTC (permalink / raw) To: Jan Beulich; +Cc: Grygorii Strashko, Andrew Cooper, Teddy Astie, xen-devel On Fri, Oct 02, 2026 at 11:23:17AM +0200, Roger Pau Monné wrote: > On Fri, Oct 02, 2026 at 10:09:02AM +0200, Jan Beulich wrote: > > On 02.10.2026 10:05, Roger Pau Monné wrote: > > > On Fri, Oct 02, 2026 at 09:55:09AM +0200, Jan Beulich wrote: > > >> On 02.10.2026 09:48, Roger Pau Monné wrote: > > >>> On Fri, Oct 02, 2026 at 07:45:07AM +0200, Jan Beulich wrote: > > >>>> On 01.10.2026 16:27, Roger Pau Monne wrote: > > >>>>> --- a/xen/arch/x86/domain.c > > >>>>> +++ b/xen/arch/x86/domain.c > > >>>>> @@ -813,8 +813,6 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) > > >>>>> void __init arch_init_idle_domain(struct domain *d) > > >>>>> { > > >>>>> static const struct arch_csw idle_csw = { > > >>>>> - .from = paravirt_ctxt_switch_from, > > >>>>> - .to = paravirt_ctxt_switch_to, > > >>>>> .tail = idle_loop, > > >>>>> }; > > >>>> > > >>>> Leaving NULL pointers around isn't a good thing, though. May I suggest to > > >>>> at least poison the pointers then? > > >>> > > >>> I don't mind doing so, but I don't think we usually do that for other > > >>> hook structures, ie: hvm_function_table for example doesn't poison > > >>> unset hooks (and it possibly can't, because there are .hook != NULL > > >>> checks). > > >>> > > >>> TBH I'm missing a benefit of the poisoning here. Using NULL or a > > >>> poisoned value will both trigger a page-fault, and NULL has the > > >>> benefit of callers easily checking whether the hook is set. > > >> > > >> NULL in the context of a HVM vCPU will #PF. NULL in the context of a PV > > >> one may not, depending on what the guest may have put there. > > > > > > It still feels a bit arbitrary to do here but not in other places, > > > > We should imo resolve this by replacing NULLs wherever hooks could, due > > to other issues, end up "in sight" on paths reachable for PV guests. This > > would then also cover potential speculation along such paths. > > FTAOD, I plan to introduce a poison value using a non-canonical > address, ie: > > #define POINTER_POISON ((void *)0xDEAD0000DEAD0000UL) s/POINTER_POISON/FUNCTION_POISON/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] x86/domain: restrict context switch hooks for the idle domain 2026-10-02 9:29 ` Roger Pau Monné @ 2026-10-02 9:35 ` Jan Beulich 2026-10-02 9:49 ` Roger Pau Monné 0 siblings, 1 reply; 12+ messages in thread From: Jan Beulich @ 2026-10-02 9:35 UTC (permalink / raw) To: Roger Pau Monné Cc: Grygorii Strashko, Andrew Cooper, Teddy Astie, xen-devel On 02.10.2026 11:29, Roger Pau Monné wrote: > On Fri, Oct 02, 2026 at 11:23:17AM +0200, Roger Pau Monné wrote: >> On Fri, Oct 02, 2026 at 10:09:02AM +0200, Jan Beulich wrote: >>> On 02.10.2026 10:05, Roger Pau Monné wrote: >>>> On Fri, Oct 02, 2026 at 09:55:09AM +0200, Jan Beulich wrote: >>>>> On 02.10.2026 09:48, Roger Pau Monné wrote: >>>>>> On Fri, Oct 02, 2026 at 07:45:07AM +0200, Jan Beulich wrote: >>>>>>> On 01.10.2026 16:27, Roger Pau Monne wrote: >>>>>>>> --- a/xen/arch/x86/domain.c >>>>>>>> +++ b/xen/arch/x86/domain.c >>>>>>>> @@ -813,8 +813,6 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) >>>>>>>> void __init arch_init_idle_domain(struct domain *d) >>>>>>>> { >>>>>>>> static const struct arch_csw idle_csw = { >>>>>>>> - .from = paravirt_ctxt_switch_from, >>>>>>>> - .to = paravirt_ctxt_switch_to, >>>>>>>> .tail = idle_loop, >>>>>>>> }; >>>>>>> >>>>>>> Leaving NULL pointers around isn't a good thing, though. May I suggest to >>>>>>> at least poison the pointers then? >>>>>> >>>>>> I don't mind doing so, but I don't think we usually do that for other >>>>>> hook structures, ie: hvm_function_table for example doesn't poison >>>>>> unset hooks (and it possibly can't, because there are .hook != NULL >>>>>> checks). >>>>>> >>>>>> TBH I'm missing a benefit of the poisoning here. Using NULL or a >>>>>> poisoned value will both trigger a page-fault, and NULL has the >>>>>> benefit of callers easily checking whether the hook is set. >>>>> >>>>> NULL in the context of a HVM vCPU will #PF. NULL in the context of a PV >>>>> one may not, depending on what the guest may have put there. >>>> >>>> It still feels a bit arbitrary to do here but not in other places, >>> >>> We should imo resolve this by replacing NULLs wherever hooks could, due >>> to other issues, end up "in sight" on paths reachable for PV guests. This >>> would then also cover potential speculation along such paths. >> >> FTAOD, I plan to introduce a poison value using a non-canonical >> address, ie: >> >> #define POINTER_POISON ((void *)0xDEAD0000DEAD0000UL) > > s/POINTER_POISON/FUNCTION_POISON/ Sure, if you think none of the present poisoning values we have is good to reuse here. Jan ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] x86/domain: restrict context switch hooks for the idle domain 2026-10-02 9:35 ` Jan Beulich @ 2026-10-02 9:49 ` Roger Pau Monné 0 siblings, 0 replies; 12+ messages in thread From: Roger Pau Monné @ 2026-10-02 9:49 UTC (permalink / raw) To: Jan Beulich; +Cc: Grygorii Strashko, Andrew Cooper, Teddy Astie, xen-devel On Fri, Oct 02, 2026 at 11:35:40AM +0200, Jan Beulich wrote: > On 02.10.2026 11:29, Roger Pau Monné wrote: > > On Fri, Oct 02, 2026 at 11:23:17AM +0200, Roger Pau Monné wrote: > >> On Fri, Oct 02, 2026 at 10:09:02AM +0200, Jan Beulich wrote: > >>> On 02.10.2026 10:05, Roger Pau Monné wrote: > >>>> On Fri, Oct 02, 2026 at 09:55:09AM +0200, Jan Beulich wrote: > >>>>> On 02.10.2026 09:48, Roger Pau Monné wrote: > >>>>>> On Fri, Oct 02, 2026 at 07:45:07AM +0200, Jan Beulich wrote: > >>>>>>> On 01.10.2026 16:27, Roger Pau Monne wrote: > >>>>>>>> --- a/xen/arch/x86/domain.c > >>>>>>>> +++ b/xen/arch/x86/domain.c > >>>>>>>> @@ -813,8 +813,6 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) > >>>>>>>> void __init arch_init_idle_domain(struct domain *d) > >>>>>>>> { > >>>>>>>> static const struct arch_csw idle_csw = { > >>>>>>>> - .from = paravirt_ctxt_switch_from, > >>>>>>>> - .to = paravirt_ctxt_switch_to, > >>>>>>>> .tail = idle_loop, > >>>>>>>> }; > >>>>>>> > >>>>>>> Leaving NULL pointers around isn't a good thing, though. May I suggest to > >>>>>>> at least poison the pointers then? > >>>>>> > >>>>>> I don't mind doing so, but I don't think we usually do that for other > >>>>>> hook structures, ie: hvm_function_table for example doesn't poison > >>>>>> unset hooks (and it possibly can't, because there are .hook != NULL > >>>>>> checks). > >>>>>> > >>>>>> TBH I'm missing a benefit of the poisoning here. Using NULL or a > >>>>>> poisoned value will both trigger a page-fault, and NULL has the > >>>>>> benefit of callers easily checking whether the hook is set. > >>>>> > >>>>> NULL in the context of a HVM vCPU will #PF. NULL in the context of a PV > >>>>> one may not, depending on what the guest may have put there. > >>>> > >>>> It still feels a bit arbitrary to do here but not in other places, > >>> > >>> We should imo resolve this by replacing NULLs wherever hooks could, due > >>> to other issues, end up "in sight" on paths reachable for PV guests. This > >>> would then also cover potential speculation along such paths. > >> > >> FTAOD, I plan to introduce a poison value using a non-canonical > >> address, ie: > >> > >> #define POINTER_POISON ((void *)0xDEAD0000DEAD0000UL) > > > > s/POINTER_POISON/FUNCTION_POISON/ > > Sure, if you think none of the present poisoning values we have is good to > reuse here. They maybe could, but I assumed we wanted differentiation between this usage and ZERO_BLOCK_PTR for example. Thanks, Roger. ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-10-02 9:50 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-10-01 14:27 [PATCH] x86/domain: restrict context switch hooks for the idle domain Roger Pau Monne 2026-10-01 15:17 ` Juergen Gross 2026-10-01 17:23 ` Jason Andryuk 2026-10-02 5:45 ` Jan Beulich 2026-10-02 7:48 ` Roger Pau Monné 2026-10-02 7:55 ` Jan Beulich 2026-10-02 8:05 ` Roger Pau Monné 2026-10-02 8:09 ` Jan Beulich 2026-10-02 9:23 ` Roger Pau Monné 2026-10-02 9:29 ` Roger Pau Monné 2026-10-02 9:35 ` Jan Beulich 2026-10-02 9:49 ` Roger Pau Monné
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.