* [GIT PULL 0/3] KVM: s390x: changes for v6.11
@ 2024-07-11 11:00 Janosch Frank
2024-07-11 11:00 ` [GIT PULL 1/3] KVM: s390: remove useless include Janosch Frank
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Janosch Frank @ 2024-07-11 11:00 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda
A couple of minor changes/fixes for 6.11 which aren't time critical.
Christoph's ucontrol selftests are on the list but might need another
round or two so they are not included but will be in 6.12.
Please pull:
The following changes since commit c3f38fa61af77b49866b006939479069cd451173:
Linux 6.10-rc2 (2024-06-02 15:44:56 -0700)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-next-6.11-1
for you to fetch changes up to 7816e58967d0e6cadce05c8540b47ed027dc2499:
kvm: s390: Reject memory region operations for ucontrol VMs (2024-07-04 09:07:24 +0200)
----------------------------------------------------------------
Assortment of tiny fixes which are not time critical:
- Rejecting memory region operations for ucontrol mode VMs
- Rewind the PSW on host intercepts for VSIE
- Remove unneeded include
----------------------------------------------------------------
Christoph Schlameuss (1):
kvm: s390: Reject memory region operations for ucontrol VMs
Claudio Imbrenda (1):
KVM: s390: remove useless include
Eric Farman (1):
KVM: s390: vsie: retry SIE instruction on host intercepts
Documentation/virt/kvm/api.rst | 12 ++++++++++++
arch/s390/include/asm/kvm_host.h | 1 -
arch/s390/kvm/kvm-s390.c | 3 +++
arch/s390/kvm/vsie.c | 24 ++++++++++++++++++++----
4 files changed, 35 insertions(+), 5 deletions(-)
--
2.45.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [GIT PULL 1/3] KVM: s390: remove useless include
2024-07-11 11:00 [GIT PULL 0/3] KVM: s390x: changes for v6.11 Janosch Frank
@ 2024-07-11 11:00 ` Janosch Frank
2024-07-11 11:00 ` [GIT PULL 2/3] KVM: s390: vsie: retry SIE instruction on host intercepts Janosch Frank
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Janosch Frank @ 2024-07-11 11:00 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda
From: Claudio Imbrenda <imbrenda@linux.ibm.com>
arch/s390/include/asm/kvm_host.h includes linux/kvm_host.h, but
linux/kvm_host.h includes asm/kvm_host.h .
It turns out that arch/s390/include/asm/kvm_host.h only needs
linux/kvm_types.h, which it already includes.
Stop including linux/kvm_host.h from arch/s390/include/asm/kvm_host.h .
Due to the #ifdef guards, the code works as it is today, but it's ugly
and it will get in the way of future patches.
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Link: https://lore.kernel.org/r/20240702155606.71398-1-imbrenda@linux.ibm.com
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Message-ID: <20240702155606.71398-1-imbrenda@linux.ibm.com>
---
arch/s390/include/asm/kvm_host.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index 95990461888f..736cc88f497d 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -15,7 +15,6 @@
#include <linux/hrtimer.h>
#include <linux/interrupt.h>
#include <linux/kvm_types.h>
-#include <linux/kvm_host.h>
#include <linux/kvm.h>
#include <linux/seqlock.h>
#include <linux/module.h>
--
2.45.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [GIT PULL 2/3] KVM: s390: vsie: retry SIE instruction on host intercepts
2024-07-11 11:00 [GIT PULL 0/3] KVM: s390x: changes for v6.11 Janosch Frank
2024-07-11 11:00 ` [GIT PULL 1/3] KVM: s390: remove useless include Janosch Frank
@ 2024-07-11 11:00 ` Janosch Frank
2024-07-11 11:00 ` [GIT PULL 3/3] kvm: s390: Reject memory region operations for ucontrol VMs Janosch Frank
2024-07-12 15:23 ` [GIT PULL 0/3] KVM: s390x: changes for v6.11 Paolo Bonzini
3 siblings, 0 replies; 5+ messages in thread
From: Janosch Frank @ 2024-07-11 11:00 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda
From: Eric Farman <farman@linux.ibm.com>
It's possible that SIE exits for work that the host needs to perform
rather than something that is intended for the guest.
A Linux guest will ignore this intercept code since there is nothing
for it to do, but a more robust solution would rewind the PSW back to
the SIE instruction. This will transparently resume the guest once
the host completes its work, without the guest needing to process
what is effectively a NOP and re-issue SIE itself.
Signed-off-by: Eric Farman <farman@linux.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Link: https://lore.kernel.org/r/20240301204342.3217540-1-farman@linux.ibm.com
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Message-ID: <20240301204342.3217540-1-farman@linux.ibm.com>
---
arch/s390/kvm/vsie.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
index c9ecae830634..54deafd0d698 100644
--- a/arch/s390/kvm/vsie.c
+++ b/arch/s390/kvm/vsie.c
@@ -1304,10 +1304,24 @@ static int vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
if (rc == -EAGAIN)
rc = 0;
- if (rc || scb_s->icptcode || signal_pending(current) ||
- kvm_s390_vcpu_has_irq(vcpu, 0) ||
- kvm_s390_vcpu_sie_inhibited(vcpu))
+
+ /*
+ * Exit the loop if the guest needs to process the intercept
+ */
+ if (rc || scb_s->icptcode)
break;
+
+ /*
+ * Exit the loop if the host needs to process an intercept,
+ * but rewind the PSW to re-enter SIE once that's completed
+ * instead of passing a "no action" intercept to the guest.
+ */
+ if (signal_pending(current) ||
+ kvm_s390_vcpu_has_irq(vcpu, 0) ||
+ kvm_s390_vcpu_sie_inhibited(vcpu)) {
+ kvm_s390_rewind_psw(vcpu, 4);
+ break;
+ }
cond_resched();
}
@@ -1426,8 +1440,10 @@ int kvm_s390_handle_vsie(struct kvm_vcpu *vcpu)
return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
if (signal_pending(current) || kvm_s390_vcpu_has_irq(vcpu, 0) ||
- kvm_s390_vcpu_sie_inhibited(vcpu))
+ kvm_s390_vcpu_sie_inhibited(vcpu)) {
+ kvm_s390_rewind_psw(vcpu, 4);
return 0;
+ }
vsie_page = get_vsie_page(vcpu->kvm, scb_addr);
if (IS_ERR(vsie_page))
--
2.45.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [GIT PULL 3/3] kvm: s390: Reject memory region operations for ucontrol VMs
2024-07-11 11:00 [GIT PULL 0/3] KVM: s390x: changes for v6.11 Janosch Frank
2024-07-11 11:00 ` [GIT PULL 1/3] KVM: s390: remove useless include Janosch Frank
2024-07-11 11:00 ` [GIT PULL 2/3] KVM: s390: vsie: retry SIE instruction on host intercepts Janosch Frank
@ 2024-07-11 11:00 ` Janosch Frank
2024-07-12 15:23 ` [GIT PULL 0/3] KVM: s390x: changes for v6.11 Paolo Bonzini
3 siblings, 0 replies; 5+ messages in thread
From: Janosch Frank @ 2024-07-11 11:00 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda
From: Christoph Schlameuss <schlameuss@linux.ibm.com>
This change rejects the KVM_SET_USER_MEMORY_REGION and
KVM_SET_USER_MEMORY_REGION2 ioctls when called on a ucontrol VM.
This is necessary since ucontrol VMs have kvm->arch.gmap set to 0 and
would thus result in a null pointer dereference further in.
Memory management needs to be performed in userspace and using the
ioctls KVM_S390_UCAS_MAP and KVM_S390_UCAS_UNMAP.
Also improve s390 specific documentation for KVM_SET_USER_MEMORY_REGION
and KVM_SET_USER_MEMORY_REGION2.
Signed-off-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
Fixes: 27e0393f15fc ("KVM: s390: ucontrol: per vcpu address spaces")
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20240624095902.29375-1-schlameuss@linux.ibm.com
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
[frankja@linux.ibm.com: commit message spelling fix, subject prefix fix]
Message-ID: <20240624095902.29375-1-schlameuss@linux.ibm.com>
---
Documentation/virt/kvm/api.rst | 12 ++++++++++++
arch/s390/kvm/kvm-s390.c | 3 +++
2 files changed, 15 insertions(+)
diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
index a71d91978d9e..eec8df1dde06 100644
--- a/Documentation/virt/kvm/api.rst
+++ b/Documentation/virt/kvm/api.rst
@@ -1403,6 +1403,12 @@ Instead, an abort (data abort if the cause of the page-table update
was a load or a store, instruction abort if it was an instruction
fetch) is injected in the guest.
+S390:
+^^^^^
+
+Returns -EINVAL if the VM has the KVM_VM_S390_UCONTROL flag set.
+Returns -EINVAL if called on a protected VM.
+
4.36 KVM_SET_TSS_ADDR
---------------------
@@ -6273,6 +6279,12 @@ state. At VM creation time, all memory is shared, i.e. the PRIVATE attribute
is '0' for all gfns. Userspace can control whether memory is shared/private by
toggling KVM_MEMORY_ATTRIBUTE_PRIVATE via KVM_SET_MEMORY_ATTRIBUTES as needed.
+S390:
+^^^^^
+
+Returns -EINVAL if the VM has the KVM_VM_S390_UCONTROL flag set.
+Returns -EINVAL if called on a protected VM.
+
4.141 KVM_SET_MEMORY_ATTRIBUTES
-------------------------------
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 82e9631cd9ef..854d0d1410be 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -5748,6 +5748,9 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
{
gpa_t size;
+ if (kvm_is_ucontrol(kvm))
+ return -EINVAL;
+
/* When we are protected, we should not change the memory slots */
if (kvm_s390_pv_get_handle(kvm))
return -EINVAL;
--
2.45.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [GIT PULL 0/3] KVM: s390x: changes for v6.11
2024-07-11 11:00 [GIT PULL 0/3] KVM: s390x: changes for v6.11 Janosch Frank
` (2 preceding siblings ...)
2024-07-11 11:00 ` [GIT PULL 3/3] kvm: s390: Reject memory region operations for ucontrol VMs Janosch Frank
@ 2024-07-12 15:23 ` Paolo Bonzini
3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2024-07-12 15:23 UTC (permalink / raw)
To: Janosch Frank; +Cc: kvm, david, borntraeger, cohuck, linux-s390, imbrenda
On Thu, Jul 11, 2024 at 1:08 PM Janosch Frank <frankja@linux.ibm.com> wrote:
>
> A couple of minor changes/fixes for 6.11 which aren't time critical.
>
> Christoph's ucontrol selftests are on the list but might need another
> round or two so they are not included but will be in 6.12.
>
> Please pull:
>
> The following changes since commit c3f38fa61af77b49866b006939479069cd451173:
>
> Linux 6.10-rc2 (2024-06-02 15:44:56 -0700)
> are available in the Git repository at:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-next-6.11-1
>
> for you to fetch changes up to 7816e58967d0e6cadce05c8540b47ed027dc2499:
>
> kvm: s390: Reject memory region operations for ucontrol VMs (2024-07-04 09:07:24 +0200)
>
> ----------------------------------------------------------------
> Assortment of tiny fixes which are not time critical:
> - Rejecting memory region operations for ucontrol mode VMs
> - Rewind the PSW on host intercepts for VSIE
> - Remove unneeded include
> --------------------------------------
Done, thanks.
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-07-12 15:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-11 11:00 [GIT PULL 0/3] KVM: s390x: changes for v6.11 Janosch Frank
2024-07-11 11:00 ` [GIT PULL 1/3] KVM: s390: remove useless include Janosch Frank
2024-07-11 11:00 ` [GIT PULL 2/3] KVM: s390: vsie: retry SIE instruction on host intercepts Janosch Frank
2024-07-11 11:00 ` [GIT PULL 3/3] kvm: s390: Reject memory region operations for ucontrol VMs Janosch Frank
2024-07-12 15:23 ` [GIT PULL 0/3] KVM: s390x: changes for v6.11 Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox