mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
ANDROID: KVM: arm64: Initialize ptr auth in protected mode
Ensure that pointer authentication is initialized when the vcpu is initialized as well, and not only when the vcpu is reset. Bug: 249192647 Signed-off-by: Fuad Tabba <tabba@google.com> Change-Id: Ida39a3ee5e6b4b0d3255bfef95601890afd80709
This commit is contained in:
@@ -414,6 +414,15 @@ static int set_host_vcpus(struct shadow_vcpu_state *shadow_vcpus, int nr_vcpus,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int init_ptrauth(struct kvm_vcpu *shadow_vcpu)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
if (test_bit(KVM_ARM_VCPU_PTRAUTH_ADDRESS, shadow_vcpu->arch.features) ||
|
||||||
|
test_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, shadow_vcpu->arch.features))
|
||||||
|
ret = kvm_vcpu_enable_ptrauth(shadow_vcpu);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int init_shadow_structs(struct kvm *kvm, struct kvm_shadow_vm *vm,
|
static int init_shadow_structs(struct kvm *kvm, struct kvm_shadow_vm *vm,
|
||||||
struct kvm_vcpu **vcpu_array, int nr_vcpus)
|
struct kvm_vcpu **vcpu_array, int nr_vcpus)
|
||||||
{
|
{
|
||||||
@@ -438,6 +447,10 @@ static int init_shadow_structs(struct kvm *kvm, struct kvm_shadow_vm *vm,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
ret = init_ptrauth(shadow_vcpu);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
if (test_bit(KVM_ARM_VCPU_SVE, shadow_vcpu->arch.features)) {
|
if (test_bit(KVM_ARM_VCPU_SVE, shadow_vcpu->arch.features)) {
|
||||||
size_t sve_state_size;
|
size_t sve_state_size;
|
||||||
void *sve_state;
|
void *sve_state;
|
||||||
@@ -851,14 +864,7 @@ void pkvm_reset_vcpu(struct kvm_vcpu *vcpu)
|
|||||||
|
|
||||||
WARN_ON(!reset_state->reset);
|
WARN_ON(!reset_state->reset);
|
||||||
|
|
||||||
if (test_bit(KVM_ARM_VCPU_PTRAUTH_ADDRESS, vcpu->arch.features) ||
|
init_ptrauth(vcpu);
|
||||||
test_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, vcpu->arch.features)) {
|
|
||||||
/*
|
|
||||||
* This call should not fail since we've already checked for
|
|
||||||
* feature support on initialization.
|
|
||||||
*/
|
|
||||||
WARN_ON(kvm_vcpu_enable_ptrauth(vcpu));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reset core registers */
|
/* Reset core registers */
|
||||||
memset(vcpu_gp_regs(vcpu), 0, sizeof(*vcpu_gp_regs(vcpu)));
|
memset(vcpu_gp_regs(vcpu), 0, sizeof(*vcpu_gp_regs(vcpu)));
|
||||||
|
|||||||
Reference in New Issue
Block a user