* [GIT PULL 01/10] KVM: s390: cmma: don't check entry content
2016-05-09 9:20 [GIT PULL 00/10] KVM: s390: features and fixes for 4.7 part2 Christian Borntraeger
@ 2016-05-09 9:20 ` Christian Borntraeger
2016-05-09 9:20 ` [GIT PULL 02/10] KVM: s390: support NQ only if the facility is enabled for the guest Christian Borntraeger
` (8 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Christian Borntraeger @ 2016-05-09 9:20 UTC (permalink / raw)
To: Paolo Bonzini, Radim Krčmář
Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger,
Jens Freimann, David Hildenbrand, Alexander Yarygin
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
We should never inject an exception after we manually rewound the PSW
(to retry the ESSA instruction in this case). This will mess up the PSW.
So this never worked and therefore never really triggered.
Looking at the details, we don't even have to perform any validity checks.
1. Bits 52-63 of an entry are stored as 0 by the hardware.
2. We are dealing with absolute addresses but only check for the prefix
starting at address 0. This isn't correct and doesn't make much sense,
cpus could still zap the prefix of other cpus. But as prefix pages
cannot be swapped out without a notifier being called for the affected
VCPU, a zap can never remove a protected prefix.
Reviewed-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
arch/s390/kvm/priv.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 0a1591d..3561119 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -744,7 +744,7 @@ static int handle_essa(struct kvm_vcpu *vcpu)
{
/* entries expected to be 1FF */
int entries = (vcpu->arch.sie_block->cbrlo & ~PAGE_MASK) >> 3;
- unsigned long *cbrlo, cbrle;
+ unsigned long *cbrlo;
struct gmap *gmap;
int i;
@@ -765,17 +765,9 @@ static int handle_essa(struct kvm_vcpu *vcpu)
vcpu->arch.sie_block->cbrlo &= PAGE_MASK; /* reset nceo */
cbrlo = phys_to_virt(vcpu->arch.sie_block->cbrlo);
down_read(&gmap->mm->mmap_sem);
- for (i = 0; i < entries; ++i) {
- cbrle = cbrlo[i];
- if (unlikely(cbrle & ~PAGE_MASK || cbrle < 2 * PAGE_SIZE))
- /* invalid entry */
- break;
- /* try to free backing */
- __gmap_zap(gmap, cbrle);
- }
+ for (i = 0; i < entries; ++i)
+ __gmap_zap(gmap, cbrlo[i]);
up_read(&gmap->mm->mmap_sem);
- if (i < entries)
- return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
return 0;
}
--
2.5.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [GIT PULL 02/10] KVM: s390: support NQ only if the facility is enabled for the guest
2016-05-09 9:20 [GIT PULL 00/10] KVM: s390: features and fixes for 4.7 part2 Christian Borntraeger
2016-05-09 9:20 ` [GIT PULL 01/10] KVM: s390: cmma: don't check entry content Christian Borntraeger
@ 2016-05-09 9:20 ` Christian Borntraeger
2016-05-09 9:20 ` [GIT PULL 03/10] KVM: s390: enable PFMFI only if guest hast EDAT1 Christian Borntraeger
` (7 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Christian Borntraeger @ 2016-05-09 9:20 UTC (permalink / raw)
To: Paolo Bonzini, Radim Krčmář
Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger,
Jens Freimann, David Hildenbrand, Alexander Yarygin
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
While we can not fully fence of the Nonquiescing Key-Setting facility,
we should as try our best to hide it.
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
arch/s390/kvm/priv.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 3561119..3137479 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -670,8 +670,9 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
if (vcpu->run->s.regs.gprs[reg1] & PFMF_RESERVED)
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
- /* Only provide non-quiescing support if the host supports it */
- if (vcpu->run->s.regs.gprs[reg1] & PFMF_NQ && !test_facility(14))
+ /* Only provide non-quiescing support if enabled for the guest */
+ if (vcpu->run->s.regs.gprs[reg1] & PFMF_NQ &&
+ !test_kvm_facility(vcpu->kvm, 14))
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
/* No support for conditional-SSKE */
--
2.5.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [GIT PULL 03/10] KVM: s390: enable PFMFI only if guest hast EDAT1
2016-05-09 9:20 [GIT PULL 00/10] KVM: s390: features and fixes for 4.7 part2 Christian Borntraeger
2016-05-09 9:20 ` [GIT PULL 01/10] KVM: s390: cmma: don't check entry content Christian Borntraeger
2016-05-09 9:20 ` [GIT PULL 02/10] KVM: s390: support NQ only if the facility is enabled for the guest Christian Borntraeger
@ 2016-05-09 9:20 ` Christian Borntraeger
2016-05-09 9:20 ` [GIT PULL 04/10] KVM: s390: enable SRS only if enabled for the guest Christian Borntraeger
` (6 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Christian Borntraeger @ 2016-05-09 9:20 UTC (permalink / raw)
To: Paolo Bonzini, Radim Krčmář
Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger,
Jens Freimann, David Hildenbrand, Alexander Yarygin
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
Only enable PFMF interpretation if the necessary facility (EDAT1) is
available, otherwise the pfmf handler in priv.c will inject an exception
Reviewed-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
arch/s390/kvm/kvm-s390.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 668c087..13b3f5e 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -1649,7 +1649,8 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
if (test_kvm_facility(vcpu->kvm, 50) && test_kvm_facility(vcpu->kvm, 73))
vcpu->arch.sie_block->ecb |= 0x10;
- vcpu->arch.sie_block->ecb2 = 8;
+ if (test_kvm_facility(vcpu->kvm, 8))
+ vcpu->arch.sie_block->ecb2 |= 0x08;
vcpu->arch.sie_block->eca = 0xC1002000U;
if (sclp.has_siif)
vcpu->arch.sie_block->eca |= 1;
--
2.5.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [GIT PULL 04/10] KVM: s390: enable SRS only if enabled for the guest
2016-05-09 9:20 [GIT PULL 00/10] KVM: s390: features and fixes for 4.7 part2 Christian Borntraeger
` (2 preceding siblings ...)
2016-05-09 9:20 ` [GIT PULL 03/10] KVM: s390: enable PFMFI only if guest hast EDAT1 Christian Borntraeger
@ 2016-05-09 9:20 ` Christian Borntraeger
2016-05-09 10:32 ` Heiko Carstens
2016-05-09 9:20 ` [GIT PULL 05/10] KVM: s390: cleanup cpuid handling Christian Borntraeger
` (5 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Christian Borntraeger @ 2016-05-09 9:20 UTC (permalink / raw)
To: Paolo Bonzini, Radim Krčmář
Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger,
Jens Freimann, David Hildenbrand, Alexander Yarygin
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
If we don't have SIGP SENSE RUNNING STATUS enabled for the guest, let's
not enable interpretation so we can correctly report an invalid order.
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
arch/s390/include/asm/sigp.h | 1 +
arch/s390/kvm/kvm-s390.c | 4 +++-
arch/s390/kvm/sigp.c | 6 ++++++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/s390/include/asm/sigp.h b/arch/s390/include/asm/sigp.h
index ec60cf7..35c91da 100644
--- a/arch/s390/include/asm/sigp.h
+++ b/arch/s390/include/asm/sigp.h
@@ -33,6 +33,7 @@
#define SIGP_STATUS_INVALID_PARAMETER 0x00000100UL
#define SIGP_STATUS_INCORRECT_STATE 0x00000200UL
#define SIGP_STATUS_NOT_RUNNING 0x00000400UL
+#define SIGP_STATUS_INVALID_ORDER 0x00000002UL
#ifndef __ASSEMBLY__
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 13b3f5e..e1e375c 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -1645,7 +1645,9 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
kvm_s390_vcpu_setup_model(vcpu);
- vcpu->arch.sie_block->ecb = 6;
+ vcpu->arch.sie_block->ecb = 0x02;
+ if (test_kvm_facility(vcpu->kvm, 9))
+ vcpu->arch.sie_block->ecb |= 0x04;
if (test_kvm_facility(vcpu->kvm, 50) && test_kvm_facility(vcpu->kvm, 73))
vcpu->arch.sie_block->ecb |= 0x10;
diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c
index 77c22d6..28ea0ca 100644
--- a/arch/s390/kvm/sigp.c
+++ b/arch/s390/kvm/sigp.c
@@ -240,6 +240,12 @@ static int __sigp_sense_running(struct kvm_vcpu *vcpu,
struct kvm_s390_local_interrupt *li;
int rc;
+ if (!test_kvm_facility(vcpu->kvm, 9)) {
+ *reg &= 0xffffffff00000000UL;
+ *reg |= SIGP_STATUS_INVALID_ORDER;
+ return SIGP_CC_STATUS_STORED;
+ }
+
li = &dst_vcpu->arch.local_int;
if (atomic_read(li->cpuflags) & CPUSTAT_RUNNING) {
/* running */
--
2.5.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [GIT PULL 04/10] KVM: s390: enable SRS only if enabled for the guest
2016-05-09 9:20 ` [GIT PULL 04/10] KVM: s390: enable SRS only if enabled for the guest Christian Borntraeger
@ 2016-05-09 10:32 ` Heiko Carstens
2016-05-09 11:00 ` Christian Borntraeger
0 siblings, 1 reply; 15+ messages in thread
From: Heiko Carstens @ 2016-05-09 10:32 UTC (permalink / raw)
To: Christian Borntraeger
Cc: Paolo Bonzini, Radim Krčmář, KVM, Cornelia Huck,
linux-s390, Jens Freimann, David Hildenbrand, Alexander Yarygin
On Mon, May 09, 2016 at 11:20:15AM +0200, Christian Borntraeger wrote:
> From: David Hildenbrand <dahi@linux.vnet.ibm.com>
>
> If we don't have SIGP SENSE RUNNING STATUS enabled for the guest, let's
> not enable interpretation so we can correctly report an invalid order.
>
> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
> arch/s390/include/asm/sigp.h | 1 +
> arch/s390/kvm/kvm-s390.c | 4 +++-
> arch/s390/kvm/sigp.c | 6 ++++++
> 3 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/arch/s390/include/asm/sigp.h b/arch/s390/include/asm/sigp.h
> index ec60cf7..35c91da 100644
> --- a/arch/s390/include/asm/sigp.h
> +++ b/arch/s390/include/asm/sigp.h
> @@ -33,6 +33,7 @@
> #define SIGP_STATUS_INVALID_PARAMETER 0x00000100UL
> #define SIGP_STATUS_INCORRECT_STATE 0x00000200UL
> #define SIGP_STATUS_NOT_RUNNING 0x00000400UL
> +#define SIGP_STATUS_INVALID_ORDER 0x00000002UL
This new define should have been added at the top the list to keep the list
sorted. Maybe Paolo or Radim can change this when applying this patch.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [GIT PULL 04/10] KVM: s390: enable SRS only if enabled for the guest
2016-05-09 10:32 ` Heiko Carstens
@ 2016-05-09 11:00 ` Christian Borntraeger
2016-05-09 11:31 ` Christian Borntraeger
0 siblings, 1 reply; 15+ messages in thread
From: Christian Borntraeger @ 2016-05-09 11:00 UTC (permalink / raw)
To: Heiko Carstens
Cc: Paolo Bonzini, Radim Krčmář, KVM, Cornelia Huck,
linux-s390, Jens Freimann, David Hildenbrand, Alexander Yarygin
On 05/09/2016 12:32 PM, Heiko Carstens wrote:
> On Mon, May 09, 2016 at 11:20:15AM +0200, Christian Borntraeger wrote:
>> From: David Hildenbrand <dahi@linux.vnet.ibm.com>
>>
>> If we don't have SIGP SENSE RUNNING STATUS enabled for the guest, let's
>> not enable interpretation so we can correctly report an invalid order.
>>
>> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
>> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
>> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
>> ---
>> arch/s390/include/asm/sigp.h | 1 +
>> arch/s390/kvm/kvm-s390.c | 4 +++-
>> arch/s390/kvm/sigp.c | 6 ++++++
>> 3 files changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/s390/include/asm/sigp.h b/arch/s390/include/asm/sigp.h
>> index ec60cf7..35c91da 100644
>> --- a/arch/s390/include/asm/sigp.h
>> +++ b/arch/s390/include/asm/sigp.h
>> @@ -33,6 +33,7 @@
>> #define SIGP_STATUS_INVALID_PARAMETER 0x00000100UL
>> #define SIGP_STATUS_INCORRECT_STATE 0x00000200UL
>> #define SIGP_STATUS_NOT_RUNNING 0x00000400UL
>> +#define SIGP_STATUS_INVALID_ORDER 0x00000002UL
>
> This new define should have been added at the top the list to keep the list
> sorted. Maybe Paolo or Radim can change this when applying this patch.
Its a signed pull request and I must redo it if requested.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [GIT PULL 04/10] KVM: s390: enable SRS only if enabled for the guest
2016-05-09 11:00 ` Christian Borntraeger
@ 2016-05-09 11:31 ` Christian Borntraeger
0 siblings, 0 replies; 15+ messages in thread
From: Christian Borntraeger @ 2016-05-09 11:31 UTC (permalink / raw)
To: Heiko Carstens
Cc: Paolo Bonzini, Radim Krčmář, KVM, Cornelia Huck,
linux-s390, Jens Freimann, David Hildenbrand, Alexander Yarygin
On 05/09/2016 01:00 PM, Christian Borntraeger wrote:
> On 05/09/2016 12:32 PM, Heiko Carstens wrote:
>> On Mon, May 09, 2016 at 11:20:15AM +0200, Christian Borntraeger wrote:
>>> From: David Hildenbrand <dahi@linux.vnet.ibm.com>
>>>
>>> If we don't have SIGP SENSE RUNNING STATUS enabled for the guest, let's
>>> not enable interpretation so we can correctly report an invalid order.
>>>
>>> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
>>> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
>>> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
>>> ---
>>> arch/s390/include/asm/sigp.h | 1 +
>>> arch/s390/kvm/kvm-s390.c | 4 +++-
>>> arch/s390/kvm/sigp.c | 6 ++++++
>>> 3 files changed, 10 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/s390/include/asm/sigp.h b/arch/s390/include/asm/sigp.h
>>> index ec60cf7..35c91da 100644
>>> --- a/arch/s390/include/asm/sigp.h
>>> +++ b/arch/s390/include/asm/sigp.h
>>> @@ -33,6 +33,7 @@
>>> #define SIGP_STATUS_INVALID_PARAMETER 0x00000100UL
>>> #define SIGP_STATUS_INCORRECT_STATE 0x00000200UL
>>> #define SIGP_STATUS_NOT_RUNNING 0x00000400UL
>>> +#define SIGP_STATUS_INVALID_ORDER 0x00000002UL
>>
>> This new define should have been added at the top the list to keep the list
>> sorted. Maybe Paolo or Radim can change this when applying this patch.
>
> Its a signed pull request and I must redo it if requested.
>
>
>
Conny noticed a typo in the subject of patch3. So I will redo the
pull request as we have now 2 things to change.
Christian
^ permalink raw reply [flat|nested] 15+ messages in thread
* [GIT PULL 05/10] KVM: s390: cleanup cpuid handling
2016-05-09 9:20 [GIT PULL 00/10] KVM: s390: features and fixes for 4.7 part2 Christian Borntraeger
` (3 preceding siblings ...)
2016-05-09 9:20 ` [GIT PULL 04/10] KVM: s390: enable SRS only if enabled for the guest Christian Borntraeger
@ 2016-05-09 9:20 ` Christian Borntraeger
2016-05-09 9:20 ` [GIT PULL 06/10] KVM: s390: force ibc into valid range Christian Borntraeger
` (4 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Christian Borntraeger @ 2016-05-09 9:20 UTC (permalink / raw)
To: Paolo Bonzini, Radim Krčmář
Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger,
Jens Freimann, David Hildenbrand, Alexander Yarygin
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
We only have one cpuid for all VCPUs, so let's directly use the one in the
cpu model. Also always store it directly as u64, no need for struct cpuid.
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
arch/s390/include/asm/kvm_host.h | 6 +-----
arch/s390/kvm/kvm-s390.c | 17 +++++++++--------
arch/s390/kvm/priv.c | 2 +-
3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index 6da41fa..9282ccf 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -544,10 +544,6 @@ struct kvm_vcpu_arch {
struct kvm_s390_local_interrupt local_int;
struct hrtimer ckc_timer;
struct kvm_s390_pgm_info pgm;
- union {
- struct cpuid cpu_id;
- u64 stidp_data;
- };
struct gmap *gmap;
struct kvm_guestdbg_info_arch guestdbg;
unsigned long pfault_token;
@@ -605,7 +601,7 @@ struct kvm_s390_cpu_model {
__u64 fac_mask[S390_ARCH_FAC_LIST_SIZE_U64];
/* facility list requested by guest (in dma page) */
__u64 *fac_list;
- struct cpuid cpu_id;
+ u64 cpuid;
unsigned short ibc;
};
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index e1e375c..0d2f242 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -652,8 +652,7 @@ static int kvm_s390_set_processor(struct kvm *kvm, struct kvm_device_attr *attr)
}
if (!copy_from_user(proc, (void __user *)attr->addr,
sizeof(*proc))) {
- memcpy(&kvm->arch.model.cpu_id, &proc->cpuid,
- sizeof(struct cpuid));
+ kvm->arch.model.cpuid = proc->cpuid;
kvm->arch.model.ibc = proc->ibc;
memcpy(kvm->arch.model.fac_list, proc->fac_list,
S390_ARCH_FAC_LIST_SIZE_BYTE);
@@ -687,7 +686,7 @@ static int kvm_s390_get_processor(struct kvm *kvm, struct kvm_device_attr *attr)
ret = -ENOMEM;
goto out;
}
- memcpy(&proc->cpuid, &kvm->arch.model.cpu_id, sizeof(struct cpuid));
+ proc->cpuid = kvm->arch.model.cpuid;
proc->ibc = kvm->arch.model.ibc;
memcpy(&proc->fac_list, kvm->arch.model.fac_list,
S390_ARCH_FAC_LIST_SIZE_BYTE);
@@ -1081,10 +1080,13 @@ static void kvm_s390_set_crycb_format(struct kvm *kvm)
kvm->arch.crypto.crycbd |= CRYCB_FORMAT1;
}
-static void kvm_s390_get_cpu_id(struct cpuid *cpu_id)
+static u64 kvm_s390_get_initial_cpuid(void)
{
- get_cpu_id(cpu_id);
- cpu_id->version = 0xff;
+ struct cpuid cpuid;
+
+ get_cpu_id(&cpuid);
+ cpuid.version = 0xff;
+ return *((u64 *) &cpuid);
}
static void kvm_s390_crypto_init(struct kvm *kvm)
@@ -1175,7 +1177,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
memcpy(kvm->arch.model.fac_list, kvm->arch.model.fac_mask,
S390_ARCH_FAC_LIST_SIZE_BYTE);
- kvm_s390_get_cpu_id(&kvm->arch.model.cpu_id);
+ kvm->arch.model.cpuid = kvm_s390_get_initial_cpuid();
kvm->arch.model.ibc = sclp.ibc & 0x0fff;
kvm_s390_crypto_init(kvm);
@@ -1624,7 +1626,6 @@ static void kvm_s390_vcpu_setup_model(struct kvm_vcpu *vcpu)
{
struct kvm_s390_cpu_model *model = &vcpu->kvm->arch.model;
- vcpu->arch.cpu_id = model->cpu_id;
vcpu->arch.sie_block->ibc = model->ibc;
if (test_kvm_facility(vcpu->kvm, 7))
vcpu->arch.sie_block->fac = (u32)(u64) model->fac_list;
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 3137479..95916fa 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -439,7 +439,7 @@ static int handle_lpswe(struct kvm_vcpu *vcpu)
static int handle_stidp(struct kvm_vcpu *vcpu)
{
- u64 stidp_data = vcpu->arch.stidp_data;
+ u64 stidp_data = vcpu->kvm->arch.model.cpuid;
u64 operand2;
int rc;
ar_t ar;
--
2.5.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [GIT PULL 06/10] KVM: s390: force ibc into valid range
2016-05-09 9:20 [GIT PULL 00/10] KVM: s390: features and fixes for 4.7 part2 Christian Borntraeger
` (4 preceding siblings ...)
2016-05-09 9:20 ` [GIT PULL 05/10] KVM: s390: cleanup cpuid handling Christian Borntraeger
@ 2016-05-09 9:20 ` Christian Borntraeger
2016-05-09 9:20 ` [GIT PULL 07/10] KVM: s390: document KVM_CAP_S390_RI Christian Borntraeger
` (3 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Christian Borntraeger @ 2016-05-09 9:20 UTC (permalink / raw)
To: Paolo Bonzini, Radim Krčmář
Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger,
Jens Freimann, David Hildenbrand, Alexander Yarygin
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
Some hardware variants will round the ibc value up/down themselves,
others will report a validity intercept. Let's always round it up/down.
This patch will also make sure that the ibc is set to 0 in case we don't
have ibc support (lowest_ibc == 0).
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
arch/s390/kvm/kvm-s390.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 0d2f242..eb52b36 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -638,6 +638,7 @@ static int kvm_s390_get_tod(struct kvm *kvm, struct kvm_device_attr *attr)
static int kvm_s390_set_processor(struct kvm *kvm, struct kvm_device_attr *attr)
{
struct kvm_s390_vm_cpu_processor *proc;
+ u16 lowest_ibc, unblocked_ibc;
int ret = 0;
mutex_lock(&kvm->lock);
@@ -653,7 +654,16 @@ static int kvm_s390_set_processor(struct kvm *kvm, struct kvm_device_attr *attr)
if (!copy_from_user(proc, (void __user *)attr->addr,
sizeof(*proc))) {
kvm->arch.model.cpuid = proc->cpuid;
- kvm->arch.model.ibc = proc->ibc;
+ lowest_ibc = sclp.ibc >> 16 & 0xfff;
+ unblocked_ibc = sclp.ibc & 0xfff;
+ if (lowest_ibc) {
+ if (proc->ibc > unblocked_ibc)
+ kvm->arch.model.ibc = unblocked_ibc;
+ else if (proc->ibc < lowest_ibc)
+ kvm->arch.model.ibc = lowest_ibc;
+ else
+ kvm->arch.model.ibc = proc->ibc;
+ }
memcpy(kvm->arch.model.fac_list, proc->fac_list,
S390_ARCH_FAC_LIST_SIZE_BYTE);
} else
--
2.5.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [GIT PULL 07/10] KVM: s390: document KVM_CAP_S390_RI
2016-05-09 9:20 [GIT PULL 00/10] KVM: s390: features and fixes for 4.7 part2 Christian Borntraeger
` (5 preceding siblings ...)
2016-05-09 9:20 ` [GIT PULL 06/10] KVM: s390: force ibc into valid range Christian Borntraeger
@ 2016-05-09 9:20 ` Christian Borntraeger
2016-05-09 9:20 ` [GIT PULL 08/10] KVM: s390: Enable all facility bits that are known good for passthrough Christian Borntraeger
` (2 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Christian Borntraeger @ 2016-05-09 9:20 UTC (permalink / raw)
To: Paolo Bonzini, Radim Krčmář
Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger,
Jens Freimann, David Hildenbrand, Alexander Yarygin
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
We forgot to document that capability, let's add documentation.
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
Documentation/virtual/kvm/api.txt | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index 4d0542c..8cc857f 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -3788,6 +3788,14 @@ a KVM_EXIT_IOAPIC_EOI vmexit will be reported to userspace.
Fails if VCPU has already been created, or if the irqchip is already in the
kernel (i.e. KVM_CREATE_IRQCHIP has already been called).
+7.6 KVM_CAP_S390_RI
+
+Architectures: s390
+Parameters: none
+
+Allows use of runtime-instrumentation introduced with zEC12 processor.
+Will return -EINVAL if the machine does not support runtime-instrumentation.
+Will return -EBUSY if a VCPU has already been created.
8. Other capabilities.
----------------------
--
2.5.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [GIT PULL 08/10] KVM: s390: Enable all facility bits that are known good for passthrough
2016-05-09 9:20 [GIT PULL 00/10] KVM: s390: features and fixes for 4.7 part2 Christian Borntraeger
` (6 preceding siblings ...)
2016-05-09 9:20 ` [GIT PULL 07/10] KVM: s390: document KVM_CAP_S390_RI Christian Borntraeger
@ 2016-05-09 9:20 ` Christian Borntraeger
2016-05-09 9:20 ` [GIT PULL 09/10] s390/sclp: Add hmfai field Christian Borntraeger
2016-05-09 9:20 ` [GIT PULL 10/10] KVM: s390: Populate mask of non-hypervisor managed facility bits Christian Borntraeger
9 siblings, 0 replies; 15+ messages in thread
From: Christian Borntraeger @ 2016-05-09 9:20 UTC (permalink / raw)
To: Paolo Bonzini, Radim Krčmář
Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger,
Jens Freimann, David Hildenbrand, Alexander Yarygin
From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Some facility bits are in a range that is defined to be "ok for guests
without any necessary hypervisor changes". Enable those bits.
Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
arch/s390/kvm/kvm-s390.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index eb52b36..5fe6605 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -119,8 +119,8 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
/* upper facilities limit for kvm */
unsigned long kvm_s390_fac_list_mask[] = {
- 0xffe6fffbfcfdfc40UL,
- 0x005e800000000000UL,
+ 0xffe6ffffffffffffUL,
+ 0x005effffffffffffUL,
};
unsigned long kvm_s390_fac_list_mask_size(void)
--
2.5.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [GIT PULL 09/10] s390/sclp: Add hmfai field
2016-05-09 9:20 [GIT PULL 00/10] KVM: s390: features and fixes for 4.7 part2 Christian Borntraeger
` (7 preceding siblings ...)
2016-05-09 9:20 ` [GIT PULL 08/10] KVM: s390: Enable all facility bits that are known good for passthrough Christian Borntraeger
@ 2016-05-09 9:20 ` Christian Borntraeger
2016-05-09 9:20 ` [GIT PULL 10/10] KVM: s390: Populate mask of non-hypervisor managed facility bits Christian Borntraeger
9 siblings, 0 replies; 15+ messages in thread
From: Christian Borntraeger @ 2016-05-09 9:20 UTC (permalink / raw)
To: Paolo Bonzini, Radim Krčmář
Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger,
Jens Freimann, David Hildenbrand, Alexander Yarygin
From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Let's add hypervisor-managed facility-apportionment indications field to
SCLP structs. KVM will use it to reduce maintenance cost of
Non-Hypervisor-Managed facility bits.
Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Reviewed-by: Eric Farman <farman@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
arch/s390/include/asm/sclp.h | 1 +
drivers/s390/char/sclp_early.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/s390/include/asm/sclp.h b/arch/s390/include/asm/sclp.h
index bab456b..994a66c 100644
--- a/arch/s390/include/asm/sclp.h
+++ b/arch/s390/include/asm/sclp.h
@@ -69,6 +69,7 @@ struct sclp_info {
unsigned int max_cores;
unsigned long hsa_size;
unsigned long facilities;
+ unsigned int hmfai;
};
extern struct sclp_info sclp;
diff --git a/drivers/s390/char/sclp_early.c b/drivers/s390/char/sclp_early.c
index 6804354..0ac520d 100644
--- a/drivers/s390/char/sclp_early.c
+++ b/drivers/s390/char/sclp_early.c
@@ -49,7 +49,9 @@ struct read_info_sccb {
u8 _pad_117[119 - 117]; /* 117-118 */
u8 fac119; /* 119 */
u16 hcpua; /* 120-121 */
- u8 _pad_122[4096 - 122]; /* 122-4095 */
+ u8 _pad_122[124 - 122]; /* 122-123 */
+ u32 hmfai; /* 124-127 */
+ u8 _pad_128[4096 - 128]; /* 128-4095 */
} __packed __aligned(PAGE_SIZE);
static char sccb_early[PAGE_SIZE] __aligned(PAGE_SIZE) __initdata;
@@ -155,6 +157,8 @@ static void __init sclp_facilities_detect(struct read_info_sccb *sccb)
sclp.mtid = (sccb->fac42 & 0x80) ? (sccb->fac42 & 31) : 0;
sclp.mtid_cp = (sccb->fac42 & 0x80) ? (sccb->fac43 & 31) : 0;
sclp.mtid_prev = (sccb->fac42 & 0x80) ? (sccb->fac66 & 31) : 0;
+
+ sclp.hmfai = sccb->hmfai;
}
/*
--
2.5.5
^ permalink raw reply related [flat|nested] 15+ messages in thread* [GIT PULL 10/10] KVM: s390: Populate mask of non-hypervisor managed facility bits
2016-05-09 9:20 [GIT PULL 00/10] KVM: s390: features and fixes for 4.7 part2 Christian Borntraeger
` (8 preceding siblings ...)
2016-05-09 9:20 ` [GIT PULL 09/10] s390/sclp: Add hmfai field Christian Borntraeger
@ 2016-05-09 9:20 ` Christian Borntraeger
9 siblings, 0 replies; 15+ messages in thread
From: Christian Borntraeger @ 2016-05-09 9:20 UTC (permalink / raw)
To: Paolo Bonzini, Radim Krčmář
Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger,
Jens Freimann, David Hildenbrand, Alexander Yarygin
From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
When a guest is initializing, KVM provides facility bits that can be
successfully used by the guest. It's done by applying
kvm_s390_fac_list_mask mask on host facility bits stored by the STFLE
instruction. Facility bits can be one of two kinds: it's either a
hypervisor managed bit or non-hypervisor managed.
The hardware provides information which bits need special handling.
Let's automatically passthrough to guests new facility bits, that
don't require hypervisor support.
Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Reviewed-by: Eric Farman <farman@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
arch/s390/kvm/kvm-s390.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 5fe6605..c597201 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -118,9 +118,9 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
};
/* upper facilities limit for kvm */
-unsigned long kvm_s390_fac_list_mask[] = {
- 0xffe6ffffffffffffUL,
- 0x005effffffffffffUL,
+unsigned long kvm_s390_fac_list_mask[16] = {
+ 0xffe6000000000000UL,
+ 0x005e000000000000UL,
};
unsigned long kvm_s390_fac_list_mask_size(void)
@@ -2985,13 +2985,26 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
return;
}
+static inline unsigned long nonhyp_mask(int i)
+{
+ unsigned int nonhyp_fai = (sclp.hmfai << i * 2) >> 30;
+
+ return 0x0000ffffffffffffUL >> (nonhyp_fai << 4);
+}
+
static int __init kvm_s390_init(void)
{
+ int i;
+
if (!sclp.has_sief2) {
pr_info("SIE not available\n");
return -ENODEV;
}
+ for (i = 0; i < 16; i++)
+ kvm_s390_fac_list_mask[i] |=
+ S390_lowcore.stfle_fac_list[i] & nonhyp_mask(i);
+
return kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE);
}
--
2.5.5
^ permalink raw reply related [flat|nested] 15+ messages in thread