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

TOMOYO Linux Cross Reference
Linux/arch/arm64/kvm/hyp/aarch32.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/arm64/kvm/hyp/aarch32.c (Architecture sparc) and /arch/i386/kvm/hyp/aarch32.c (Architecture i386)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /*                                                
  3  * Hyp portion of the (not much of an) Emulati    
  4  *                                                
  5  * Copyright (C) 2012,2013 - ARM Ltd              
  6  * Author: Marc Zyngier <marc.zyngier@arm.com>    
  7  *                                                
  8  * based on arch/arm/kvm/emulate.c                
  9  * Copyright (C) 2012 - Virtual Open Systems a    
 10  * Author: Christoffer Dall <c.dall@virtualope    
 11  */                                               
 12                                                   
 13 #include <linux/kvm_host.h>                       
 14 #include <asm/kvm_emulate.h>                      
 15 #include <asm/kvm_hyp.h>                          
 16                                                   
 17 /*                                                
 18  * stolen from arch/arm/kernel/opcodes.c          
 19  *                                                
 20  * condition code lookup table                    
 21  * index into the table is test code: EQ, NE,     
 22  *                                                
 23  * bit position in short is condition code: NZ    
 24  */                                               
 25 static const unsigned short cc_map[16] = {        
 26         0xF0F0,                 /* EQ == Z set    
 27         0x0F0F,                 /* NE             
 28         0xCCCC,                 /* CS == C set    
 29         0x3333,                 /* CC             
 30         0xFF00,                 /* MI == N set    
 31         0x00FF,                 /* PL             
 32         0xAAAA,                 /* VS == V set    
 33         0x5555,                 /* VC             
 34         0x0C0C,                 /* HI == C set    
 35         0xF3F3,                 /* LS == C cle    
 36         0xAA55,                 /* GE == (N==V    
 37         0x55AA,                 /* LT == (N!=V    
 38         0x0A05,                 /* GT == (!Z &    
 39         0xF5FA,                 /* LE == (Z ||    
 40         0xFFFF,                 /* AL always      
 41         0                       /* NV             
 42 };                                                
 43                                                   
 44 /*                                                
 45  * Check if a trapped instruction should have     
 46  */                                               
 47 bool kvm_condition_valid32(const struct kvm_vc    
 48 {                                                 
 49         unsigned long cpsr;                       
 50         u32 cpsr_cond;                            
 51         int cond;                                 
 52                                                   
 53         /*                                        
 54          * These are the exception classes tha    
 55          * conditional instruction.               
 56          */                                       
 57         switch (kvm_vcpu_trap_get_class(vcpu))    
 58         case ESR_ELx_EC_CP15_32:                  
 59         case ESR_ELx_EC_CP15_64:                  
 60         case ESR_ELx_EC_CP14_MR:                  
 61         case ESR_ELx_EC_CP14_LS:                  
 62         case ESR_ELx_EC_FP_ASIMD:                 
 63         case ESR_ELx_EC_CP10_ID:                  
 64         case ESR_ELx_EC_CP14_64:                  
 65         case ESR_ELx_EC_SVC32:                    
 66                 break;                            
 67         default:                                  
 68                 return true;                      
 69         }                                         
 70                                                   
 71         /* Is condition field valid? */           
 72         cond = kvm_vcpu_get_condition(vcpu);      
 73         if (cond == 0xE)                          
 74                 return true;                      
 75                                                   
 76         cpsr = *vcpu_cpsr(vcpu);                  
 77                                                   
 78         if (cond < 0) {                           
 79                 /* This can happen in Thumb mo    
 80                 unsigned long it;                 
 81                                                   
 82                 it = ((cpsr >> 8) & 0xFC) | ((    
 83                                                   
 84                 /* it == 0 => unconditional. *    
 85                 if (it == 0)                      
 86                         return true;              
 87                                                   
 88                 /* The cond for this insn work    
 89                 cond = (it >> 4);                 
 90         }                                         
 91                                                   
 92         cpsr_cond = cpsr >> 28;                   
 93                                                   
 94         if (!((cc_map[cond] >> cpsr_cond) & 1)    
 95                 return false;                     
 96                                                   
 97         return true;                              
 98 }                                                 
 99                                                   
100 /**                                               
101  * kvm_adjust_itstate - adjust ITSTATE when em    
102  * @vcpu:       The VCPU pointer                  
103  *                                                
104  * When exceptions occur while instructions ar    
105  * blocks, the ITSTATE field of the CPSR is no    
106  * to do this little bit of work manually. The    
107  *                                                
108  * IT[7:0] -> CPSR[26:25],CPSR[15:10]             
109  */                                               
110 static void kvm_adjust_itstate(struct kvm_vcpu    
111 {                                                 
112         unsigned long itbits, cond;               
113         unsigned long cpsr = *vcpu_cpsr(vcpu);    
114         bool is_arm = !(cpsr & PSR_AA32_T_BIT)    
115                                                   
116         if (is_arm || !(cpsr & PSR_AA32_IT_MAS    
117                 return;                           
118                                                   
119         cond = (cpsr & 0xe000) >> 13;             
120         itbits = (cpsr & 0x1c00) >> (10 - 2);     
121         itbits |= (cpsr & (0x3 << 25)) >> 25;     
122                                                   
123         /* Perform ITAdvance (see page A2-52 i    
124         if ((itbits & 0x7) == 0)                  
125                 itbits = cond = 0;                
126         else                                      
127                 itbits = (itbits << 1) & 0x1f;    
128                                                   
129         cpsr &= ~PSR_AA32_IT_MASK;                
130         cpsr |= cond << 13;                       
131         cpsr |= (itbits & 0x1c) << (10 - 2);      
132         cpsr |= (itbits & 0x3) << 25;             
133         *vcpu_cpsr(vcpu) = cpsr;                  
134 }                                                 
135                                                   
136 /**                                               
137  * kvm_skip_instr32 - skip a trapped instructi    
138  * @vcpu: The vcpu pointer                        
139  */                                               
140 void kvm_skip_instr32(struct kvm_vcpu *vcpu)      
141 {                                                 
142         u32 pc = *vcpu_pc(vcpu);                  
143         bool is_thumb;                            
144                                                   
145         is_thumb = !!(*vcpu_cpsr(vcpu) & PSR_A    
146         if (is_thumb && !kvm_vcpu_trap_il_is32    
147                 pc += 2;                          
148         else                                      
149                 pc += 4;                          
150                                                   
151         *vcpu_pc(vcpu) = pc;                      
152                                                   
153         kvm_adjust_itstate(vcpu);                 
154 }                                                 
155                                                   

~ [ 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