On Mon, Dec 12, 2022 at 11:50:29PM +0100, Paolo Bonzini wrote:
> On 12/12/22 18:39, Sean Christopherson wrote:
> > > The notion of address spaces is already existing architecture-neutral
> > > concept in KVM (e.g. see uses of KVM_ADDRESS_SPACE_NUM in
> > > virt/kvm/kvm_main.c), although SMM is the
On Mon, Dec 12, 2022 at 06:17:36PM +, Oliver Upton wrote:
> On Mon, Dec 12, 2022 at 05:39:38PM +, Sean Christopherson wrote:
> > On Fri, Dec 09, 2022, David Matlack wrote:
> > > On Fri, Dec 9, 2022 at 9:25 AM Oliver Upton
> > > wrote:
> > My preferenc
On Mon, Dec 12, 2022 at 3:11 PM Paolo Bonzini wrote:
>
> On 12/8/22 20:38, David Matlack wrote:
> > +/*
> > + * kvm_mmu_page_role tracks the properties of a shadow page (where shadow
> > page
> > + * also includes TDP pages) to determine whether or not a page c
On Mon, Dec 12, 2022 at 2:32 PM Paolo Bonzini wrote:
>
> On 12/8/22 20:38, David Matlack wrote:
> > This commit increases the size of struct kvm_mmu_page by 64 bytes on
> > x86_64 (184 bytes -> 248 bytes). The size of this struct can be reduced
> > in future commits by
On Mon, Dec 12, 2022 at 2:03 PM Ben Gardon wrote:
>
> On Thu, Dec 8, 2022 at 11:40 AM David Matlack wrote:
> >
> > Move kvm_arch_flush_remote_tlbs_memslot() to common code and drop
> > "arch_" from the name. kvm_arch_flush_remote_tlbs_memslot() is just a
>
On Mon, Dec 12, 2022 at 10:24:31AM -0800, Ben Gardon wrote:
> On Thu, Dec 8, 2022 at 11:39 AM David Matlack wrote:
> >
> > Move struct kvm_page_fault to common code. This will be used in a future
> > commit to move the TDP MMU to common code.
> >
> > No functiona
On Mon, Dec 12, 2022 at 11:32 AM Ben Gardon wrote:
>
> On Thu, Dec 8, 2022 at 11:39 AM David Matlack wrote:
> >
> > Abstract away kvm_mmu_max_mapping_level(), which is an x86-specific
> > function for computing the max level that a given GFN can be mapped in
> > K
On Fri, Dec 9, 2022 at 11:07 AM Oliver Upton wrote:
>
> On Thu, Dec 08, 2022 at 11:38:20AM -0800, David Matlack wrote:
>
> >Also do we want to keep "TDP" or switch
> >to something more familiar across architectures (e.g. ARM and RISC-V
> >both
On Fri, Dec 9, 2022 at 9:32 AM Oliver Upton wrote:
>
> Hey David,
>
> On Thu, Dec 08, 2022 at 11:38:43AM -0800, David Matlack wrote:
> > Move VM-level TDP MMU state to struct kvm so it can be accessed by
> > common code in a future commit.
> >
> > No funct
On Fri, Dec 9, 2022 at 9:25 AM Oliver Upton wrote:
>
> On Fri, Dec 09, 2022 at 10:37:47AM +0800, Yang, Weijiang wrote:
> >
> > On 12/9/2022 3:38 AM, David Matlack wrote:
> > > Rename kvm_mmu_page_role.smm with kvm_mmu_page_role.as_id and use it
> > > directl
Move tdp_mmu.[ch] from arch/x86 and into the common code directories.
This will allow other architectures to use the TDP MMU in the future.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/kvm/Makefile | 2 +-
arch/x86/kvm/mmu/mmu.c
Move is_tdp_mmu_page(), which is x86-specific, into mmu_internal.h. This
prepares for moving tdp_mmu.h into common code.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/mmu_internal.h | 9 +
arch/x86/kvm/mmu/tdp_mmu.h | 9 -
2 files changed
.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/mmu_internal.h | 1 -
include/linux/kvm_host.h| 1 +
virt/kvm/kvm_main.c | 9 +
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_internal.h
index
Move arch/x86/kvm/mmu/tdp_iter.{c,h} to into common code so that it can
be used by other architectures in the future.
No functional change intended.
Signed-off-by: David Matlack
---
MAINTAINERS | 2 +-
arch/x86/kvm/Makefile| 2 +-
arch
Move tdp_mmu_max_gfn_exclusive() to tdp_pgtable.c since it currently
relies on the x86-specific kvm_mmu_max_gfn() function. This can be
improved in the future by implementing a common API for calculating the
max GFN.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86
(MIPS does not set __GFP_ZERO.)
This eliminates a dependency of the TDP MMU on an architecture-specific
field, which will be used in a future commit to move the TDP MMU to
common code.
Signed-off-by: David Matlack
---
arch/arm64/include/asm/kvm_host.h | 3 ---
arch/arm64/kvm/arm.c | 4
t use that and drop a bunch of duplicate code from the arch
directories.
Note this adds a lockdep assertion for slot_lock being held when calling
kvm_flush_remote_tlbs_memslot(), which was previously only asserted on
x86.
Signed-off-by: David Matlack
---
arch/arm64/kvm/arm.c | 6 --
arc
functional change intended.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/mmu.c | 32 ++--
arch/x86/kvm/mmu/mmu_internal.h | 3 +--
arch/x86/kvm/mmu/paging_tmpl.h | 4 ++--
arch/x86/kvm/mmu/tdp_mmu.c | 7 +++
4 files changed, 20 insertions(+), 26
Use gfn_t instead of u64 for the start_gfn parameter to
kvm_flush_remote_tlbs_range(), since that is the standard type for GFNs
throughout KVM.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/mmu.c | 2 +-
arch/x86/kvm/mmu/mmu_internal.h | 2 +-
2
Collapse kvm_flush_remote_tlbs_with_range() and
kvm_flush_remote_tlbs_with_address() into a single function. This
eliminates some lines of code and a useless NULL check on the range
struct.
Opportunistically switch from ENOTSUPP to EOPNOTSUPP to make checkpatch
happy.
Signed-off-by: David
ional change intended.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/mmu.c | 6 --
arch/x86/kvm/mmu/tdp_mmu.c | 2 --
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 0593d4a60139..9307608ae975 100644
--- a/arch/x86/kv
the code to
manage this cache to common code.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/mmu.c | 11 +--
arch/x86/kvm/mmu/mmu_internal.h | 2 --
arch/x86/kvm/mmu/tdp_mmu.c | 2 +-
include/kvm/mmu.h | 2 ++
include/li
Pass the root role from the caller rather than grabbing it from
vcpu->arch.mmu. This will enable the TDP MMU to be moved to common code
in a future commit by removing a dependency on vcpu->arch.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/mmu.c
Create stub tracepoints outside of x86. The KVM MMU tracepoints can be
moved to common code, but will be deferred to a future commit.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/tdp_mmu.c | 2 +-
include/kvm/mmutrace.h | 17 +
2 files
Move VM-level TDP MMU state to struct kvm so it can be accessed by
common code in a future commit.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/include/asm/kvm_host.h | 39
arch/x86/kvm/mmu/tdp_mmu.c | 40
In preparation for moving the TDP MMU implementation into virt/kvm/
guarded behind HAVE_TDP_MMU, ensure that HAVE_TDP_MMU is selected in
X86_64 builds that enable KVM. This matches the existing behavior of the
TDP MMU in x86.
No functional change intended.
Signed-off-by: David Matlack
---
arch
-off-by: David Matlack
---
virt/kvm/Kconfig | 3 +++
1 file changed, 3 insertions(+)
diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig
index 9fb1ff6f19e5..75d86794d6cf 100644
--- a/virt/kvm/Kconfig
+++ b/virt/kvm/Kconfig
@@ -92,3 +92,6 @@ config KVM_XFER_TO_GUEST_WORK
config HAVE_KVM_PM_NOTIFIER
n-x86 architectures that just
returns the max level. This will result in more zapping than necessary
when disabling dirty logging (i.e. less than optimal performance) but no
correctness issues.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/tdp_mmu.c | 14 ++
arch/x86/kvm/mmu/tdp_pgtable.c
architecture-specific code.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/include/asm/kvm/tdp_pgtable.h | 10 +++
arch/x86/kvm/mmu/tdp_mmu.c | 18 +
arch/x86/kvm/mmu/tdp_pgtable.c | 36 ++
3 files changed, 52
MMU.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/tdp_mmu.c | 57 +++---
arch/x86/kvm/mmu/tdp_pgtable.c | 52 +++
2 files changed, 84 insertions(+), 25 deletions(-)
diff --git a/arch/x86/kvm/mmu
Move struct kvm_gfn_range to kvm_types.h so that it's definition can be
accessed in a future commit by arch/x86/include/asm/kvm/tdp_pgtable.h
without needing to include the mega-header kvm_host.h.
No functional change intended.
Signed-off-by: David Matlack
---
include/linux/kvm_host.h
overrides for any of these macros in the future on a case
by case basis.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/tdp_iter.c | 14 +++---
arch/x86/kvm/mmu/tdp_iter.h | 3 ++-
arch/x86/kvm/mmu/tdp_mmu.c | 24 +---
include/kvm/tdp_pgtable.h | 21
()
tdp_pte_clear_accessed()
Note that this does not cover constructing PTEs from scratch (e.g.
during page fault handling). This will be added in a subsequent commit.
Signed-off-by: David Matlack
---
arch/x86/include/asm/kvm/tdp_pgtable.h | 58 +
arch/x86/kvm/Makefile | 2 +-
arch/x86
_data, as that is now always true by construction.
Fixes: 0b45d58738cd ("KVM: selftests: Add selftest for KVM statistics data
binary interface")
Signed-off-by: Jing Zhang
Signed-off-by: David Matlack
[Re-worded the commit message.]
Signed-off-by: David Matlack
---
tools/testin
Abstract the code that looks up the TDP MMU root from vcpu->arch.mmu
behind a function, tdp_mmu_root(). This will be used in a future commit
to allow the TDP MMU to be moved to common code, where vcpu->arch.mmu
cannot be accessed directly.
Signed-off-by: David Matlack
---
arch/x86/inclu
Move the RET_PF_* enum into common code in preparation for moving the
TDP MMU into common code.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/mmu_internal.h | 28
include/kvm/mmu_types.h | 26 ++
2 files changed, 26 insertions
Move sptep_to_sp() to common code in preparation for moving the TDP MMU
to common code.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/spte.h | 14 ++
include/kvm/mmu.h | 19 +++
2 files changed, 21 insertions(+), 12 deletions
Use PG_LEVEL_{PTE,PMD,PUD} in the TDP MMU instead of the x86-specific
PG_LEVEL_{4K,2M,1G} aliases. This prepares for moving the TDP MMU to
common code, where not all architectures will have 4K PAGE_SIZE.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu
Move struct kvm_page_fault to common code. This will be used in a future
commit to move the TDP MMU to common code.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/include/asm/kvm/mmu_types.h | 20 +++
arch/x86/kvm/mmu/mmu.c | 19 +++
arch/x86/kvm
ate struct
and by dynamically allocating fields only used by the Shadow MMU.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/include/asm/kvm/mmu_types.h | 62 ++
arch/x86/include/asm/kvm_host.h | 4 -
arch/x86/kvm/mmu/mmu.c |
nt code to
architecture-neutral code.
Signed-off-by: David Matlack
---
arch/x86/include/asm/pgtable_types.h | 12
include/linux/mm_types.h | 9 +
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/arch/x86/include/asm/pgtable_types.h
b/arch/x86/i
, refcount_dec_and_test() returns true if the resulting refcount is
0. Hence the check in mmu_free_root_page() is inverted to check if
shadow root refcount is 0.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/mmu.c | 14 +++---
arch/x86/kvm/mmu/mmu_internal.h | 6 ++
arch/x86/kvm
these stats on x86, since that's currently the
only architecture that populates them.
Signed-off-by: David Matlack
---
arch/x86/include/asm/kvm_host.h | 8
arch/x86/kvm/mmu.h | 5 -
arch/x86/kvm/x86.c | 6 +++---
include/linux/kvm_host.h
Move the definition of tdp_ptep_t into kvm/mmu_types.h so it can be used
from common code in future commits.
No functional changed intended.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/mmu_internal.h | 2 --
include/kvm/mmu_types.h | 2 ++
2 files changed, 2 insertions(+), 2
Invert the meaning of sp->tdp_mmu_page and rename it accordingly. This
allows the TDP MMU code to not care about this field, which will be used
in a subsequent commit to move the TDP MMU to common code.
No functional change intended.
Signed-off-by: David Matlack
---
arch/x86/kvm/mmu/mm
86 (unrelated to
this refactor).
Thanks.
P.S. Looking to the future... This is just the first step toward
building a common TDP MMU for KVM. After this, We are looking at adding
KUnit testing to the common TDP MMU as a way to offset the risk of
sharing more code across architectures, and then tar
Move struct kvm_mmu_page_role into common code, and move all
x86-specific fields into a separate sub-struct within the role,
kvm_mmu_page_role_arch.
Signed-off-by: David Matlack
---
MAINTAINERS | 4 +-
arch/x86/include/asm/kvm/mmu_types.h | 56 ++
arch/x86
Rename kvm_mmu_page_role.smm with kvm_mmu_page_role.as_id and use it
directly as the address space ID throughout the KVM MMU code. This
eliminates a needless level of indirection, kvm_mmu_role_as_id(), and
prepares for making kvm_mmu_page_role architecture-neutral.
Signed-off-by: David Matlack
On Tue, Nov 15, 2022 at 11:28:56AM +0800, wangyanan (Y) wrote:
> Hi Sean, Paolo,
>
> I recently also notice the behavior change of param halt_poll_ns.
> Now it loses the ability to:
> 1) dynamically disable halt polling for all the running VMs
> by `echo 0 > /sys`
> 2) dynamically adjust the halt
On Fri, Sep 24, 2021 at 05:55:20PM -0700, Sean Christopherson wrote:
> Drop kvm_arch_vcpu_block_finish() now that all arch implementations are
> nops.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson
Reviewed-by: David Matlack
> ---
>
7;t
> overloaded on x86, e.g. in KVM's stats. Skipping halt-polling for WFS
> (and RESET_HOLD) has no meaningful effect on guest performance as there
> are typically single-digit numbers of INIT-SIPI sequences per AP vCPU,
> per boot, versus thousands of HLTs just to boot to
gram stats into the helper to
> resolve a discrepancy in what is considered a "successful" halt-poll.
>
> No functional change intended.
>
> Cc: David Matlack
> Signed-off-by: Sean Christopherson
Reviewed-by: David Matlack
> ---
> virt/kvm/kvm_main.c | 8 +-
d. And if the branch is
> mispredicted, arguably that extra latency should count toward the
> halt-polling time.
>
> In all likelihood, the numbers involved are in the noise and either
> approach is perfectly ok.
>
> Signed-off-by: Sean Christopherson
Reviewed-by: David Matlac
'0', and so KVM will not attempt
> halt-polling, i.e. this really only affects the post-block bookkeeping.
>
> Signed-off-by: Sean Christopherson
Reviewed-by: David Matlack
> ---
> arch/x86/kvm/x86.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
uce the
> line length for the call site so that it fits on a single line, and so
> that the prototype conforms to the more traditional kernel style.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson
Reviewed-by: David Matlack
> ---
> virt
>
> Signed-off-by: Sean Christopherson
Reviewed-by: David Matlack
> ---
> include/linux/kvm_host.h | 1 +
> virt/kvm/kvm_main.c | 50
> 2 files changed, 36 insertions(+), 15 deletions(-)
>
> diff --git a/include/linux/kvm_host.
stead of
> using "cur". But that change is desirable as it means all the stats are
> now updated with the same polling time, and avoids the extra ktime_get(),
> which isn't expensive but isn't free either.
>
> Signed-off-by: Sean Christopherson
Reviewed-by: Davi
o handle
> non-halt cases where the vCPU is not runnable.
>
> Rename block_ns to halt_ns to match the new function name.
>
> Opportunistically move an x86-specific comment to x86, and enhance it, too.
>
> No functional change intended.
>
> Signed-off-by: Se
lly-by: Cannon Matthews
> Suggested-by: Sean Christopherson
> Signed-off-by: Jing Zhang
> [sean: renamed stat to "blocking", massaged changelog]
> Signed-off-by: Sean Christopherson
Reviewed-by: David Matlack
> ---
> include/linux/kvm_host.h | 3 ++-
> include/linux
o functional change intended.
>
> Signed-off-by: Sean Christopherson
Reviewed-by: David Matlack
> ---
> arch/x86/include/asm/kvm_host.h | 2 +-
> arch/x86/kvm/vmx/nested.c | 2 +-
> arch/x86/kvm/vmx/vmx.c | 4 ++--
> arch/x86/kvm/x86.c | 1
On Mon, Sep 27, 2021 at 8:17 AM Christian Borntraeger
wrote:
>
>
>
> Am 27.09.21 um 17:03 schrieb Paolo Bonzini:
> > On 27/09/21 16:59, Sean Christopherson wrote:
> >>> commit acd05785e48c01edb2c4f4d014d28478b5f19fb5
> >>> Author: David Matlack
> &
On Wed, Sep 22, 2021 at 11:53 AM Marc Zyngier wrote:
>
> On Wed, 22 Sep 2021 19:13:40 +0100,
> Sean Christopherson wrote:
>
> > Stepping back a bit, this is one piece of the larger issue of how to
> > modernize KVM for hyperscale usage. BPF and tracing are great when
> > the debugger has root ac
On Mon, May 24, 2021 at 8:18 AM Jing Zhang wrote:
>
> Add selftest to check KVM stats descriptors validity.
>
> Reviewed-by: David Matlack
> Reviewed-by: Ricardo Koller
> Signed-off-by: Jing Zhang
Reviewed-by: David Matlack
> ---
> tools/testing/selftests/kvm
On Mon, May 24, 2021 at 8:18 AM Jing Zhang wrote:
>
> Put all common statistics in a separate structure to ease
> statistics handling for the incoming new statistics API.
>
> No functional change intended.
>
> Reviewed-by: David Matlack
FYI I think you only add Reviewe
On Mon, May 24, 2021 at 8:18 AM Jing Zhang wrote:
>
> Provides a file descriptor per VM to read VM stats info/data.
> Provides a file descriptor per vCPU to read vCPU stats info/data.
>
> Reviewed-by: David Matlack
> Reviewed-by: Ricardo Koller
> Signed-off-by: Jing Zha
On Mon, May 24, 2021 at 8:18 AM Jing Zhang wrote:
>
> Update KVM API documentation for binary statistics.
>
> Reviewed-by: David Matlack
> Reviewed-by: Ricardo Koller
> Signed-off-by: Jing Zhang
Reviewed-by: David Matlack
> ---
> Documentatio
On Mon, May 17, 2021 at 9:25 AM Jing Zhang wrote:
>
> Update KVM API documentation for binary statistics.
>
> Signed-off-by: Jing Zhang
> ---
> Documentation/virt/kvm/api.rst | 171 +
> 1 file changed, 171 insertions(+)
>
> diff --git a/Documentation/virt/kvm/api.
On Mon, May 17, 2021 at 9:24 AM Jing Zhang wrote:
>
> Add selftest to check KVM stats descriptors validity.
>
> Signed-off-by: Jing Zhang
> ---
> tools/testing/selftests/kvm/.gitignore| 1 +
> tools/testing/selftests/kvm/Makefile | 3 +
> .../testing/selftests/kvm/include/kv
On Mon, May 17, 2021 at 9:25 AM Jing Zhang wrote:
>
> Update KVM API documentation for binary statistics.
>
> Signed-off-by: Jing Zhang
> ---
> Documentation/virt/kvm/api.rst | 171 +
> 1 file changed, 171 insertions(+)
>
> diff --git a/Documentation/virt/kvm/api.
On Mon, May 17, 2021 at 9:32 AM Jing Zhang wrote:
>
> Provides a file descriptor per VM to read VM stats info/data.
> Provides a file descriptor per vCPU to read vCPU stats info/data.
>
> Signed-off-by: Jing Zhang
> ---
> arch/arm64/kvm/guest.c| 26 +
> arch/mips/kvm/mips.c | 52 +
On Mon, May 17, 2021 at 5:10 PM Jing Zhang wrote:
> Actually the definition of kvm_{vcpu,vm}_stat are arch specific. There is
> no real structure for arch agnostic stats. Most of the stats in common
> structures are arch agnostic, but not all of them.
> There are some benefits to put all common s
On Mon, May 17, 2021 at 9:24 AM Jing Zhang wrote:
>
> Put all common statistics in a separate structure to ease
> statistics handling for the incoming new statistics API.
>
> No functional change intended.
>
> Signed-off-by: Jing Zhang
> ---
> arch/arm64/include/asm/kvm_host.h | 9 ++---
>
72 matches
Mail list logo