Re: [PATCH v2 14/26] KVM: x86/mmu: Decouple rmap_add() and link_shadow_page() from kvm_vcpu

2022-03-15 Thread Peter Xu
On Fri, Mar 11, 2022 at 12:25:16AM +, David Matlack wrote: > Allow adding new entries to the rmap and linking shadow pages without a > struct kvm_vcpu pointer by moving the implementation of rmap_add() and > link_shadow_page() into inner helper functions. > > No functional change intended. >

Re: [PATCH v2 15/26] KVM: x86/mmu: Update page stats in __rmap_add()

2022-03-15 Thread Peter Xu
On Fri, Mar 11, 2022 at 12:25:17AM +, David Matlack wrote: > Update the page stats in __rmap_add() rather than at the call site. This > will avoid having to manually update page stats when splitting huge > pages in a subsequent commit. > > No functional change intended. > > Reviewed-by: Ben

Re: [PATCH v2 05/26] KVM: x86/mmu: Rename shadow MMU functions that deal with shadow pages

2022-03-15 Thread Peter Xu
On Fri, Mar 11, 2022 at 12:25:07AM +, David Matlack wrote: > Rename 3 functions: > > kvm_mmu_get_page() -> kvm_mmu_get_shadow_page() > kvm_mmu_alloc_page() -> kvm_mmu_alloc_shadow_page() > kvm_mmu_free_page() -> kvm_mmu_free_shadow_page() > > This change makes it clear that these

Re: [PATCH v2 08/26] KVM: x86/mmu: Link spt to sp during allocation

2022-03-15 Thread Peter Xu
On Fri, Mar 11, 2022 at 12:25:10AM +, David Matlack wrote: > Link the shadow page table to the sp (via set_page_private()) during > allocation rather than initialization. This is a more logical place to > do it because allocation time is also where we do the reverse link > (setting sp->spt). >

Re: [PATCH v2 01/26] KVM: x86/mmu: Optimize MMU page cache lookup for all direct SPs

2022-03-15 Thread Peter Xu
On Fri, Mar 11, 2022 at 12:25:03AM +, David Matlack wrote: > Commit fb58a9c345f6 ("KVM: x86/mmu: Optimize MMU page cache lookup for > fully direct MMUs") skipped the unsync checks and write flood clearing > for full direct MMUs. We can extend this further and skip the checks for > all direct

Re: [PATCH v2 04/26] KVM: x86/mmu: Decompose kvm_mmu_get_page() into separate functions

2022-03-15 Thread Peter Xu
On Fri, Mar 11, 2022 at 12:25:06AM +, David Matlack wrote: > Decompose kvm_mmu_get_page() into separate helper functions to increase > readability and prepare for allocating shadow pages without a vcpu > pointer. > > Specifically, pull the guts of kvm_mmu_get_page() into 3 helper > functions:

Re: [PATCH v2 09/26] KVM: x86/mmu: Move huge page split sp allocation code to mmu.c

2022-03-15 Thread Peter Xu
On Fri, Mar 11, 2022 at 12:25:11AM +, David Matlack wrote: > Move the code that allocates a new shadow page for splitting huge pages > into mmu.c. Currently this code is only used by the TDP MMU but it will > be reused in subsequent commits to also split huge pages mapped by the > shadow MMU.

[PATCH kvm-unit-tests] arch-run: Introduce QEMU_ARCH

2022-03-15 Thread Andrew Jones
Add QEMU_ARCH, which allows run scripts to specify which architecture of QEMU should be used. This is useful on AArch64 when running with KVM and running AArch32 tests. For those tests, we *don't* want to select the 'arm' QEMU, as would have been selected, but rather the $HOST ('aarch64') QEMU.

Re: [PATCH v2 06/26] KVM: x86/mmu: Pass memslot to kvm_mmu_new_shadow_page()

2022-03-15 Thread Peter Xu
On Fri, Mar 11, 2022 at 12:25:08AM +, David Matlack wrote: > Passing the memslot to kvm_mmu_new_shadow_page() avoids the need for the > vCPU pointer when write-protecting indirect 4k shadow pages. This moves > us closer to being able to create new shadow pages during VM ioctls for > eager page

Re: [PATCH v2 10/26] KVM: x86/mmu: Use common code to free kvm_mmu_page structs

2022-03-15 Thread Peter Xu
On Fri, Mar 11, 2022 at 12:25:12AM +, David Matlack wrote: > static void tdp_mmu_free_sp(struct kvm_mmu_page *sp) > { > - free_page((unsigned long)sp->spt); > - kmem_cache_free(mmu_page_header_cache, sp); > + kvm_mmu_free_shadow_page(sp); > } Perhaps tdp_mmu_free_sp() can be

Re: [PATCH v2 02/26] KVM: x86/mmu: Use a bool for direct

2022-03-15 Thread Peter Xu
On Fri, Mar 11, 2022 at 12:25:04AM +, David Matlack wrote: > The parameter "direct" can either be true or false, and all of the > callers pass in a bool variable or true/false literal, so just use the > type bool. > > No functional change intended. > > Signed-off-by: David Matlack If we

Re: [PATCH v2 03/26] KVM: x86/mmu: Derive shadow MMU page role from parent

2022-03-15 Thread Peter Xu
On Fri, Mar 11, 2022 at 12:25:05AM +, David Matlack wrote: > Instead of computing the shadow page role from scratch for every new > page, we can derive most of the information from the parent shadow page. > This avoids redundant calculations and reduces the number of parameters > to

Re: [PATCH v2 07/26] KVM: x86/mmu: Separate shadow MMU sp allocation from initialization

2022-03-15 Thread Peter Xu
On Fri, Mar 11, 2022 at 12:25:09AM +, David Matlack wrote: > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > index 519910938478..e866e05c4ba5 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -1716,16 +1716,9 @@ static struct kvm_mmu_page >

Re: [PATCH v2 11/26] KVM: x86/mmu: Use common code to allocate kvm_mmu_page structs from vCPU caches

2022-03-15 Thread Peter Xu
On Fri, Mar 11, 2022 at 12:25:13AM +, David Matlack wrote: > static struct kvm_mmu_page *tdp_mmu_alloc_sp(struct kvm_vcpu *vcpu) > { > - struct kvm_mmu_page *sp; > - > - sp = kvm_mmu_memory_cache_alloc(>arch.mmu_page_header_cache); > - sp->spt =

[kvm-unit-tests] Adding the QCBOR library to kvm-unit-tests

2022-03-15 Thread Alexandru Elisei
Hi, Arm is planning to upstream tests that are being developed as part of the Confidential Compute Architecture [1]. Some of the tests target the attestation part of creating and managing a confidential compute VM, which requires the manipulation of messages in the Concise Binary Object

Re: [kvm-unit-tests] Adding the QCBOR library to kvm-unit-tests

2022-03-15 Thread Thomas Huth
On 15/03/2022 14.33, Alexandru Elisei wrote: Hi, Arm is planning to upstream tests that are being developed as part of the Confidential Compute Architecture [1]. Some of the tests target the attestation part of creating and managing a confidential compute VM, which requires the manipulation of

Re: [PATCH kvm-unit-tests] arch-run: Introduce QEMU_ARCH

2022-03-15 Thread Alexandru Elisei
Hi, On Tue, Mar 15, 2022 at 09:01:52AM +0100, Andrew Jones wrote: > Add QEMU_ARCH, which allows run scripts to specify which architecture > of QEMU should be used. This is useful on AArch64 when running with > KVM and running AArch32 tests. For those tests, we *don't* want to > select the 'arm'

Re: [kvm-unit-tests] Adding the QCBOR library to kvm-unit-tests

2022-03-15 Thread Andrew Jones
On Tue, Mar 15, 2022 at 01:33:57PM +, Alexandru Elisei wrote: > Hi, > > Arm is planning to upstream tests that are being developed as part of the > Confidential Compute Architecture [1]. Some of the tests target the > attestation part of creating and managing a confidential compute VM, which

Re: [PATCH kvm-unit-tests] arch-run: Introduce QEMU_ARCH

2022-03-15 Thread Andrew Jones
On Tue, Mar 15, 2022 at 12:33:17PM +, Alexandru Elisei wrote: > Hi, > > On Tue, Mar 15, 2022 at 09:01:52AM +0100, Andrew Jones wrote: > > Add QEMU_ARCH, which allows run scripts to specify which architecture > > of QEMU should be used. This is useful on AArch64 when running with > > KVM and

Re: [kvm-unit-tests] Adding the QCBOR library to kvm-unit-tests

2022-03-15 Thread Alexandru Elisei
Hi, On Tue, Mar 15, 2022 at 03:21:39PM +0100, Thomas Huth wrote: > On 15/03/2022 14.33, Alexandru Elisei wrote: > > Hi, > > > > Arm is planning to upstream tests that are being developed as part of the > > Confidential Compute Architecture [1]. Some of the tests target the > > attestation part

Re: [PATCH kvm-unit-tests] arch-run: Introduce QEMU_ARCH

2022-03-15 Thread Alexandru Elisei
Hi, On Tue, Mar 15, 2022 at 04:16:30PM +0100, Andrew Jones wrote: > On Tue, Mar 15, 2022 at 12:33:17PM +, Alexandru Elisei wrote: > > Hi, > > > > On Tue, Mar 15, 2022 at 09:01:52AM +0100, Andrew Jones wrote: > > > Add QEMU_ARCH, which allows run scripts to specify which architecture > > > of

Re: [PATCH kvm-unit-tests] arch-run: Introduce QEMU_ARCH

2022-03-15 Thread Andrew Jones
On Tue, Mar 15, 2022 at 04:31:34PM +, Alexandru Elisei wrote: > Well, kvm-unit-tests selects KVM or TCG under the hood without the user > being involved at all. The under the hood aspect isn't great. It's best for testers to know what they're testing. It's pretty obvious, though, that if you