Skip to content

Commit

Permalink
KVM: SVM: remove double lock of psc lock in dump_ghcb()
Browse files Browse the repository at this point in the history
dump_ghcb() is called from sev_es_validate_vmgexit() which already holds
the psc_lock and runs with the ghcb mapped. No need to map it again, so
remove this.
  • Loading branch information
jepio committed Jan 20, 2023
1 parent 5725b12 commit e14fff2
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions arch/x86/kvm/svm/sev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2929,21 +2929,17 @@ static inline void svm_unmap_ghcb(struct vcpu_svm *svm, struct kvm_host_map *map
sev_post_unmap_gfn(vcpu->kvm, map->gfn, map->pfn);
}

static void dump_ghcb(struct vcpu_svm *svm)
static void dump_ghcb(struct vcpu_svm *svm, struct kvm_host_map *map)
{
struct kvm_host_map map;
unsigned int nbits;
struct ghcb *ghcb;

if (svm_map_ghcb(svm, &map))
return;

ghcb = map.hva;
ghcb = map->hva;

/* Re-use the dump_invalid_vmcb module parameter */
if (!dump_invalid_vmcb) {
pr_warn_ratelimited("set kvm_amd.dump_invalid_vmcb=1 to dump internal KVM state.\n");
goto e_unmap;
return;
}

nbits = sizeof(ghcb->save.valid_bitmap) * 8;
Expand All @@ -2958,9 +2954,6 @@ static void dump_ghcb(struct vcpu_svm *svm)
pr_err("%-20s%016llx is_valid: %u\n", "sw_scratch",
ghcb->save.sw_scratch, ghcb_sw_scratch_is_valid(ghcb));
pr_err("%-20s%*pb\n", "valid_bitmap", nbits, ghcb->save.valid_bitmap);

e_unmap:
svm_unmap_ghcb(svm, &map);
}

static bool sev_es_sync_to_ghcb(struct vcpu_svm *svm)
Expand Down Expand Up @@ -3200,7 +3193,7 @@ static int sev_es_validate_vmgexit(struct vcpu_svm *svm, u64 *exit_code)
} else {
vcpu_unimpl(vcpu, "vmgexit: exit code %#llx input is not valid\n",
*exit_code);
dump_ghcb(svm);
dump_ghcb(svm, &map);
}

/* Clear the valid entries fields */
Expand Down

0 comments on commit e14fff2

Please sign in to comment.