11/*
2- * SPDX-FileCopyrightText: Copyright (c) 2013-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+ * SPDX-FileCopyrightText: Copyright (c) 2013-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33 * SPDX-License-Identifier: MIT
44 *
55 * Permission is hereby granted, free of charge, to any person obtaining a
@@ -1505,41 +1505,49 @@ NV_STATUS nvUvmInterfaceCslInitContext(UvmCslContext *uvmCslContext,
15051505void nvUvmInterfaceDeinitCslContext (UvmCslContext * uvmCslContext );
15061506
15071507/*******************************************************************************
1508- nvUvmInterfaceCslUpdateContext
1508+ nvUvmInterfaceCslRotateKey
15091509
1510- Updates a context after a key rotation event and can only be called once per
1511- key rotation event. Following a key rotation event, and before
1512- nvUvmInterfaceCslUpdateContext is called, data encrypted by the GPU with the
1513- previous key can be decrypted with nvUvmInterfaceCslDecrypt.
1510+ Disables channels and rotates keys.
15141511
1515- Locking: This function acquires an API lock.
1516- Memory : This function does not dynamically allocate memory.
1512+ This function disables channels and rotates associated keys. The channels
1513+ associated with the given CSL contexts must be idled before this function is
1514+ called. To trigger key rotation all allocated channels for a given key must
1515+ be present in the list. If the function returns successfully then the CSL
1516+ contexts have been updated with the new key.
15171517
1518- Arguments:
1519- uvmCslContext[IN] - The CSL context associated with a channel.
1518+ Locking: This function attempts to acquire the GPU lock. In case of failure
1519+ to acquire the return code is NV_ERR_STATE_IN_USE. The caller must
1520+ guarantee that no CSL function, including this one, is invoked
1521+ concurrently with the CSL contexts in contextList.
1522+ Memory : This function dynamically allocates memory.
15201523
1524+ Arguments:
1525+ contextList[IN/OUT] - An array of pointers to CSL contexts.
1526+ contextListCount[IN] - Number of CSL contexts in contextList. Its value
1527+ must be greater than 0.
15211528 Error codes:
1522- NV_ERR_INVALID_ARGUMENT - The CSL context is not associated with a channel.
1529+ NV_ERR_INVALID_ARGUMENT - contextList is NULL or contextListCount is 0.
1530+ NV_ERR_STATE_IN_USE - Unable to acquire lock / resource. Caller
1531+ can retry at a later time.
1532+ NV_ERR_GENERIC - A failure other than _STATE_IN_USE occurred
1533+ when attempting to acquire a lock.
15231534*/
1524- NV_STATUS nvUvmInterfaceCslUpdateContext (UvmCslContext * uvmCslContext );
1535+ NV_STATUS nvUvmInterfaceCslRotateKey (UvmCslContext * contextList [],
1536+ NvU32 contextListCount );
15251537
15261538/*******************************************************************************
15271539 nvUvmInterfaceCslRotateIv
15281540
15291541 Rotates the IV for a given channel and operation.
15301542
15311543 This function will rotate the IV on both the CPU and the GPU.
1532- Outstanding messages that have been encrypted by the GPU should first be
1533- decrypted before calling this function with operation equal to
1534- UVM_CSL_OPERATION_DECRYPT. Similarly, outstanding messages that have been
1535- encrypted by the CPU should first be decrypted before calling this function
1536- with operation equal to UVM_CSL_OPERATION_ENCRYPT. For a given operation
1537- the channel must be idle before calling this function. This function can be
1538- called regardless of the value of the IV's message counter.
1539-
1540- Locking: This function attempts to acquire the GPU lock.
1541- In case of failure to acquire the return code
1542- is NV_ERR_STATE_IN_USE.
1544+ For a given operation the channel must be idle before calling this function.
1545+ This function can be called regardless of the value of the IV's message counter.
1546+
1547+ Locking: This function attempts to acquire the GPU lock. In case of failure to
1548+ acquire the return code is NV_ERR_STATE_IN_USE. The caller must guarantee
1549+ that no CSL function, including this one, is invoked concurrently with
1550+ the same CSL context.
15431551 Memory : This function does not dynamically allocate memory.
15441552
15451553Arguments:
@@ -1573,8 +1581,8 @@ NV_STATUS nvUvmInterfaceCslRotateIv(UvmCslContext *uvmCslContext,
15731581 However, it is optional. If it is NULL, the next IV in line will be used.
15741582
15751583 Locking: This function does not acquire an API or GPU lock.
1576- If called concurrently in different threads with the same UvmCslContext
1577- the caller must guarantee exclusion .
1584+ The caller must guarantee that no CSL function, including this one,
1585+ is invoked concurrently with the same CSL context .
15781586 Memory : This function does not dynamically allocate memory.
15791587
15801588Arguments:
@@ -1610,9 +1618,14 @@ NV_STATUS nvUvmInterfaceCslEncrypt(UvmCslContext *uvmCslContext,
16101618 maximized when the input and output buffers are 16-byte aligned. This is
16111619 natural alignment for AES block.
16121620
1621+ During a key rotation event the previous key is stored in the CSL context.
1622+ This allows data encrypted by the GPU to be decrypted with the previous key.
1623+ The keyRotationId parameter identifies which key is used. The first key rotation
1624+ ID has a value of 0 that increments by one for each key rotation event.
1625+
16131626 Locking: This function does not acquire an API or GPU lock.
1614- If called concurrently in different threads with the same UvmCslContext
1615- the caller must guarantee exclusion .
1627+ The caller must guarantee that no CSL function, including this one,
1628+ is invoked concurrently with the same CSL context .
16161629 Memory : This function does not dynamically allocate memory.
16171630
16181631 Arguments:
@@ -1622,6 +1635,8 @@ NV_STATUS nvUvmInterfaceCslEncrypt(UvmCslContext *uvmCslContext,
16221635 decryptIv[IN] - IV used to decrypt the ciphertext. Its value can either be given by
16231636 nvUvmInterfaceCslIncrementIv, or, if NULL, the CSL context's
16241637 internal counter is used.
1638+ keyRotationId[IN] - Specifies the key that is used for decryption.
1639+ A value of NV_U32_MAX specifies the current key.
16251640 inputBuffer[IN] - Address of ciphertext input buffer.
16261641 outputBuffer[OUT] - Address of plaintext output buffer.
16271642 addAuthData[IN] - Address of the plaintext additional authenticated data used to
@@ -1642,6 +1657,7 @@ NV_STATUS nvUvmInterfaceCslDecrypt(UvmCslContext *uvmCslContext,
16421657 NvU32 bufferSize ,
16431658 NvU8 const * inputBuffer ,
16441659 UvmCslIv const * decryptIv ,
1660+ NvU32 keyRotationId ,
16451661 NvU8 * outputBuffer ,
16461662 NvU8 const * addAuthData ,
16471663 NvU32 addAuthDataSize ,
@@ -1656,8 +1672,8 @@ NV_STATUS nvUvmInterfaceCslDecrypt(UvmCslContext *uvmCslContext,
16561672 undefined behavior.
16571673
16581674 Locking: This function does not acquire an API or GPU lock.
1659- If called concurrently in different threads with the same UvmCslContext
1660- the caller must guarantee exclusion .
1675+ The caller must guarantee that no CSL function, including this one,
1676+ is invoked concurrently with the same CSL context .
16611677 Memory : This function does not dynamically allocate memory.
16621678
16631679 Arguments:
@@ -1685,8 +1701,8 @@ NV_STATUS nvUvmInterfaceCslSign(UvmCslContext *uvmCslContext,
16851701
16861702 Locking: This function does not acquire an API or GPU lock.
16871703 Memory : This function does not dynamically allocate memory.
1688- If called concurrently in different threads with the same UvmCslContext
1689- the caller must guarantee exclusion .
1704+ The caller must guarantee that no CSL function, including this one,
1705+ is invoked concurrently with the same CSL context .
16901706
16911707 Arguments:
16921708 uvmCslContext[IN/OUT] - The CSL context.
@@ -1711,8 +1727,8 @@ NV_STATUS nvUvmInterfaceCslQueryMessagePool(UvmCslContext *uvmCslContext,
17111727 the returned IV can be used in nvUvmInterfaceCslDecrypt.
17121728
17131729 Locking: This function does not acquire an API or GPU lock.
1714- If called concurrently in different threads with the same UvmCslContext
1715- the caller must guarantee exclusion .
1730+ The caller must guarantee that no CSL function, including this one,
1731+ is invoked concurrently with the same CSL context .
17161732 Memory : This function does not dynamically allocate memory.
17171733
17181734Arguments:
@@ -1734,28 +1750,41 @@ NV_STATUS nvUvmInterfaceCslIncrementIv(UvmCslContext *uvmCslContext,
17341750 UvmCslIv * iv );
17351751
17361752/*******************************************************************************
1737- nvUvmInterfaceCslLogExternalEncryption
1753+ nvUvmInterfaceCslLogEncryption
1754+
1755+ Checks and logs information about encryptions associated with the given
1756+ CSL context.
17381757
1739- Checks and logs information about non-CSL encryptions, such as those that
1740- originate from the GPU.
1758+ For contexts associated with channels, this function does not modify elements of
1759+ the UvmCslContext, and must be called for every CPU/ GPU encryption .
17411760
1742- This function does not modify elements of the UvmCslContext.
1761+ For the context associated with fault buffers, bufferSize can encompass multiple
1762+ encryption invocations, and the UvmCslContext will be updated following a key
1763+ rotation event.
1764+
1765+ In either case the IV remains unmodified after this function is called.
17431766
17441767 Locking: This function does not acquire an API or GPU lock.
17451768 Memory : This function does not dynamically allocate memory.
1746- If called concurrently in different threads with the same UvmCslContext
1747- the caller must guarantee exclusion .
1769+ The caller must guarantee that no CSL function, including this one,
1770+ is invoked concurrently with the same CSL context .
17481771
17491772 Arguments:
17501773 uvmCslContext[IN/OUT] - The CSL context.
1751- bufferSize[OUT] - The size of the buffer encrypted by the
1774+ operation[IN] - If the CSL context is associated with a fault
1775+ buffer, this argument is ignored. If it is
1776+ associated with a channel, it must be either
1777+ - UVM_CSL_OPERATION_ENCRYPT
1778+ - UVM_CSL_OPERATION_DECRYPT
1779+ bufferSize[IN] - The size of the buffer(s) encrypted by the
17521780 external entity in units of bytes.
17531781
17541782 Error codes:
1755- NV_ERR_INSUFFICIENT_RESOURCES - The device encryption would cause a counter
1783+ NV_ERR_INSUFFICIENT_RESOURCES - The encryption would cause a counter
17561784 to overflow.
17571785*/
1758- NV_STATUS nvUvmInterfaceCslLogExternalEncryption (UvmCslContext * uvmCslContext ,
1759- NvU32 bufferSize );
1786+ NV_STATUS nvUvmInterfaceCslLogEncryption (UvmCslContext * uvmCslContext ,
1787+ UvmCslOperation operation ,
1788+ NvU32 bufferSize );
17601789
17611790#endif // _NV_UVM_INTERFACE_H_
0 commit comments