mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
ANDROID: KVM: arm64: Do not pass host struct pointers to pkvm_vcpu_put()
This function only works for loaded vcpus and no more information is needed by hyp. This removes the need to access potentially unsafe host memory. Bug: 220830416 Signed-off-by: Fuad Tabba <tabba@google.com> Change-Id: I09cb49b06e541bba09e91ce5885b963b88a3c315
This commit is contained in:
committed by
Quentin Perret
parent
6733943e55
commit
0e6b940fce
@@ -567,7 +567,7 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
|
||||
if (is_protected_kvm_enabled()) {
|
||||
kvm_call_hyp(__vgic_v3_save_vmcr_aprs,
|
||||
&vcpu->arch.vgic_cpu.vgic_v3);
|
||||
kvm_call_hyp_nvhe(__pkvm_vcpu_put, vcpu);
|
||||
kvm_call_hyp_nvhe(__pkvm_vcpu_put);
|
||||
|
||||
/* __pkvm_vcpu_put implies a sync of the state */
|
||||
if (!kvm_vm_is_protected(vcpu->kvm))
|
||||
|
||||
@@ -665,19 +665,17 @@ static void handle___pkvm_vcpu_load(struct kvm_cpu_context *host_ctxt)
|
||||
|
||||
static void handle___pkvm_vcpu_put(struct kvm_cpu_context *host_ctxt)
|
||||
{
|
||||
DECLARE_REG(struct kvm_vcpu *, vcpu, host_ctxt, 1);
|
||||
|
||||
if (unlikely(is_protected_kvm_enabled())) {
|
||||
struct pkvm_loaded_state *state = this_cpu_ptr(&loaded_state);
|
||||
|
||||
vcpu = kern_hyp_va(vcpu);
|
||||
if (state->vcpu) {
|
||||
struct kvm_vcpu *host_vcpu = state->vcpu->arch.pkvm.host_vcpu;
|
||||
|
||||
if (state->vcpu && state->vcpu->arch.pkvm.host_vcpu == vcpu) {
|
||||
if (state->vcpu->arch.flags & KVM_ARM64_FP_ENABLED)
|
||||
fpsimd_host_restore();
|
||||
|
||||
if (!state->is_protected &&
|
||||
!(READ_ONCE(vcpu->arch.flags) & KVM_ARM64_PKVM_STATE_DIRTY))
|
||||
!(READ_ONCE(host_vcpu->arch.flags) & KVM_ARM64_PKVM_STATE_DIRTY))
|
||||
__sync_vcpu_state(state->vcpu);
|
||||
|
||||
put_shadow_vcpu(state->vcpu);
|
||||
|
||||
Reference in New Issue
Block a user