On Fri, 2024-04-19 at 20:14 -0500, Haitao Huang wrote:Sorry I missed this point. below.
> > I think we can add support for "sgx_cgroup=disabled" in future if indeed
> > needed. But just for init failure, no?
> >
>
> It's not about the commandline, which we can add in the future when
> needed. It's about we need to have a way to handle SGX cgroup being
> disabled at boot time nicely, because we already have a case where we > need
> to do so.
>
> Your approach looks half-way to me, and is not future extendible. If we
> choose to do it, do it right -- that is, we need a way to disable it
> completely in both kernel and userspace so that userspace won't be able> to
> see it.
That would need more changes in misc cgroup implementation to support sgx-disable. Right now misc does not have separate files for different resource types. So we can only block echo "sgx_epc..." to those interfacefiles, can't really make files not visible.
"won't be able to see" I mean "only for SGX EPC resource", but not the
control files for the entire MISC cgroup.
I replied at the beginning of the previous reply:
"
Given SGX EPC is just one type of MISC cgroup resources, we cannot just
disable MISC cgroup as a whole.
"
You just need to set the SGX EPC "capacity" to 0 to disable SGX EPC. See
the comment of @misc_res_capacity:
* Miscellaneous resources capacity for the entire machine. 0 capacity
* means resource is not initialized or not present in the host.
And "blocking echo sgx_epc ... to those control files" is alreadyYou are right, capacity == 0 does block echoing max and users see an error if they do that. But 1) doubt you literately wanted "SGX EPC is disabled" and make it unsupported in this case, 2) even if we accept this is "sgx cgroup disabled" I don't see how it is much better user experience than current solution or really helps user better.
sufficient for the purpose of not exposing SGX EPC to userspace, correct?
E.g., if SGX cgroup is enabled, you can see below when you read "max":
# cat /sys/fs/cgroup/my_group/misc.max
# <resource1> <max1>
sgx_epc ...
...
Otherwise you won't be able to see "sgx_epc":
# cat /sys/fs/cgroup/my_group/misc.max
# <resource1> <max1>
...
And when you try to write the "max" for "sgx_epc", you will hit error:
# echo "sgx_epc 100" > /sys/fs/cgroup/my_group/misc.max
# ... echo: write error: Invalid argument
The above applies to all the control files. To me this is pretty much
means "SGX EPC is disabled" or "not supported" for userspace.