From: David Gibson <david@gibson.dropbear.id.au>
To: Bharata B Rao <bharata@linux.ibm.com>
Cc: farosas@linux.ibm.com, aneesh.kumar@linux.ibm.com,
npiggin@gmail.com, kvm-ppc@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v6 6/6] KVM: PPC: Book3S HV: Use H_RPT_INVALIDATE in nested KVM
Date: Tue, 23 Mar 2021 02:35:53 +0000 [thread overview]
Message-ID: <YFlUCdMQezdPg9LJ@yekko.fritz.box> (raw)
In-Reply-To: <20210311083939.595568-7-bharata@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 3909 bytes --]
On Thu, Mar 11, 2021 at 02:09:39PM +0530, Bharata B Rao wrote:
> In the nested KVM case, replace H_TLB_INVALIDATE by the new hcall
> H_RPT_INVALIDATE if available. The availability of this hcall
> is determined from "hcall-rpt-invalidate" string in ibm,hypertas-functions
> DT property.
>
> Signed-off-by: Bharata B Rao <bharata@linux.ibm.com>
> Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> arch/powerpc/kvm/book3s_64_mmu_radix.c | 27 +++++++++++++++++++++-----
> arch/powerpc/kvm/book3s_hv_nested.c | 12 ++++++++++--
> 2 files changed, 32 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> index e603de7ade52..1e1e55fd0ee5 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> @@ -21,6 +21,7 @@
> #include <asm/pte-walk.h>
> #include <asm/ultravisor.h>
> #include <asm/kvm_book3s_uvmem.h>
> +#include <asm/plpar_wrappers.h>
>
> /*
> * Supported radix tree geometry.
> @@ -318,9 +319,19 @@ void kvmppc_radix_tlbie_page(struct kvm *kvm, unsigned long addr,
> }
>
> psi = shift_to_mmu_psize(pshift);
> - rb = addr | (mmu_get_ap(psi) << PPC_BITLSHIFT(58));
> - rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(0, 0, 1),
> - lpid, rb);
> +
> + if (!firmware_has_feature(FW_FEATURE_RPT_INVALIDATE)) {
> + rb = addr | (mmu_get_ap(psi) << PPC_BITLSHIFT(58));
> + rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(0, 0, 1),
> + lpid, rb);
> + } else {
> + rc = pseries_rpt_invalidate(lpid, H_RPTI_TARGET_CMMU,
> + H_RPTI_TYPE_NESTED |
> + H_RPTI_TYPE_TLB,
> + psize_to_rpti_pgsize(psi),
> + addr, addr + psize);
> + }
> +
> if (rc)
> pr_err("KVM: TLB page invalidation hcall failed, rc=%ld\n", rc);
> }
> @@ -334,8 +345,14 @@ static void kvmppc_radix_flush_pwc(struct kvm *kvm, unsigned int lpid)
> return;
> }
>
> - rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(1, 0, 1),
> - lpid, TLBIEL_INVAL_SET_LPID);
> + if (!firmware_has_feature(FW_FEATURE_RPT_INVALIDATE))
> + rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(1, 0, 1),
> + lpid, TLBIEL_INVAL_SET_LPID);
> + else
> + rc = pseries_rpt_invalidate(lpid, H_RPTI_TARGET_CMMU,
> + H_RPTI_TYPE_NESTED |
> + H_RPTI_TYPE_PWC, H_RPTI_PAGE_ALL,
> + 0, -1UL);
> if (rc)
> pr_err("KVM: TLB PWC invalidation hcall failed, rc=%ld\n", rc);
> }
> diff --git a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3s_hv_nested.c
> index adcc8e26ef22..5601b7eb9b89 100644
> --- a/arch/powerpc/kvm/book3s_hv_nested.c
> +++ b/arch/powerpc/kvm/book3s_hv_nested.c
> @@ -19,6 +19,7 @@
> #include <asm/pgalloc.h>
> #include <asm/pte-walk.h>
> #include <asm/reg.h>
> +#include <asm/plpar_wrappers.h>
>
> static struct patb_entry *pseries_partition_tb;
>
> @@ -444,8 +445,15 @@ static void kvmhv_flush_lpid(unsigned int lpid)
> return;
> }
>
> - rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(2, 0, 1),
> - lpid, TLBIEL_INVAL_SET_LPID);
> + if (!firmware_has_feature(FW_FEATURE_RPT_INVALIDATE))
> + rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(2, 0, 1),
> + lpid, TLBIEL_INVAL_SET_LPID);
> + else
> + rc = pseries_rpt_invalidate(lpid, H_RPTI_TARGET_CMMU,
> + H_RPTI_TYPE_NESTED |
> + H_RPTI_TYPE_TLB | H_RPTI_TYPE_PWC |
> + H_RPTI_TYPE_PAT,
> + H_RPTI_PAGE_ALL, 0, -1UL);
> if (rc)
> pr_err("KVM: TLB LPID invalidation hcall failed, rc=%ld\n", rc);
> }
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: David Gibson <david@gibson.dropbear.id.au>
To: Bharata B Rao <bharata@linux.ibm.com>
Cc: farosas@linux.ibm.com, aneesh.kumar@linux.ibm.com,
npiggin@gmail.com, kvm-ppc@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v6 6/6] KVM: PPC: Book3S HV: Use H_RPT_INVALIDATE in nested KVM
Date: Tue, 23 Mar 2021 13:35:53 +1100 [thread overview]
Message-ID: <YFlUCdMQezdPg9LJ@yekko.fritz.box> (raw)
In-Reply-To: <20210311083939.595568-7-bharata@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 3909 bytes --]
On Thu, Mar 11, 2021 at 02:09:39PM +0530, Bharata B Rao wrote:
> In the nested KVM case, replace H_TLB_INVALIDATE by the new hcall
> H_RPT_INVALIDATE if available. The availability of this hcall
> is determined from "hcall-rpt-invalidate" string in ibm,hypertas-functions
> DT property.
>
> Signed-off-by: Bharata B Rao <bharata@linux.ibm.com>
> Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> arch/powerpc/kvm/book3s_64_mmu_radix.c | 27 +++++++++++++++++++++-----
> arch/powerpc/kvm/book3s_hv_nested.c | 12 ++++++++++--
> 2 files changed, 32 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> index e603de7ade52..1e1e55fd0ee5 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> @@ -21,6 +21,7 @@
> #include <asm/pte-walk.h>
> #include <asm/ultravisor.h>
> #include <asm/kvm_book3s_uvmem.h>
> +#include <asm/plpar_wrappers.h>
>
> /*
> * Supported radix tree geometry.
> @@ -318,9 +319,19 @@ void kvmppc_radix_tlbie_page(struct kvm *kvm, unsigned long addr,
> }
>
> psi = shift_to_mmu_psize(pshift);
> - rb = addr | (mmu_get_ap(psi) << PPC_BITLSHIFT(58));
> - rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(0, 0, 1),
> - lpid, rb);
> +
> + if (!firmware_has_feature(FW_FEATURE_RPT_INVALIDATE)) {
> + rb = addr | (mmu_get_ap(psi) << PPC_BITLSHIFT(58));
> + rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(0, 0, 1),
> + lpid, rb);
> + } else {
> + rc = pseries_rpt_invalidate(lpid, H_RPTI_TARGET_CMMU,
> + H_RPTI_TYPE_NESTED |
> + H_RPTI_TYPE_TLB,
> + psize_to_rpti_pgsize(psi),
> + addr, addr + psize);
> + }
> +
> if (rc)
> pr_err("KVM: TLB page invalidation hcall failed, rc=%ld\n", rc);
> }
> @@ -334,8 +345,14 @@ static void kvmppc_radix_flush_pwc(struct kvm *kvm, unsigned int lpid)
> return;
> }
>
> - rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(1, 0, 1),
> - lpid, TLBIEL_INVAL_SET_LPID);
> + if (!firmware_has_feature(FW_FEATURE_RPT_INVALIDATE))
> + rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(1, 0, 1),
> + lpid, TLBIEL_INVAL_SET_LPID);
> + else
> + rc = pseries_rpt_invalidate(lpid, H_RPTI_TARGET_CMMU,
> + H_RPTI_TYPE_NESTED |
> + H_RPTI_TYPE_PWC, H_RPTI_PAGE_ALL,
> + 0, -1UL);
> if (rc)
> pr_err("KVM: TLB PWC invalidation hcall failed, rc=%ld\n", rc);
> }
> diff --git a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3s_hv_nested.c
> index adcc8e26ef22..5601b7eb9b89 100644
> --- a/arch/powerpc/kvm/book3s_hv_nested.c
> +++ b/arch/powerpc/kvm/book3s_hv_nested.c
> @@ -19,6 +19,7 @@
> #include <asm/pgalloc.h>
> #include <asm/pte-walk.h>
> #include <asm/reg.h>
> +#include <asm/plpar_wrappers.h>
>
> static struct patb_entry *pseries_partition_tb;
>
> @@ -444,8 +445,15 @@ static void kvmhv_flush_lpid(unsigned int lpid)
> return;
> }
>
> - rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(2, 0, 1),
> - lpid, TLBIEL_INVAL_SET_LPID);
> + if (!firmware_has_feature(FW_FEATURE_RPT_INVALIDATE))
> + rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(2, 0, 1),
> + lpid, TLBIEL_INVAL_SET_LPID);
> + else
> + rc = pseries_rpt_invalidate(lpid, H_RPTI_TARGET_CMMU,
> + H_RPTI_TYPE_NESTED |
> + H_RPTI_TYPE_TLB | H_RPTI_TYPE_PWC |
> + H_RPTI_TYPE_PAT,
> + H_RPTI_PAGE_ALL, 0, -1UL);
> if (rc)
> pr_err("KVM: TLB LPID invalidation hcall failed, rc=%ld\n", rc);
> }
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2021-03-23 2:35 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-11 8:39 [PATCH v6 0/6] Support for H_RPT_INVALIDATE in PowerPC KVM Bharata B Rao
2021-03-11 8:51 ` Bharata B Rao
2021-03-11 8:39 ` [PATCH v6 1/6] KVM: PPC: Book3S HV: Fix comments of H_RPT_INVALIDATE arguments Bharata B Rao
2021-03-11 8:51 ` Bharata B Rao
2021-03-23 1:19 ` David Gibson
2021-03-23 1:19 ` David Gibson
2021-03-11 8:39 ` [PATCH v6 2/6] powerpc/book3s64/radix: Add H_RPT_INVALIDATE pgsize encodings to mmu_psize_def Bharata B Rao
2021-03-11 8:51 ` Bharata B Rao
2021-03-23 1:24 ` David Gibson
2021-03-23 1:24 ` David Gibson
2021-03-11 8:39 ` [PATCH v6 3/6] KVM: PPC: Book3S HV: Add support for H_RPT_INVALIDATE Bharata B Rao
2021-03-11 8:51 ` Bharata B Rao
2021-03-23 2:26 ` David Gibson
2021-03-23 2:26 ` David Gibson
2021-03-23 4:05 ` Bharata B Rao
2021-03-23 4:17 ` Bharata B Rao
2021-03-11 8:39 ` [PATCH v6 4/6] KVM: PPC: Book3S HV: Nested support in H_RPT_INVALIDATE Bharata B Rao
2021-03-11 8:51 ` Bharata B Rao
2021-03-23 2:33 ` David Gibson
2021-03-23 2:33 ` David Gibson
2021-03-11 8:39 ` [PATCH v6 5/6] KVM: PPC: Book3S HV: Add KVM_CAP_PPC_RPT_INVALIDATE capability Bharata B Rao
2021-03-11 8:51 ` Bharata B Rao
2021-03-23 2:34 ` David Gibson
2021-03-23 2:34 ` David Gibson
2021-03-11 8:39 ` [PATCH v6 6/6] KVM: PPC: Book3S HV: Use H_RPT_INVALIDATE in nested KVM Bharata B Rao
2021-03-11 8:51 ` Bharata B Rao
2021-03-23 2:35 ` David Gibson [this message]
2021-03-23 2:35 ` David Gibson
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=YFlUCdMQezdPg9LJ@yekko.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=aneesh.kumar@linux.ibm.com \
--cc=bharata@linux.ibm.com \
--cc=farosas@linux.ibm.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.