diff mbox series

[SRU,Disco] KVM: PPC: Book3S: Add count cache flush parameters to kvmppc_get_cpu_char()

Message ID 20190902153535.16091-1-juergh@canonical.com
State New
Headers show
Series [SRU,Disco] KVM: PPC: Book3S: Add count cache flush parameters to kvmppc_get_cpu_char() | expand

Commit Message

Juerg Haefliger Sept. 2, 2019, 3:35 p.m. UTC
From: Suraj Jitindar Singh <sjitindarsingh@gmail.com>

BugLink: https://bugs.launchpad.net/bugs/1822870
BugLink: https://bugs.launchpad.net/bugs/1832622

Add KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST &
KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE to the characteristics returned
from the H_GET_CPU_CHARACTERISTICS H-CALL, as queried from either the
hypervisor or the device tree.

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
(cherry picked from commit 2b57ecd0208f7ac0b20b1b171698f027481a39f6)
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
---
 arch/powerpc/include/uapi/asm/kvm.h |  2 ++
 arch/powerpc/kvm/powerpc.c          | 18 ++++++++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

Comments

Kleber Sacilotto de Souza Sept. 2, 2019, 3:53 p.m. UTC | #1
On 9/2/19 5:35 PM, Juerg Haefliger wrote:
> From: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1822870
> BugLink: https://bugs.launchpad.net/bugs/1832622
> 
> Add KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST &
> KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE to the characteristics returned
> from the H_GET_CPU_CHARACTERISTICS H-CALL, as queried from either the
> hypervisor or the device tree.
> 
> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
> (cherry picked from commit 2b57ecd0208f7ac0b20b1b171698f027481a39f6)
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

> ---
>  arch/powerpc/include/uapi/asm/kvm.h |  2 ++
>  arch/powerpc/kvm/powerpc.c          | 18 ++++++++++++++----
>  2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/include/uapi/asm/kvm.h b/arch/powerpc/include/uapi/asm/kvm.h
> index 8c876c166ef2..26ca425f4c2c 100644
> --- a/arch/powerpc/include/uapi/asm/kvm.h
> +++ b/arch/powerpc/include/uapi/asm/kvm.h
> @@ -463,10 +463,12 @@ struct kvm_ppc_cpu_char {
>  #define KVM_PPC_CPU_CHAR_BR_HINT_HONOURED	(1ULL << 58)
>  #define KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF	(1ULL << 57)
>  #define KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS	(1ULL << 56)
> +#define KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST	(1ull << 54)
>  
>  #define KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY	(1ULL << 63)
>  #define KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR		(1ULL << 62)
>  #define KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR	(1ULL << 61)
> +#define KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE	(1ull << 58)
>  
>  /* Per-vcpu XICS interrupt controller state */
>  #define KVM_REG_PPC_ICP_STATE	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8c)
> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 399cb4b779e1..150abc009659 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -2192,10 +2192,12 @@ static int pseries_get_cpu_char(struct kvm_ppc_cpu_char *cp)
>  			KVM_PPC_CPU_CHAR_L1D_THREAD_PRIV |
>  			KVM_PPC_CPU_CHAR_BR_HINT_HONOURED |
>  			KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF |
> -			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS;
> +			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS |
> +			KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST;
>  		cp->behaviour_mask = KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY |
>  			KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR |
> -			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR;
> +			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR |
> +			KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE;
>  	}
>  	return 0;
>  }
> @@ -2254,12 +2256,16 @@ static int kvmppc_get_cpu_char(struct kvm_ppc_cpu_char *cp)
>  		if (have_fw_feat(fw_features, "enabled",
>  				 "fw-count-cache-disabled"))
>  			cp->character |= KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS;
> +		if (have_fw_feat(fw_features, "enabled",
> +				 "fw-count-cache-flush-bcctr2,0,0"))
> +			cp->character |= KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST;
>  		cp->character_mask = KVM_PPC_CPU_CHAR_SPEC_BAR_ORI31 |
>  			KVM_PPC_CPU_CHAR_BCCTRL_SERIALISED |
>  			KVM_PPC_CPU_CHAR_L1D_FLUSH_ORI30 |
>  			KVM_PPC_CPU_CHAR_L1D_FLUSH_TRIG2 |
>  			KVM_PPC_CPU_CHAR_L1D_THREAD_PRIV |
> -			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS;
> +			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS |
> +			KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST;
>  
>  		if (have_fw_feat(fw_features, "enabled",
>  				 "speculation-policy-favor-security"))
> @@ -2270,9 +2276,13 @@ static int kvmppc_get_cpu_char(struct kvm_ppc_cpu_char *cp)
>  		if (!have_fw_feat(fw_features, "disabled",
>  				  "needs-spec-barrier-for-bound-checks"))
>  			cp->behaviour |= KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR;
> +		if (have_fw_feat(fw_features, "enabled",
> +				 "needs-count-cache-flush-on-context-switch"))
> +			cp->behaviour |= KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE;
>  		cp->behaviour_mask = KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY |
>  			KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR |
> -			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR;
> +			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR |
> +			KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE;
>  
>  		of_node_put(fw_features);
>  	}
>
Khalid Elmously Sept. 4, 2019, 3:06 a.m. UTC | #2
On 2019-09-02 17:35:35 , Juerg Haefliger wrote:
> From: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1822870
> BugLink: https://bugs.launchpad.net/bugs/1832622
> 
> Add KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST &
> KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE to the characteristics returned
> from the H_GET_CPU_CHARACTERISTICS H-CALL, as queried from either the
> hypervisor or the device tree.
> 
> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
> (cherry picked from commit 2b57ecd0208f7ac0b20b1b171698f027481a39f6)
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> ---
>  arch/powerpc/include/uapi/asm/kvm.h |  2 ++
>  arch/powerpc/kvm/powerpc.c          | 18 ++++++++++++++----
>  2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/include/uapi/asm/kvm.h b/arch/powerpc/include/uapi/asm/kvm.h
> index 8c876c166ef2..26ca425f4c2c 100644
> --- a/arch/powerpc/include/uapi/asm/kvm.h
> +++ b/arch/powerpc/include/uapi/asm/kvm.h
> @@ -463,10 +463,12 @@ struct kvm_ppc_cpu_char {
>  #define KVM_PPC_CPU_CHAR_BR_HINT_HONOURED	(1ULL << 58)
>  #define KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF	(1ULL << 57)
>  #define KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS	(1ULL << 56)
> +#define KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST	(1ull << 54)
>  
>  #define KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY	(1ULL << 63)
>  #define KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR		(1ULL << 62)
>  #define KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR	(1ULL << 61)
> +#define KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE	(1ull << 58)
>  
>  /* Per-vcpu XICS interrupt controller state */
>  #define KVM_REG_PPC_ICP_STATE	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8c)
> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 399cb4b779e1..150abc009659 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -2192,10 +2192,12 @@ static int pseries_get_cpu_char(struct kvm_ppc_cpu_char *cp)
>  			KVM_PPC_CPU_CHAR_L1D_THREAD_PRIV |
>  			KVM_PPC_CPU_CHAR_BR_HINT_HONOURED |
>  			KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF |
> -			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS;
> +			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS |
> +			KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST;
>  		cp->behaviour_mask = KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY |
>  			KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR |
> -			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR;
> +			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR |
> +			KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE;
>  	}
>  	return 0;
>  }
> @@ -2254,12 +2256,16 @@ static int kvmppc_get_cpu_char(struct kvm_ppc_cpu_char *cp)
>  		if (have_fw_feat(fw_features, "enabled",
>  				 "fw-count-cache-disabled"))
>  			cp->character |= KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS;
> +		if (have_fw_feat(fw_features, "enabled",
> +				 "fw-count-cache-flush-bcctr2,0,0"))
> +			cp->character |= KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST;
>  		cp->character_mask = KVM_PPC_CPU_CHAR_SPEC_BAR_ORI31 |
>  			KVM_PPC_CPU_CHAR_BCCTRL_SERIALISED |
>  			KVM_PPC_CPU_CHAR_L1D_FLUSH_ORI30 |
>  			KVM_PPC_CPU_CHAR_L1D_FLUSH_TRIG2 |
>  			KVM_PPC_CPU_CHAR_L1D_THREAD_PRIV |
> -			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS;
> +			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS |
> +			KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST;
>  
>  		if (have_fw_feat(fw_features, "enabled",
>  				 "speculation-policy-favor-security"))
> @@ -2270,9 +2276,13 @@ static int kvmppc_get_cpu_char(struct kvm_ppc_cpu_char *cp)
>  		if (!have_fw_feat(fw_features, "disabled",
>  				  "needs-spec-barrier-for-bound-checks"))
>  			cp->behaviour |= KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR;
> +		if (have_fw_feat(fw_features, "enabled",
> +				 "needs-count-cache-flush-on-context-switch"))
> +			cp->behaviour |= KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE;
>  		cp->behaviour_mask = KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY |
>  			KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR |
> -			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR;
> +			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR |
> +			KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE;
>  
>  		of_node_put(fw_features);
>  	}
> -- 
> 2.20.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Khalid Elmously Sept. 4, 2019, 3:07 a.m. UTC | #3
On 2019-09-02 17:35:35 , Juerg Haefliger wrote:
> From: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1822870
> BugLink: https://bugs.launchpad.net/bugs/1832622
> 
> Add KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST &
> KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE to the characteristics returned
> from the H_GET_CPU_CHARACTERISTICS H-CALL, as queried from either the
> hypervisor or the device tree.
> 
> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
> (cherry picked from commit 2b57ecd0208f7ac0b20b1b171698f027481a39f6)
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> ---
>  arch/powerpc/include/uapi/asm/kvm.h |  2 ++
>  arch/powerpc/kvm/powerpc.c          | 18 ++++++++++++++----
>  2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/include/uapi/asm/kvm.h b/arch/powerpc/include/uapi/asm/kvm.h
> index 8c876c166ef2..26ca425f4c2c 100644
> --- a/arch/powerpc/include/uapi/asm/kvm.h
> +++ b/arch/powerpc/include/uapi/asm/kvm.h
> @@ -463,10 +463,12 @@ struct kvm_ppc_cpu_char {
>  #define KVM_PPC_CPU_CHAR_BR_HINT_HONOURED	(1ULL << 58)
>  #define KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF	(1ULL << 57)
>  #define KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS	(1ULL << 56)
> +#define KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST	(1ull << 54)
>  
>  #define KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY	(1ULL << 63)
>  #define KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR		(1ULL << 62)
>  #define KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR	(1ULL << 61)
> +#define KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE	(1ull << 58)
>  
>  /* Per-vcpu XICS interrupt controller state */
>  #define KVM_REG_PPC_ICP_STATE	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8c)
> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 399cb4b779e1..150abc009659 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -2192,10 +2192,12 @@ static int pseries_get_cpu_char(struct kvm_ppc_cpu_char *cp)
>  			KVM_PPC_CPU_CHAR_L1D_THREAD_PRIV |
>  			KVM_PPC_CPU_CHAR_BR_HINT_HONOURED |
>  			KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF |
> -			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS;
> +			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS |
> +			KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST;
>  		cp->behaviour_mask = KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY |
>  			KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR |
> -			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR;
> +			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR |
> +			KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE;
>  	}
>  	return 0;
>  }
> @@ -2254,12 +2256,16 @@ static int kvmppc_get_cpu_char(struct kvm_ppc_cpu_char *cp)
>  		if (have_fw_feat(fw_features, "enabled",
>  				 "fw-count-cache-disabled"))
>  			cp->character |= KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS;
> +		if (have_fw_feat(fw_features, "enabled",
> +				 "fw-count-cache-flush-bcctr2,0,0"))
> +			cp->character |= KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST;
>  		cp->character_mask = KVM_PPC_CPU_CHAR_SPEC_BAR_ORI31 |
>  			KVM_PPC_CPU_CHAR_BCCTRL_SERIALISED |
>  			KVM_PPC_CPU_CHAR_L1D_FLUSH_ORI30 |
>  			KVM_PPC_CPU_CHAR_L1D_FLUSH_TRIG2 |
>  			KVM_PPC_CPU_CHAR_L1D_THREAD_PRIV |
> -			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS;
> +			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS |
> +			KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST;
>  
>  		if (have_fw_feat(fw_features, "enabled",
>  				 "speculation-policy-favor-security"))
> @@ -2270,9 +2276,13 @@ static int kvmppc_get_cpu_char(struct kvm_ppc_cpu_char *cp)
>  		if (!have_fw_feat(fw_features, "disabled",
>  				  "needs-spec-barrier-for-bound-checks"))
>  			cp->behaviour |= KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR;
> +		if (have_fw_feat(fw_features, "enabled",
> +				 "needs-count-cache-flush-on-context-switch"))
> +			cp->behaviour |= KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE;
>  		cp->behaviour_mask = KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY |
>  			KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR |
> -			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR;
> +			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR |
> +			KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE;
>  
>  		of_node_put(fw_features);
>  	}
> -- 
> 2.20.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
diff mbox series

Patch

diff --git a/arch/powerpc/include/uapi/asm/kvm.h b/arch/powerpc/include/uapi/asm/kvm.h
index 8c876c166ef2..26ca425f4c2c 100644
--- a/arch/powerpc/include/uapi/asm/kvm.h
+++ b/arch/powerpc/include/uapi/asm/kvm.h
@@ -463,10 +463,12 @@  struct kvm_ppc_cpu_char {
 #define KVM_PPC_CPU_CHAR_BR_HINT_HONOURED	(1ULL << 58)
 #define KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF	(1ULL << 57)
 #define KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS	(1ULL << 56)
+#define KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST	(1ull << 54)
 
 #define KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY	(1ULL << 63)
 #define KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR		(1ULL << 62)
 #define KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR	(1ULL << 61)
+#define KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE	(1ull << 58)
 
 /* Per-vcpu XICS interrupt controller state */
 #define KVM_REG_PPC_ICP_STATE	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8c)
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 399cb4b779e1..150abc009659 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -2192,10 +2192,12 @@  static int pseries_get_cpu_char(struct kvm_ppc_cpu_char *cp)
 			KVM_PPC_CPU_CHAR_L1D_THREAD_PRIV |
 			KVM_PPC_CPU_CHAR_BR_HINT_HONOURED |
 			KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF |
-			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS;
+			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS |
+			KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST;
 		cp->behaviour_mask = KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY |
 			KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR |
-			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR;
+			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR |
+			KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE;
 	}
 	return 0;
 }
@@ -2254,12 +2256,16 @@  static int kvmppc_get_cpu_char(struct kvm_ppc_cpu_char *cp)
 		if (have_fw_feat(fw_features, "enabled",
 				 "fw-count-cache-disabled"))
 			cp->character |= KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS;
+		if (have_fw_feat(fw_features, "enabled",
+				 "fw-count-cache-flush-bcctr2,0,0"))
+			cp->character |= KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST;
 		cp->character_mask = KVM_PPC_CPU_CHAR_SPEC_BAR_ORI31 |
 			KVM_PPC_CPU_CHAR_BCCTRL_SERIALISED |
 			KVM_PPC_CPU_CHAR_L1D_FLUSH_ORI30 |
 			KVM_PPC_CPU_CHAR_L1D_FLUSH_TRIG2 |
 			KVM_PPC_CPU_CHAR_L1D_THREAD_PRIV |
-			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS;
+			KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS |
+			KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST;
 
 		if (have_fw_feat(fw_features, "enabled",
 				 "speculation-policy-favor-security"))
@@ -2270,9 +2276,13 @@  static int kvmppc_get_cpu_char(struct kvm_ppc_cpu_char *cp)
 		if (!have_fw_feat(fw_features, "disabled",
 				  "needs-spec-barrier-for-bound-checks"))
 			cp->behaviour |= KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR;
+		if (have_fw_feat(fw_features, "enabled",
+				 "needs-count-cache-flush-on-context-switch"))
+			cp->behaviour |= KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE;
 		cp->behaviour_mask = KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY |
 			KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR |
-			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR;
+			KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR |
+			KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE;
 
 		of_node_put(fw_features);
 	}