Skip to content

Commit 1b98f0d

Browse files
committed
s390/uv: Rename find_secret() to uv_find_secret() and publish
JIRA: https://issues.redhat.com/browse/RHEL-113440 commit 933dd21 Author: Harald Freudenberger <freude@linux.ibm.com> Date: Thu Apr 24 15:36:15 2025 +0200 s390/uv: Rename find_secret() to uv_find_secret() and publish Rename the internal UV function find_secret() to uv_find_secret() and publish it as new UV API in-kernel function. The pkey uv handler may be called in a do-not-allocate memory situation where sleeping is allowed but allocating memory which may cause IO operations is not. For example when an encrypted swap file is used and the encryption is done via UV retrievable secrets with protected keys. The UV API function uv_get_secret_metadata() allocates memory and then calls the find_secret() function. By exposing the find_secret() function as a new UV API function uv_find_secret() it is possible to retrieve UV secret meta data without any memory allocations from the UV when the caller offers space for one struct uv_secret_list. Signed-off-by: Harald Freudenberger <freude@linux.ibm.com> Reviewed-by: Steffen Eiden <seiden@linux.ibm.com> Acked-by: Holger Dengler <dengler@linux.ibm.com> Link: https://lore.kernel.org/r/20250424133619.16495-22-freude@linux.ibm.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
1 parent 931cc47 commit 1b98f0d

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

arch/s390/include/asm/uv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,9 @@ static inline int uv_remove_shared(unsigned long addr)
616616
return share(addr, UVC_CMD_REMOVE_SHARED_ACCESS);
617617
}
618618

619+
int uv_find_secret(const u8 secret_id[UV_SECRET_ID_LEN],
620+
struct uv_secret_list *list,
621+
struct uv_secret_list_item_hdr *secret);
619622
int uv_get_secret_metadata(const u8 secret_id[UV_SECRET_ID_LEN],
620623
struct uv_secret_list_item_hdr *secret);
621624
int uv_retrieve_secret(u16 secret_idx, u8 *buf, size_t buf_size);

arch/s390/kernel/uv.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,12 @@ static int __init uv_sysfs_init(void)
841841
device_initcall(uv_sysfs_init);
842842

843843
/*
844-
* Find the secret with the secret_id in the provided list.
844+
* Locate a secret in the list by its id.
845+
* @secret_id: search pattern.
846+
* @list: ephemeral buffer space
847+
* @secret: output data, containing the secret's metadata.
848+
*
849+
* Search for a secret with the given secret_id in the Ultravisor secret store.
845850
*
846851
* Context: might sleep.
847852
*/
@@ -862,12 +867,15 @@ static int find_secret_in_page(const u8 secret_id[UV_SECRET_ID_LEN],
862867

863868
/*
864869
* Do the actual search for `uv_get_secret_metadata`.
870+
* @secret_id: search pattern.
871+
* @list: ephemeral buffer space
872+
* @secret: output data, containing the secret's metadata.
865873
*
866874
* Context: might sleep.
867875
*/
868-
static int find_secret(const u8 secret_id[UV_SECRET_ID_LEN],
869-
struct uv_secret_list *list,
870-
struct uv_secret_list_item_hdr *secret)
876+
int uv_find_secret(const u8 secret_id[UV_SECRET_ID_LEN],
877+
struct uv_secret_list *list,
878+
struct uv_secret_list_item_hdr *secret)
871879
{
872880
u16 start_idx = 0;
873881
u16 list_rc;
@@ -889,6 +897,7 @@ static int find_secret(const u8 secret_id[UV_SECRET_ID_LEN],
889897

890898
return -ENOENT;
891899
}
900+
EXPORT_SYMBOL_GPL(uv_find_secret);
892901

893902
/**
894903
* uv_get_secret_metadata() - get secret metadata for a given secret id.
@@ -914,7 +923,7 @@ int uv_get_secret_metadata(const u8 secret_id[UV_SECRET_ID_LEN],
914923
buf = kzalloc(sizeof(*buf), GFP_KERNEL);
915924
if (!buf)
916925
return -ENOMEM;
917-
rc = find_secret(secret_id, buf, secret);
926+
rc = uv_find_secret(secret_id, buf, secret);
918927
kfree(buf);
919928
return rc;
920929
}

0 commit comments

Comments
 (0)