KVM: s390: Fixes and features for 4.14
Subsystems (5)
cover KVM: s390: Fixes and features for 4.14
This is what I have pending for 4.14 in
git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git kvm-s390-next-4.14-1
It contains 2 merges (on topic branch from Martin for the tlb flushing and a back-merge from the s390 fixes for master to avoid merge conflicts with followup fixes).
"New" patches are marked (x) below. (patches 5,6,10,11). Pull request will come later this week.
----------------------------------------------------------------
KVM: s390: Fixes and features for 4.14
- merge of topic branch tlb-flushing from the s390 tree to get the no-dat base features
- wire up the no-dat enhancements in KVM
- multiple epoch facility (z14 feature)
- Configuration z/Architecture Mode fixup
- merge of kvm/master to avoid conflicts with additional sthyi fixes
- more sthyi fixes
----------------------------------------------------------------
Christian Borntraeger (3):
Merge branch 'tlb-flushing' of git://git.kernel.org/.../s390/linux into kernelorgnext
KVM: s390: take srcu lock when getting/setting storage keys
Merge tag 'kvm-s390-master-4.13-2' into kvms390/next
Claudio Imbrenda (1):
(x) KVM: s390: expose no-DAT to guest and migration support
Collin L. Walling (1):
(x) KVM: s390: Multiple Epoch Facility support
Heiko Carstens (3):
KVM: s390: sthyi: fix sthyi inline assembly
KVM: s390: sthyi: fix specification exception detection
(x) KVM: s390: sthyi: remove invalid guest write access
Jason J. Herne (1):
(x) KVM: s390: Support Configuration z/Architecture Mode
Martin Schwidefsky (4):
s390/mm: tag normal pages vs pages used in page tables s390/mm: add no-dat TLB flush optimization s390/mm: add guest ASCE TLB flush optimization s390/mm,kvm: use nodat PGSTE tag to optimize TLB flushing
Documentation/virtual/kvm/devices/vm.txt | 14 ++- arch/s390/include/asm/kvm_host.h | 6 +- arch/s390/include/asm/page-states.h | 3 +- arch/s390/include/asm/page.h | 3 + arch/s390/include/asm/pgtable.h | 88 ++++++++++---- arch/s390/include/asm/setup.h | 9 +- arch/s390/include/asm/tlbflush.h | 7 +- arch/s390/include/uapi/asm/kvm.h | 6 + arch/s390/kernel/suspend.c | 22 +++- arch/s390/kernel/vdso.c | 2 + arch/s390/kvm/kvm-s390.c | 117 +++++++++++++++++- arch/s390/kvm/kvm-s390.h | 2 + arch/s390/kvm/priv.c | 6 +- arch/s390/kvm/sigp.c | 36 +++--- arch/s390/kvm/sthyi.c | 13 +- arch/s390/kvm/vsie.c | 10 ++ arch/s390/mm/init.c | 2 + arch/s390/mm/page-states.c | 196 ++++++++++++++++++++++++++++--- arch/s390/mm/pageattr.c | 2 +- arch/s390/mm/pgalloc.c | 2 + arch/s390/mm/pgtable.c | 160 +++++++++++++++++++------ arch/s390/tools/gen_facilities.c | 2 + drivers/s390/char/sclp_early.c | 6 +- 23 files changed, 595 insertions(+), 119 deletions(-)
PATCH 5/11 KVM: s390: Support Configuration z/Architecture Mode
From: "Jason J. Herne" <[email protected]>
kvm has always supported the concept of starting in z/Arch mode so let's reflect the feature bit to the guest.
Also, we change sigp set architecture to reject any request to change architecture modes.
--- arch/s390/kvm/sigp.c | 36 +++++++++++++++++------------------- arch/s390/tools/gen_facilities.c | 1 + 2 files changed, 18 insertions(+), 19 deletions(-)
arch/s390/kvm/sigp.c +17 -19
@@ -155,29 +155,26 @@ static int __sigp_stop_and_store_status(struct kvm_vcpu *vcpu,return rc; } -static int __sigp_set_arch (struct kvm_vcpu *vcpu,u32 parameter) +static int __sigp_set_arch (struct kvm_vcpu *vcpu,u32 parameter, +u64 *status_reg) { -int rc;unsigned int i;struct kvm_vcpu *v; +bool all_stopped = true; -switch (parameter &0xff ) { -case 0 : - rc =SIGP_CC_NOT_OPERATIONAL ; -break ; -case 1 : -case 2 : -kvm_for_each_vcpu (i, v, vcpu->kvm) { - v->arch.pfault_token =KVM_S390_PFAULT_TOKEN_INVALID ; -kvm_clear_async_pf_completion_queue (v); - } - - rc =SIGP_CC_ORDER_CODE_ACCEPTED ; -break ; -default : - rc = -EOPNOTSUPP ; +kvm_for_each_vcpu (i, v, vcpu->kvm) { +if (v == vcpu) +continue ; +if (!is_vcpu_stopped (v)) + all_stopped = false; } -return rc; + + *status_reg &=0xffffffff00000000ULL ; + +/* Reject set arch order, with czam we're always in z/Arch mode. */ + *status_reg |= (all_stopped ?SIGP_STATUS_INVALID_PARAMETER : +SIGP_STATUS_INCORRECT_STATE ); +return SIGP_CC_STATUS_STORED ; } static int __sigp_set_prefix(struct kvm_vcpu *vcpu, struct kvm_vcpu *dst_vcpu,
@@ -446,7 +443,8 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)switch (order_code) {case SIGP_SET_ARCHITECTURE : vcpu->stat.instruction_sigp_arch++; - rc =__sigp_set_arch (vcpu, parameter); + rc =__sigp_set_arch (vcpu, parameter, + &vcpu->run->s.regs.gprs[r1]);break ;default : rc = handle_sigp_dst(vcpu, order_code, cpu_addr,
arch/s390/tools/gen_facilities.c +1 -0
@@ -80,6 +80,7 @@ static struct facility_def facility_defs[] = {78 ,/* enhanced-DAT 2 */ 130 ,/* instruction-execution-protection */ 131 ,/* enhanced-SOP 2 and side-effect */ +138 ,/* configuration z/architecture mode (czam) */ 146 ,/* msa extension 8 */ -1 /* END */ }
Signature · 1 line
2.7.4
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
Quoted 7 lines · On Mon, 28 Aug 2017 10:07:28 +0200 Christian Borntraeger…
From: "Jason J. Herne" <[email protected]>
kvm has always supported the concept of starting in z/Arch mode so let's reflect the feature bit to the guest.
Also, we change sigp set architecture to reject any request to change architecture modes.
What are the implications of this for guests? IIRC, czam is a z14 feature (the updated PoP is not yet out, is it?). We now reject any set arch sigp, even if we profess to be an older machine. Linux can probably deal with this, but is it correct?
Quoted 8 lines
Signed-off-by Jason J. Herne <[email protected]>Reviewed-by Christian Borntraeger <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>--- arch/s390/kvm/sigp.c | 36 +++++++++++++++++------------------- arch/s390/tools/gen_facilities.c | 1 + 2 files changed, 18 insertions(+), 19 deletions(-)
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
Quoted 8 lines · Cornelia Huck
Quoted 5 lines · On Mon, 28 Aug 2017 10:07:28 +0200 Christian Borntraeger…
From: "Jason J. Herne" <[email protected]>
kvm has always supported the concept of starting in z/Arch mode so let's reflect the feature bit to the guest.
Quoted 7 lines
Quoted 2 lines
Also, we change sigp set architecture to reject any request to change architecture modes.
What are the implications of this for guests? IIRC, czam is a z14 feature (the updated PoP is not yet out, is it?). We now reject any set arch sigp, even if we profess to be an older machine. Linux can probably deal with this, but is it correct?
Linux can deal with it. Since KVM does not support IPL in ESA mode, we basically always provided the czam functionality. We now do it like it was architected. z/VM does it the same way when enabling czam on an older system like z13.
In other words the old code was not compliant (and never was), the new code is compliant. Since czam is kind of a "negative" facility, we can implement it also on older systems.
Quoted 10 lines
Quoted 9 lines
Signed-off-by Jason J. Herne <[email protected]>Reviewed-by Christian Borntraeger <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>--- arch/s390/kvm/sigp.c | 36 +++++++++++++++++------------------- arch/s390/tools/gen_facilities.c | 1 + 2 files changed, 18 insertions(+), 19 deletions(-)
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
Quoted 19 lines · Christian Borntraeger
Quoted 8 lines · Cornelia Huck
Quoted 5 lines · On Mon, 28 Aug 2017 10:07:28 +0200 Christian Borntraeger…
From: "Jason J. Herne" <[email protected]>
kvm has always supported the concept of starting in z/Arch mode so let's reflect the feature bit to the guest.
Quoted 7 lines
Quoted 2 lines
Also, we change sigp set architecture to reject any request to change architecture modes.
What are the implications of this for guests? IIRC, czam is a z14 feature (the updated PoP is not yet out, is it?). We now reject any set arch sigp, even if we profess to be an older machine. Linux can probably deal with this, but is it correct?
Quoted 7 lines
Linux can deal with it. Since KVM does not support IPL in ESA mode, we basically always provided the czam functionality. We now do it like it was architected. z/VM does it the same way when enabling czam on an older system like z13.
In other words the old code was not compliant (and never was), the new code is compliant. Since czam is kind of a "negative" facility, we can implement it also on older systems.
FWIW, this code will only run when QEMU does not enable the SIGP forwarding. All new QEMUs handle this in QEMU. The equivalent fix in QEMU is
commit 075e52b816648f21ca6bf5cc01624dff3993c99e
Author: Jason J. Herne <[email protected]> AuthorDate: Thu Sep 1 10:56:49 2016 +0200 Commit: Christian Borntraeger <[email protected]> CommitDate: Fri Jul 14 12:29:49 2017 +0200
s390x/cpumodel: we are always in zarchitecture model
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
In reply to Christian BorntraegerQuoted 12 lines · On Mon, 28 Aug 2017 11:11:15 +0200 Christian Borntraeger…
Quoted 11 lines · Cornelia Huck
Quoted 7 lines · On Mon, 28 Aug 2017 10:07:28 +0200 Christian Borntraeger…
From: "Jason J. Herne" <[email protected]>
kvm has always supported the concept of starting in z/Arch mode so let's reflect the feature bit to the guest.
Also, we change sigp set architecture to reject any request to change architecture modes.
Quoted 8 lines
Quoted 4 lines
What are the implications of this for guests? IIRC, czam is a z14 feature (the updated PoP is not yet out, is it?). We now reject any set arch sigp, even if we profess to be an older machine. Linux can probably deal with this, but is it correct?
Linux can deal with it. Since KVM does not support IPL in ESA mode, we basically always provided the czam functionality. We now do it like it was architected. z/VM does it the same way when enabling czam on an older system like z13.
OK, this implies any z operating system needs to be able to deal with czam on older machines.
Quoted 3 lines
In other words the old code was not compliant (and never was), the new code is compliant. Since czam is kind of a "negative" facility, we can implement it also on older systems.
Looking at this, we should mirror this in qemu in tcg mode, as the corresponding qemu patch only handles the kvm path (I obviously did not look at the patch in enough detail...) Added to my list.
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
In reply to Christian BorntraegerQuoted 8 lines · On Mon, 28 Aug 2017 10:07:28 +0200 Christian Borntraeger…
From: "Jason J. Herne" <[email protected]>
kvm has always supported the concept of starting in z/Arch mode so let's reflect the feature bit to the guest.
Also, we change sigp set architecture to reject any request to change architecture modes.
Quoted 7 lines
Signed-off-by Jason J. Herne <[email protected]>Reviewed-by Christian Borntraeger <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>--- arch/s390/kvm/sigp.c | 36 +++++++++++++++++------------------- arch/s390/tools/gen_facilities.c | 1 + 2 files changed, 18 insertions(+), 19 deletions(-)
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
In reply to Christian BorntraegerQuoted 7 lines · Christian Borntraeger
From: "Jason J. Herne" <[email protected]>
kvm has always supported the concept of starting in z/Arch mode so let's reflect the feature bit to the guest.
Also, we change sigp set architecture to reject any request to change architecture modes.
Hm ... this seems to imply that CZAM is always set, but what about running on old user space (possibly on old hw)? Old QEMU will not enable CZAM.
And especially old user space will rely on SET ARCHITECTURE being handled in the kernel.
I agree, that for QEMU we can always do that change (as we control which features are indicated to the guest). But I am wondering if we would have to stick to existing behavior unless test_kvm_facility(vcpu->kvm, 138).
Quoted 17 lines
Signed-off-by Jason J. Herne <[email protected]>Reviewed-by Christian Borntraeger <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>--- arch/s390/kvm/sigp.c | 36 +++++++++++++++++------------------- arch/s390/tools/gen_facilities.c | 1 + 2 files changed, 18 insertions(+), 19 deletions(-)arch/s390/kvm/sigp.c +0
-0@@ -155,29 +155,26 @@ static int __sigp_stop_and_store_status(struct kvm_vcpu *vcpu,return rc; }
[...]
arch/s390/kvm/sigp.c static int __sigp_stop_and_store_status(struct kvm_vcpu *vcpu, · line 172
Quoted 4 lines
arch/s390/kvm/sigp.c +2
-1} -return rc; + + *status_reg &=0xffffffff00000000ULL ;
s/ULL/UL/
Quoted 31 lines
arch/s390/kvm/sigp.c +7
-1+ +/* Reject set arch order, with czam we're always in z/Arch mode. */ + *status_reg |= (all_stopped ?SIGP_STATUS_INVALID_PARAMETER : +SIGP_STATUS_INCORRECT_STATE ); +return SIGP_CC_STATUS_STORED ; } static int __sigp_set_prefix(struct kvm_vcpu *vcpu, struct kvm_vcpu *dst_vcpu,@@ -446,7 +443,8 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)switch (order_code) {case SIGP_SET_ARCHITECTURE : vcpu->stat.instruction_sigp_arch++; - rc =__sigp_set_arch (vcpu, parameter); + rc =__sigp_set_arch (vcpu, parameter, + &vcpu->run->s.regs.gprs[r1]);break ;default : rc = handle_sigp_dst(vcpu, order_code, cpu_addr,arch/s390/tools/gen_facilities.c +1
-0@@ -80,6 +80,7 @@ static struct facility_def facility_defs[] = {78 ,/* enhanced-DAT 2 */ 130 ,/* instruction-execution-protection */ 131 ,/* enhanced-SOP 2 and side-effect */ +138 ,/* configuration z/architecture mode (czam) */ 146 ,/* msa extension 8 */ -1 /* END */ }
Signature · 3 lines
Thanks, David
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
Quoted 6 lines · David Hildenbrand
Quoted 5 lines · Christian Borntraeger
From: "Jason J. Herne" <[email protected]>
kvm has always supported the concept of starting in z/Arch mode so let's reflect the feature bit to the guest.
Quoted 6 lines
Quoted 2 lines
Also, we change sigp set architecture to reject any request to change architecture modes.
Hm ... this seems to imply that CZAM is always set, but what about running on old user space (possibly on old hw)? Old QEMU will not enable CZAM.
3 cases.
1. very old QEMU without user sigp
2. old QEMU with user sigp/without CPU model
3. new QEMU with user sigp/cpu model
I think we agree that cases 2 and 3 should not matter at all for this kernel patch as the sigp is handled by QEMU.
This is case 1:
Quoted 2 lines
And especially old user space will rely on SET ARCHITECTURE being handled in the kernel.
Yes, and it continues to be handled in the kernel. It is just that the guest will now see a different sigp return code. Before, our sigp implementation lied to the guest in a way that worked for Linux (we lied by saying "yes, we switched"). We now say "sorry, we are already in zarch mode, sigp ignored" which also works perfectly fine for Linux. And IMHO it is even the better choice even without STFLE.138 being set as it matches what an old hardware would do when in zarch mode.
Quoted 24 lines
I agree, that for QEMU we can always do that change (as we control which features are indicated to the guest). But I am wondering if we would have to stick to existing behavior unless
test_kvm_facility(vcpu->kvm, 138).Quoted 17 lines
Signed-off-by Jason J. Herne <[email protected]>Reviewed-by Christian Borntraeger <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>--- arch/s390/kvm/sigp.c | 36 +++++++++++++++++------------------- arch/s390/tools/gen_facilities.c | 1 + 2 files changed, 18 insertions(+), 19 deletions(-)arch/s390/kvm/sigp.c +0
-0@@ -155,29 +155,26 @@ static int __sigp_stop_and_store_status(struct kvm_vcpu *vcpu,return rc; }[...]
Quoted 6 lines
arch/s390/kvm/sigp.c static int __sigp_stop_and_store_status(struct kvm_vcpu *vcpu, · line 172
Quoted 4 lines
arch/s390/kvm/sigp.c +2
-1} -return rc; + + *status_reg &=0xffffffff00000000ULL ;s/ULL/UL/
Right, will fix.
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
Quoted 31 lines · Christian Borntraeger
Quoted 6 lines · David Hildenbrand
Quoted 5 lines · Christian Borntraeger
From: "Jason J. Herne" <[email protected]>
kvm has always supported the concept of starting in z/Arch mode so let's reflect the feature bit to the guest.
Quoted 6 lines
Quoted 2 lines
Also, we change sigp set architecture to reject any request to change architecture modes.
Hm ... this seems to imply that CZAM is always set, but what about running on old user space (possibly on old hw)? Old QEMU will not enable CZAM.
3 cases.
1. very old QEMU without user sigp
2. old QEMU with user sigp/without CPU model
3. new QEMU with user sigp/cpu modelI think we agree that cases 2 and 3 should not matter at all for this kernel patch as the sigp is handled by QEMU.
This is case 1:
Quoted 2 lines
And especially old user space will rely on SET ARCHITECTURE being handled in the kernel.
Quoted 6 lines
Yes, and it continues to be handled in the kernel. It is just that the guest will now see a different sigp return code. Before, our sigp implementation lied to the guest in a way that worked for Linux (we lied by saying "yes, we switched"). We now say "sorry, we are already in zarch mode, sigp ignored" which also works perfectly fine for Linux. And IMHO it is even the better choice even without STFLE.138 being set as it matches what an old hardware would do when in zarch mode.
Ok, if it worked for relevant Linux versions, than it should indeed be fine.
Thanks!
Quoted 12 lines
Quoted 8 lines
[...]
arch/s390/kvm/sigp.c static int __sigp_stop_and_store_status(struct kvm_vcpu *vcpu, · line 172
Quoted 4 lines
arch/s390/kvm/sigp.c +2
-1} -return rc; + + *status_reg &=0xffffffff00000000ULL ;s/ULL/UL/
Right, will fix.
Signature · 3 lines
Thanks, David
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
Quoted 32 lines · David Hildenbrand
Quoted 31 lines · Christian Borntraeger
Quoted 6 lines · David Hildenbrand
Quoted 5 lines · Christian Borntraeger
From: "Jason J. Herne" <[email protected]>
kvm has always supported the concept of starting in z/Arch mode so let's reflect the feature bit to the guest.
Quoted 6 lines
Quoted 2 lines
Also, we change sigp set architecture to reject any request to change architecture modes.
Hm ... this seems to imply that CZAM is always set, but what about running on old user space (possibly on old hw)? Old QEMU will not enable CZAM.
3 cases.
1. very old QEMU without user sigp
2. old QEMU with user sigp/without CPU model
3. new QEMU with user sigp/cpu modelI think we agree that cases 2 and 3 should not matter at all for this kernel patch as the sigp is handled by QEMU.
This is case 1:
Quoted 2 lines
And especially old user space will rely on SET ARCHITECTURE being handled in the kernel.
Quoted 8 lines
Quoted 6 lines
Yes, and it continues to be handled in the kernel. It is just that the guest will now see a different sigp return code. Before, our sigp implementation lied to the guest in a way that worked for Linux (we lied by saying "yes, we switched"). We now say "sorry, we are already in zarch mode, sigp ignored" which also works perfectly fine for Linux. And IMHO it is even the better choice even without STFLE.138 being set as it matches what an old hardware would do when in zarch mode.
Ok, if it worked for relevant Linux versions, than it should indeed be fine.
I checked back to 2006 and Linux never checked the return value for this sigp.
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
In reply to Christian BorntraegerQuoted 8 lines
(quoted diff) +0
-0rc = handle_sigp_dst(vcpu, order_code, cpu_addr,arch/s390/tools/gen_facilities.c +0
-0
arch/s390/tools/gen_facilities.c static struct facility_def facility_defs[] = { · line 86
Quoted 7 lines
arch/s390/tools/gen_facilities.c +1
-0@@ -80,6 +80,7 @@ static struct facility_def facility_defs[] = {78 ,/* enhanced-DAT 2 */ 130 ,/* instruction-execution-protection */ 131 ,/* enhanced-SOP 2 and side-effect */ +138 ,/* configuration z/architecture mode (czam) */ 146 ,/* msa extension 8 */ -1 /* END */ }
Thinking about it, this should be the right thing to do instead of the last hunk:
arch/s390/kvm/kvm-s390.c +0 -0
@@ -1927,6 +1927,10 @@ 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);+ /* we are always in CZAM mode - even on pre z14 machines */
+ set_kvm_facility(kvm->arch.model.fac_mask, 138);
+ set_kvm_facility(kvm->arch.model.fac_list, 138);
+ /* we emulate STHYI in kvm */
set_kvm_facility(kvm->arch.model.fac_mask, 74);
set_kvm_facility(kvm->arch.model.fac_list, 74);
if (MACHINE_HAS_TLB_GUEST) {That would produce consistent results for very old QEMU.
Signature · 3 lines
Thanks, David
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
Quoted 36 lines · David Hildenbrand
Quoted 8 lines
(quoted diff) +0
-0rc = handle_sigp_dst(vcpu, order_code, cpu_addr,arch/s390/tools/gen_facilities.c +0
-0arch/s390/tools/gen_facilities.c static struct facility_def facility_defs[] = { · line 86
Quoted 7 lines
arch/s390/tools/gen_facilities.c +1
-0@@ -80,6 +80,7 @@ static struct facility_def facility_defs[] = {78 ,/* enhanced-DAT 2 */ 130 ,/* instruction-execution-protection */ 131 ,/* enhanced-SOP 2 and side-effect */ +138 ,/* configuration z/architecture mode (czam) */ 146 ,/* msa extension 8 */ -1 /* END */ }Thinking about it, this should be the right thing to do instead of the last hunk:
arch/s390/kvm/kvm-s390.c +4
-0@@ -1927,6 +1927,10 @@ 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 ); +/* we are always in CZAM mode - even on pre z14 machines */ +set_kvm_facility (kvm->arch.model.fac_mask,138 ); +set_kvm_facility (kvm->arch.model.fac_list,138 ); +/* we emulate STHYI in kvm */ set_kvm_facility (kvm->arch.model.fac_mask,74 );set_kvm_facility (kvm->arch.model.fac_list,74 );if (MACHINE_HAS_TLB_GUEST) {
Quoted 2 lines
That would produce consistent results for very old QEMU.
This should be identical as the initial fac_list is populated from the fac_mask, which is populated by the facility_defs structure.
[..]
/* Populate the facility list initially. */
kvm->arch.model.fac_list = kvm->arch.sie_page2->fac_list;
----> memcpy(kvm->arch.model.fac_list, kvm->arch.model.fac_mask,
S390_ARCH_FAC_LIST_SIZE_BYTE);[,..]
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
Quoted 45 lines · Christian Borntraeger
Quoted 36 lines · David Hildenbrand
Quoted 8 lines
(quoted diff) +0
-0rc = handle_sigp_dst(vcpu, order_code, cpu_addr,arch/s390/tools/gen_facilities.c +0
-0arch/s390/tools/gen_facilities.c static struct facility_def facility_defs[] = { · line 86
Quoted 7 lines
arch/s390/tools/gen_facilities.c +1
-0@@ -80,6 +80,7 @@ static struct facility_def facility_defs[] = {78 ,/* enhanced-DAT 2 */ 130 ,/* instruction-execution-protection */ 131 ,/* enhanced-SOP 2 and side-effect */ +138 ,/* configuration z/architecture mode (czam) */ 146 ,/* msa extension 8 */ -1 /* END */ }Thinking about it, this should be the right thing to do instead of the last hunk:
arch/s390/kvm/kvm-s390.c +4
-0@@ -1927,6 +1927,10 @@ 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 ); +/* we are always in CZAM mode - even on pre z14 machines */ +set_kvm_facility (kvm->arch.model.fac_mask,138 ); +set_kvm_facility (kvm->arch.model.fac_list,138 ); +/* we emulate STHYI in kvm */ set_kvm_facility (kvm->arch.model.fac_mask,74 );set_kvm_facility (kvm->arch.model.fac_list,74 );if (MACHINE_HAS_TLB_GUEST) {Quoted 2 lines
That would produce consistent results for very old QEMU.
This should be identical as the initial
fac_listis populated from thefac_mask, which is populated by thefacility_defsstructure.
Quoted 7 lines
[..]
/* Populate the facility list initially. */ kvm->arch.model.fac_list = kvm->arch.sie_page2->fac_list; ----> memcpy(kvm->arch.model.fac_list, kvm->arch.model.fac_mask, S390_ARCH_FAC_LIST_SIZE_BYTE);[,..]
Well not identical. The patch actually enables the czam facility only if the host hardware while your variant enables it always. Interesting discussion if it matters if we should enable it on z13, z12 and earlier or not
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
Quoted 54 lines · Christian Borntraeger
Quoted 51 lines · Christian Borntraeger
Quoted 36 lines · David Hildenbrand
Quoted 8 lines
(quoted diff) +0
-0rc = handle_sigp_dst(vcpu, order_code, cpu_addr,arch/s390/tools/gen_facilities.c +0
-0arch/s390/tools/gen_facilities.c static struct facility_def facility_defs[] = { · line 86
Quoted 7 lines
arch/s390/tools/gen_facilities.c +1
-0@@ -80,6 +80,7 @@ static struct facility_def facility_defs[] = {78 ,/* enhanced-DAT 2 */ 130 ,/* instruction-execution-protection */ 131 ,/* enhanced-SOP 2 and side-effect */ +138 ,/* configuration z/architecture mode (czam) */ 146 ,/* msa extension 8 */ -1 /* END */ }Thinking about it, this should be the right thing to do instead of the last hunk:
arch/s390/kvm/kvm-s390.c +4
-0@@ -1927,6 +1927,10 @@ 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 ); +/* we are always in CZAM mode - even on pre z14 machines */ +set_kvm_facility (kvm->arch.model.fac_mask,138 ); +set_kvm_facility (kvm->arch.model.fac_list,138 ); +/* we emulate STHYI in kvm */ set_kvm_facility (kvm->arch.model.fac_mask,74 );set_kvm_facility (kvm->arch.model.fac_list,74 );if (MACHINE_HAS_TLB_GUEST) {Quoted 2 lines
That would produce consistent results for very old QEMU.
This should be identical as the initial
fac_listis populated from thefac_mask, which is populated by thefacility_defsstructure.[..]
/* Populate the facility list initially. */ kvm->arch.model.fac_list = kvm->arch.sie_page2->fac_list; ----> memcpy(kvm->arch.model.fac_list, kvm->arch.model.fac_mask, S390_ARCH_FAC_LIST_SIZE_BYTE);
Quoted 6 lines
Quoted 1 line
[,..]
Well not identical. The patch actually enables the czam facility only if the host hardware while your variant enables it always. Interesting discussion if it matters if we should enable it on z13, z12 and earlier or not
This is also what we do on the QEMU side and what I meant by "consistent".
Signature · 3 lines
Thanks, David
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
Quoted 55 lines · David Hildenbrand
Quoted 54 lines · Christian Borntraeger
Quoted 51 lines · Christian Borntraeger
Quoted 36 lines · David Hildenbrand
Quoted 8 lines
(quoted diff) +0
-0rc = handle_sigp_dst(vcpu, order_code, cpu_addr,arch/s390/tools/gen_facilities.c +0
-0arch/s390/tools/gen_facilities.c static struct facility_def facility_defs[] = { · line 86
Quoted 7 lines
arch/s390/tools/gen_facilities.c +1
-0@@ -80,6 +80,7 @@ static struct facility_def facility_defs[] = {78 ,/* enhanced-DAT 2 */ 130 ,/* instruction-execution-protection */ 131 ,/* enhanced-SOP 2 and side-effect */ +138 ,/* configuration z/architecture mode (czam) */ 146 ,/* msa extension 8 */ -1 /* END */ }Thinking about it, this should be the right thing to do instead of the last hunk:
arch/s390/kvm/kvm-s390.c +4
-0@@ -1927,6 +1927,10 @@ 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 ); +/* we are always in CZAM mode - even on pre z14 machines */ +set_kvm_facility (kvm->arch.model.fac_mask,138 ); +set_kvm_facility (kvm->arch.model.fac_list,138 ); +/* we emulate STHYI in kvm */ set_kvm_facility (kvm->arch.model.fac_mask,74 );set_kvm_facility (kvm->arch.model.fac_list,74 );if (MACHINE_HAS_TLB_GUEST) {Quoted 2 lines
That would produce consistent results for very old QEMU.
This should be identical as the initial
fac_listis populated from thefac_mask, which is populated by thefacility_defsstructure.[..]
/* Populate the facility list initially. */ kvm->arch.model.fac_list = kvm->arch.sie_page2->fac_list; ----> memcpy(kvm->arch.model.fac_list, kvm->arch.model.fac_mask, S390_ARCH_FAC_LIST_SIZE_BYTE);
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
[,..]
Well not identical. The patch actually enables the czam facility only if the host hardware while your variant enables it always. Interesting discussion if it matters if we should enable it on z13, z12 and earlier or not
This is also what we do on the QEMU side and what I meant by "consistent".
Yes, I agree. QEMU will always enable stfle.138. So should the kernel. Shall I fixup the patch with your change proposal or do you want to send an on-top patch?
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
Quoted 6 lines
Quoted 2 lines
This is also what we do on the QEMU side and what I meant by "consistent".
Yes, I agree. QEMU will always enable stfle.138. So should the kernel. Shall I fixup the patch with your change proposal or do you want to send an on-top patch?
Whatever you prefer!
Signature · 3 lines
Thanks, David
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
Quoted 8 lines · David Hildenbrand
Quoted 6 lines
Quoted 2 lines
This is also what we do on the QEMU side and what I meant by "consistent".
Yes, I agree. QEMU will always enable stfle.138. So should the kernel. Shall I fixup the patch with your change proposal or do you want to send an on-top patch?
Whatever you prefer!
Can you send a fixup patch on top?
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
Quoted 6 lines · Christian Borntraeger
Quoted 3 lines · David Hildenbrand
Quoted 3 lines
Quoted 2 lines
This is also what we do on the QEMU side and what I meant by "consistent".
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Yes, I agree. QEMU will always enable stfle.138. So should the kernel. Shall I fixup the patch with your change proposal or do you want to send an on-top patch?
Whatever you prefer!
Can you send a fixup patch on top?
Will do!
Signature · 3 lines
Thanks, David
PATCH 1/1 KVM: s390: we are always in czam mode
In reply to Christian BorntraegerIndepenent of the underlying hardware, kvm will now always handle SIGP SET ARCHITECTURE as if czam is enabled. Therefore, let's not only forward that bit but always set it.
While at it, add a comment regarding STHYI.
--- arch/s390/kvm/kvm-s390.c | 4 ++++ arch/s390/tools/gen_facilities.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-)
arch/s390/kvm/kvm-s390.c +4 -0
@@ -1927,6 +1927,10 @@ 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 ); +/* we are always in czam mode - even on pre z14 machines */ +set_kvm_facility (kvm->arch.model.fac_mask,138 ); +set_kvm_facility (kvm->arch.model.fac_list,138 ); +/* we emulate STHYI in kvm */ set_kvm_facility (kvm->arch.model.fac_mask,74 );set_kvm_facility (kvm->arch.model.fac_list,74 );if (MACHINE_HAS_TLB_GUEST ) {
arch/s390/tools/gen_facilities.c +0 -1
@@ -80,7 +80,6 @@ static struct facility_def facility_defs[] = {78 ,/* enhanced-DAT 2 */ 130 ,/* instruction-execution-protection */ 131 ,/* enhanced-SOP 2 and side-effect */ -138 ,/* configuration z/architecture mode (czam) */ 139 ,/* multiple epoch facility */ 146 ,/* msa extension 8 */ -1 /* END */
Signature · 1 line
2.13.5
Re: [PATCH] KVM: s390: we are always in czam mode
Quoted 1 line · On Tue, 29 Aug 2017 16:31:08 +0200 David Hildenbrand <[email protected]> wrote:
Indepenent of the underlying hardware, kvm will now always handle
s/Indepenent/Independent/
Quoted 1 line
SIGP SET ARCHITECTURE as if czam is enabled. Therefore, let's not
s/is/were/, I think?
Quoted 9 lines
only forward that bit but always set it.
While at it, add a comment regarding STHYI.
Signed-off-by David Hildenbrand <[email protected]>--- arch/s390/kvm/kvm-s390.c | 4 ++++ arch/s390/tools/gen_facilities.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-)
Christian Borntraeger
AppliedRe: [PATCH] KVM: s390: we are always in czam mode
In reply to David Hildenbrandapplied to next (with Connys language fixes)
Quoted 40 lines · David Hildenbrand
Indepenent of the underlying hardware, kvm will now always handle SIGP SET ARCHITECTURE as if czam is enabled. Therefore, let's not only forward that bit but always set it.
While at it, add a comment regarding STHYI.
Signed-off-by David Hildenbrand <[email protected]>--- arch/s390/kvm/kvm-s390.c | 4 ++++ arch/s390/tools/gen_facilities.c | 1 - 2 files changed, 4 insertions(+), 1 deletion(-)arch/s390/kvm/kvm-s390.c +4
-0@@ -1927,6 +1927,10 @@ 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 ); +/* we are always in czam mode - even on pre z14 machines */ +set_kvm_facility (kvm->arch.model.fac_mask,138 ); +set_kvm_facility (kvm->arch.model.fac_list,138 ); +/* we emulate STHYI in kvm */ set_kvm_facility (kvm->arch.model.fac_mask,74 );set_kvm_facility (kvm->arch.model.fac_list,74 );if (MACHINE_HAS_TLB_GUEST ) {arch/s390/tools/gen_facilities.c +0
-1@@ -80,7 +80,6 @@ static struct facility_def facility_defs[] = {78 ,/* enhanced-DAT 2 */ 130 ,/* instruction-execution-protection */ 131 ,/* enhanced-SOP 2 and side-effect */ -138 ,/* configuration z/architecture mode (czam) */ 139 ,/* multiple epoch facility */ 146 ,/* msa extension 8 */ -1 /* END */
Re: [PATCH 05/11] KVM: s390: Support Configuration z/Architecture Mode
In reply to Christian BorntraegerQuoted 45 lines · Christian Borntraeger
Quoted 36 lines · David Hildenbrand
Quoted 8 lines
(quoted diff) +0
-0rc = handle_sigp_dst(vcpu, order_code, cpu_addr,arch/s390/tools/gen_facilities.c +0
-0arch/s390/tools/gen_facilities.c static struct facility_def facility_defs[] = { · line 86
Quoted 7 lines
arch/s390/tools/gen_facilities.c +1
-0@@ -80,6 +80,7 @@ static struct facility_def facility_defs[] = {78 ,/* enhanced-DAT 2 */ 130 ,/* instruction-execution-protection */ 131 ,/* enhanced-SOP 2 and side-effect */ +138 ,/* configuration z/architecture mode (czam) */ 146 ,/* msa extension 8 */ -1 /* END */ }Thinking about it, this should be the right thing to do instead of the last hunk:
arch/s390/kvm/kvm-s390.c +4
-0@@ -1927,6 +1927,10 @@ 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 ); +/* we are always in CZAM mode - even on pre z14 machines */ +set_kvm_facility (kvm->arch.model.fac_mask,138 ); +set_kvm_facility (kvm->arch.model.fac_list,138 ); +/* we emulate STHYI in kvm */ set_kvm_facility (kvm->arch.model.fac_mask,74 );set_kvm_facility (kvm->arch.model.fac_list,74 );if (MACHINE_HAS_TLB_GUEST) {Quoted 2 lines
That would produce consistent results for very old QEMU.
This should be identical as the initial
fac_listis populated from thefac_mask, which is populated by thefacility_defsstructure.
Quoted 8 lines
[..]
/* Populate the facility list initially. */ kvm->arch.model.fac_list = kvm->arch.sie_page2->fac_list; ----> memcpy(kvm->arch.model.fac_list, kvm->arch.model.fac_mask, S390_ARCH_FAC_LIST_SIZE_BYTE);[,..]
This would keep it unset on e.g. a z13, no? (that's why I added the comment regarding z14)
By always enabling it we would behave exactly like QEMU.
Signature · 3 lines
Thanks, David
PATCH 6/11 KVM: s390: Multiple Epoch Facility support
In reply to Christian BorntraegerFrom: "Collin L. Walling" <[email protected]>
Allow for the enablement of MEF and the support for the extended epoch in SIE and VSIE for the extended guest TOD-Clock.
A new interface is used for getting/setting a guest's extended TOD-Clock that uses a single ioctl invocation, KVM_S390_VM_TOD_EXT. The old method of getting and setting the guest TOD-Clock is retained and is used when the old ioctls are called.
--- Documentation/virtual/kvm/devices/vm.txt | 14 ++++- arch/s390/include/asm/kvm_host.h | 6 +- arch/s390/include/uapi/asm/kvm.h | 6 ++ arch/s390/kvm/kvm-s390.c | 101 +++++++++++++++++++++++++++++++ arch/s390/kvm/kvm-s390.h | 2 + arch/s390/kvm/vsie.c | 10 +++ arch/s390/tools/gen_facilities.c | 1 + 7 files changed, 138 insertions(+), 2 deletions(-)
Documentation/virtual/kvm/devices/vm.txt +13 -1
@@ -176,7 +176,8 @@ Architectures: s390 3.1. ATTRIBUTE: KVM_S390_VM_TOD_HIGH -Allows user space to set/get the TOD clock extension (u8). +Allows user space to set/get the TOD clock extension (u8). (superseded by +KVM_S390_VM_TOD_EXT). Parameters: address of a buffer in user space to store the data (u8) to Returns: -EFAULT if the given address is not accessible from kernel space
@@ -190,6 +191,17 @@ the POP (u64). Parameters: address of a buffer in user space to store the data (u64) to Returns: -EFAULT if the given address is not accessible from kernel space +3.3. ATTRIBUTE: KVM_S390_VM_TOD_EXT + +Allows user space to set/get bits 0-63 of the TOD clock register as defined in +the POP (u64), as well as the TOD clock extension (u8) if supported by the +host. + +Parameters: address of a buffer in user space to store the data + (kvm_s390_vm_tod_clock) to +Returns: -EFAULT if the given address is not accessible from kernel space + -EINVAL if setting the TOD clock extension to != 0 is not supported + 4. GROUP: KVM_S390_VM_CRYPTO Architectures: s390
arch/s390/include/asm/kvm_host.h +5 -1
@@ -226,7 +226,9 @@ struct kvm_s390_sie_block {#define ECB3_RI 0x01__u8 ecb3;/* 0x0063 */ __u32 scaol;/* 0x0064 */ -__u8 reserved68[4 ];/* 0x0068 */ +__u8 reserved68;/* 0x0068 */ +__u8 epdx;/* 0x0069 */ +__u8 reserved6a[2 ];/* 0x006a */ __u32 todpr;/* 0x006c */ __u8 reserved70[16 ];/* 0x0070 */ __u64 mso;/* 0x0080 */
@@ -265,6 +267,7 @@ struct kvm_s390_sie_block {__u64 cbrlo;/* 0x01b8 */ __u8 reserved1c0[8 ];/* 0x01c0 */ #define ECD_HOSTREGMGMT 0x20000000 +#define ECD_MEF 0x08000000__u32 ecd;/* 0x01c8 */ __u8 reserved1cc[18 ];/* 0x01cc */ __u64 pp;/* 0x01de */
@@ -739,6 +742,7 @@ struct kvm_arch{struct kvm_s390_cpu_model model;struct kvm_s390_crypto crypto;struct kvm_s390_vsie vsie; +u8 epdx;u64 epoch;struct kvm_s390_migration_state *migration_state;/* subset of available cpu features enabled by user space */
arch/s390/include/uapi/asm/kvm.h +6 -0
@@ -88,6 +88,12 @@ struct kvm_s390_io_adapter_req {/* kvm attributes for KVM_S390_VM_TOD */ #define KVM_S390_VM_TOD_LOW 0#define KVM_S390_VM_TOD_HIGH 1 +#define KVM_S390_VM_TOD_EXT 2 + +struct kvm_s390_vm_tod_clock { +__u8 epoch_idx; +__u64 tod; +};/* kvm attributes for KVM_S390_VM_CPU_MODEL */ /* processor related attributes are r/w */
arch/s390/kvm/kvm-s390.c +101 -0
143 lines not on this page · raw message
arch/s390/kvm/kvm-s390.h +2 -0
@@ -272,6 +272,8 @@ int kvm_s390_handle_sigp_pei(struct kvm_vcpu *vcpu);int handle_sthyi (struct kvm_vcpu *vcpu);/* implemented in kvm-s390.c */ +void kvm_s390_set_tod_clock_ext (struct kvm *kvm, +const struct kvm_s390_vm_tod_clock *gtod);void kvm_s390_set_tod_clock (struct kvm *kvm,u64 tod);long kvm_arch_fault_in_page (struct kvm_vcpu *vcpu,gpa_t gpa,int writable);int kvm_s390_store_status_unloaded (struct kvm_vcpu *vcpu,unsigned long addr);
arch/s390/kvm/vsie.c +10 -0
@@ -349,6 +349,9 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) scb_s->eca |= scb_o->eca &ECA_IB ;if (test_kvm_cpu_feat (vcpu->kvm,KVM_S390_VM_CPU_FEAT_CEI )) scb_s->eca |= scb_o->eca &ECA_CEI ; +/* Epoch Extension */ +if (test_kvm_facility (vcpu->kvm,139 )) + scb_s->ecd |= scb_o->ecd &ECD_MEF ;prepare_ibc (vcpu, vsie_page); rc =shadow_crycb (vcpu, vsie_page);
@@ -919,6 +922,13 @@ static void register_shadow_scb(struct kvm_vcpu *vcpu,*/ preempt_disable (); scb_s->epoch += vcpu->kvm->arch.epoch; + +if (test_kvm_facility (vcpu->kvm,139 )) { + scb_s->epdx += vcpu->kvm->arch.epdx; +if (scb_s->epoch < vcpu->kvm->arch.epoch) + scb_s->epdx +=1 ; + } +preempt_enable (); }
arch/s390/tools/gen_facilities.c +1 -0
@@ -81,6 +81,7 @@ static struct facility_def facility_defs[] = {130 ,/* instruction-execution-protection */ 131 ,/* enhanced-SOP 2 and side-effect */ 138 ,/* configuration z/architecture mode (czam) */ +139 ,/* multiple epoch facility */ 146 ,/* msa extension 8 */ -1 /* END */ }
Signature · 1 line
2.7.4
Re: [PATCH 06/11] KVM: s390: Multiple Epoch Facility support
Quoted 30 lines · On Mon, 28 Aug 2017 10:07:29 +0200 Christian Borntraeger…
From: "Collin L. Walling" <[email protected]>
Allow for the enablement of MEF and the support for the extended epoch in SIE and VSIE for the extended guest TOD-Clock.
A new interface is used for getting/setting a guest's extended TOD-Clock that uses a single ioctl invocation,
KVM_S390_VM_TOD_EXT. The old method of getting and setting the guest TOD-Clock is retained and is used when the old ioctls are called.Signed-off-by Collin L. Walling <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>Reviewed-by Jason J. Herne <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>--- Documentation/virtual/kvm/devices/vm.txt | 14 ++++- arch/s390/include/asm/kvm_host.h | 6 +- arch/s390/include/uapi/asm/kvm.h | 6 ++ arch/s390/kvm/kvm-s390.c | 101 +++++++++++++++++++++++++++++++ arch/s390/kvm/kvm-s390.h | 2 + arch/s390/kvm/vsie.c | 10 +++ arch/s390/tools/gen_facilities.c | 1 + 7 files changed, 138 insertions(+), 2 deletions(-)Documentation/virtual/kvm/devices/vm.txt +0
-0
Documentation/virtual/kvm/devices/vm.txt Architectures: s390 · line 179
Quoted 5 lines
Documentation/virtual/kvm/devices/vm.txt +1
-1@@ -176,7 +176,8 @@ Architectures: s390 3.1. ATTRIBUTE: KVM_S390_VM_TOD_HIGH -Allows user space to set/get the TOD clock extension (u8). +Allows user space to set/get the TOD clock extension (u8). (superseded by
s/(u8)./(u8)/
Documentation/virtual/kvm/devices/vm.txt the POP (u64). · line 198
Quoted 13 lines
Documentation/virtual/kvm/devices/vm.txt +6
-0+KVM_S390_VM_TOD_EXT). Parameters: address of a buffer in user space to store the data (u8) to Returns: -EFAULT if the given address is not accessible from kernel space@@ -190,6 +191,17 @@ the POP (u64). Parameters: address of a buffer in user space to store the data (u64) to Returns: -EFAULT if the given address is not accessible from kernel space +3.3. ATTRIBUTE: KVM_S390_VM_TOD_EXT + +Allows user space to set/get bits 0-63 of the TOD clock register as defined in +the POP (u64), as well as the TOD clock extension (u8) if supported by the +host.
I would be a bit more explicit on what happens if the tod clock extension is not supported. What about:
"Allows user space to set/get bits 0-63 of the TOD clock register as defined in the POP (u64). If the host supports the TOD clock extension (u8), it also allows user space to set it. If the host does not support it, it is stored as 0 and not allowed to be set to a value != 0."
Documentation/virtual/kvm/devices/vm.txt the POP (u64). · line 207
Quoted 9 lines
Documentation/virtual/kvm/devices/vm.txt +6
-0+ +Parameters: address of a buffer in user space to store the data + (kvm_s390_vm_tod_clock) to +Returns: -EFAULT if the given address is not accessible from kernel space + -EINVAL if setting the TOD clock extension to != 0 is not supported + 4. GROUP: KVM_S390_VM_CRYPTO Architectures: s390
Else, looks good AFAICS.
Re: [PATCH 06/11] KVM: s390: Multiple Epoch Facility support
Quoted 34 lines · Cornelia Huck
Quoted 31 lines · On Mon, 28 Aug 2017 10:07:29 +0200 Christian Borntraeger…
From: "Collin L. Walling" <[email protected]>
Allow for the enablement of MEF and the support for the extended epoch in SIE and VSIE for the extended guest TOD-Clock.
A new interface is used for getting/setting a guest's extended TOD-Clock that uses a single ioctl invocation,
KVM_S390_VM_TOD_EXT. The old method of getting and setting the guest TOD-Clock is retained and is used when the old ioctls are called.Signed-off-by Collin L. Walling <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>Reviewed-by Jason J. Herne <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>--- Documentation/virtual/kvm/devices/vm.txt | 14 ++++- arch/s390/include/asm/kvm_host.h | 6 +- arch/s390/include/uapi/asm/kvm.h | 6 ++ arch/s390/kvm/kvm-s390.c | 101 +++++++++++++++++++++++++++++++ arch/s390/kvm/kvm-s390.h | 2 + arch/s390/kvm/vsie.c | 10 +++ arch/s390/tools/gen_facilities.c | 1 + 7 files changed, 138 insertions(+), 2 deletions(-)Documentation/virtual/kvm/devices/vm.txt +0
-0@@ -176,7 +176,8 @@ Architectures: s390
Quoted 6 lines
Documentation/virtual/kvm/devices/vm.txt Architectures: s390 · line 179
Quoted 4 lines
Documentation/virtual/kvm/devices/vm.txt +1
-13.1. ATTRIBUTE: KVM_S390_VM_TOD_HIGH -Allows user space to set/get the TOD clock extension (u8). +Allows user space to set/get the TOD clock extension (u8). (superseded bys/(u8)./(u8)/
ok
Quoted 18 lines
Quoted 6 lines
Documentation/virtual/kvm/devices/vm.txt +1
-0+KVM_S390_VM_TOD_EXT). Parameters: address of a buffer in user space to store the data (u8) to Returns: -EFAULT if the given address is not accessible from kernel spaceDocumentation/virtual/kvm/devices/vm.txt the POP (u64). · line 198
Quoted 8 lines
Documentation/virtual/kvm/devices/vm.txt +5
-0@@ -190,6 +191,17 @@ the POP (u64). Parameters: address of a buffer in user space to store the data (u64) to Returns: -EFAULT if the given address is not accessible from kernel space +3.3. ATTRIBUTE: KVM_S390_VM_TOD_EXT + +Allows user space to set/get bits 0-63 of the TOD clock register as defined in +the POP (u64), as well as the TOD clock extension (u8) if supported by the +host.I would be a bit more explicit on what happens if the tod clock extension is not supported. What about:
Quoted 4 lines
"Allows user space to set/get bits 0-63 of the TOD clock register as defined in the POP (u64). If the host supports the TOD clock extension (u8), it also allows user space to set it. If the host does not support it, it is stored as 0 and not allowed to be set to a value != 0."
We check test_kvm_facility(kvm, 139))
so what about using your text with the following change,
"host" --> "guest cpu model" ?
Quoted 13 lines
Documentation/virtual/kvm/devices/vm.txt the POP (u64). · line 207
Quoted 10 lines
Documentation/virtual/kvm/devices/vm.txt +6
-0+ +Parameters: address of a buffer in user space to store the data + (kvm_s390_vm_tod_clock) to +Returns: -EFAULT if the given address is not accessible from kernel space + -EINVAL if setting the TOD clock extension to != 0 is not supported + 4. GROUP: KVM_S390_VM_CRYPTO Architectures: s390Else, looks good AFAICS.
Quoted 1 line
Reviewed-by Cornelia Huck <[email protected]>
Thanks
Re: [PATCH 06/11] KVM: s390: Multiple Epoch Facility support
Quoted 67 lines · On Mon, 28 Aug 2017 13:36:24 +0200 Christian Borntraeger…
Quoted 34 lines · Cornelia Huck
Quoted 31 lines · On Mon, 28 Aug 2017 10:07:29 +0200 Christian Borntraeger…
From: "Collin L. Walling" <[email protected]>
Allow for the enablement of MEF and the support for the extended epoch in SIE and VSIE for the extended guest TOD-Clock.
A new interface is used for getting/setting a guest's extended TOD-Clock that uses a single ioctl invocation,
KVM_S390_VM_TOD_EXT. The old method of getting and setting the guest TOD-Clock is retained and is used when the old ioctls are called.Signed-off-by Collin L. Walling <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>Reviewed-by Jason J. Herne <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>--- Documentation/virtual/kvm/devices/vm.txt | 14 ++++- arch/s390/include/asm/kvm_host.h | 6 +- arch/s390/include/uapi/asm/kvm.h | 6 ++ arch/s390/kvm/kvm-s390.c | 101 +++++++++++++++++++++++++++++++ arch/s390/kvm/kvm-s390.h | 2 + arch/s390/kvm/vsie.c | 10 +++ arch/s390/tools/gen_facilities.c | 1 + 7 files changed, 138 insertions(+), 2 deletions(-)Documentation/virtual/kvm/devices/vm.txt +0
-0@@ -176,7 +176,8 @@ Architectures: s390Quoted 6 lines
Documentation/virtual/kvm/devices/vm.txt Architectures: s390 · line 179
Quoted 4 lines
Documentation/virtual/kvm/devices/vm.txt +1
-13.1. ATTRIBUTE: KVM_S390_VM_TOD_HIGH -Allows user space to set/get the TOD clock extension (u8). +Allows user space to set/get the TOD clock extension (u8). (superseded bys/(u8)./(u8)/
ok
Quoted 18 lines
Quoted 6 lines
Documentation/virtual/kvm/devices/vm.txt +1
-0+KVM_S390_VM_TOD_EXT). Parameters: address of a buffer in user space to store the data (u8) to Returns: -EFAULT if the given address is not accessible from kernel spaceDocumentation/virtual/kvm/devices/vm.txt the POP (u64). · line 198
Quoted 8 lines
Documentation/virtual/kvm/devices/vm.txt +5
-0@@ -190,6 +191,17 @@ the POP (u64). Parameters: address of a buffer in user space to store the data (u64) to Returns: -EFAULT if the given address is not accessible from kernel space +3.3. ATTRIBUTE: KVM_S390_VM_TOD_EXT + +Allows user space to set/get bits 0-63 of the TOD clock register as defined in +the POP (u64), as well as the TOD clock extension (u8) if supported by the +host.I would be a bit more explicit on what happens if the tod clock extension is not supported. What about:
Quoted 4 lines
"Allows user space to set/get bits 0-63 of the TOD clock register as defined in the POP (u64). If the host supports the TOD clock extension (u8), it also allows user space to set it. If the host does not support it, it is stored as 0 and not allowed to be set to a value != 0."
Quoted 4 lines
We check
test_kvm_facility(kvm, 139))
so what about using your text with the following change,"host" --> "guest cpu model" ?
Fine with me.
Re: [PATCH 06/11] KVM: s390: Multiple Epoch Facility support
In reply to Christian BorntraegerQuoted 9 lines · Christian Borntraeger
From: "Collin L. Walling" <[email protected]>
Allow for the enablement of MEF and the support for the extended epoch in SIE and VSIE for the extended guest TOD-Clock.
A new interface is used for getting/setting a guest's extended TOD-Clock that uses a single ioctl invocation,
KVM_S390_VM_TOD_EXT. The old method of getting and setting the guest TOD-Clock is retained and is used when the old ioctls are called.
After talking to Christian, I understand that we have to set it in "one shot" as we can otherwise run into problems when getting/setting the TOD as we are looking at a moving target. This should go into the cover letter.
I need some more info regarding the architecture change.
For now, epoch was an unsigned value that is interpreted as an signed value.
a) Is that still true with multiple epoch?
b) What is the format of the epoch index? Can it also be "negative"?
Why I am asking: I can see comparison made with the epoch:
arch/s390/kvm/vsie.c static void register_shadow_scb(struct kvm_vcpu *vcpu, · line 930
Quoted 5 lines
arch/s390/kvm/vsie.c +5
-0+if (test_kvm_facility (vcpu->kvm,139 )) { + scb_s->epdx += vcpu->kvm->arch.epdx; +if (scb_s->epoch < vcpu->kvm->arch.epoch) + scb_s->epdx +=1 ; + }
or
arch/s390/kvm/kvm-s390.c static int kvm_s390_handle_requests(struct kvm_vcpu *vcpu) · line 2942
Quoted 2 lines
arch/s390/kvm/kvm-s390.c +2
-0+if (kvm->arch.epoch > gtod->tod) + kvm->arch.epdx -=1 ;
If I remember correctly, such comparisons won't work correctly when having this signed/unsigned duality. But I might be wrong.
Quoted 7 lines
Signed-off-by Collin L. Walling <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>Reviewed-by Jason J. Herne <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>---
[...]
Quoted 22 lines
/* implemented in
kvm-s390.c*/arch/s390/kvm/kvm-s390.h +2
-0+void kvm_s390_set_tod_clock_ext (struct kvm *kvm, +const struct kvm_s390_vm_tod_clock *gtod);void kvm_s390_set_tod_clock (struct kvm *kvm,u64 tod);long kvm_arch_fault_in_page (struct kvm_vcpu *vcpu,gpa_t gpa,int writable);int kvm_s390_store_status_unloaded (struct kvm_vcpu *vcpu,unsigned long addr);arch/s390/kvm/vsie.c +3
-0@@ -349,6 +349,9 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) scb_s->eca |= scb_o->eca &ECA_IB ;if (test_kvm_cpu_feat (vcpu->kvm,KVM_S390_VM_CPU_FEAT_CEI )) scb_s->eca |= scb_o->eca &ECA_CEI ; +/* Epoch Extension */ +if (test_kvm_facility (vcpu->kvm,139 )) + scb_s->ecd |= scb_o->ecd &ECD_MEF ;prepare_ibc (vcpu, vsie_page); rc =shadow_crycb (vcpu, vsie_page);
arch/s390/kvm/vsie.c static void register_shadow_scb(struct kvm_vcpu *vcpu, · line 926
Quoted 5 lines
arch/s390/kvm/vsie.c +2
-0@@ -919,6 +922,13 @@ static void register_shadow_scb(struct kvm_vcpu *vcpu,*/ preempt_disable (); scb_s->epoch += vcpu->kvm->arch.epoch; + +if (test_kvm_facility (vcpu->kvm,139 )) {
Although scb_s->epdx won't be interpreted without ECD_MEF, this should be (so data is only copied if really enabled).
if (scb_s->ecd | ECD_MEF)
Quoted 21 lines
arch/s390/kvm/vsie.c +5
-0+ scb_s->epdx += vcpu->kvm->arch.epdx; +if (scb_s->epoch < vcpu->kvm->arch.epoch) + scb_s->epdx +=1 ; + } +preempt_enable (); }arch/s390/tools/gen_facilities.c +1
-0@@ -81,6 +81,7 @@ static struct facility_def facility_defs[] = {130 ,/* instruction-execution-protection */ 131 ,/* enhanced-SOP 2 and side-effect */ 138 ,/* configuration z/architecture mode (czam) */ +139 ,/* multiple epoch facility */ 146 ,/* msa extension 8 */ -1 /* END */ }
Signature · 3 lines
Thanks, David
Re: [PATCH 06/11] KVM: s390: Multiple Epoch Facility support
Quoted 6 lines · David Hildenbrand
Quoted 5 lines · Christian Borntraeger
From: "Collin L. Walling" <[email protected]>
Allow for the enablement of MEF and the support for the extended epoch in SIE and VSIE for the extended guest TOD-Clock.
Quoted 8 lines
Quoted 4 lines
A new interface is used for getting/setting a guest's extended TOD-Clock that uses a single ioctl invocation,
KVM_S390_VM_TOD_EXT. The old method of getting and setting the guest TOD-Clock is retained and is used when the old ioctls are called.After talking to Christian, I understand that we have to set it in "one shot" as we can otherwise run into problems when getting/setting the TOD as we are looking at a moving target. This should go into the cover letter.
You mean in the patch description or in the git tag description?
Quoted 4 lines
I need some more info regarding the architecture change.
For now, epoch was an unsigned value that is interpreted as an signed value.
It is always considered a signed value, (so the guest can be before or after the host) we just used u64 to make the wraparound defined (doing all the math in the unsigned realm as signed overflow is undefined)
Quoted 3 lines
a) Is that still true with multiple epoch?
b) What is the format of the epoch index? Can it also be "negative"?
The concatenation of both is considered a 72bit signed value.
Quoted 6 lines
Why I am asking: I can see comparison made with the epoch:
arch/s390/kvm/vsie.c static void register_shadow_scb(struct kvm_vcpu *vcpu, · line 928
Quoted 3 lines
arch/s390/kvm/vsie.c +3
-0+if (test_kvm_facility (vcpu->kvm,139 )) { + scb_s->epdx += vcpu->kvm->arch.epdx; +if (scb_s->epoch < vcpu->kvm->arch.epoch)
This checks for an overflow after the addition and
Quoted 1 line
arch/s390/kvm/vsie.c static void register_shadow_scb(struct kvm_vcpu *vcpu, · line 929
Quoted 1 line
arch/s390/kvm/vsie.c +1
-0+ scb_s->epdx +=1 ;
corrects this. Since this is all unsigned math this is defined to wrap around and should work unless I missed something
Quoted 10 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ }or
arch/s390/kvm/kvm-s390.c static int kvm_s390_handle_requests(struct kvm_vcpu *vcpu) · line 2942
Quoted 2 lines
arch/s390/kvm/kvm-s390.c +2
-0+if (kvm->arch.epoch > gtod->tod) + kvm->arch.epdx -=1 ;If I remember correctly, such comparisons won't work correctly when having this signed/unsigned duality. But I might be wrong.
As far as I can see we have unsigned data types everywhere.
Quoted 42 lines
Quoted 9 lines
Signed-off-by Collin L. Walling <[email protected]>Reviewed-by Janosch Frank <[email protected]>Reviewed-by Claudio Imbrenda <[email protected]>Reviewed-by Jason J. Herne <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>---
[...]
Quoted 22 lines
/* implemented in
kvm-s390.c*/arch/s390/kvm/kvm-s390.h +2
-0+void kvm_s390_set_tod_clock_ext (struct kvm *kvm, +const struct kvm_s390_vm_tod_clock *gtod);void kvm_s390_set_tod_clock (struct kvm *kvm,u64 tod);long kvm_arch_fault_in_page (struct kvm_vcpu *vcpu,gpa_t gpa,int writable);int kvm_s390_store_status_unloaded (struct kvm_vcpu *vcpu,unsigned long addr);arch/s390/kvm/vsie.c +3
-0@@ -349,6 +349,9 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) scb_s->eca |= scb_o->eca &ECA_IB ;if (test_kvm_cpu_feat (vcpu->kvm,KVM_S390_VM_CPU_FEAT_CEI )) scb_s->eca |= scb_o->eca &ECA_CEI ; +/* Epoch Extension */ +if (test_kvm_facility (vcpu->kvm,139 )) + scb_s->ecd |= scb_o->ecd &ECD_MEF ;prepare_ibc (vcpu, vsie_page); rc =shadow_crycb (vcpu, vsie_page);arch/s390/kvm/vsie.c static void register_shadow_scb(struct kvm_vcpu *vcpu, · line 926
Quoted 5 lines
arch/s390/kvm/vsie.c +2
-0@@ -919,6 +922,13 @@ static void register_shadow_scb(struct kvm_vcpu *vcpu,*/ preempt_disable (); scb_s->epoch += vcpu->kvm->arch.epoch; + +if (test_kvm_facility (vcpu->kvm,139 )) {Although
scb_s->epdxwon't be interpreted withoutECD_MEF, this should be (so data is only copied if really enabled).
Quoted 1 line
if (
scb_s->ecd|ECD_MEF)
As you said, it does not matter but it certainly is clearer. I can fix.
Quoted 24 lines
Quoted 22 lines
arch/s390/kvm/vsie.c +5
-0+ scb_s->epdx += vcpu->kvm->arch.epdx; +if (scb_s->epoch < vcpu->kvm->arch.epoch) + scb_s->epdx +=1 ; + } +preempt_enable (); }arch/s390/tools/gen_facilities.c +1
-0@@ -81,6 +81,7 @@ static struct facility_def facility_defs[] = {130 ,/* instruction-execution-protection */ 131 ,/* enhanced-SOP 2 and side-effect */ 138 ,/* configuration z/architecture mode (czam) */ +139 ,/* multiple epoch facility */ 146 ,/* msa extension 8 */ -1 /* END */ }
Re: [PATCH 06/11] KVM: s390: Multiple Epoch Facility support
Quoted 14 lines · Christian Borntraeger
Quoted 11 lines · David Hildenbrand
Quoted 9 lines · Christian Borntraeger
From: "Collin L. Walling" <[email protected]>
Allow for the enablement of MEF and the support for the extended epoch in SIE and VSIE for the extended guest TOD-Clock.
A new interface is used for getting/setting a guest's extended TOD-Clock that uses a single ioctl invocation,
KVM_S390_VM_TOD_EXT. The old method of getting and setting the guest TOD-Clock is retained and is used when the old ioctls are called.
Quoted 5 lines
Quoted 3 lines
After talking to Christian, I understand that we have to set it in "one shot" as we can otherwise run into problems when getting/setting the TOD as we are looking at a moving target. This should go into the cover letter.
You mean in the patch description or in the git tag description?
Patch description. But just my opinion.
Quoted 11 lines
Quoted 5 lines
I need some more info regarding the architecture change.
For now, epoch was an unsigned value that is interpreted as an signed value.
It is always considered a signed value, (so the guest can be before or after the host) we just used u64 to make the wraparound defined (doing all the math in the unsigned realm as signed overflow is undefined)
Quoted 1 line
Quoted 4 lines
Quoted 2 lines
a) Is that still true with multiple epoch?
b) What is the format of the epoch index? Can it also be "negative"?The concatenation of both is considered a 72bit signed value.
Ah okay. So subtracting 1 from idx=0, epoch=0 will result in idx=0xff epoch=0xffffff
Quoted 10 lines
Quoted 7 lines
Why I am asking: I can see comparison made with the epoch:
arch/s390/kvm/vsie.c static void register_shadow_scb(struct kvm_vcpu *vcpu, · line 928
Quoted 3 lines
arch/s390/kvm/vsie.c +3
-0+if (test_kvm_facility (vcpu->kvm,139 )) { + scb_s->epdx += vcpu->kvm->arch.epdx; +if (scb_s->epoch < vcpu->kvm->arch.epoch)This checks for an overflow after the addition and
Quoted 5 lines
Quoted 1 line
arch/s390/kvm/vsie.c static void register_shadow_scb(struct kvm_vcpu *vcpu, · line 929
Quoted 1 line
arch/s390/kvm/vsie.c +1
-0+ scb_s->epdx +=1 ;corrects this. Since this is all unsigned math this is defined to wrap around and should work unless I missed something
I just had in mind:
-1 < 0
but 0xffffffff is clearly > 0x0
I might be mistaking, but we could get both an overflow or an underflow here.
But my brain has to consume new information first, so ignore the noise for now :)
Quoted 14 lines
Quoted 11 lines
Review
Quoted 2 lines
(quoted diff) +1
-0+ }or
arch/s390/kvm/kvm-s390.c static int kvm_s390_handle_requests(struct kvm_vcpu *vcpu) · line 2942
Quoted 2 lines
arch/s390/kvm/kvm-s390.c +2
-0+if (kvm->arch.epoch > gtod->tod) + kvm->arch.epdx -=1 ;If I remember correctly, such comparisons won't work correctly when having this signed/unsigned duality. But I might be wrong.
As far as I can see we have unsigned data types everywhere.
Signature · 3 lines
Thanks, David
Re: [PATCH 06/11] KVM: s390: Multiple Epoch Facility support
In reply to Christian BorntraegerQuoted 9 lines · Christian Borntraeger
Quoted 7 lines
arch/s390/kvm/vsie.c static void register_shadow_scb(struct kvm_vcpu *vcpu, · line 926
Quoted 2 lines
arch/s390/kvm/vsie.c +2
-0+ +if (test_kvm_facility (vcpu->kvm,139 )) {Although
scb_s->epdxwon't be interpreted withoutECD_MEF, this should be (so data is only copied if really enabled).if (
scb_s->ecd|ECD_MEF)As you said, it does not matter but it certainly is clearer. I can fix.
FWIW, It will be & and not |
so
if (scb_s->ecd & ECD_MEF)
PATCH 10/11 KVM: s390: sthyi: remove invalid guest write access
In reply to Christian BorntraegerFrom: Heiko Carstens <[email protected]>
handle_sthyi() always writes to guest memory if the sthyi function code is zero in order to fault in the page that later is written to.
However a function code of zero does not necessarily mean that a write to guest memory happens: if the KVM host is running as a second level guest under z/VM 6.2 the sthyi instruction is indicated to be available to the KVM host, however if the instruction is executed it will always return with a return code that indicates "unsupported function code".
In such a case handle_sthyi() must not write to guest memory. This means that the prior write access to fault in the guest page may result in invalid guest exceptions, and/or invalid data modification.
In order to be architecture compliant simply remove the write_guest() call.
Given that the guest assumed a write access anyway, this fix does not qualify for -stable. This just makes sure the sthyi handler is architecture compliant.
--- arch/s390/kvm/sthyi.c | 8 -------- 1 file changed, 8 deletions(-)
arch/s390/kvm/sthyi.c +0 -8
@@ -436,14 +436,6 @@ int handle_sthyi(struct kvm_vcpu *vcpu)if (addr & ~PAGE_MASK )return kvm_s390_inject_program_int (vcpu,PGM_SPECIFICATION ); -/* -* If the page has not yet been faulted in, we want to do that -* now and not after all the expensive calculations. -*/ - r =write_guest (vcpu, addr, reg2, &cc,1 ); -if (r) -return kvm_s390_inject_prog_cond (vcpu, r); - sctns = (void *)get_zeroed_page (GFP_KERNEL );if (!sctns)return -ENOMEM ;
Signature · 1 line
2.7.4
Re: [PATCH 10/11] KVM: s390: sthyi: remove invalid guest write access
Quoted 23 lines · On Mon, 28 Aug 2017 10:07:30 +0200 Christian Borntraeger…
From: Heiko Carstens <[email protected]>
handle_sthyi()always writes to guest memory if the sthyi function code is zero in order to fault in the page that later is written to.However a function code of zero does not necessarily mean that a write to guest memory happens: if the KVM host is running as a second level guest under z/VM 6.2 the sthyi instruction is indicated to be available to the KVM host, however if the instruction is executed it will always return with a return code that indicates "unsupported function code".
In such a case
handle_sthyi()must not write to guest memory. This means that the prior write access to fault in the guest page may result in invalid guest exceptions, and/or invalid data modification.In order to be architecture compliant simply remove the
write_guest()call.Given that the guest assumed a write access anyway, this fix does not qualify for -stable. This just makes sure the sthyi handler is architecture compliant.
Quoted 7 lines
Fixes 95ca2cb57985 ("KVM: s390: Add sthyi emulation")Reviewed-by Janosch Frank <[email protected]>Signed-off-by Heiko Carstens <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>--- arch/s390/kvm/sthyi.c | 8 -------- 1 file changed, 8 deletions(-)
PATCH 11/11 KVM: s390: expose no-DAT to guest and migration support
In reply to Christian BorntraegerFrom: Claudio Imbrenda <[email protected]>
The STFLE bit 147 indicates whether the ESSA no-DAT operation code is valid, the bit is not normally provided to the host; the host is instead provided with an SCLP bit that indicates whether guests can support the feature.
This patch:
* enables the STFLE bit in the guest if the corresponding SCLP bit is present in the host.
* adds support for migrating the no-DAT bit in the PGSTEs
* fixes the software interpretation of the ESSA instruction that is used when migrating, both for the new operation code and for the old "set stable", as per specifications.
--- arch/s390/include/asm/page-states.h | 2 +- arch/s390/kvm/kvm-s390.c | 8 ++++++-- arch/s390/kvm/priv.c | 6 +++++- arch/s390/mm/pgtable.c | 6 +++++- 4 files changed, 17 insertions(+), 5 deletions(-)
arch/s390/include/asm/page-states.h +1 -1
@@ -15,6 +15,6 @@#define ESSA_SET_STABLE_IF_RESIDENT 6#define ESSA_SET_STABLE_NODAT 7 -#define ESSA_MAX ESSA_SET_STABLE_IF_RESIDENT +#define ESSA_MAX ESSA_SET_STABLE_NODAT#endif
arch/s390/kvm/kvm-s390.c +6 -2
@@ -1574,7 +1574,7 @@ static int kvm_s390_get_cmma_bits(struct kvm *kvm,if (r <0 ) pgstev =0 ;/* save the value */ - res[i++] = (pgstev >>24 ) &0x3 ; + res[i++] = (pgstev >>24 ) &0x43 ;/* * if the next bit is too far away, stop. * if we reached the previous "next", find the next one
@@ -1652,7 +1652,7 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm, pgstev = bits[i]; pgstev = pgstev <<24 ; - mask &= _PGSTE_GPS_USAGE_MASK; + mask &= _PGSTE_GPS_USAGE_MASK | _PGSTE_GPS_NODAT;set_pgste_bits (kvm->mm, hva, mask, pgstev); }srcu_read_unlock (&kvm->srcu, srcu_idx);
@@ -1929,6 +1929,10 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)set_kvm_facility (kvm->arch.model.fac_mask,74 );set_kvm_facility (kvm->arch.model.fac_list,74 ); +if (MACHINE_HAS_TLB_GUEST ) { +set_kvm_facility (kvm->arch.model.fac_mask,147 ); +set_kvm_facility (kvm->arch.model.fac_list,147 ); + } kvm->arch.model.cpuid =kvm_s390_get_initial_cpuid (); kvm->arch.model.ibc = sclp.ibc &0x0fff ;
arch/s390/kvm/priv.c +5 -1
@@ -988,6 +988,8 @@ static inline int do_essa(struct kvm_vcpu *vcpu, const int orc)if (pgstev & _PGSTE_GPS_ZERO) res |=1 ; } +if (pgstev & _PGSTE_GPS_NODAT) + res |=0x20 ; vcpu->run->s.regs.gprs[r1] = res;/* * It is possible that all the normal 511 slots were full, in which case
@@ -1027,7 +1029,9 @@ static int handle_essa(struct kvm_vcpu *vcpu)return kvm_s390_inject_program_int (vcpu,PGM_PRIVILEGED_OP );/* Check for invalid operation request code */ orc = (vcpu->arch.sie_block->ipb &0xf0000000 ) >>28 ; -if (orc >ESSA_MAX ) +/* ORCs 0-6 are always valid */ +if (orc > (test_kvm_facility (vcpu->kvm,147 ) ?ESSA_SET_STABLE_NODAT + :ESSA_SET_STABLE_IF_RESIDENT ))return kvm_s390_inject_program_int (vcpu,PGM_SPECIFICATION );if (likely (!vcpu->kvm->arch.migration_state)) {
arch/s390/mm/pgtable.c +5 -1
@@ -919,7 +919,7 @@ int pgste_perform_essa(struct mm_struct *mm, unsigned long hva, int orc,case ESSA_GET_STATE :break ;case ESSA_SET_STABLE : - pgstev &= ~_PGSTE_GPS_USAGE_MASK; + pgstev &= ~(_PGSTE_GPS_USAGE_MASK | _PGSTE_GPS_NODAT); pgstev |= _PGSTE_GPS_USAGE_STABLE;break ;case ESSA_SET_UNUSED :
@@ -965,6 +965,10 @@ int pgste_perform_essa(struct mm_struct *mm, unsigned long hva, int orc, pgstev |= _PGSTE_GPS_USAGE_STABLE; }break ; +case ESSA_SET_STABLE_NODAT : + pgstev &= ~_PGSTE_GPS_USAGE_MASK; + pgstev |= _PGSTE_GPS_USAGE_STABLE | _PGSTE_GPS_NODAT; +break ;default :/* we should never get here! */ break ;
Signature · 1 line
2.7.4
Re: [PATCH 11/11] KVM: s390: expose no-DAT to guest and migration support
Quoted 19 lines · On Mon, 28 Aug 2017 10:07:31 +0200 Christian Borntraeger…
From: Claudio Imbrenda <[email protected]>
The STFLE bit 147 indicates whether the ESSA no-DAT operation code is valid, the bit is not normally provided to the host; the host is instead provided with an SCLP bit that indicates whether guests can support the feature.
This patch:
* enables the STFLE bit in the guest if the corresponding SCLP bit is present in the host.
* adds support for migrating the no-DAT bit in the PGSTEs
* fixes the software interpretation of the ESSA instruction that is used when migrating, both for the new operation code and for the old "set stable", as per specifications.Signed-off-by Claudio Imbrenda <[email protected]>Reviewed-by Christian Borntraeger <[email protected]>Signed-off-by Claudio Imbrenda <[email protected]>Signed-off-by Christian Borntraeger <[email protected]>
Quoted 6 lines
--- arch/s390/include/asm/page-states.h | 2 +- arch/s390/kvm/kvm-s390.c | 8 ++++++-- arch/s390/kvm/priv.c | 6 +++++- arch/s390/mm/pgtable.c | 6 +++++- 4 files changed, 17 insertions(+), 5 deletions(-)
This is a bit hard to review without the previous patches (I had to hunt down MACHINE_HAS_TLB_GUEST, for example), and it seems much if not all of this is not externally documented... but it seems consistent and reasonable, so
Quoted 4 lines · On Mon, 28 Aug 2017 10:07:27 +0200 Christian Borntraeger…
This is what I have pending for 4.14 in
git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.gitkvm-s390-next-4.14-1It contains 2 merges (on topic branch from Martin for the tlb flushing
Have those been posted anywhere? Might have made looking at the feature easier to post them as well so you do not have to track down the branch.
Quoted 34 lines
and a back-merge from the s390 fixes for master to avoid merge conflicts with followup fixes).
"New" patches are marked (x) below. (patches 5,6,10,11). Pull request will come later this week.
----------------------------------------------------------------
KVM: s390: Fixes and features for 4.14- merge of topic branch tlb-flushing from the s390 tree to get the no-dat base features
- wire up the no-dat enhancements in KVM
- multiple epoch facility (z14 feature)
- Configuration z/Architecture Mode fixup
- merge of kvm/master to avoid conflicts with additional sthyi fixes
- more sthyi fixes----------------------------------------------------------------
Christian Borntraeger (3):
Merge branch 'tlb-flushing' ofgit://git.kernel.org/.../s390/linuxinto kernelorgnext
KVM: s390: take srcu lock when getting/setting storage keys
Merge tag 'kvm-s390-master-4.13-2' into kvms390/nextClaudio Imbrenda (1):
(x) KVM: s390: expose no-DAT to guest and migration supportCollin L. Walling (1):
(x) KVM: s390: Multiple Epoch Facility supportHeiko Carstens (3):
KVM: s390: sthyi: fix sthyi inline assembly
KVM: s390: sthyi: fix specification exception detection
(x) KVM: s390: sthyi: remove invalid guest write access
Quoted 8 lines
Jason J. Herne (1):
(x) KVM: s390: Support Configuration z/Architecture ModeMartin Schwidefsky (4):
s390/mm: tag normal pages vs pages used in page tables s390/mm: add no-dat TLB flush optimization s390/mm: add guest ASCE TLB flush optimization s390/mm,kvm: use nodat PGSTE tag to optimize TLB flushing
I have not reviewed Martin's patches (not surprising, I guess), but the series looks fine.