All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Martin Schwidefsky <schwidefsky@de.ibm.com>,
	linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
	kvm@vger.kernel.org
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jon Masters <jcm@redhat.com>, Marcus Meissner <meissner@suse.de>,
	Jiri Kosina <jkosina@suse.cz>
Subject: Re: [PATCH 5/6] KVM: s390: wire up seb feature
Date: Wed, 17 Jan 2018 12:33:52 +0100	[thread overview]
Message-ID: <2fa06836-75f8-9c3f-a5e3-217763f6ff4e@redhat.com> (raw)
In-Reply-To: <1516182519-10623-6-git-send-email-schwidefsky@de.ibm.com>


>  #define ECB_GS		0x40
>  #define ECB_TE		0x10
>  #define ECB_SRSI	0x04
> diff --git a/arch/s390/include/uapi/asm/kvm.h b/arch/s390/include/uapi/asm/kvm.h
> index 38535a57..20b9e9f 100644
> --- a/arch/s390/include/uapi/asm/kvm.h
> +++ b/arch/s390/include/uapi/asm/kvm.h
> @@ -224,6 +224,7 @@ struct kvm_guest_debug_arch {
>  #define KVM_SYNC_RICCB  (1UL << 7)
>  #define KVM_SYNC_FPRS   (1UL << 8)
>  #define KVM_SYNC_GSCB   (1UL << 9)
> +#define KVM_SYNC_SEBC   (1UL << 10)
>  /* length and alignment of the sdnx as a power of two */
>  #define SDNXC 8
>  #define SDNXL (1UL << SDNXC)
> @@ -247,7 +248,8 @@ struct kvm_sync_regs {
>  	};
>  	__u8  reserved[512];	/* for future vector expansion */
>  	__u32 fpc;		/* valid on KVM_SYNC_VRS or KVM_SYNC_FPRS */
> -	__u8 padding1[52];	/* riccb needs to be 64byte aligned */
> +	__u8 sebc:1;		/* spec blocking */

do you want to define the unused bits as reserved? Nicer to read IMHO

(especially also using spaces "sebc : 1")

> +	__u8 padding1[51];	/* riccb needs to be 64byte aligned */
>  	__u8 riccb[64];		/* runtime instrumentation controls block */
>  	__u8 padding2[192];	/* sdnx needs to be 256byte aligned */
>  	union {
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 2c93cbb..0c18f73 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -421,6 +421,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
>  	case KVM_CAP_S390_GS:
>  		r = test_facility(133);
>  		break;
> +	case KVM_CAP_S390_SEB:
> +		r = test_facility(82);
> +		break;
>  	default:
>  		r = 0;
>  	}
> @@ -2198,6 +2201,8 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *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_SEBC;
>  	if (test_kvm_facility(vcpu->kvm, 133))
>  		vcpu->run->kvm_valid_regs |= KVM_SYNC_GSCB;
>  	/* fprs can be synchronized via vrs, even if the guest has no vx. With
> @@ -2339,6 +2344,7 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu)
>  	current->thread.fpu.fpc = 0;
>  	vcpu->arch.sie_block->gbea = 1;
>  	vcpu->arch.sie_block->pp = 0;
> +	vcpu->arch.sie_block->fpf &= ~FPF_SEBC;
>  	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))
> @@ -3298,6 +3304,10 @@ static void sync_regs(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
>  		vcpu->arch.sie_block->ecd |= ECD_HOSTREGMGMT;
>  		vcpu->arch.gs_enabled = 1;
>  	}
> +	if (kvm_run->kvm_dirty_regs & KVM_SYNC_SEBC) {

We should test for test_facility(82). Otherwise user space can enable
undefined bits in the SCB on machines with !facility 82.

> +		vcpu->arch.sie_block->fpf &= ~FPF_SEBC;
> +		vcpu->arch.sie_block->fpf |= kvm_run->s.regs.sebc ? FPF_SEBC : 0;
> +	}
>  	save_access_regs(vcpu->arch.host_acrs);
>  	restore_access_regs(vcpu->run->s.regs.acrs);
>  	/* save host (userspace) fprs/vrs */
> @@ -3344,6 +3354,7 @@ static void store_regs(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
>  	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.sebc = (vcpu->arch.sie_block->fpf & FPF_SEBC) == FPF_SEBC;
>  	save_access_regs(vcpu->run->s.regs.acrs);
>  	restore_access_regs(vcpu->arch.host_acrs);
>  	/* Save guest register state */
> diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
> index 5d6ae03..10ea208 100644
> --- a/arch/s390/kvm/vsie.c
> +++ b/arch/s390/kvm/vsie.c
> @@ -223,6 +223,10 @@ static void unshadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
>  	memcpy(scb_o->gcr, scb_s->gcr, 128);
>  	scb_o->pp = scb_s->pp;
>  
> +	/* speculative blocking */

This field should only be written back with test_kvm_facility(vcpu->kvm, 82)

(no public documentation, this looks like the SIE can modify this field?
Triggered by which instruction?)

> +	scb_o->fpf &= ~FPF_SEBC;
> +	scb_o->fpf |= scb_s->fpf & FPF_SEBC;
> +
>  	/* interrupt intercept */
>  	switch (scb_s->icptcode) {
>  	case ICPT_PROGI:
> @@ -265,6 +269,7 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
>  	scb_s->ecb3 = 0;
>  	scb_s->ecd = 0;
>  	scb_s->fac = 0;
> +	scb_s->fpf = 0;
>  
>  	rc = prepare_cpuflags(vcpu, vsie_page);
>  	if (rc)
> @@ -324,6 +329,9 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
>  			prefix_unmapped(vsie_page);
>  		scb_s->ecb |= scb_o->ecb & ECB_TE;
>  	}
> +	/* speculative blocking */
> +	if (test_kvm_facility(vcpu->kvm, 82))
> +		scb_s->fpf |= scb_o->fpf & FPF_SEBC;
>  	/* SIMD */
>  	if (test_kvm_facility(vcpu->kvm, 129)) {
>  		scb_s->eca |= scb_o->eca & ECA_VX;




-- 

Thanks,

David / dhildenb

  parent reply	other threads:[~2018-01-17 11:33 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-17  9:48 [PATCH 0/6] s390: improve speculative execution handling Martin Schwidefsky
2018-01-17  9:48 ` [PATCH 1/6] s390/alternative: use a copy of the facility bit mask Martin Schwidefsky
2018-01-17 13:54   ` David Hildenbrand
2018-01-17 14:24   ` Cornelia Huck
2018-01-17  9:48 ` [PATCH 2/6] s390: implement nospec_[load|ptr] Martin Schwidefsky
2018-01-17 12:41   ` Jiri Kosina
2018-01-17 14:52     ` Jon Masters
2018-01-17 13:58   ` David Hildenbrand
2018-01-17 14:04     ` Christian Borntraeger
2018-01-17  9:48 ` [PATCH 3/6] s390: add options to change branch prediction behaviour for the kernel Martin Schwidefsky
2018-01-18  9:52   ` Cornelia Huck
2018-01-19  4:53   ` QingFeng Hao
2018-01-17  9:48 ` [PATCH 4/6] s390: add system call to run tasks with modified branch prediction Martin Schwidefsky
2018-01-17 10:03   ` Florian Weimer
2018-01-17 10:05     ` Paolo Bonzini
2018-01-17 11:14     ` Christian Borntraeger
2018-01-17 11:50       ` Paolo Bonzini
2018-01-17 11:55       ` Martin Schwidefsky
2018-01-17 13:25         ` Heiko Carstens
2018-01-17  9:48 ` [PATCH 5/6] KVM: s390: wire up seb feature Martin Schwidefsky
2018-01-17 11:18   ` Christian Borntraeger
2018-01-17 11:22     ` Paolo Bonzini
2018-01-17 11:28       ` Christian Borntraeger
2018-01-17 11:29         ` Christian Borntraeger
2018-01-17 11:32           ` Paolo Bonzini
2018-01-17 11:33   ` David Hildenbrand [this message]
2018-01-17 11:39     ` Christian Borntraeger
2018-01-17 13:44   ` [PATCH v2] KVM: s390: wire up bpb feature Christian Borntraeger
2018-01-17 13:51     ` David Hildenbrand
2018-01-17 21:43       ` Christian Borntraeger
2018-01-18  6:27         ` Martin Schwidefsky
2018-01-18  9:59     ` Cornelia Huck
2018-01-18 10:09       ` Christian Borntraeger
2018-01-17  9:48 ` [PATCH 6/6] s390: scrub registers on kernel entry and KVM exit Martin Schwidefsky
2018-01-19  6:29   ` QingFeng Hao
2018-01-19  7:57     ` Christian Borntraeger
2018-01-19  8:27       ` QingFeng Hao
2018-01-17 12:00 ` [PATCH 0/6] s390: improve speculative execution handling Cornelia Huck
2018-01-17 12:05   ` Christian Borntraeger
2018-01-17 13:29 ` Greg Kroah-Hartman

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=2fa06836-75f8-9c3f-a5e3-217763f6ff4e@redhat.com \
    --to=david@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jcm@redhat.com \
    --cc=jkosina@suse.cz \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=meissner@suse.de \
    --cc=pbonzini@redhat.com \
    --cc=schwidefsky@de.ibm.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.