FROMLIST: KVM: arm64: Factor out vector address calculation
In order to re-map the guest vectors at EL2 when pKVM is enabled, refactor __kvm_vector_slot2idx() and kvm_init_vector_slot() to move all the address calculation logic in a static inline function. Acked-by: Will Deacon <will@kernel.org> Signed-off-by: Quentin Perret <qperret@google.com> Link: https://lore.kernel.org/r/20210315143536.214621-16-qperret@google.com Bug: 178098380 Change-Id: I52442e4b873cb881b2306dc2aacd3060812f5520
This commit is contained in:
@@ -168,6 +168,14 @@ phys_addr_t kvm_mmu_get_httbr(void);
|
|||||||
phys_addr_t kvm_get_idmap_vector(void);
|
phys_addr_t kvm_get_idmap_vector(void);
|
||||||
int kvm_mmu_init(void);
|
int kvm_mmu_init(void);
|
||||||
|
|
||||||
|
static inline void *__kvm_vector_slot2addr(void *base,
|
||||||
|
enum arm64_hyp_spectre_vector slot)
|
||||||
|
{
|
||||||
|
int idx = slot - (slot != HYP_VECTOR_DIRECT);
|
||||||
|
|
||||||
|
return base + (idx * SZ_2K);
|
||||||
|
}
|
||||||
|
|
||||||
struct kvm;
|
struct kvm;
|
||||||
|
|
||||||
#define kvm_flush_dcache_to_poc(a,l) __flush_dcache_area((a), (l))
|
#define kvm_flush_dcache_to_poc(a,l) __flush_dcache_area((a), (l))
|
||||||
|
@@ -1359,16 +1359,9 @@ static unsigned long nvhe_percpu_order(void)
|
|||||||
/* A lookup table holding the hypervisor VA for each vector slot */
|
/* A lookup table holding the hypervisor VA for each vector slot */
|
||||||
static void *hyp_spectre_vector_selector[BP_HARDEN_EL2_SLOTS];
|
static void *hyp_spectre_vector_selector[BP_HARDEN_EL2_SLOTS];
|
||||||
|
|
||||||
static int __kvm_vector_slot2idx(enum arm64_hyp_spectre_vector slot)
|
|
||||||
{
|
|
||||||
return slot - (slot != HYP_VECTOR_DIRECT);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void kvm_init_vector_slot(void *base, enum arm64_hyp_spectre_vector slot)
|
static void kvm_init_vector_slot(void *base, enum arm64_hyp_spectre_vector slot)
|
||||||
{
|
{
|
||||||
int idx = __kvm_vector_slot2idx(slot);
|
hyp_spectre_vector_selector[slot] = __kvm_vector_slot2addr(base, slot);
|
||||||
|
|
||||||
hyp_spectre_vector_selector[slot] = base + (idx * SZ_2K);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int kvm_init_vector_slots(void)
|
static int kvm_init_vector_slots(void)
|
||||||
|
Reference in New Issue
Block a user