mirror of
https://github.com/NVIDIA/open-gpu-kernel-modules.git
synced 2026-02-01 05:59:48 +00:00
550.40.55
This commit is contained in:
@@ -57,7 +57,11 @@
|
||||
#include "nv-dmabuf.h"
|
||||
#include "nv-caps-imex.h"
|
||||
|
||||
#if !defined(CONFIG_RETPOLINE)
|
||||
/*
|
||||
* Commit aefb2f2e619b ("x86/bugs: Rename CONFIG_RETPOLINE =>
|
||||
* CONFIG_MITIGATION_RETPOLINE) in v6.8 renamed CONFIG_RETPOLINE.
|
||||
*/
|
||||
#if !defined(CONFIG_RETPOLINE) && !defined(CONFIG_MITIGATION_RETPOLINE)
|
||||
#include "nv-retpoline.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -250,6 +250,7 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += num_registered_fb
|
||||
NV_CONFTEST_TYPE_COMPILE_TESTS += pci_driver_has_driver_managed_dma
|
||||
NV_CONFTEST_TYPE_COMPILE_TESTS += vm_area_struct_has_const_vm_flags
|
||||
NV_CONFTEST_TYPE_COMPILE_TESTS += memory_failure_has_trapno_arg
|
||||
NV_CONFTEST_TYPE_COMPILE_TESTS += foll_longterm_present
|
||||
|
||||
NV_CONFTEST_GENERIC_COMPILE_TESTS += dom0_kernel_present
|
||||
NV_CONFTEST_GENERIC_COMPILE_TESTS += nvidia_vgpu_kvm_build
|
||||
|
||||
@@ -26,6 +26,12 @@
|
||||
#include "os-interface.h"
|
||||
#include "nv-linux.h"
|
||||
|
||||
#if defined(NVCPU_FAMILY_X86) && defined(NV_FOLL_LONGTERM_PRESENT) && \
|
||||
(defined(NV_PIN_USER_PAGES_HAS_ARGS_VMAS) || \
|
||||
defined(NV_GET_USER_PAGES_HAS_ARGS_FLAGS_VMAS))
|
||||
#define NV_NUM_PIN_PAGES_PER_ITERATION 0x80000
|
||||
#endif
|
||||
|
||||
static inline int nv_follow_pfn(struct vm_area_struct *vma,
|
||||
unsigned long address,
|
||||
unsigned long *pfn)
|
||||
@@ -163,9 +169,15 @@ NV_STATUS NV_API_CALL os_lock_user_pages(
|
||||
NV_STATUS rmStatus;
|
||||
struct mm_struct *mm = current->mm;
|
||||
struct page **user_pages;
|
||||
NvU64 i, pinned;
|
||||
NvU64 i;
|
||||
NvU64 npages = page_count;
|
||||
NvU64 pinned = 0;
|
||||
unsigned int gup_flags = DRF_VAL(_LOCK_USER_PAGES, _FLAGS, _WRITE, flags) ? FOLL_WRITE : 0;
|
||||
int ret;
|
||||
long ret;
|
||||
|
||||
#if defined(NVCPU_FAMILY_X86) && defined(NV_FOLL_LONGTERM_PRESENT)
|
||||
gup_flags |= FOLL_LONGTERM;
|
||||
#endif
|
||||
|
||||
if (!NV_MAY_SLEEP())
|
||||
{
|
||||
@@ -185,16 +197,51 @@ NV_STATUS NV_API_CALL os_lock_user_pages(
|
||||
|
||||
nv_mmap_read_lock(mm);
|
||||
ret = NV_PIN_USER_PAGES((unsigned long)address,
|
||||
page_count, gup_flags, user_pages);
|
||||
nv_mmap_read_unlock(mm);
|
||||
pinned = ret;
|
||||
|
||||
if (ret < 0)
|
||||
npages, gup_flags, user_pages);
|
||||
if (ret > 0)
|
||||
{
|
||||
os_free_mem(user_pages);
|
||||
return NV_ERR_INVALID_ADDRESS;
|
||||
pinned = ret;
|
||||
}
|
||||
else if (pinned < page_count)
|
||||
#if defined(NVCPU_FAMILY_X86) && defined(NV_FOLL_LONGTERM_PRESENT) && \
|
||||
(defined(NV_PIN_USER_PAGES_HAS_ARGS_VMAS) || \
|
||||
defined(NV_GET_USER_PAGES_HAS_ARGS_FLAGS_VMAS))
|
||||
//
|
||||
// NV_PIN_USER_PAGES() passes in NULL for the vmas parameter (if required)
|
||||
// in pin_user_pages() (or get_user_pages() if pin_user_pages() does not
|
||||
// exist). For kernels which do not contain the commit 52650c8b466b
|
||||
// (mm/gup: remove the vma allocation from gup_longterm_locked()), if
|
||||
// FOLL_LONGTERM is passed in, this results in the kernel trying to kcalloc
|
||||
// the vmas array, and since the limit for kcalloc is 4 MB, it results in
|
||||
// NV_PIN_USER_PAGES() failing with ENOMEM if more than
|
||||
// NV_NUM_PIN_PAGES_PER_ITERATION pages are requested on 64-bit systems.
|
||||
//
|
||||
// As a workaround, if we requested more than
|
||||
// NV_NUM_PIN_PAGES_PER_ITERATION pages and failed with ENOMEM, try again
|
||||
// with multiple calls of NV_NUM_PIN_PAGES_PER_ITERATION pages at a time.
|
||||
//
|
||||
else if ((ret == -ENOMEM) &&
|
||||
(page_count > NV_NUM_PIN_PAGES_PER_ITERATION))
|
||||
{
|
||||
for (pinned = 0; pinned < page_count; pinned += ret)
|
||||
{
|
||||
npages = page_count - pinned;
|
||||
if (npages > NV_NUM_PIN_PAGES_PER_ITERATION)
|
||||
{
|
||||
npages = NV_NUM_PIN_PAGES_PER_ITERATION;
|
||||
}
|
||||
|
||||
ret = NV_PIN_USER_PAGES(((unsigned long) address) + (pinned * PAGE_SIZE),
|
||||
npages, gup_flags, &user_pages[pinned]);
|
||||
if (ret <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
nv_mmap_read_unlock(mm);
|
||||
|
||||
if (pinned < page_count)
|
||||
{
|
||||
for (i = 0; i < pinned; i++)
|
||||
NV_UNPIN_USER_PAGE(user_pages[i]);
|
||||
|
||||
Reference in New Issue
Block a user