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.

crypto: ccp - Refactor out sev_fw_alloc()

Create a helper function sev_fw_alloc() which can be used to allocate
aligned memory regions for use by the PSP firmware. Currently only used
for the SEV-ES TMR region but will be used for the SEV_INIT_EX NV memory
region.

Signed-off-by: Peter Gonda <pgonda@google.com>
Reviewed-by: Marc Orr <marcorr@google.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Brijesh Singh <brijesh.singh@amd.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Marc Orr <marcorr@google.com>
Cc: Joerg Roedel <jroedel@suse.de>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David Rientjes <rientjes@google.com>
Cc: John Allen <john.allen@amd.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-crypto@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Peter Gonda and committed by
Herbert Xu
cc17982d e423b9d7

+13 -7
+13 -7
drivers/crypto/ccp/sev-dev.c
··· 141 141 return 0; 142 142 } 143 143 144 + static void *sev_fw_alloc(unsigned long len) 145 + { 146 + struct page *page; 147 + 148 + page = alloc_pages(GFP_KERNEL, get_order(len)); 149 + if (!page) 150 + return NULL; 151 + 152 + return page_address(page); 153 + } 154 + 144 155 static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret) 145 156 { 146 157 struct psp_device *psp = psp_master; ··· 1089 1078 void sev_pci_init(void) 1090 1079 { 1091 1080 struct sev_device *sev = psp_master->sev_data; 1092 - struct page *tmr_page; 1093 1081 int error, rc; 1094 1082 1095 1083 if (!sev) ··· 1104 1094 sev_get_api_version(); 1105 1095 1106 1096 /* Obtain the TMR memory area for SEV-ES use */ 1107 - tmr_page = alloc_pages(GFP_KERNEL, get_order(SEV_ES_TMR_SIZE)); 1108 - if (tmr_page) { 1109 - sev_es_tmr = page_address(tmr_page); 1110 - } else { 1111 - sev_es_tmr = NULL; 1097 + sev_es_tmr = sev_fw_alloc(SEV_ES_TMR_SIZE); 1098 + if (!sev_es_tmr) 1112 1099 dev_warn(sev->dev, 1113 1100 "SEV: TMR allocation failed, SEV-ES support unavailable\n"); 1114 - } 1115 1101 1116 1102 /* Initialize the platform */ 1117 1103 rc = sev_platform_init(&error);