mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
Most implementations cache the combined result of two-stage translation, but some, like Andes cores, use split TLBs that store VS-stage and G-stage entries separately. On such systems, when a VCPU migrates to another CPU, an additional HFENCE.VVMA is required to avoid using stale VS-stage entries, which could otherwise cause guest faults. Introduce a static key to identify CPUs with split two-stage TLBs. When enabled, KVM issues an extra HFENCE.VVMA on VCPU migration to prevent stale VS-stage mappings. Signed-off-by: Hui Min Mina Chou <minachou@andestech.com> Signed-off-by: Ben Zong-You Xie <ben717@andestech.com> Reviewed-by: Radim Krčmář <rkrcmar@ventanamicro.com> Reviewed-by: Nutty Liu <nutty.liu@hotmail.com> Link: https://lore.kernel.org/r/20251117084555.157642-1-minachou@andestech.com Signed-off-by: Anup Patel <anup@brainfault.org>
27 lines
654 B
C
27 lines
654 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (c) 2025 Ventana Micro Systems Inc.
|
|
*/
|
|
|
|
#ifndef __RISCV_KVM_VMID_H_
|
|
#define __RISCV_KVM_VMID_H_
|
|
|
|
#include <linux/kvm_types.h>
|
|
|
|
struct kvm_vmid {
|
|
/*
|
|
* Writes to vmid_version and vmid happen with vmid_lock held
|
|
* whereas reads happen without any lock held.
|
|
*/
|
|
unsigned long vmid_version;
|
|
unsigned long vmid;
|
|
};
|
|
|
|
void __init kvm_riscv_gstage_vmid_detect(void);
|
|
unsigned long kvm_riscv_gstage_vmid_bits(void);
|
|
int kvm_riscv_gstage_vmid_init(struct kvm *kvm);
|
|
bool kvm_riscv_gstage_vmid_ver_changed(struct kvm_vmid *vmid);
|
|
void kvm_riscv_gstage_vmid_update(struct kvm_vcpu *vcpu);
|
|
|
|
#endif
|