lkml.org 
[lkml]   [2018]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH 4.9 30/74] KVM: s390: wire up bpb feature
    From
    Date


    On 04/27/2018 03:58 PM, Greg Kroah-Hartman wrote:
    > 4.9-stable review patch. If anyone has any objections, please let me know.
    >
    > ------------------
    >
    > From: Martin Schwidefsky <schwidefsky@de.ibm.com>
    >
    >
    > From: Christian Borntraeger <borntraeger@de.ibm.com>

    Minus the double author and the unrelated white space change this backport looks good.


    >
    > [ Upstream commit 35b3fde6203b932b2b1a5b53b3d8808abc9c4f60 ]
    >
    > The new firmware interfaces for branch prediction behaviour changes
    > are transparently available for the guest. Nevertheless, there is
    > new state attached that should be migrated and properly resetted.
    > Provide a mechanism for handling reset, migration and VSIE.
    >
    > Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
    > Reviewed-by: David Hildenbrand <david@redhat.com>
    > Reviewed-by: Cornelia Huck <cohuck@redhat.com>
    > [Changed capability number to 152. - Radim]
    > Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
    > Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
    > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    > ---
    > arch/s390/include/asm/kvm_host.h | 3 ++-
    > arch/s390/include/uapi/asm/kvm.h | 5 ++++-
    > arch/s390/kvm/kvm-s390.c | 13 ++++++++++++-
    > arch/s390/kvm/vsie.c | 10 ++++++++++
    > include/uapi/linux/kvm.h | 1 +
    > 5 files changed, 29 insertions(+), 3 deletions(-)
    >
    > --- a/arch/s390/include/asm/kvm_host.h
    > +++ b/arch/s390/include/asm/kvm_host.h
    > @@ -181,7 +181,8 @@ struct kvm_s390_sie_block {
    > __u16 ipa; /* 0x0056 */
    > __u32 ipb; /* 0x0058 */
    > __u32 scaoh; /* 0x005c */
    > - __u8 reserved60; /* 0x0060 */
    > +#define FPF_BPBC 0x20
    > + __u8 fpf; /* 0x0060 */
    > __u8 ecb; /* 0x0061 */
    > __u8 ecb2; /* 0x0062 */
    > #define ECB3_AES 0x04
    > --- a/arch/s390/include/uapi/asm/kvm.h
    > +++ b/arch/s390/include/uapi/asm/kvm.h
    > @@ -197,6 +197,7 @@ struct kvm_guest_debug_arch {
    > #define KVM_SYNC_VRS (1UL << 6)
    > #define KVM_SYNC_RICCB (1UL << 7)
    > #define KVM_SYNC_FPRS (1UL << 8)
    > +#define KVM_SYNC_BPBC (1UL << 10)
    > /* definition of registers in kvm_run */
    > struct kvm_sync_regs {
    > __u64 prefix; /* prefix register */
    > @@ -217,7 +218,9 @@ struct kvm_sync_regs {
    > };
    > __u8 reserved[512]; /* for future vector expansion */
    > __u32 fpc; /* valid on KVM_SYNC_VRS or KVM_SYNC_FPRS */
    > - __u8 padding[52]; /* riccb needs to be 64byte aligned */
    > + __u8 bpbc : 1; /* bp mode */
    > + __u8 reserved2 : 7;
    > + __u8 padding1[51]; /* riccb needs to be 64byte aligned */
    > __u8 riccb[64]; /* runtime instrumentation controls block */
    > };
    >
    > --- a/arch/s390/kvm/kvm-s390.c
    > +++ b/arch/s390/kvm/kvm-s390.c
    > @@ -401,6 +401,9 @@ int kvm_vm_ioctl_check_extension(struct
    > case KVM_CAP_S390_RI:
    > r = test_facility(64);
    > break;
    > + case KVM_CAP_S390_BPB:
    > + r = test_facility(82);
    > + break;
    > default:
    > r = 0;
    > }
    > @@ -1713,6 +1716,8 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *
    > kvm_s390_set_prefix(vcpu, 0);
    > if (test_kvm_facility(vcpu->kvm, 64))
    > vcpu->run->kvm_valid_regs |= KVM_SYNC_RICCB;
    > + if (test_kvm_facility(vcpu->kvm, 82))
    > + vcpu->run->kvm_valid_regs |= KVM_SYNC_BPBC;
    > /* fprs can be synchronized via vrs, even if the guest has no vx. With
    > * MACHINE_HAS_VX, (load|store)_fpu_regs() will work with vrs format.
    > */
    > @@ -1829,7 +1834,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu
    > if (test_fp_ctl(current->thread.fpu.fpc))
    > /* User space provided an invalid FPC, let's clear it */
    > current->thread.fpu.fpc = 0;
    > -
    > save_access_regs(vcpu->arch.host_acrs);
    > restore_access_regs(vcpu->run->s.regs.acrs);
    > gmap_enable(vcpu->arch.enabled_gmap);
    > @@ -1877,6 +1881,7 @@ static void kvm_s390_vcpu_initial_reset(
    > current->thread.fpu.fpc = 0;
    > vcpu->arch.sie_block->gbea = 1;
    > vcpu->arch.sie_block->pp = 0;
    > + vcpu->arch.sie_block->fpf &= ~FPF_BPBC;
    > vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID;
    > kvm_clear_async_pf_completion_queue(vcpu);
    > if (!kvm_s390_user_cpu_state_ctrl(vcpu->kvm))
    > @@ -2744,6 +2749,11 @@ static void sync_regs(struct kvm_vcpu *v
    > if (riccb->valid)
    > vcpu->arch.sie_block->ecb3 |= 0x01;
    > }
    > + if ((kvm_run->kvm_dirty_regs & KVM_SYNC_BPBC) &&
    > + test_kvm_facility(vcpu->kvm, 82)) {
    > + vcpu->arch.sie_block->fpf &= ~FPF_BPBC;
    > + vcpu->arch.sie_block->fpf |= kvm_run->s.regs.bpbc ? FPF_BPBC : 0;
    > + }
    >
    > kvm_run->kvm_dirty_regs = 0;
    > }
    > @@ -2762,6 +2772,7 @@ static void store_regs(struct kvm_vcpu *
    > kvm_run->s.regs.pft = vcpu->arch.pfault_token;
    > kvm_run->s.regs.pfs = vcpu->arch.pfault_select;
    > kvm_run->s.regs.pfc = vcpu->arch.pfault_compare;
    > + kvm_run->s.regs.bpbc = (vcpu->arch.sie_block->fpf & FPF_BPBC) == FPF_BPBC;
    > }
    >
    > int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
    > --- a/arch/s390/kvm/vsie.c
    > +++ b/arch/s390/kvm/vsie.c
    > @@ -217,6 +217,12 @@ static void unshadow_scb(struct kvm_vcpu
    > memcpy(scb_o->gcr, scb_s->gcr, 128);
    > scb_o->pp = scb_s->pp;
    >
    > + /* branch prediction */
    > + if (test_kvm_facility(vcpu->kvm, 82)) {
    > + scb_o->fpf &= ~FPF_BPBC;
    > + scb_o->fpf |= scb_s->fpf & FPF_BPBC;
    > + }
    > +
    > /* interrupt intercept */
    > switch (scb_s->icptcode) {
    > case ICPT_PROGI:
    > @@ -259,6 +265,7 @@ static int shadow_scb(struct kvm_vcpu *v
    > scb_s->ecb3 = 0;
    > scb_s->ecd = 0;
    > scb_s->fac = 0;
    > + scb_s->fpf = 0;
    >
    > rc = prepare_cpuflags(vcpu, vsie_page);
    > if (rc)
    > @@ -316,6 +323,9 @@ static int shadow_scb(struct kvm_vcpu *v
    > prefix_unmapped(vsie_page);
    > scb_s->ecb |= scb_o->ecb & 0x10U;
    > }
    > + /* branch prediction */
    > + if (test_kvm_facility(vcpu->kvm, 82))
    > + scb_s->fpf |= scb_o->fpf & FPF_BPBC;
    > /* SIMD */
    > if (test_kvm_facility(vcpu->kvm, 129)) {
    > scb_s->eca |= scb_o->eca & 0x00020000U;
    > --- a/include/uapi/linux/kvm.h
    > +++ b/include/uapi/linux/kvm.h
    > @@ -870,6 +870,7 @@ struct kvm_ppc_smmu_info {
    > #define KVM_CAP_S390_USER_INSTR0 130
    > #define KVM_CAP_MSI_DEVID 131
    > #define KVM_CAP_PPC_HTM 132
    > +#define KVM_CAP_S390_BPB 152
    >
    > #ifdef KVM_CAP_IRQ_ROUTING
    >
    >
    >

    \
     
     \ /
      Last update: 2018-04-27 17:44    [W:4.118 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site