[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b4f8ca28-f24a-d619-3682-d92fb35db56d@intel.com>
Date: Thu, 16 Jun 2022 12:25:20 -0700
From: Sohil Mehta <sohil.mehta@...el.com>
To: <ira.weiny@...el.com>, <linux-api@...r.kernel.org>
CC: Dave Hansen <dave.hansen@...ux.intel.com>,
"Aneesh Kumar K . V" <aneesh.kumar@...ux.ibm.com>,
<x86@...nel.org>, <linuxppc-dev@...ts.ozlabs.org>,
<linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
<linux-kselftest@...r.kernel.org>
Subject: Re: [RFC PATCH 3/6] testing/pkeys: Add additional test for
pkey_alloc()
On 6/10/2022 4:35 PM, ira.weiny@...el.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.
> +}
> +
Powered by blists - more mailing lists