Revert "ANDROID: KVM: arm64: Remove stale shadow_handle field"

This reverts commit 10bb2d3f93.

Bug: 233587962
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I8cbfe4020bc6349887ccacf8fde477db6b076686
This commit is contained in:
Will Deacon
2022-07-07 15:48:47 +01:00
parent b6e3528d30
commit c845bb9e8d
3 changed files with 17 additions and 1 deletions

View File

@@ -214,6 +214,9 @@ struct kvm_arch {
};
struct kvm_protected_vcpu {
/* A unique id to the shadow structs in the hyp shadow area. */
int shadow_handle;
/* A pointer to the host's vcpu. */
struct kvm_vcpu *host_vcpu;

View File

@@ -445,6 +445,7 @@ static int init_shadow_structs(struct kvm *kvm, struct kvm_shadow_vm *vm,
shadow_state->vm = vm;
shadow_vcpu->arch.hw_mmu = &vm->arch.mmu;
shadow_vcpu->arch.pkvm.shadow_handle = vm->shadow_handle;
shadow_vcpu->arch.pkvm.shadow_vm = vm;
shadow_vcpu->arch.power_off = true;

View File

@@ -105,6 +105,14 @@ void __init kvm_hyp_reserve(void)
hyp_mem_base);
}
/*
* Updates the state of the host's version of the vcpu state.
*/
static void update_vcpu_state(struct kvm_vcpu *vcpu, int shadow_handle)
{
vcpu->arch.pkvm.shadow_handle = shadow_handle;
}
/*
* Allocates and donates memory for EL2 shadow structs.
*
@@ -122,7 +130,7 @@ static int __create_el2_shadow(struct kvm *kvm)
void *pgd, *shadow_addr;
unsigned long idx;
int shadow_handle;
int ret;
int ret, i;
if (kvm->created_vcpus < 1)
return -EINVAL;
@@ -163,6 +171,10 @@ static int __create_el2_shadow(struct kvm *kvm)
/* Store the shadow handle given by hyp for future call reference. */
kvm->arch.pkvm.shadow_handle = shadow_handle;
/* Adjust host's vcpu state as it doesn't control it anymore. */
for (i = 0; i < kvm->created_vcpus; i++)
update_vcpu_state(kvm->vcpus[i], shadow_handle);
return 0;
free_shadow: