lkml.org 
[lkml]   [2022]   [Jun]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC PATCH 3/6] testing/pkeys: Add additional test for pkey_alloc()
From
On 6/10/2022 4:35 PM, ira.weiny@intel.com wrote:
>
> +void test_pkey_alloc_on_unsupported_cpu(void)
> +{
> + int test_pkey = sys_pkey_alloc(0, 0);
> +
> + dprintf1("pkey_alloc: %d (%d %s)\n", test_pkey, errno,
> + strerror(errno));
> + pkey_assert(test_pkey < 0);
> + pkey_assert(errno == ENOSPC);

This assert fails on a kernel with
CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS disabled.

Since pkey_alloc() is an architecture dependent syscall, ENOSYS is
returned instead of ENOSPC when support is disabled at compile time.
See kernel/sys_ni.c

This brings us to an interesting question.

Should we have different return error codes when compile support is
disabled vs when runtime support is missing?

Here is the current behavior for pkey_alloc():

No compile time support -> return ENOSYS
No runtime support (but compile time support present) -> return ENOSPC

I would think applications would prefer the same error code. But, I am
not sure if we can achieve this now due to ABI reasons.


> +}
> +

\
 
 \ /
  Last update: 2022-06-16 21:27    [W:0.192 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site