From: "Alejandro Vallejo" <alejandro.vallejo@cloud.com>
To: "Penny Zheng" <Penny.Zheng@amd.com>, <xen-devel@lists.xenproject.org>
Cc: <ray.huang@amd.com>, "Daniel P. Smith" <dpsmith@apertussolutions.com>
Subject: Re: [PATCH v1 02/19] xen/xsm: wrap around xsm_sysctl with CONFIG_SYSCTL
Date: Thu, 13 Mar 2025 11:43:54 +0000 [thread overview]
Message-ID: <D8F41PA5JHTU.ABSSG427OH5@cloud.com> (raw)
In-Reply-To: <20250312040632.2853485-3-Penny.Zheng@amd.com>
Hi,
On Wed Mar 12, 2025 at 4:06 AM GMT, Penny Zheng wrote:
> Signed-off-by: Penny Zheng <Penny.Zheng@amd.com>
> ---
> xen/include/xsm/dummy.h | 7 +++++++
> xen/include/xsm/xsm.h | 9 +++++++++
> xen/xsm/dummy.c | 2 ++
> xen/xsm/flask/hooks.c | 4 ++++
> 4 files changed, 22 insertions(+)
>
> diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
> index a8d06de6b0..afc54a0b2f 100644
> --- a/xen/include/xsm/dummy.h
> +++ b/xen/include/xsm/dummy.h
> @@ -180,11 +180,18 @@ static XSM_INLINE int cf_check xsm_domctl(
> }
> }
>
> +#ifdef CONFIG_SYSCTL
> static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd)
> {
> XSM_ASSERT_ACTION(XSM_PRIV);
> return xsm_default_action(action, current->domain, NULL);
> }
> +#else
> +static XSM_INLINE int cf_check xsm_sysctl(XSM_DEFAULT_ARG int cmd)
> +{
> + return -EOPNOTSUPP;
> +}
> +#endif
Doesn't this need to be -ENOSYS instead?
I'd put the ifdefs inside the function (making the signature common) and
then have the body ifdef-ed. But rather than that, I suspect the `else` branch
can just go away because...
>
> static XSM_INLINE int cf_check xsm_readconsole(XSM_DEFAULT_ARG uint32_t clear)
> {
> diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
> index 8c33b055fc..276507b515 100644
> --- a/xen/include/xsm/xsm.h
> +++ b/xen/include/xsm/xsm.h
> @@ -60,7 +60,9 @@ struct xsm_ops {
> int (*sysctl_scheduler_op)(int op);
> int (*set_target)(struct domain *d, struct domain *e);
> int (*domctl)(struct domain *d, unsigned int cmd, uint32_t ssidref);
> +#ifdef CONFIG_SYSCTL
> int (*sysctl)(int cmd);
> +#endif
> int (*readconsole)(uint32_t clear);
... either you remove this field or make the dummy handler. Doing both seems
redundant.
The dummy handler would return -ENOTSUPP, so the field is benign (in which case
I don't really get why it must go). But if the field is gone, there's no need
for the handler to begin with.
All in all, removing the else branch in xsm_sysctl would make everything
consistent. Same in the files below.
Also, you may want to add the readconsole hook (and its handler) since that's
a specific sysctl that would also be disabled by !CONFIG_SYSCTL.
>
> int (*evtchn_unbound)(struct domain *d, struct evtchn *chn, domid_t id2);
> @@ -259,10 +261,17 @@ static inline int xsm_domctl(xsm_default_t def, struct domain *d,
> return alternative_call(xsm_ops.domctl, d, cmd, ssidref);
> }
>
> +#ifdef CONFIG_SYSCTL
> static inline int xsm_sysctl(xsm_default_t def, int cmd)
> {
> return alternative_call(xsm_ops.sysctl, cmd);
> }
> +#else
> +static inline int xsm_sysctl(xsm_default_t def, int cmd)
> +{
> + return -EOPNOTSUPP;
> +}
> +#endif
Same as above
>
> static inline int xsm_readconsole(xsm_default_t def, uint32_t clear)
> {
> diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c
> index ce6fbdc6c5..0a5fc06bbf 100644
> --- a/xen/xsm/dummy.c
> +++ b/xen/xsm/dummy.c
Same remarks here as in the header.
> @@ -22,7 +22,9 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = {
> .sysctl_scheduler_op = xsm_sysctl_scheduler_op,
> .set_target = xsm_set_target,
> .domctl = xsm_domctl,
> +#ifdef CONFIG_SYSCTL
> .sysctl = xsm_sysctl,
> +#endif
> .readconsole = xsm_readconsole,
>
> .evtchn_unbound = xsm_evtchn_unbound,
> diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
> index 389707a164..7c5e7f5879 100644
> --- a/xen/xsm/flask/hooks.c
> +++ b/xen/xsm/flask/hooks.c
> @@ -856,6 +856,7 @@ static int cf_check flask_domctl(struct domain *d, unsigned int cmd,
> }
> }
>
> +#ifdef CONFIG_SYSCTL
> static int cf_check flask_sysctl(int cmd)
> {
> switch ( cmd )
> @@ -933,6 +934,7 @@ static int cf_check flask_sysctl(int cmd)
> return avc_unknown_permission("sysctl", cmd);
> }
> }
> +#endif
>
> static int cf_check flask_readconsole(uint32_t clear)
> {
> @@ -1884,7 +1886,9 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = {
> .sysctl_scheduler_op = flask_sysctl_scheduler_op,
> .set_target = flask_set_target,
> .domctl = flask_domctl,
> +#ifdef CONFIG_SYSCTL
> .sysctl = flask_sysctl,
> +#endif
> .readconsole = flask_readconsole,
readconsole ought to be included, imo. And its handler wiped out as well.
>
> .evtchn_unbound = flask_evtchn_unbound,
Cheers,
Alejandro
next prev parent reply other threads:[~2025-03-13 11:44 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-12 4:06 [PATCH v1 00/19] xen: introduce CONFIG_SYSCTL Penny Zheng
2025-03-12 4:06 ` [PATCH v1 01/19] " Penny Zheng
2025-03-12 4:10 ` Penny, Zheng
2025-03-12 8:34 ` Jan Beulich
2025-03-13 10:58 ` Alejandro Vallejo
2025-03-13 16:24 ` Jan Beulich
2025-03-14 9:51 ` Alejandro Vallejo
2025-03-12 4:06 ` [PATCH v1 02/19] xen/xsm: wrap around xsm_sysctl with CONFIG_SYSCTL Penny Zheng
2025-03-12 8:38 ` Jan Beulich
2025-03-13 11:43 ` Alejandro Vallejo [this message]
2025-03-13 12:05 ` Jan Beulich
2025-03-13 14:31 ` Alejandro Vallejo
2025-03-12 4:06 ` [PATCH v1 03/19] xen/sysctl: wrap around XEN_SYSCTL_readconsole Penny Zheng
2025-03-13 12:02 ` Alejandro Vallejo
2025-03-20 8:02 ` Penny, Zheng
2025-03-20 8:46 ` Jan Beulich
2025-03-20 9:01 ` Penny, Zheng
2025-03-12 4:06 ` [PATCH v1 04/19] xen/sysctl: make CONFIG_TRACEBUFFER depend on CONFIG_SYSCTL Penny Zheng
2025-03-12 23:07 ` Stefano Stabellini
2025-03-12 4:06 ` [PATCH v1 05/19] xen/sysctl: wrap around XEN_SYSCTL_sched_id Penny Zheng
2025-03-12 23:09 ` Stefano Stabellini
2025-03-13 12:04 ` Alejandro Vallejo
2025-03-12 4:06 ` [PATCH v1 06/19] xen/sysctl: wrap around XEN_SYSCTL_perfc_op Penny Zheng
2025-03-12 23:12 ` Stefano Stabellini
2025-03-13 8:23 ` Jan Beulich
2025-03-13 21:50 ` Stefano Stabellini
2025-03-12 4:06 ` [PATCH v1 07/19] xen/sysctl: wrap around XEN_SYSCTL_lockprof_op Penny Zheng
2025-03-12 23:13 ` Stefano Stabellini
2025-03-13 8:24 ` Jan Beulich
2025-03-12 4:06 ` [PATCH v1 08/19] xen/sysctl: introduce CONFIG_PM_STATISTIC Penny Zheng
2025-03-13 8:44 ` Jan Beulich
2025-03-12 4:06 ` [PATCH v1 09/19] xen/sysctl: make CONFIG_PM_STATISTIC depend on CONFIG_SYSCTL Penny Zheng
2025-03-13 8:45 ` Jan Beulich
2025-03-12 4:06 ` [PATCH v1 10/19] xen/page: fix return type of online_page() Penny Zheng
2025-03-12 23:17 ` Stefano Stabellini
2025-03-13 8:30 ` Jan Beulich
2025-03-13 15:12 ` Jan Beulich
2025-03-12 4:06 ` [PATCH v1 11/19] xen/sysctl: wrap around XEN_SYSCTL_page_offline_op Penny Zheng
2025-03-12 23:19 ` Stefano Stabellini
2025-03-13 8:47 ` Jan Beulich
2025-03-12 4:06 ` [PATCH v1 12/19] xen/sysctl: wrap around XEN_SYSCTL_cpupool_op Penny Zheng
2025-03-12 23:23 ` Stefano Stabellini
2025-03-12 4:06 ` [PATCH v1 13/19] xen/sysctl: wrap around XEN_SYSCTL_scheduler_op Penny Zheng
2025-03-12 23:26 ` Stefano Stabellini
2025-03-12 4:06 ` [PATCH v1 14/19] xen: make avail_domheap_pages() static Penny Zheng
2025-03-12 23:28 ` Stefano Stabellini
2025-03-12 23:34 ` Stefano Stabellini
2025-03-12 4:06 ` [PATCH v1 15/19] xen/sysctl: wrap around XEN_SYSCTL_physinfo Penny Zheng
2025-03-12 23:35 ` Stefano Stabellini
2025-03-13 9:00 ` Jan Beulich
2025-03-12 4:06 ` [PATCH v1 16/19] xen/sysctl: wrap around XEN_SYSCTL_coverage_op Penny Zheng
2025-03-12 23:37 ` Stefano Stabellini
2025-03-12 4:06 ` [PATCH v1 17/19] xen/sysctl: wrap around XEN_SYSCTL_livepatch_op Penny Zheng
2025-03-12 23:38 ` Stefano Stabellini
2025-03-13 9:04 ` Jan Beulich
2025-03-12 4:06 ` [PATCH v1 18/19] xen/sysctl: wrap around arch-specific arch_do_sysctl Penny Zheng
2025-03-12 23:44 ` Stefano Stabellini
2025-03-13 9:05 ` Jan Beulich
2025-03-13 16:33 ` Jan Beulich
2025-03-24 7:59 ` Penny, Zheng
2025-03-24 10:09 ` Jan Beulich
2025-03-12 4:06 ` [PATCH v1 19/19] xen/sysctl: wrap around sysctl hypercall Penny Zheng
2025-03-14 9:27 ` Jan Beulich
2025-03-24 6:11 ` Penny, Zheng
2025-03-24 10:12 ` 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=D8F41PA5JHTU.ABSSG427OH5@cloud.com \
--to=alejandro.vallejo@cloud.com \
--cc=Penny.Zheng@amd.com \
--cc=dpsmith@apertussolutions.com \
--cc=ray.huang@amd.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.