ANDROID: KVM: arm64: Separate functions for pvm sysreg init and reset

Different actions need to be taken on sysreg initialization
compared with on reset. Split the function into two to be able to
control what happens and when.

Bug: 357781595
Change-Id: I33a612738993bdd2dab936c7a1ac08d3c7ef45b1
Signed-off-by: Fuad Tabba <tabba@google.com>
This commit is contained in:
Fuad Tabba
2024-11-25 13:05:58 +00:00
parent 65702a481a
commit 2ca26e65e1
3 changed files with 23 additions and 12 deletions
+1
View File
@@ -113,6 +113,7 @@ void put_pkvm_hyp_vm(struct pkvm_hyp_vm *hyp_vm);
bool kvm_handle_pvm_sysreg(struct kvm_vcpu *vcpu, u64 *exit_code);
bool kvm_handle_pvm_restricted(struct kvm_vcpu *vcpu, u64 *exit_code);
void kvm_init_pvm_id_regs(struct kvm_vcpu *vcpu);
void kvm_reset_pvm_sys_regs(struct kvm_vcpu *vcpu);
int kvm_check_pvm_sysreg_table(void);
+1
View File
@@ -652,6 +652,7 @@ static int init_pkvm_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu,
hyp_vcpu->vcpu.arch.debug_ptr = &host_vcpu->arch.vcpu_debug_state;
hyp_vcpu->vcpu.arch.hyp_reqs->type = KVM_HYP_LAST_REQ;
kvm_init_pvm_id_regs(&hyp_vcpu->vcpu);
kvm_reset_pvm_sys_regs(&hyp_vcpu->vcpu);
ret = pkvm_vcpu_init_traps(hyp_vcpu);
+21 -12
View File
@@ -614,12 +614,9 @@ static const struct sys_reg_desc_reset pvm_sys_reg_reset_vals[] = {
};
/*
* Sets system registers to reset value
*
* This function finds the right entry and sets the registers on the protected
* vcpu to their architecturally defined reset values.
* Initializes feature registers for protected vms.
*/
void kvm_reset_pvm_sys_regs(struct kvm_vcpu *vcpu)
void kvm_init_pvm_id_regs(struct kvm_vcpu *vcpu)
{
/* List of feature registers to reset for protected VMs. */
const u32 pvm_feat_id_regs[] = {
@@ -636,13 +633,7 @@ void kvm_reset_pvm_sys_regs(struct kvm_vcpu *vcpu)
SYS_ID_AA64DFR0_EL1,
};
struct kvm *kvm = vcpu->kvm;
unsigned long i;
for (i = 0; i < ARRAY_SIZE(pvm_sys_reg_reset_vals); i++) {
const struct sys_reg_desc_reset *r = &pvm_sys_reg_reset_vals[i];
r->reset(vcpu, r);
}
int i;
if (test_bit(KVM_ARCH_FLAG_ID_REGS_INITIALIZED, &kvm->arch.flags))
return;
@@ -657,6 +648,24 @@ void kvm_reset_pvm_sys_regs(struct kvm_vcpu *vcpu)
set_bit(KVM_ARCH_FLAG_ID_REGS_INITIALIZED, &kvm->arch.flags);
}
/*
* Sets system registers to reset value
*
* This function finds the right entry and sets the registers on the protected
* vcpu to their architecturally defined reset values.
*/
void kvm_reset_pvm_sys_regs(struct kvm_vcpu *vcpu)
{
unsigned long i;
for (i = 0; i < ARRAY_SIZE(pvm_sys_reg_reset_vals); i++) {
const struct sys_reg_desc_reset *r = &pvm_sys_reg_reset_vals[i];
r->reset(vcpu, r);
}
}
/*
* Checks that the sysreg tables are unique and in-order.
*