From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Nicholas Piggin <npiggin@gmail.com>
Subject: [PATCH 1/6] KVM: PPC: Remove kvmppc_claim_lpid
Date: Sun, 23 Jan 2022 22:00:38 +1000 [thread overview]
Message-ID: <20220123120043.3586018-2-npiggin@gmail.com> (raw)
In-Reply-To: <20220123120043.3586018-1-npiggin@gmail.com>
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.
---
arch/powerpc/include/asm/kvm_ppc.h | 1 -
arch/powerpc/kvm/book3s_64_mmu_hv.c | 14 ++++++--------
arch/powerpc/kvm/e500mc.c | 1 -
arch/powerpc/kvm/powerpc.c | 7 +------
4 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index a14dbcd1b8ce..7e22199a95c9 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -863,7 +863,6 @@ int kvm_vcpu_ioctl_dirty_tlb(struct kvm_vcpu *vcpu,
struct kvm_dirty_tlb *cfg);
long kvmppc_alloc_lpid(void);
-void kvmppc_claim_lpid(long lpid);
void kvmppc_free_lpid(long lpid);
void kvmppc_init_lpid(unsigned long nr_lpids);
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
index 213232914367..09fc52b6f390 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -256,14 +256,15 @@ void kvmppc_map_vrma(struct kvm_vcpu *vcpu, struct kvm_memory_slot *memslot,
int kvmppc_mmu_hv_init(void)
{
- unsigned long host_lpid, rsvd_lpid;
+ unsigned long rsvd_lpid;
if (!mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE))
return -EINVAL;
- host_lpid = 0;
- if (cpu_has_feature(CPU_FTR_HVMODE))
- host_lpid = mfspr(SPRN_LPID);
+ if (cpu_has_feature(CPU_FTR_HVMODE)) {
+ if (WARN_ON(mfspr(SPRN_LPID) != 0))
+ return -EINVAL;
+ }
/* POWER8 and above have 12-bit LPIDs (10-bit in POWER7) */
if (cpu_has_feature(CPU_FTR_ARCH_207S))
@@ -271,11 +272,8 @@ int kvmppc_mmu_hv_init(void)
else
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 */
- kvmppc_claim_lpid(rsvd_lpid);
+ kvmppc_init_lpid(rsvd_lpid);
return 0;
}
diff --git a/arch/powerpc/kvm/e500mc.c b/arch/powerpc/kvm/e500mc.c
index 1c189b5aadcc..7087d8f2037a 100644
--- a/arch/powerpc/kvm/e500mc.c
+++ b/arch/powerpc/kvm/e500mc.c
@@ -398,7 +398,6 @@ static int __init kvmppc_e500mc_init(void)
* allocator.
*/
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);
if (r)
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 2ad0ccd202d5..102993462872 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -2472,12 +2472,6 @@ long kvmppc_alloc_lpid(void)
}
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)
{
clear_bit(lpid, lpid_inuse);
@@ -2488,6 +2482,7 @@ void kvmppc_init_lpid(unsigned long nr_lpids_param)
{
nr_lpids = min_t(unsigned long, KVMPPC_NR_LPIDS, nr_lpids_param);
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);
--
2.23.0
next prev parent reply other threads:[~2022-01-23 12:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-23 12:00 [PATCH 0/6] KVM: PPC: Book3S: Make LPID/nested LPID allocations dynamic Nicholas Piggin
2022-01-23 12:00 ` Nicholas Piggin [this message]
2022-01-23 12:00 ` [PATCH 2/6] KVM: PPC: Book3S HV: Update LPID allocator init for POWER9, Nested Nicholas Piggin
2022-01-24 22:13 ` Fabiano Rosas
2022-01-23 12:00 ` [PATCH 3/6] KVM: PPC: Book3S HV: Use IDA allocator for LPID allocator Nicholas Piggin
2022-01-24 22:13 ` Fabiano Rosas
2022-01-23 12:00 ` [PATCH 4/6] KVM: PPC: Book3S HV Nested: Change nested guest lookup to use idr Nicholas Piggin
2022-01-24 22:14 ` Fabiano Rosas
2022-01-23 12:00 ` [PATCH 5/6] KVM: PPC: Book3S Nested: Use explicit 4096 LPID maximum Nicholas Piggin
2022-01-24 22:15 ` Fabiano Rosas
2022-01-23 12:00 ` [PATCH 6/6] KVM: PPC: Book3S HV: Remove KVMPPC_NR_LPIDS Nicholas Piggin
2022-01-24 22:15 ` Fabiano Rosas
2022-05-24 10:51 ` [PATCH 0/6] KVM: PPC: Book3S: Make LPID/nested LPID allocations dynamic Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220123120043.3586018-2-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).