KVM: PPC: powerpc: Add count cache flush parameters to kvmppc_get_cpu_char()
Subsystems (3)
PATCH 1/1 KVM: PPC: powerpc: Add count cache flush parameters to kvmppc_get_cpu_char()
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.
--- arch/powerpc/include/uapi/asm/kvm.h | 2 ++ arch/powerpc/kvm/powerpc.c | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
arch/powerpc/include/uapi/asm/kvm.h +2 -0
@@ -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)
arch/powerpc/kvm/powerpc.c +14 -4
@@ -2189,10 +2189,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 ; }
@@ -2251,12 +2253,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" ))
@@ -2267,9 +2273,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); }
Signature · 1 line
2.13.6
Michael Ellerman
reviewerQuoted 16 lines · Suraj Jitindar Singh
Add
KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST&KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHEto the characteristics returned from theH_GET_CPU_CHARACTERISTICSH-CALL, as queried from either the hypervisor or the device tree.Signed-off-by Suraj Jitindar Singh <[email protected]>--- arch/powerpc/include/uapi/asm/kvm.h | 2 ++ arch/powerpc/kvm/powerpc.c | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)arch/powerpc/kvm/powerpc.c +0
-0
arch/powerpc/kvm/powerpc.c static int kvmppc_get_cpu_char(struct kvm_ppc_cpu_char *cp) · line 2257
Quoted 5 lines
arch/powerpc/kvm/powerpc.c +2
-0@@ -2251,12 +2253,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" ))
I don't think there's any reason KVM needs to be querying the device tree directly, is there?
Can't it just use the security flags (security_features.h), that are initialised by the powernv platform code based on the device tree.
I seem to remember we didn't do it that way originally just because we didn't have time to get everything lined up.
cheers
Quoted 27 lines · Michael Ellerman
Quoted 16 lines · Suraj Jitindar Singh
Add
KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST&KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHEto the characteristics returned from theH_GET_CPU_CHARACTERISTICSH-CALL, as queried from either the hypervisor or the device tree.Signed-off-by Suraj Jitindar Singh <[email protected]>--- arch/powerpc/include/uapi/asm/kvm.h | 2 ++ arch/powerpc/kvm/powerpc.c | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)arch/powerpc/kvm/powerpc.c +0
-0arch/powerpc/kvm/powerpc.c static int kvmppc_get_cpu_char(struct kvm_ppc_cpu_char *cp) · line 2257
Quoted 5 lines
arch/powerpc/kvm/powerpc.c +2
-0@@ -2251,12 +2253,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" ))I don't think there's any reason KVM needs to be querying the device tree directly, is there?
Quoted 2 lines
Can't it just use the security flags (
security_features.h), that are initialised by the powernv platform code based on the device tree.
My recollection is that the security flags didn't have all the information we need. It's possible that's no longer true.
I merged the patch and sent a pull request to Paolo; using the same pattern as the existing code made it a low-risk patch and I wanted to get it in for 5.1. For 5.2 we can look at changing it over if you like.
Paul.
Michael Ellerman
reviewerQuoted 28 lines · Paul Mackerras
Quoted 27 lines · Michael Ellerman
Quoted 16 lines · Suraj Jitindar Singh
Add
KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST&KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHEto the characteristics returned from theH_GET_CPU_CHARACTERISTICSH-CALL, as queried from either the hypervisor or the device tree.Signed-off-by Suraj Jitindar Singh <[email protected]>--- arch/powerpc/include/uapi/asm/kvm.h | 2 ++ arch/powerpc/kvm/powerpc.c | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)arch/powerpc/kvm/powerpc.c +0
-0arch/powerpc/kvm/powerpc.c static int kvmppc_get_cpu_char(struct kvm_ppc_cpu_char *cp) · line 2257
Quoted 5 lines
arch/powerpc/kvm/powerpc.c +2
-0@@ -2251,12 +2253,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" ))I don't think there's any reason KVM needs to be querying the device tree directly, is there?
Quoted 5 lines
Quoted 2 lines
Can't it just use the security flags (
security_features.h), that are initialised by the powernv platform code based on the device tree.My recollection is that the security flags didn't have all the information we need. It's possible that's no longer true.
Actually I don't think they existed at all back then, we didn't add them until after the initial panic.
Quoted 4 lines
I merged the patch and sent a pull request to Paolo; using the same pattern as the existing code made it a low-risk patch and I wanted to get it in for 5.1. For 5.2 we can look at changing it over if you like.
Yep that's fine.
cheers