Skip to content

Commit cc4ce37

Browse files
committed
KVM: SVM: Set sev->asid in sev_asid_new() instead of overloading the return
Explicitly set sev->asid in sev_asid_new() when a new ASID is successfully allocated, and return '0' to indicate success instead of overloading the return value to multiplex the ASID with error codes. There is exactly one caller of sev_asid_new(), and sev_asid_free() already consumes sev->asid, i.e. returning the ASID isn't necessary for flexibility, nor does it provide symmetry between related APIs. Reviewed-by: Tom Lendacky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 41bccc9 commit cc4ce37

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ static int sev_asid_new(struct kvm_sev_info *sev)
179179

180180
mutex_unlock(&sev_bitmap_lock);
181181

182-
return asid;
182+
sev->asid = asid;
183+
return 0;
183184
e_uncharge:
184185
sev_misc_cg_uncharge(sev);
185186
put_misc_cg(sev->misc_cg);
@@ -246,7 +247,7 @@ static void sev_unbind_asid(struct kvm *kvm, unsigned int handle)
246247
static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
247248
{
248249
struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
249-
int asid, ret;
250+
int ret;
250251

251252
if (kvm->created_vcpus)
252253
return -EINVAL;
@@ -257,10 +258,9 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
257258

258259
sev->active = true;
259260
sev->es_active = argp->id == KVM_SEV_ES_INIT;
260-
asid = sev_asid_new(sev);
261-
if (asid < 0)
261+
ret = sev_asid_new(sev);
262+
if (ret)
262263
goto e_no_asid;
263-
sev->asid = asid;
264264

265265
ret = sev_platform_init(&argp->error);
266266
if (ret)

0 commit comments

Comments
 (0)