mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
ANDROID: BACKPORT: KVM: arm64: Use guest VMID as owner id
We currently track page-ownership in nVHE protected mode with a rather coarse granularity -- all guests share a unique owner id. But a finer grain tracking will be useful soon, to e.g. handle host stage-2 faults caused by an access to guest memory. To prepare the ground for this, let's use the guest VMIDs as owner ids, hence allowing to distinguish between all of them. This only works since the pKVM EL2 hypervisor guarantees the stability of the VMIDs for the entire lifetime of a guest VM. This will need some rework when/if we attempt to run more than 255 guests concurrently in protected mode as we'll have to handle VMID rollovers, but there is no clear need for now, so let's keep it simple to start. Signed-off-by: Quentin Perret <qperret@google.com> [willdeacon@: Update constants in mem_protect.h] Bug: 209580772 Change-Id: I5c5c8061617d7dc481ae5e25a0391b306aabbd8c Signed-off-by: Will Deacon <willdeacon@google.com>
This commit is contained in:
committed by
Will Deacon
parent
5da4a4ca5f
commit
dded44bcfd
@@ -53,8 +53,7 @@ extern struct host_kvm host_kvm;
|
||||
|
||||
typedef u32 pkvm_id;
|
||||
static const pkvm_id pkvm_host_id = 0;
|
||||
static const pkvm_id pkvm_hyp_id = 1;
|
||||
static const pkvm_id pkvm_guest_id = 2;
|
||||
static const pkvm_id pkvm_hyp_id = (1 << 16);
|
||||
|
||||
extern unsigned long hyp_nr_cpus;
|
||||
|
||||
|
||||
@@ -29,6 +29,12 @@ struct host_kvm host_kvm;
|
||||
|
||||
static struct hyp_pool host_s2_pool;
|
||||
|
||||
static pkvm_id pkvm_guest_id(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
return vcpu->arch.hw_mmu->vmid.vmid;
|
||||
|
||||
}
|
||||
|
||||
static DEFINE_PER_CPU(struct kvm_shadow_vm *, __current_vm);
|
||||
#define current_vm (*this_cpu_ptr(&__current_vm))
|
||||
|
||||
@@ -687,6 +693,8 @@ static pkvm_id completer_owner_id(const struct pkvm_mem_transition *tx)
|
||||
return pkvm_host_id;
|
||||
case PKVM_ID_HYP:
|
||||
return pkvm_hyp_id;
|
||||
case PKVM_ID_GUEST:
|
||||
return pkvm_guest_id(tx->completer.guest.vcpu);
|
||||
default:
|
||||
WARN_ON(1);
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user