From: "Daniel P. Smith" <dpsmith@apertussolutions.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 01/24] XSM: reduce redundancy in hook machinery
Date: Thu, 30 Jul 2026 14:21:42 -0400 [thread overview]
Message-ID: <19775f5b-e458-4336-92a3-8f8103708564@apertussolutions.com> (raw)
In-Reply-To: <8030ff8e-ed83-46c4-ba69-4954ee645c38@suse.com>
On 7/30/26 11:18 AM, Jan Beulich wrote:
> On 30.07.2026 17:05, Daniel P. Smith wrote:
>> On 7/28/26 9:13 AM, Jan Beulich wrote:
>>> Hooks not taking xsm_default_t as first argument could of course be
>>> adjusted to take one, at which point they could be covered here as well.
>>> Question is why there is this difference in the first place.
>>
>> I have a theory but I am not confident to write it down. I can see if I
>> can confirm with DDG if you really care that much to know the why.
>> Personally having a consistent hook interface convention would provide a
>> simpler pattern for people to follow if they are having to introdcue a
>> new hook.
>
> Well, I don't really need to know the reason. If you agree that making
> things uniform is a good move, I can simply stick a few more patches at
> the end of this series.
>
Correct me if I am wrong, but we would be introducing an unused
parameter in exchange for uniform interfaces that can be generated with
machinery reducing hook maintenance overhead. IMHO I feel from a
security standpoint this would be a win. Would you disagree?
>>> .{alloc,free}_security_evtchns() and their dummy wrappers use struct
>>> evtchn[] notation, while xsm_{alloc,free}_security_evtchns() use struct
>>> evtchn *. Is there a reason for this inconsistency?
>>
>> Person had one habit that was counter to Xen preference and missed one?
>> I have no justification for it. IMHO the interfaces should be kept
>> consistent to enable better grep-ability.
>
> Which direction would you want it changed? Personally I like the []
> notation better when arrays are meant, but the pointer notation will be
> quite a bit easier with the new hooks.h machinery.
>
I agree, my preference is [] for array parameters. But this is a
readability vs less fragile machinery. As much as I like to know that
the parameter is meant to be an array vs a instance reference, I would
prefer more reliability in the machinery. Since you are doing the work,
I leave to you to decide level of effort vs the most resilient
implementation of the machinery.
>>> @@ -206,113 +117,57 @@ static inline void xsm_security_domainin
>>> alternative_vcall(xsm_ops.security_domaininfo, d, info);
>>> }
>>>
>>> -static inline int xsm_domain_create(
>>> - xsm_default_t def, struct domain *d, uint32_t ssidref)
>>> -{
>>> - return alternative_call(xsm_ops.domain_create, d, ssidref);
>>> -}
>>> +#define XSM_ALT_void alternative_vcall
>>> +#define XSM_ALT_int return alternative_call
>>>
>>> -static inline int xsm_getdomaininfo(xsm_default_t def, struct domain *d)
>>> -{
>>> - return alternative_call(xsm_ops.getdomaininfo, d);
>>> +#define XSM_HOOK0(rtype, name) \
>>> +static inline rtype xsm_ ## name(xsm_default_t def) \
>>> +{ \
>>> + XSM_ALT_ ## rtype(xsm_ops.name); \
>>> }
>>>
>>> -static inline int xsm_get_domain_state(xsm_default_t def, struct domain *d)
>>> -{
>>> - return alternative_call(xsm_ops.get_domain_state, d);
>>> +#define XSM_HOOK1(rtype, name, type1) \
>>> +static inline rtype xsm_ ## name(xsm_default_t def, type1 arg1) \
>>> +{ \
>>> + XSM_ALT_ ## rtype(xsm_ops.name, arg1); \
>>> }
>>>
>>> -static inline int xsm_set_target(
>>> - xsm_default_t def, struct domain *d, struct domain *e)
>>> -{
>>> - return alternative_call(xsm_ops.set_target, d, e);
>>> +#define XSM_HOOK2(rtype, name, type1, type2) \
>>> +static inline rtype xsm_ ## name( \
>>> + xsm_default_t def, type1 arg1, type2 arg2) \
>>> +{ \
>>> + XSM_ALT_ ## rtype(xsm_ops.name, arg1, arg2); \
>>> }
>>>
>>> -static inline int xsm_domctl(xsm_default_t def, struct domain *d,
>>> - struct xen_domctl *op)
>>> -{
>>> - return alternative_call(xsm_ops.domctl, d, op);
>>> +#define XSM_HOOK3(rtype, name, type1, type2, type3) \
>>> +static inline rtype xsm_ ## name( \
>>> + xsm_default_t def, type1 arg1, type2 arg2, type3 arg3) \
>>> +{ \
>>> + XSM_ALT_ ## rtype(xsm_ops.name, arg1, arg2, arg3); \
>>> }
>>>
>>> -#ifdef CONFIG_SYSCTL
>>> -static inline int xsm_sysctl(xsm_default_t def, const struct xen_sysctl *op)
>>> -{
>>> - return alternative_call(xsm_ops.sysctl, op);
>>> +#define XSM_HOOK4(rtype, name, type1, type2, type3, type4) \
>>> +static inline rtype xsm_ ## name( \
>>> + xsm_default_t def, type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
>>> +{ \
>>> + XSM_ALT_ ## rtype(xsm_ops.name, arg1, arg2, arg3, arg4); \
>>> }
>>> -#endif
>>>
>>> -static inline int xsm_evtchn_unbound(
>>> - xsm_default_t def, struct domain *d1, struct evtchn *chn, domid_t id2)
>>> -{
>>> - return alternative_call(xsm_ops.evtchn_unbound, d1, chn, id2);
>>> +#define XSM_HOOK5(rtype, name, type1, type2, type3, type4, type5) \
>>> +static inline rtype xsm_ ## name( \
>>> + xsm_default_t def, type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
>>> + type4 arg5) \
>>
>> Looks like you have copy/paste typo?
>
> Indeed. And the last two parameters of .pci_config_permission() sadly aren't
> distinct enough to make the flaw apparent at build time. (That looks to be
> the only hook with 5 parameters.)
>
I believe in 19 pci_config_permission() 5th parameter gets changed from
1(uint8_t) to true (bool), while type4 is uint16_t.
> Thanks much for spotting.
>
Your welcome.
>> I would just note there is quite a bit of churn in this patch, most of
>> it is mechanical, but makes it easy for these to slip through.
>
> Right. Fortunately this needs doing only once.
>
Yep, just makes review a little more fun.
>> After fixing this typo,
>>
>> Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com>
>
> Thanks.
>
> Jan
next prev parent reply other threads:[~2026-07-30 18:22 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 13:10 [PATCH 00/24] XSM: follow-on to XSAs 492 and 499 Jan Beulich
2026-07-28 13:13 ` [PATCH 01/24] XSM: reduce redundancy in hook machinery Jan Beulich
2026-07-30 15:05 ` Daniel P. Smith
2026-07-30 15:18 ` Jan Beulich
2026-07-30 18:21 ` Daniel P. Smith [this message]
2026-07-28 13:14 ` [PATCH 02/24] XSM: make .grant_*() hooks dependent upon GRANT_TABLE=y Jan Beulich
2026-07-30 18:23 ` Daniel P. Smith
2026-07-28 13:14 ` [PATCH 03/24] XSM: make .{,un}map_domain_pirq() hooks dependent upon HAS_PIRQ=y Jan Beulich
2026-07-28 13:14 ` [PATCH 04/24] XSM: make PCI hooks dependent upon HAS_PCI=y Jan Beulich
2026-07-28 13:15 ` [PATCH 05/24] XSM: make .iomem_mapping_vcpi() hook dependent upon HAS_VPCI=y Jan Beulich
2026-07-28 13:15 ` [PATCH 06/24] XSM: make .kexec() hook dependent upon KEXEC=y Jan Beulich
2026-07-28 13:15 ` [PATCH 07/24] XSM: make .hypfs() hook dependent upon HYPFS=y Jan Beulich
2026-07-28 13:16 ` [PATCH 08/24] XSM: make .hvm_altp2mhvm_op() hook dependent upon ALTP2M=y Jan Beulich
2026-07-28 13:17 ` [PATCH 09/24] XSM: make .hvm_param*() hooks dependent upon HVM=y Jan Beulich
2026-07-28 13:17 ` [PATCH 10/24] XSM: make .dm_op() hook dependent upon IOREQ_SERVER=y Jan Beulich
2026-07-28 13:18 ` [PATCH 11/24] XSM: make certain x86-specific hooks dependent upon PV=y Jan Beulich
2026-07-28 13:18 ` [PATCH 12/24] x86/mm: get_page_from_l1e() is PV-or-shadow-only Jan Beulich
2026-07-28 13:19 ` [PATCH 13/24] x86: restrict PHYSDEVOP_* when PV=n Jan Beulich
2026-07-28 13:19 ` [PATCH 14/24] XSM/dummy: fold cf_check into XSM_INLINE Jan Beulich
2026-07-28 13:20 ` [PATCH 15/24] XSM/dummy: drop redundant return statements Jan Beulich
2026-07-28 13:20 ` [PATCH 16/24] XSM: suppress hypercall when XSM=n Jan Beulich
2026-07-28 13:22 ` [PATCH 17/24] XSM: make Argo hooks well-formed ones Jan Beulich
2026-07-28 13:22 ` [PATCH 18/24] XSM: make XSM " Jan Beulich
2026-07-28 13:23 ` [PATCH 19/24] XSM: convert "allow" (Flask: "access") parameters to bool Jan Beulich
2026-07-28 13:23 ` [PATCH 20/24] XSM: fold xsm_{,un}map_domain_pirq() hooks Jan Beulich
2026-07-28 13:24 ` [PATCH 21/24] x86: type-correct last parameter of map_domain_pirq() Jan Beulich
2026-07-28 13:25 ` [PATCH 22/24] XSM: pass just SBDF to xsm_{,un}map_domain_irq() Jan Beulich
2026-07-28 13:26 ` [PATCH 23/24] XSM: fold xsm_{,un}map_domain_irq() hooks Jan Beulich
2026-07-28 13:26 ` [PATCH 24/24] XSM: fold xsm_{,un}bind_pt_irq() hooks Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19775f5b-e458-4336-92a3-8f8103708564@apertussolutions.com \
--to=dpsmith@apertussolutions.com \
--cc=jbeulich@suse.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.