Skip to content

Commit b3cefd6

Browse files
Janis Schoetterl-Glauschfrankjaa
authored andcommitted
KVM: s390: Pass initialized arg even if unused
This silences smatch warnings reported by kbuild bot: arch/s390/kvm/gaccess.c:859 guest_range_to_gpas() error: uninitialized symbol 'prot'. arch/s390/kvm/gaccess.c:1064 access_guest_with_key() error: uninitialized symbol 'prot'. This is because it cannot tell that the value is not used in this case. The trans_exc* only examine prot if code is PGM_PROTECTION. Pass a dummy value for other codes. Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Janis Schoetterl-Glausch <[email protected]> Reviewed-by: Claudio Imbrenda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Borntraeger <[email protected]> Signed-off-by: Janosch Frank <[email protected]>
1 parent e8c924a commit b3cefd6

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

arch/s390/kvm/gaccess.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,8 @@ enum prot_type {
489489
PROT_TYPE_ALC = 2,
490490
PROT_TYPE_DAT = 3,
491491
PROT_TYPE_IEP = 4,
492+
/* Dummy value for passing an initialized value when code != PGM_PROTECTION */
493+
PROT_NONE,
492494
};
493495

494496
static int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva, u8 ar,
@@ -504,6 +506,10 @@ static int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva,
504506
switch (code) {
505507
case PGM_PROTECTION:
506508
switch (prot) {
509+
case PROT_NONE:
510+
/* We should never get here, acts like termination */
511+
WARN_ON_ONCE(1);
512+
break;
507513
case PROT_TYPE_IEP:
508514
tec->b61 = 1;
509515
fallthrough;
@@ -968,8 +974,10 @@ static int guest_range_to_gpas(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar,
968974
return rc;
969975
} else {
970976
gpa = kvm_s390_real_to_abs(vcpu, ga);
971-
if (kvm_is_error_gpa(vcpu->kvm, gpa))
977+
if (kvm_is_error_gpa(vcpu->kvm, gpa)) {
972978
rc = PGM_ADDRESSING;
979+
prot = PROT_NONE;
980+
}
973981
}
974982
if (rc)
975983
return trans_exc(vcpu, rc, ga, ar, mode, prot);
@@ -1112,8 +1120,6 @@ int access_guest_with_key(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar,
11121120
if (rc == PGM_PROTECTION && try_storage_prot_override)
11131121
rc = access_guest_page_with_key(vcpu->kvm, mode, gpas[idx],
11141122
data, fragment_len, PAGE_SPO_ACC);
1115-
if (rc == PGM_PROTECTION)
1116-
prot = PROT_TYPE_KEYC;
11171123
if (rc)
11181124
break;
11191125
len -= fragment_len;
@@ -1123,6 +1129,10 @@ int access_guest_with_key(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar,
11231129
if (rc > 0) {
11241130
bool terminate = (mode == GACC_STORE) && (idx > 0);
11251131

1132+
if (rc == PGM_PROTECTION)
1133+
prot = PROT_TYPE_KEYC;
1134+
else
1135+
prot = PROT_NONE;
11261136
rc = trans_exc_ending(vcpu, rc, ga, ar, mode, prot, terminate);
11271137
}
11281138
out_unlock:

0 commit comments

Comments
 (0)