~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/mm/mem_encrypt.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/x86/mm/mem_encrypt.c (Architecture m68k) and /arch/i386/mm/mem_encrypt.c (Architecture i386)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  * Memory Encryption Support Common Code          
  4  *                                                
  5  * Copyright (C) 2016 Advanced Micro Devices,     
  6  *                                                
  7  * Author: Tom Lendacky <thomas.lendacky@amd.c    
  8  */                                               
  9                                                   
 10 #include <linux/dma-direct.h>                     
 11 #include <linux/dma-mapping.h>                    
 12 #include <linux/swiotlb.h>                        
 13 #include <linux/cc_platform.h>                    
 14 #include <linux/mem_encrypt.h>                    
 15 #include <linux/virtio_anchor.h>                  
 16                                                   
 17 #include <asm/sev.h>                              
 18                                                   
 19 /* Override for DMA direct allocation check -     
 20 bool force_dma_unencrypted(struct device *dev)    
 21 {                                                 
 22         /*                                        
 23          * For SEV, all DMA must be to unencry    
 24          */                                       
 25         if (cc_platform_has(CC_ATTR_GUEST_MEM_    
 26                 return true;                      
 27                                                   
 28         /*                                        
 29          * For SME, all DMA must be to unencry    
 30          * device does not support DMA to addr    
 31          * encryption mask.                       
 32          */                                       
 33         if (cc_platform_has(CC_ATTR_HOST_MEM_E    
 34                 u64 dma_enc_mask = DMA_BIT_MAS    
 35                 u64 dma_dev_mask = min_not_zer    
 36                                                   
 37                                                   
 38                 if (dma_dev_mask <= dma_enc_ma    
 39                         return true;              
 40         }                                         
 41                                                   
 42         return false;                             
 43 }                                                 
 44                                                   
 45 static void print_mem_encrypt_feature_info(voi    
 46 {                                                 
 47         pr_info("Memory Encryption Features ac    
 48                                                   
 49         switch (cc_vendor) {                      
 50         case CC_VENDOR_INTEL:                     
 51                 pr_cont("Intel TDX\n");           
 52                 break;                            
 53         case CC_VENDOR_AMD:                       
 54                 pr_cont("AMD");                   
 55                                                   
 56                 /* Secure Memory Encryption */    
 57                 if (cc_platform_has(CC_ATTR_HO    
 58                 /*                                
 59                  * SME is mutually exclusive w    
 60                  * features below.                
 61                 */                                
 62                         pr_cont(" SME\n");        
 63                         return;                   
 64                 }                                 
 65                                                   
 66                 /* Secure Encrypted Virtualiza    
 67                 if (cc_platform_has(CC_ATTR_GU    
 68                         pr_cont(" SEV");          
 69                                                   
 70                 /* Encrypted Register State */    
 71                 if (cc_platform_has(CC_ATTR_GU    
 72                         pr_cont(" SEV-ES");       
 73                                                   
 74                 /* Secure Nested Paging */        
 75                 if (cc_platform_has(CC_ATTR_GU    
 76                         pr_cont(" SEV-SNP");      
 77                                                   
 78                 pr_cont("\n");                    
 79                                                   
 80                 sev_show_status();                
 81                                                   
 82                 break;                            
 83         default:                                  
 84                 pr_cont("Unknown\n");             
 85         }                                         
 86 }                                                 
 87                                                   
 88 /* Architecture __weak replacement functions *    
 89 void __init mem_encrypt_init(void)                
 90 {                                                 
 91         if (!cc_platform_has(CC_ATTR_MEM_ENCRY    
 92                 return;                           
 93                                                   
 94         /* Call into SWIOTLB to update the SWI    
 95         swiotlb_update_mem_attributes();          
 96                                                   
 97         print_mem_encrypt_feature_info();         
 98 }                                                 
 99                                                   
100 void __init mem_encrypt_setup_arch(void)          
101 {                                                 
102         phys_addr_t total_mem = memblock_phys_    
103         unsigned long size;                       
104                                                   
105         /*                                        
106          * Do RMP table fixups after the e820     
107          * e820__memory_setup().                  
108          */                                       
109         if (cc_platform_has(CC_ATTR_HOST_SEV_S    
110                 snp_fixup_e820_tables();          
111                                                   
112         if (!cc_platform_has(CC_ATTR_GUEST_MEM    
113                 return;                           
114                                                   
115         /*                                        
116          * For SEV and TDX, all DMA has to occ    
117          * Kernel uses SWIOTLB to make this ha    
118          * drivers. However, depending on the     
119          * default 64MB of SWIOTLB may not be     
120          * run out of buffers for DMA, resulti    
121          * performance degradation especially     
122          *                                        
123          * Adjust the default size of SWIOTLB     
124          * memory for SWIOTLB buffers. Also, a    
125          * memory is allocated from low memory    
126          * is within the limits of low availab    
127          *                                        
128          * The percentage of guest memory used    
129          * is more of an approximation of the     
130          * 64MB for <1G, and ~128M to 256M for    
131          */                                       
132         size = total_mem * 6 / 100;               
133         size = clamp_val(size, IO_TLB_DEFAULT_    
134         swiotlb_adjust_size(size);                
135                                                   
136         /* Set restricted memory access for vi    
137         virtio_set_mem_acc_cb(virtio_require_r    
138 }                                                 
139                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php