@@ -512,7 +512,7 @@ static void vie_calc_bytereg(const struct instr_emul_vie *vie,
512
512
enum cpu_reg_name * reg , int * lhbr )
513
513
{
514
514
* lhbr = 0 ;
515
- * reg = vie -> reg ;
515
+ * reg = ( enum cpu_reg_name )( vie -> reg ) ;
516
516
517
517
/*
518
518
* 64-bit mode imposes limitations on accessing legacy high byte
@@ -529,7 +529,7 @@ static void vie_calc_bytereg(const struct instr_emul_vie *vie,
529
529
if (vie -> rex_present == 0U ) {
530
530
if ((vie -> reg & 0x4U ) != 0U ) {
531
531
* lhbr = 1 ;
532
- * reg = vie -> reg & 0x3U ;
532
+ * reg = ( enum cpu_reg_name )( vie -> reg & 0x3U ) ;
533
533
}
534
534
}
535
535
}
@@ -689,7 +689,7 @@ static int emulate_mov(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie)
689
689
* REX.W + 89/r mov r/m64, r64
690
690
*/
691
691
692
- reg = vie -> reg ;
692
+ reg = ( enum cpu_reg_name )( vie -> reg ) ;
693
693
val = vm_get_register (vcpu , reg );
694
694
val &= size2mask [size ];
695
695
vie_mmio_write (vcpu , val );
@@ -712,7 +712,7 @@ static int emulate_mov(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie)
712
712
* REX.W 8B/r: mov r64, r/m64
713
713
*/
714
714
vie_mmio_read (vcpu , & val );
715
- reg = vie -> reg ;
715
+ reg = ( enum cpu_reg_name )( vie -> reg ) ;
716
716
vie_update_register (vcpu , reg , val , size );
717
717
break ;
718
718
case 0xA1U :
@@ -796,7 +796,7 @@ static int emulate_movx(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie
796
796
vie_mmio_read (vcpu , & val );
797
797
798
798
/* get the second operand */
799
- reg = vie -> reg ;
799
+ reg = ( enum cpu_reg_name )( vie -> reg ) ;
800
800
801
801
/* zero-extend byte */
802
802
val = (uint8_t )val ;
@@ -814,7 +814,7 @@ static int emulate_movx(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie
814
814
*/
815
815
vie_mmio_read (vcpu , & val );
816
816
817
- reg = vie -> reg ;
817
+ reg = ( enum cpu_reg_name )( vie -> reg ) ;
818
818
819
819
/* zero-extend word */
820
820
val = (uint16_t )val ;
@@ -835,7 +835,7 @@ static int emulate_movx(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie
835
835
vie_mmio_read (vcpu , & val );
836
836
837
837
/* get the second operand */
838
- reg = vie -> reg ;
838
+ reg = ( enum cpu_reg_name )( vie -> reg ) ;
839
839
840
840
/* sign extend byte */
841
841
val = (int8_t )val ;
@@ -969,8 +969,8 @@ static int emulate_movs(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie
969
969
uint64_t rcx , rdi , rsi , rflags ;
970
970
uint32_t err_code ;
971
971
enum cpu_reg_name seg ;
972
- int error , repeat ;
973
- uint8_t opsize = vie -> opsize ;
972
+ int error ;
973
+ uint8_t repeat , opsize = vie -> opsize ;
974
974
bool is_mmio_write ;
975
975
976
976
error = 0 ;
@@ -985,7 +985,7 @@ static int emulate_movs(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie
985
985
*/
986
986
repeat = vie -> repz_present | vie -> repnz_present ;
987
987
988
- if (repeat != 0 ) {
988
+ if (repeat != 0U ) {
989
989
rcx = vm_get_register (vcpu , CPU_REG_RCX );
990
990
991
991
/*
@@ -1034,7 +1034,7 @@ static int emulate_movs(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie
1034
1034
vie_update_register (vcpu , CPU_REG_RSI , rsi , vie -> addrsize );
1035
1035
vie_update_register (vcpu , CPU_REG_RDI , rdi , vie -> addrsize );
1036
1036
1037
- if (repeat != 0 ) {
1037
+ if (repeat != 0U ) {
1038
1038
rcx = rcx - 1 ;
1039
1039
vie_update_register (vcpu , CPU_REG_RCX , rcx , vie -> addrsize );
1040
1040
@@ -1051,14 +1051,13 @@ static int emulate_movs(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie
1051
1051
1052
1052
static int emulate_stos (struct acrn_vcpu * vcpu , const struct instr_emul_vie * vie )
1053
1053
{
1054
- int repeat ;
1055
- uint8_t opsize = vie -> opsize ;
1054
+ uint8_t repeat , opsize = vie -> opsize ;
1056
1055
uint64_t val ;
1057
1056
uint64_t rcx , rdi , rflags ;
1058
1057
1059
1058
repeat = vie -> repz_present | vie -> repnz_present ;
1060
1059
1061
- if (repeat != 0 ) {
1060
+ if (repeat != 0U ) {
1062
1061
rcx = vm_get_register (vcpu , CPU_REG_RCX );
1063
1062
1064
1063
/*
@@ -1085,7 +1084,7 @@ static int emulate_stos(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie
1085
1084
1086
1085
vie_update_register (vcpu , CPU_REG_RDI , rdi , vie -> addrsize );
1087
1086
1088
- if (repeat != 0 ) {
1087
+ if (repeat != 0U ) {
1089
1088
rcx = rcx - 1 ;
1090
1089
vie_update_register (vcpu , CPU_REG_RCX , rcx , vie -> addrsize );
1091
1090
@@ -1129,7 +1128,7 @@ static int emulate_test(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie
1129
1128
*/
1130
1129
1131
1130
/* get the first operand */
1132
- reg = vie -> reg ;
1131
+ reg = ( enum cpu_reg_name )( vie -> reg ) ;
1133
1132
val1 = vm_get_register (vcpu , reg );
1134
1133
1135
1134
/* get the second operand */
@@ -1186,7 +1185,7 @@ static int emulate_and(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie)
1186
1185
*/
1187
1186
1188
1187
/* get the first operand */
1189
- reg = vie -> reg ;
1188
+ reg = ( enum cpu_reg_name )( vie -> reg ) ;
1190
1189
val1 = vm_get_register (vcpu , reg );
1191
1190
1192
1191
/* get the second operand */
@@ -1299,7 +1298,7 @@ static int emulate_or(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie)
1299
1298
vie_mmio_read (vcpu , & val1 );
1300
1299
1301
1300
/* get the second operand */
1302
- reg = vie -> reg ;
1301
+ reg = ( enum cpu_reg_name )( vie -> reg ) ;
1303
1302
val2 = vm_get_register (vcpu , reg );
1304
1303
1305
1304
/* perform the operation and write the result */
@@ -1360,7 +1359,7 @@ static int emulate_cmp(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie)
1360
1359
*/
1361
1360
1362
1361
/* Get the register operand */
1363
- reg = vie -> reg ;
1362
+ reg = ( enum cpu_reg_name )( vie -> reg ) ;
1364
1363
regop = vm_get_register (vcpu , reg );
1365
1364
1366
1365
/* Get the memory operand */
@@ -1440,7 +1439,7 @@ static int emulate_sub(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie)
1440
1439
*/
1441
1440
1442
1441
/* get the first operand */
1443
- reg = vie -> reg ;
1442
+ reg = ( enum cpu_reg_name )( vie -> reg ) ;
1444
1443
val1 = vm_get_register (vcpu , reg );
1445
1444
1446
1445
/* get the second operand */
@@ -1847,7 +1846,7 @@ static int decode_modrm(struct instr_emul_vie *vie, enum vm_cpu_mode cpu_mode)
1847
1846
goto done ;
1848
1847
}
1849
1848
1850
- vie -> base_register = vie -> rm ;
1849
+ vie -> base_register = ( enum cpu_reg_name ) vie -> rm ;
1851
1850
1852
1851
switch (vie -> mod ) {
1853
1852
case VIE_MOD_INDIRECT_DISP8 :
@@ -1942,7 +1941,7 @@ static int decode_sib(struct instr_emul_vie *vie)
1942
1941
*/
1943
1942
vie -> disp_bytes = 4U ;
1944
1943
} else {
1945
- vie -> base_register = vie -> base ;
1944
+ vie -> base_register = ( enum cpu_reg_name ) vie -> base ;
1946
1945
}
1947
1946
1948
1947
/*
@@ -1953,7 +1952,7 @@ static int decode_sib(struct instr_emul_vie *vie)
1953
1952
* Table 2-5: Special Cases of REX Encodings
1954
1953
*/
1955
1954
if (vie -> index != 4U ) {
1956
- vie -> index_register = vie -> index ;
1955
+ vie -> index_register = ( enum cpu_reg_name ) vie -> index ;
1957
1956
}
1958
1957
1959
1958
/* 'scale' makes sense only in the context of an index register */
@@ -1968,8 +1967,7 @@ static int decode_sib(struct instr_emul_vie *vie)
1968
1967
1969
1968
static int decode_displacement (struct instr_emul_vie * vie )
1970
1969
{
1971
- int n , i ;
1972
- uint8_t x ;
1970
+ uint8_t n , i , x ;
1973
1971
1974
1972
union {
1975
1973
uint8_t buf [4 ];
@@ -1978,17 +1976,17 @@ static int decode_displacement(struct instr_emul_vie *vie)
1978
1976
} u ;
1979
1977
1980
1978
n = vie -> disp_bytes ;
1981
- if (n == 0 ) {
1979
+ if (n == 0U ) {
1982
1980
return 0 ;
1983
1981
}
1984
1982
1985
- if ((n != 1 ) && (n != 4 )) {
1983
+ if ((n != 1U ) && (n != 4U )) {
1986
1984
pr_err ("%s: decode_displacement: invalid disp_bytes %d" ,
1987
1985
__func__ , n );
1988
1986
return - EINVAL ;
1989
1987
}
1990
1988
1991
- for (i = 0 ; i < n ; i ++ ) {
1989
+ for (i = 0U ; i < n ; i ++ ) {
1992
1990
if (vie_peek (vie , & x ) != 0 ) {
1993
1991
return -1 ;
1994
1992
}
@@ -1997,7 +1995,7 @@ static int decode_displacement(struct instr_emul_vie *vie)
1997
1995
vie_advance (vie );
1998
1996
}
1999
1997
2000
- if (n == 1 ) {
1998
+ if (n == 1U ) {
2001
1999
vie -> displacement = u .signed8 ; /* sign-extended */
2002
2000
} else {
2003
2001
vie -> displacement = u .signed32 ; /* sign-extended */
@@ -2008,8 +2006,7 @@ static int decode_displacement(struct instr_emul_vie *vie)
2008
2006
2009
2007
static int decode_immediate (struct instr_emul_vie * vie )
2010
2008
{
2011
- int i , n ;
2012
- uint8_t x ;
2009
+ uint8_t i , n , x ;
2013
2010
union {
2014
2011
uint8_t buf [4 ];
2015
2012
int8_t signed8 ;
@@ -2039,17 +2036,17 @@ static int decode_immediate(struct instr_emul_vie *vie)
2039
2036
}
2040
2037
2041
2038
n = vie -> imm_bytes ;
2042
- if (n == 0 ) {
2039
+ if (n == 0U ) {
2043
2040
return 0 ;
2044
2041
}
2045
2042
2046
- if ((n != 1 ) && (n != 2 ) && (n != 4 )) {
2043
+ if ((n != 1U ) && (n != 2U ) && (n != 4U )) {
2047
2044
pr_err ("%s: invalid number of immediate bytes: %d" ,
2048
2045
__func__ , n );
2049
2046
return - EINVAL ;
2050
2047
}
2051
2048
2052
- for (i = 0 ; i < n ; i ++ ) {
2049
+ for (i = 0U ; i < n ; i ++ ) {
2053
2050
if (vie_peek (vie , & x ) != 0 ) {
2054
2051
return -1 ;
2055
2052
}
@@ -2059,9 +2056,9 @@ static int decode_immediate(struct instr_emul_vie *vie)
2059
2056
}
2060
2057
2061
2058
/* sign-extend the immediate value before use */
2062
- if (n == 1 ) {
2059
+ if (n == 1U ) {
2063
2060
vie -> immediate = u .signed8 ;
2064
- } else if (n == 2 ) {
2061
+ } else if (n == 2U ) {
2065
2062
vie -> immediate = u .signed16 ;
2066
2063
} else {
2067
2064
vie -> immediate = u .signed32 ;
@@ -2317,7 +2314,7 @@ int32_t emulate_instruction(const struct acrn_vcpu *vcpu)
2317
2314
pr_err ("%s: Failed to get instr_emul_ctxt" , __func__ );
2318
2315
ret = -1 ;
2319
2316
} else {
2320
- ret = vmm_emulate_instruction (ctxt );
2317
+ ret = vmm_emulate_instruction (ctxt );
2321
2318
}
2322
2319
2323
2320
return ret ;
0 commit comments