<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/arch/s390/kvm/pv.c, branch linux-6.2.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.2.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.2.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2023-05-17T11:58:50Z</updated>
<entry>
<title>KVM: s390: pv: fix asynchronous teardown for small VMs</title>
<updated>2023-05-17T11:58:50Z</updated>
<author>
<name>Claudio Imbrenda</name>
<email>imbrenda@linux.ibm.com</email>
</author>
<published>2023-04-21T08:50:36Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=83a320c038c6571e7e4c6039bbd9e065acc8d12c'/>
<id>urn:sha1:83a320c038c6571e7e4c6039bbd9e065acc8d12c</id>
<content type='text'>
[ Upstream commit 292a7d6fca33df70ca4b8e9b0d0e74adf87582dc ]

On machines without the Destroy Secure Configuration Fast UVC, the
topmost level of page tables is set aside and freed asynchronously
as last step of the asynchronous teardown.

Each gmap has a host_to_guest radix tree mapping host (userspace)
addresses (with 1M granularity) to gmap segment table entries (pmds).

If a guest is smaller than 2GB, the topmost level of page tables is the
segment table (i.e. there are only 2 levels). Replacing it means that
the pointers in the host_to_guest mapping would become stale and cause
all kinds of nasty issues.

This patch fixes the issue by disallowing asynchronous teardown for
guests with only 2 levels of page tables. Userspace should (and already
does) try using the normal destroy if the asynchronous one fails.

Update s390_replace_asce so it refuses to replace segment type ASCEs.
This is still needed in case the normal destroy VM fails.

Fixes: fb491d5500a7 ("KVM: s390: pv: asynchronous destroy for reboot")
Reviewed-by: Marc Hartmayer &lt;mhartmay@linux.ibm.com&gt;
Reviewed-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
Signed-off-by: Claudio Imbrenda &lt;imbrenda@linux.ibm.com&gt;
Message-Id: &lt;20230421085036.52511-2-imbrenda@linux.ibm.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>KVM: s390: pv: support for Destroy fast UVC</title>
<updated>2022-11-23T09:06:50Z</updated>
<author>
<name>Claudio Imbrenda</name>
<email>imbrenda@linux.ibm.com</email>
</author>
<published>2022-11-11T17:06:31Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=f7866f582b1c9d80d1a3bd0953170185668c52ca'/>
<id>urn:sha1:f7866f582b1c9d80d1a3bd0953170185668c52ca</id>
<content type='text'>
Add support for the Destroy Secure Configuration Fast Ultravisor call,
and take advantage of it for asynchronous destroy.

When supported, the protected guest is destroyed immediately using the
new UVC, leaving only the memory to be cleaned up asynchronously.

Signed-off-by: Claudio Imbrenda &lt;imbrenda@linux.ibm.com&gt;
Reviewed-by: Nico Boehr &lt;nrb@linux.ibm.com&gt;
Reviewed-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
Reviewed-by: Steffen Eiden &lt;seiden@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20221111170632.77622-6-imbrenda@linux.ibm.com
Message-Id: &lt;20221111170632.77622-6-imbrenda@linux.ibm.com&gt;
Signed-off-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
</content>
</entry>
<entry>
<title>KVM: s390: pv: asynchronous destroy for reboot</title>
<updated>2022-11-23T09:06:50Z</updated>
<author>
<name>Claudio Imbrenda</name>
<email>imbrenda@linux.ibm.com</email>
</author>
<published>2022-11-11T17:06:27Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=fb491d5500a7ca551e49bc32d9b19d226023f68d'/>
<id>urn:sha1:fb491d5500a7ca551e49bc32d9b19d226023f68d</id>
<content type='text'>
Until now, destroying a protected guest was an entirely synchronous
operation that could potentially take a very long time, depending on
the size of the guest, due to the time needed to clean up the address
space from protected pages.

This patch implements an asynchronous destroy mechanism, that allows a
protected guest to reboot significantly faster than previously.

This is achieved by clearing the pages of the old guest in background.
In case of reboot, the new guest will be able to run in the same
address space almost immediately.

The old protected guest is then only destroyed when all of its memory
has been destroyed or otherwise made non protected.

Two new PV commands are added for the KVM_S390_PV_COMMAND ioctl:

KVM_PV_ASYNC_CLEANUP_PREPARE: set aside the current protected VM for
later asynchronous teardown. The current KVM VM will then continue
immediately as non-protected. If a protected VM had already been
set aside for asynchronous teardown, but without starting the teardown
process, this call will fail. There can be at most one VM set aside at
any time. Once it is set aside, the protected VM only exists in the
context of the Ultravisor, it is not associated with the KVM VM
anymore. Its protected CPUs have already been destroyed, but not its
memory. This command can be issued again immediately after starting
KVM_PV_ASYNC_CLEANUP_PERFORM, without having to wait for completion.

KVM_PV_ASYNC_CLEANUP_PERFORM: tears down the protected VM previously
set aside using KVM_PV_ASYNC_CLEANUP_PREPARE. Ideally the
KVM_PV_ASYNC_CLEANUP_PERFORM PV command should be issued by userspace
from a separate thread. If a fatal signal is received (or if the
process terminates naturally), the command will terminate immediately
without completing. All protected VMs whose teardown was interrupted
will be put in the need_cleanup list. The rest of the normal KVM
teardown process will take care of properly cleaning up all remaining
protected VMs, including the ones on the need_cleanup list.

Signed-off-by: Claudio Imbrenda &lt;imbrenda@linux.ibm.com&gt;
Reviewed-by: Nico Boehr &lt;nrb@linux.ibm.com&gt;
Reviewed-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
Reviewed-by: Steffen Eiden &lt;seiden@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20221111170632.77622-2-imbrenda@linux.ibm.com
Message-Id: &lt;20221111170632.77622-2-imbrenda@linux.ibm.com&gt;
Signed-off-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
</content>
</entry>
<entry>
<title>KVM: s390: pv: sort out physical vs virtual pointers usage</title>
<updated>2022-10-26T12:27:41Z</updated>
<author>
<name>Nico Boehr</name>
<email>nrb@linux.ibm.com</email>
</author>
<published>2022-10-20T14:31:59Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=4435b79a366495a5cb43b792d9e7d69d489428cd'/>
<id>urn:sha1:4435b79a366495a5cb43b792d9e7d69d489428cd</id>
<content type='text'>
Fix virtual vs physical address confusion (which currently are the same).

Signed-off-by: Nico Boehr &lt;nrb@linux.ibm.com&gt;
Reviewed-by: Claudio Imbrenda &lt;imbrenda@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20221020143159.294605-6-nrb@linux.ibm.com
Message-Id: &lt;20221020143159.294605-6-nrb@linux.ibm.com&gt;
Signed-off-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
</content>
</entry>
<entry>
<title>KVM: s390: sida: sort out physical vs virtual pointers usage</title>
<updated>2022-10-26T12:27:41Z</updated>
<author>
<name>Nico Boehr</name>
<email>nrb@linux.ibm.com</email>
</author>
<published>2022-10-20T14:31:58Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=b99f4512197acc10f63b5fb462c088c2f62b5120'/>
<id>urn:sha1:b99f4512197acc10f63b5fb462c088c2f62b5120</id>
<content type='text'>
All callers of the sida_origin() macro actually expected a virtual
address, so rename it to sida_addr() and hand out a virtual address.

At some places, the macro wasn't used, potentially creating problems
if the sida size ever becomes nonzero (not currently the case), so let's
start using it everywhere now while at it.

Signed-off-by: Nico Boehr &lt;nrb@linux.ibm.com&gt;
Reviewed-by: Claudio Imbrenda &lt;imbrenda@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20221020143159.294605-5-nrb@linux.ibm.com
Message-Id: &lt;20221020143159.294605-5-nrb@linux.ibm.com&gt;
Signed-off-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
</content>
</entry>
<entry>
<title>KVM: s390: pv: destroy the configuration before its memory</title>
<updated>2022-07-19T12:06:56Z</updated>
<author>
<name>Claudio Imbrenda</name>
<email>imbrenda@linux.ibm.com</email>
</author>
<published>2022-06-28T13:56:13Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=7746f735f55205176a447e737fe15a5ba7a4d2d4'/>
<id>urn:sha1:7746f735f55205176a447e737fe15a5ba7a4d2d4</id>
<content type='text'>
Move the Destroy Secure Configuration UVC before the loop to destroy
the memory. If the protected VM has memory, it will be cleaned up and
made accessible by the Destroy Secure Configuration UVC. The struct
page for the relevant pages will still have the protected bit set, so
the loop is still needed to clean that up.

Switching the order of those two operations does not change the
outcome, but it is significantly faster.

Signed-off-by: Claudio Imbrenda &lt;imbrenda@linux.ibm.com&gt;
Reviewed-by: Nico Boehr &lt;nrb@linux.ibm.com&gt;
Reviewed-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20220628135619.32410-13-imbrenda@linux.ibm.com
Message-Id: &lt;20220628135619.32410-13-imbrenda@linux.ibm.com&gt;
Signed-off-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
</content>
</entry>
<entry>
<title>KVM: s390: pv: refactoring of kvm_s390_pv_deinit_vm</title>
<updated>2022-07-19T12:06:56Z</updated>
<author>
<name>Claudio Imbrenda</name>
<email>imbrenda@linux.ibm.com</email>
</author>
<published>2022-06-28T13:56:12Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=da15fbc646f377ebfe992c13053b93783fea0db2'/>
<id>urn:sha1:da15fbc646f377ebfe992c13053b93783fea0db2</id>
<content type='text'>
Refactor kvm_s390_pv_deinit_vm to improve readability and simplify the
improvements that are coming in subsequent patches.

No functional change intended.

Signed-off-by: Claudio Imbrenda &lt;imbrenda@linux.ibm.com&gt;
Reviewed-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20220628135619.32410-12-imbrenda@linux.ibm.com
Message-Id: &lt;20220628135619.32410-12-imbrenda@linux.ibm.com&gt;
[frankja@linux.ibm.com: Dropped commit message line regarding review]
Signed-off-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
</content>
</entry>
<entry>
<title>KVM: s390: pv: add mmu_notifier</title>
<updated>2022-07-19T12:05:57Z</updated>
<author>
<name>Claudio Imbrenda</name>
<email>imbrenda@linux.ibm.com</email>
</author>
<published>2022-06-28T13:56:10Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=ca2fd0609b5ddd15fe57c917a41508a7a9fc17e1'/>
<id>urn:sha1:ca2fd0609b5ddd15fe57c917a41508a7a9fc17e1</id>
<content type='text'>
Add an mmu_notifier for protected VMs. The callback function is
triggered when the mm is torn down, and will attempt to convert all
protected vCPUs to non-protected. This allows the mm teardown to use
the destroy page UVC instead of export.

Also make KVM select CONFIG_MMU_NOTIFIER, needed to use mmu_notifiers.

Signed-off-by: Claudio Imbrenda &lt;imbrenda@linux.ibm.com&gt;
Acked-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
Reviewed-by: Nico Boehr &lt;nrb@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20220628135619.32410-10-imbrenda@linux.ibm.com
Message-Id: &lt;20220628135619.32410-10-imbrenda@linux.ibm.com&gt;
[frankja@linux.ibm.com: Conflict resolution for mmu_notifier.h include
and struct kvm_s390_pv]
Signed-off-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
</content>
</entry>
<entry>
<title>KVM: s390: pv: clear the state without memset</title>
<updated>2022-07-13T14:42:11Z</updated>
<author>
<name>Claudio Imbrenda</name>
<email>imbrenda@linux.ibm.com</email>
</author>
<published>2022-06-28T13:56:08Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=e40df9efd68a621734fe03efc68b8f3e8da47cf8'/>
<id>urn:sha1:e40df9efd68a621734fe03efc68b8f3e8da47cf8</id>
<content type='text'>
Do not use memset to clean the whole struct kvm_s390_pv; instead,
explicitly clear the fields that need to be cleared.

Upcoming patches will introduce new fields in the struct kvm_s390_pv
that will not need to be cleared.

Signed-off-by: Claudio Imbrenda &lt;imbrenda@linux.ibm.com&gt;
Reviewed-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20220628135619.32410-8-imbrenda@linux.ibm.com
Message-Id: &lt;20220628135619.32410-8-imbrenda@linux.ibm.com&gt;
Signed-off-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
</content>
</entry>
<entry>
<title>KVM: s390: pv: usage counter instead of flag</title>
<updated>2022-07-13T14:42:11Z</updated>
<author>
<name>Claudio Imbrenda</name>
<email>imbrenda@linux.ibm.com</email>
</author>
<published>2022-06-28T13:56:06Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=07fbdf7f934795a9e1728fcb3bdce6e0d8039e0c'/>
<id>urn:sha1:07fbdf7f934795a9e1728fcb3bdce6e0d8039e0c</id>
<content type='text'>
Use the new protected_count field as a counter instead of the old
is_protected flag. This will be used in upcoming patches.

Increment the counter when a secure configuration is created, and
decrement it when it is destroyed. Previously the flag was set when the
set secure parameters UVC was performed.

Signed-off-by: Claudio Imbrenda &lt;imbrenda@linux.ibm.com&gt;
Acked-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20220628135619.32410-6-imbrenda@linux.ibm.com
Message-Id: &lt;20220628135619.32410-6-imbrenda@linux.ibm.com&gt;
Signed-off-by: Janosch Frank &lt;frankja@linux.ibm.com&gt;
</content>
</entry>
</feed>
