Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ccp: Make snp_reclaim_pages and __sev_do_cmd_locked public

The snp_reclaim_pages() helper reclaims pages in the FW state. SEV-TIO
and the TMPM driver (a hardware engine which smashes IOMMU PDEs among
other things) will use to reclaim memory when cleaning up.

Share and export snp_reclaim_pages().

Most of the SEV-TIO code uses sev_do_cmd() which locks the sev_cmd_mutex
and already exported. But the SNP init code (which also sets up SEV-TIO)
executes under the sev_cmd_mutex lock so the SEV-TIO code has to use
the __sev_do_cmd_locked() helper. This one though does not need to be
exported/shared globally as SEV-TIO is a part of the CCP driver still.

Share __sev_do_cmd_locked() via the CCP internal header.

Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
Link: https://patch.msgid.link/20251202024449.542361-2-aik@amd.com
Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

authored by

Alexey Kardashevskiy and committed by
Dan Williams
8a5dd102 f7ae6d4e

+11 -8
+3 -8
drivers/crypto/ccp/sev-dev.c
··· 387 387 return sev_write_init_ex_file(); 388 388 } 389 389 390 - /* 391 - * snp_reclaim_pages() needs __sev_do_cmd_locked(), and __sev_do_cmd_locked() 392 - * needs snp_reclaim_pages(), so a forward declaration is needed. 393 - */ 394 - static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret); 395 - 396 - static int snp_reclaim_pages(unsigned long paddr, unsigned int npages, bool locked) 390 + int snp_reclaim_pages(unsigned long paddr, unsigned int npages, bool locked) 397 391 { 398 392 int ret, err, i; 399 393 ··· 421 427 snp_leak_pages(__phys_to_pfn(paddr), npages - i); 422 428 return ret; 423 429 } 430 + EXPORT_SYMBOL_GPL(snp_reclaim_pages); 424 431 425 432 static int rmp_mark_pages_firmware(unsigned long paddr, unsigned int npages, bool locked) 426 433 { ··· 852 857 return 0; 853 858 } 854 859 855 - static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret) 860 + int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret) 856 861 { 857 862 struct cmd_buf_desc desc_list[CMD_BUF_DESC_MAX] = {0}; 858 863 struct psp_device *psp = psp_master;
+2
drivers/crypto/ccp/sev-dev.h
··· 66 66 int sev_dev_init(struct psp_device *psp); 67 67 void sev_dev_destroy(struct psp_device *psp); 68 68 69 + int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret); 70 + 69 71 void sev_pci_init(void); 70 72 void sev_pci_exit(void); 71 73
+6
include/linux/psp-sev.h
··· 992 992 993 993 void *psp_copy_user_blob(u64 uaddr, u32 len); 994 994 void *snp_alloc_firmware_page(gfp_t mask); 995 + int snp_reclaim_pages(unsigned long paddr, unsigned int npages, bool locked); 995 996 void snp_free_firmware_page(void *addr); 996 997 void sev_platform_shutdown(void); 997 998 bool sev_is_snp_ciphertext_hiding_supported(void); ··· 1026 1025 static inline void *snp_alloc_firmware_page(gfp_t mask) 1027 1026 { 1028 1027 return NULL; 1028 + } 1029 + 1030 + static inline int snp_reclaim_pages(unsigned long paddr, unsigned int npages, bool locked) 1031 + { 1032 + return -ENODEV; 1029 1033 } 1030 1034 1031 1035 static inline void snp_free_firmware_page(void *addr) { }