From: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
To: Christophe Lombard <clombard@linux.vnet.ibm.com>,
linuxppc-dev@lists.ozlabs.org, vaibhav@linux.vnet.ibm.com,
andrew.donnellan@au1.ibm.com
Subject: Re: [PATCH V5] cxl: Add support for ASB_Notify on POWER9
Date: Wed, 20 Dec 2017 20:05:35 +0100 [thread overview]
Message-ID: <d5a44740-a3d5-def3-8ec0-209d7e47c61e@linux.vnet.ibm.com> (raw)
In-Reply-To: <1513790844-27779-1-git-send-email-clombard@linux.vnet.ibm.com>
> --- a/drivers/misc/cxl/file.c
> +++ b/drivers/misc/cxl/file.c
> @@ -173,7 +173,7 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,
> * flags are set it's invalid
> */
> if (work.reserved1 || work.reserved2 || work.reserved3 ||
> - work.reserved4 || work.reserved5 || work.reserved6 ||
> + work.reserved4 || work.reserved5 ||
> (work.flags & ~CXL_START_WORK_ALL)) {
> rc = -EINVAL;
> goto out;
> @@ -248,7 +248,19 @@ static long afu_ioctl_start_work(struct cxl_context *ctx,
> */
> smp_mb();
>
> - trace_cxl_attach(ctx, work.work_element_descriptor, work.num_interrupts, amr);
> + /* Assign a unique TIDR (thread id) for the current thread */
> + if (work.flags & CXL_START_WORK_TID) {
> + rc = cxl_context_thread_tidr(ctx);
> + if (rc)
We're already pretty deep and have allocated quite a few resources, we
we'd need to unwind (see error path below when the attach fails).
However, we cannot clear the thread TIDR register, so we need to be
careful that a user process cannot exhaust our limited pool of TIDs by
calling the attach ioctl with bogus arguments. Which should be easy to
do: attach the max number of contexts, and keep calling attach!
So we're going to need to figure out something to prevent that (define a
max allocation per context? with a value of 1 for now?)
> diff --git a/include/uapi/misc/cxl.h b/include/uapi/misc/cxl.h
> index 49e8fd0..3ea2d4b4 100644
> --- a/include/uapi/misc/cxl.h
> +++ b/include/uapi/misc/cxl.h
> @@ -20,20 +20,22 @@ struct cxl_ioctl_start_work {
> __u64 work_element_descriptor;
> __u64 amr;
> __s16 num_interrupts;
> - __s16 reserved1;
> - __s32 reserved2;
> + __s16 tid;
Should probably be unsigned.
Fred
> + __s32 reserved1;
> + __u64 reserved2;
> __u64 reserved3;
> __u64 reserved4;
> __u64 reserved5;
> - __u64 reserved6;
> };
>
> #define CXL_START_WORK_AMR 0x0000000000000001ULL
> #define CXL_START_WORK_NUM_IRQS 0x0000000000000002ULL
> #define CXL_START_WORK_ERR_FF 0x0000000000000004ULL
> +#define CXL_START_WORK_TID 0x0000000000000008ULL
> #define CXL_START_WORK_ALL (CXL_START_WORK_AMR |\
> CXL_START_WORK_NUM_IRQS |\
> - CXL_START_WORK_ERR_FF)
> + CXL_START_WORK_ERR_FF |\
> + CXL_START_WORK_TID)
>
>
> /* Possible modes that an afu can be in */
>
prev parent reply other threads:[~2017-12-20 19:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-20 17:27 [PATCH V5] cxl: Add support for ASB_Notify on POWER9 Christophe Lombard
2017-12-20 19:05 ` Frederic Barrat [this message]
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=d5a44740-a3d5-def3-8ec0-209d7e47c61e@linux.vnet.ibm.com \
--to=fbarrat@linux.vnet.ibm.com \
--cc=andrew.donnellan@au1.ibm.com \
--cc=clombard@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=vaibhav@linux.vnet.ibm.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).