Commit 18827eee authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Michael Ellerman

KVM: PPC: Remove kvmppc_claim_lpid

Removing kvmppc_claim_lpid makes the lpid allocator API a bit simpler to
change the underlying implementation in a future patch.

The host LPID is always 0, so that can be a detail of the allocator. If
the allocator range is restricted, that can reserve LPIDs at the top of
the range. This allows kvmppc_claim_lpid to be removed.
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220123120043.3586018-2-npiggin@gmail.com
parent 361234d7
...@@ -877,7 +877,6 @@ int kvm_vcpu_ioctl_dirty_tlb(struct kvm_vcpu *vcpu, ...@@ -877,7 +877,6 @@ int kvm_vcpu_ioctl_dirty_tlb(struct kvm_vcpu *vcpu,
struct kvm_dirty_tlb *cfg); struct kvm_dirty_tlb *cfg);
long kvmppc_alloc_lpid(void); long kvmppc_alloc_lpid(void);
void kvmppc_claim_lpid(long lpid);
void kvmppc_free_lpid(long lpid); void kvmppc_free_lpid(long lpid);
void kvmppc_init_lpid(unsigned long nr_lpids); void kvmppc_init_lpid(unsigned long nr_lpids);
......
...@@ -256,14 +256,15 @@ void kvmppc_map_vrma(struct kvm_vcpu *vcpu, struct kvm_memory_slot *memslot, ...@@ -256,14 +256,15 @@ void kvmppc_map_vrma(struct kvm_vcpu *vcpu, struct kvm_memory_slot *memslot,
int kvmppc_mmu_hv_init(void) int kvmppc_mmu_hv_init(void)
{ {
unsigned long host_lpid, rsvd_lpid; unsigned long rsvd_lpid;
if (!mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE)) if (!mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE))
return -EINVAL; return -EINVAL;
host_lpid = 0; if (cpu_has_feature(CPU_FTR_HVMODE)) {
if (cpu_has_feature(CPU_FTR_HVMODE)) if (WARN_ON(mfspr(SPRN_LPID) != 0))
host_lpid = mfspr(SPRN_LPID); return -EINVAL;
}
/* POWER8 and above have 12-bit LPIDs (10-bit in POWER7) */ /* POWER8 and above have 12-bit LPIDs (10-bit in POWER7) */
if (cpu_has_feature(CPU_FTR_ARCH_207S)) if (cpu_has_feature(CPU_FTR_ARCH_207S))
...@@ -271,11 +272,8 @@ int kvmppc_mmu_hv_init(void) ...@@ -271,11 +272,8 @@ int kvmppc_mmu_hv_init(void)
else else
rsvd_lpid = LPID_RSVD_POWER7; rsvd_lpid = LPID_RSVD_POWER7;
kvmppc_init_lpid(rsvd_lpid + 1);
kvmppc_claim_lpid(host_lpid);
/* rsvd_lpid is reserved for use in partition switching */ /* rsvd_lpid is reserved for use in partition switching */
kvmppc_claim_lpid(rsvd_lpid); kvmppc_init_lpid(rsvd_lpid);
return 0; return 0;
} }
......
...@@ -399,7 +399,6 @@ static int __init kvmppc_e500mc_init(void) ...@@ -399,7 +399,6 @@ static int __init kvmppc_e500mc_init(void)
* allocator. * allocator.
*/ */
kvmppc_init_lpid(KVMPPC_NR_LPIDS/threads_per_core); kvmppc_init_lpid(KVMPPC_NR_LPIDS/threads_per_core);
kvmppc_claim_lpid(0); /* host */
r = kvm_init(NULL, sizeof(struct kvmppc_vcpu_e500), 0, THIS_MODULE); r = kvm_init(NULL, sizeof(struct kvmppc_vcpu_e500), 0, THIS_MODULE);
if (r) if (r)
......
...@@ -2515,12 +2515,6 @@ long kvmppc_alloc_lpid(void) ...@@ -2515,12 +2515,6 @@ long kvmppc_alloc_lpid(void)
} }
EXPORT_SYMBOL_GPL(kvmppc_alloc_lpid); EXPORT_SYMBOL_GPL(kvmppc_alloc_lpid);
void kvmppc_claim_lpid(long lpid)
{
set_bit(lpid, lpid_inuse);
}
EXPORT_SYMBOL_GPL(kvmppc_claim_lpid);
void kvmppc_free_lpid(long lpid) void kvmppc_free_lpid(long lpid)
{ {
clear_bit(lpid, lpid_inuse); clear_bit(lpid, lpid_inuse);
...@@ -2531,6 +2525,7 @@ void kvmppc_init_lpid(unsigned long nr_lpids_param) ...@@ -2531,6 +2525,7 @@ void kvmppc_init_lpid(unsigned long nr_lpids_param)
{ {
nr_lpids = min_t(unsigned long, KVMPPC_NR_LPIDS, nr_lpids_param); nr_lpids = min_t(unsigned long, KVMPPC_NR_LPIDS, nr_lpids_param);
memset(lpid_inuse, 0, sizeof(lpid_inuse)); memset(lpid_inuse, 0, sizeof(lpid_inuse));
set_bit(0, lpid_inuse); /* The host LPID must always be 0 */
} }
EXPORT_SYMBOL_GPL(kvmppc_init_lpid); EXPORT_SYMBOL_GPL(kvmppc_init_lpid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment