Re: [PATCH 1/4] KVM: delete .change_pte MMU notifier callback

2024-04-19 Thread Sean Christopherson
On Fri, Apr 19, 2024, Will Deacon wrote: > > @@ -663,10 +669,22 @@ static __always_inline kvm_mn_ret_t > > __kvm_handle_hva_range(struct kvm *kvm, > > break; > > } > > r.ret |= range->handler(kvm, _range); > > + > > +

Re: [PATCH 1/4] KVM: delete .change_pte MMU notifier callback

2024-04-18 Thread Sean Christopherson
On Thu, Apr 18, 2024, Will Deacon wrote: > On Mon, Apr 15, 2024 at 10:03:51AM -0700, Sean Christopherson wrote: > > On Sat, Apr 13, 2024, Marc Zyngier wrote: > > > On Fri, 12 Apr 2024 15:54:22 +0100, Sean Christopherson > > > wrote: > > > > > >

Re: [PATCH 1/4] KVM: delete .change_pte MMU notifier callback

2024-04-15 Thread Sean Christopherson
On Sat, Apr 13, 2024, Marc Zyngier wrote: > On Fri, 12 Apr 2024 15:54:22 +0100, Sean Christopherson > wrote: > > > > On Fri, Apr 12, 2024, Marc Zyngier wrote: > > > On Fri, 12 Apr 2024 11:44:09 +0100, Will Deacon wrote: > > > > On Fri, Apr 05, 2024 a

Re: [PATCH 1/4] KVM: delete .change_pte MMU notifier callback

2024-04-12 Thread Sean Christopherson
On Fri, Apr 12, 2024, Marc Zyngier wrote: > On Fri, 12 Apr 2024 11:44:09 +0100, Will Deacon wrote: > > On Fri, Apr 05, 2024 at 07:58:12AM -0400, Paolo Bonzini wrote: > > Also, if you're in the business of hacking the MMU notifier code, it > > would be really great to change the

Re: [PATCH v5 12/18] x86/sgx: Add EPC OOM path to forcefully reclaim EPC

2023-10-17 Thread Sean Christopherson
On Mon, Oct 16, 2023, Haitao Huang wrote: > Hi Sean > > On Mon, 16 Oct 2023 16:32:31 -0500, Sean Christopherson > wrote: > > > On Mon, Oct 16, 2023, Haitao Huang wrote: > > > From this perspective, I think the current implementation is > > > "we

Re: [PATCH v5 12/18] x86/sgx: Add EPC OOM path to forcefully reclaim EPC

2023-10-16 Thread Sean Christopherson
On Mon, Oct 16, 2023, Haitao Huang wrote: > From this perspective, I think the current implementation is "well-defined": > EPC cgroup limits for VMs are only enforced at VM launch time, not runtime. > In practice, SGX VM can be launched only with fixed EPC size and all those > EPCs are fully

Re: [PATCH v5 12/18] x86/sgx: Add EPC OOM path to forcefully reclaim EPC

2023-10-10 Thread Sean Christopherson
On Tue, Oct 10, 2023, Haitao Huang wrote: > On Mon, 09 Oct 2023 21:23:12 -0500, Huang, Kai wrote: > > > On Mon, 2023-10-09 at 20:42 -0500, Haitao Huang wrote: > > > Hi Sean > > > > > > On Mon, 09 Oct 2023 19:23:04 -0500, Sean Christopherson > >

Re: [PATCH] KVM: deprecate KVM_WERROR in favor of general WERROR

2023-10-10 Thread Sean Christopherson
On Tue, Oct 10, 2023, Jakub Kicinski wrote: > On Tue, 10 Oct 2023 11:04:18 +0300 Jani Nikula wrote: > > > If you do invest in build testing automation, why can't your automation > > > count warnings rather than depend on WERROR? I don't understand. > > > > Because having both CI and the

Re: [PATCH v5 12/18] x86/sgx: Add EPC OOM path to forcefully reclaim EPC

2023-10-09 Thread Sean Christopherson
On Mon, Oct 09, 2023, Kai Huang wrote: > On Fri, 2023-09-22 at 20:06 -0700, Haitao Huang wrote: > > +/** > > + * sgx_epc_oom() - invoke EPC out-of-memory handling on target LRU > > + * @lru: LRU that is low > > + * > > + * Return: %true if a victim was found and kicked. > > + */ > > +bool

Re: [PATCH] KVM: deprecate KVM_WERROR in favor of general WERROR

2023-10-09 Thread Sean Christopherson
On Mon, Oct 09, 2023, Jakub Kicinski wrote: > On Mon, 9 Oct 2023 10:43:43 -0700 Sean Christopherson wrote: > > On Fri, Oct 06, 2023, Jakub Kicinski wrote: > > On a related topic, this is comically stale as WERROR is on by default for > > both > > allmodconfig and allye

Re: [PATCH] KVM: deprecate KVM_WERROR in favor of general WERROR

2023-10-09 Thread Sean Christopherson
On Fri, Oct 06, 2023, Jakub Kicinski wrote: > Setting WERROR for random subsystems make life really hard > for subsystems which want to build-test their stuff with W=1. > WERROR for the entire kernel now exists and can be used > instead. W=1 people probably know how to deal with the global > W=1

[PATCH] KVM: x86: Fix implicit enum conversion goof in scattered reverse CPUID code

2021-04-20 Thread Sean Christopherson
eatures") Cc: Kai Huang Signed-off-by: Sean Christopherson --- Hopefully it's not too late to squash this... arch/x86/kvm/cpuid.c | 5 +++-- arch/x86/kvm/cpuid.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 96e41e1a

Re: [PATCH v3 3/9] KVM: x86: Defer tick-based accounting 'til after IRQ handling

2021-04-20 Thread Sean Christopherson
On Wed, Apr 21, 2021, Frederic Weisbecker wrote: > On Thu, Apr 15, 2021 at 03:21:00PM -0700, Sean Christopherson wrote: > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index 16fb39503296..e4d475df1d4a 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x

Re: [PATCH 0/3] KVM: x86: guest interface for SEV live migration

2021-04-20 Thread Sean Christopherson
On Tue, Apr 20, 2021, Sean Christopherson wrote: > On Tue, Apr 20, 2021, Paolo Bonzini wrote: > > On 20/04/21 22:16, Sean Christopherson wrote: > > > On Tue, Apr 20, 2021, Sean Christopherson wrote: > > > > On Tue, Apr 20, 2021, Paolo Bonzini wrote: > > > &g

Re: [PATCH 0/3] KVM: x86: guest interface for SEV live migration

2021-04-20 Thread Sean Christopherson
On Tue, Apr 20, 2021, Paolo Bonzini wrote: > On 20/04/21 22:16, Sean Christopherson wrote: > > On Tue, Apr 20, 2021, Sean Christopherson wrote: > > > On Tue, Apr 20, 2021, Paolo Bonzini wrote: > > > > In this particular case, if userspace sets the bit in CPU

Re: [PATCH 0/3] KVM: x86: guest interface for SEV live migration

2021-04-20 Thread Sean Christopherson
On Tue, Apr 20, 2021, Sean Christopherson wrote: > On Tue, Apr 20, 2021, Paolo Bonzini wrote: > > On 20/04/21 19:31, Sean Christopherson wrote: > > > > + case KVM_HC_PAGE_ENC_STATUS: { > > > > + u64 gpa = a0, npages = a1, enc = a2; >

Re: [PATCH 0/3] KVM: x86: guest interface for SEV live migration

2021-04-20 Thread Sean Christopherson
On Tue, Apr 20, 2021, Paolo Bonzini wrote: > On 20/04/21 19:31, Sean Christopherson wrote: > > > + case KVM_HC_PAGE_ENC_STATUS: { > > > + u64 gpa = a0, npages = a1, enc = a2; > > > + > > > + ret = -KVM_ENOSYS; > > > + if (!vc

Re: [PATCH 0/3] KVM: x86: guest interface for SEV live migration

2021-04-20 Thread Sean Christopherson
On Tue, Apr 20, 2021, Sean Christopherson wrote: > On Tue, Apr 20, 2021, Ashish Kalra wrote: > > On Tue, Apr 20, 2021 at 05:31:07PM +0000, Sean Christopherson wrote: > > > On Tue, Apr 20, 2021, Paolo Bonzini wrote: > > > > + case KVM_HC_PAGE_ENC_STATUS: { > &

Re: [PATCH 0/3] KVM: x86: guest interface for SEV live migration

2021-04-20 Thread Sean Christopherson
On Tue, Apr 20, 2021, Ashish Kalra wrote: > On Tue, Apr 20, 2021 at 05:31:07PM +0000, Sean Christopherson wrote: > > On Tue, Apr 20, 2021, Paolo Bonzini wrote: > > > + case KVM_HC_PAGE_ENC_STATUS: { > > > + u64 gpa = a0, npages = a1, enc = a2; > > >

Re: [PATCH v5 1/3] KVM: nVMX: Sync L2 guest CET states between L1/L2

2021-04-20 Thread Sean Christopherson
one blank line in previous patch. > > Suggested-by: Sean Christopherson > Signed-off-by: Yang Weijiang > --- > arch/x86/kvm/cpuid.c | 1 - > arch/x86/kvm/vmx/nested.c | 30 ++ > arch/x86/kvm/vmx/vmx.h| 3 +++ > 3 files changed, 33

Re: [PATCH 0/3] KVM: x86: guest interface for SEV live migration

2021-04-20 Thread Sean Christopherson
On Tue, Apr 20, 2021, Paolo Bonzini wrote: > From ef78673f78e3f2eedc498c1fbf9271146caa83cb Mon Sep 17 00:00:00 2001 > From: Ashish Kalra > Date: Thu, 15 Apr 2021 15:57:02 + > Subject: [PATCH 2/3] KVM: X86: Introduce KVM_HC_PAGE_ENC_STATUS hypercall > > This hypercall is used by the SEV guest

Re: [PATCH v13 08/12] KVM: X86: Introduce KVM_HC_PAGE_ENC_STATUS hypercall

2021-04-20 Thread Sean Christopherson
On Tue, Apr 20, 2021, Paolo Bonzini wrote: > On 15/04/21 17:57, Ashish Kalra wrote: > > From: Ashish Kalra > > > > This hypercall is used by the SEV guest to notify a change in the page > > encryption status to the hypervisor. The hypercall should be invoked > > only when the encryption

Re: [RFCv2 13/13] KVM: unmap guest memory using poisoned pages

2021-04-20 Thread Sean Christopherson
On Tue, Apr 20, 2021, Kirill A. Shutemov wrote: > On Mon, Apr 19, 2021 at 08:09:13PM +0000, Sean Christopherson wrote: > > On Mon, Apr 19, 2021, Kirill A. Shutemov wrote: > > > The critical question is whether we ever need to translate hva->pfn after > > > the page

Re: [PATCH 0/3] KVM: x86: guest interface for SEV live migration

2021-04-20 Thread Sean Christopherson
On Tue, Apr 20, 2021, Paolo Bonzini wrote: > From 547d4d4edcd05fdfac6ce650d65db1d42bcd2807 Mon Sep 17 00:00:00 2001 > From: Paolo Bonzini > Date: Tue, 20 Apr 2021 05:49:11 -0400 > Subject: [PATCH 1/3] KVM: SEV: mask CPUID[0x801F].eax according to > supported features Your mailer is

Re: [PATCH v2 09/10] KVM: Don't take mmu_lock for range invalidation unless necessary

2021-04-19 Thread Sean Christopherson
On Tue, Apr 20, 2021, Paolo Bonzini wrote: > On 19/04/21 17:09, Sean Christopherson wrote: > > > - this loses the rwsem fairness. On the other hand, mm/mmu_notifier.c's > > > own interval-tree-based filter is also using a similar mechanism that is > > > likewise

Re: [PATCH v13 10/12] KVM: x86: Introduce new KVM_FEATURE_SEV_LIVE_MIGRATION feature & Custom MSR.

2021-04-19 Thread Sean Christopherson
On Thu, Apr 15, 2021, Ashish Kalra wrote: > From: Ashish Kalra > > Add new KVM_FEATURE_SEV_LIVE_MIGRATION feature for guest to check > for host-side support for SEV live migration. Also add a new custom > MSR_KVM_SEV_LIVE_MIGRATION for guest to enable the SEV live migration > feature. > > MSR

Re: [RFCv2 13/13] KVM: unmap guest memory using poisoned pages

2021-04-19 Thread Sean Christopherson
On Mon, Apr 19, 2021, Kirill A. Shutemov wrote: > On Mon, Apr 19, 2021 at 06:09:29PM +0000, Sean Christopherson wrote: > > On Mon, Apr 19, 2021, Kirill A. Shutemov wrote: > > > On Mon, Apr 19, 2021 at 04:01:46PM +, Sean Christopherson wrote: > > > > But f

Re: [RFCv2 13/13] KVM: unmap guest memory using poisoned pages

2021-04-19 Thread Sean Christopherson
On Mon, Apr 19, 2021, Kirill A. Shutemov wrote: > On Mon, Apr 19, 2021 at 04:01:46PM +0000, Sean Christopherson wrote: > > But fundamentally the private pages, are well, private. They can't be > > shared > > across processes, so I think we could (should?) requ

Re: [PATCH] KVM: Boost vCPU candidiate in user mode which is delivering interrupt

2021-04-19 Thread Sean Christopherson
On Mon, Apr 19, 2021, Wanpeng Li wrote: > On Sat, 17 Apr 2021 at 21:09, Paolo Bonzini wrote: > > > > On 16/04/21 05:08, Wanpeng Li wrote: > > > From: Wanpeng Li > > > > > > Both lock holder vCPU and IPI receiver that has halted are condidate for > > > boost. However, the PLE handler was

Re: [RFCv2 13/13] KVM: unmap guest memory using poisoned pages

2021-04-19 Thread Sean Christopherson
On Mon, Apr 19, 2021, Kirill A. Shutemov wrote: > On Fri, Apr 16, 2021 at 05:30:30PM +0000, Sean Christopherson wrote: > > I like the idea of using "special" PTE value to denote guest private memory, > > e.g. in this RFC, HWPOISON. But I strongly di

Re: [PATCH v2 09/10] KVM: Don't take mmu_lock for range invalidation unless necessary

2021-04-19 Thread Sean Christopherson
On Mon, Apr 19, 2021, Paolo Bonzini wrote: > On 19/04/21 10:49, Wanpeng Li wrote: > > I saw this splatting: > > > > == > > WARNING: possible circular locking dependency detected > > 5.12.0-rc3+ #6 Tainted: G OE > >

Re: [RFCv2 13/13] KVM: unmap guest memory using poisoned pages

2021-04-16 Thread Sean Christopherson
On Fri, Apr 16, 2021, Kirill A. Shutemov wrote: > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 1b404e4d7dd8..f8183386abe7 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -8170,6 +8170,12 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu) >

[PATCH v3 9/9] KVM: Move instrumentation-safe annotations for enter/exit to x86 code

2021-04-15 Thread Sean Christopherson
deal with the annotations avoids unnecessary nops by squashing back-to-back instrumention-safe sequences. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.h | 4 ++-- include/linux/kvm_host.h | 9 + 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm

[PATCH v3 8/9] KVM: x86: Consolidate guest enter/exit logic to common helpers

2021-04-15 Thread Sean Christopherson
Move the enter/exit logic in {svm,vmx}_vcpu_enter_exit() to common helpers. Opportunistically update the somewhat stale comment about the updates needing to occur immediately after VM-Exit. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 46

[PATCH v3 2/9] context_tracking: Move guest exit vtime accounting to separate helpers

2021-04-15 Thread Sean Christopherson
Gleixner Cc: Michael Tokarev Cc: Christian Borntraeger Signed-off-by: Wanpeng Li Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson --- include/linux/context_tracking.h | 24 +--- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/include

[PATCH v3 6/9] context_tracking: Consolidate guest enter/exit wrappers

2021-04-15 Thread Sean Christopherson
Consolidate the guest enter/exit wrappers, providing and tweaking stubs as needed. This will allow moving the wrappers under KVM without having to bleed #ifdefs into the soon-to-be KVM code. No functional change intended. Signed-off-by: Sean Christopherson --- include/linux/context_tracking.h

[PATCH v3 7/9] context_tracking: KVM: Move guest enter/exit wrappers to KVM's domain

2021-04-15 Thread Sean Christopherson
Move the guest enter/exit wrappers to kvm_host.h so that KVM can manage its context tracking vs. vtime accounting without bleeding too many KVM details into the context tracking code. No functional change intended. Signed-off-by: Sean Christopherson --- include/linux/context_tracking.h | 45

[PATCH v3 1/9] context_tracking: Move guest exit context tracking to separate helpers

2021-04-15 Thread Sean Christopherson
From: Wanpeng Li Provide separate context tracking helpers for guest exit, the standalone helpers will be called separately by KVM x86 in later patches to fix tick-based accounting. Suggested-by: Thomas Gleixner Cc: Thomas Gleixner Cc: Sean Christopherson Cc: Michael Tokarev Cc: Christian

[PATCH v3 4/9] sched/vtime: Move vtime accounting external declarations above inlines

2021-04-15 Thread Sean Christopherson
-by: Sean Christopherson --- include/linux/vtime.h | 94 +-- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/include/linux/vtime.h b/include/linux/vtime.h index 041d6524d144..6a4317560539 100644 --- a/include/linux/vtime.h +++ b/include/linux

[PATCH v3 5/9] sched/vtime: Move guest enter/exit vtime accounting to vtime.h

2021-04-15 Thread Sean Christopherson
cleanups via deduplication of context tracking code. Opportunstically delete the vtime_account_kernel() stub now that all callers are wrapped with CONFIG_VIRT_CPU_ACCOUNTING_NATIVE=y. No functional change intended. Signed-off-by: Sean Christopherson --- include/linux/context_tracking.h | 17

[PATCH v3 0/9] KVM: Fix tick-based accounting for x86 guests

2021-04-15 Thread Sean Christopherson
kernel.org/r/20210413182933.1046389-1-sea...@google.com Sean Christopherson (6): sched/vtime: Move vtime accounting external declarations above inlines sched/vtime: Move guest enter/exit vtime accounting to vtime.h context_tracking: Consolidate guest enter/exit wrappers context_tracking:

[PATCH v3 3/9] KVM: x86: Defer tick-based accounting 'til after IRQ handling

2021-04-15 Thread Sean Christopherson
s Gleixner Cc: Sean Christopherson Cc: Michael Tokarev Cc: sta...@vger.kernel.org#v5.9-rc1+ Suggested-by: Thomas Gleixner Signed-off-by: Wanpeng Li Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 13 ++--- arch/x86/kvm/vmx/

Re: [PATCH 3/3] KVM: Add proper lockdep assertion in I/O bus unregister

2021-04-15 Thread Sean Christopherson
On Thu, Apr 15, 2021, Jim Mattson wrote: > On Mon, Apr 12, 2021 at 3:23 PM Sean Christopherson wrote: > > > > Convert a comment above kvm_io_bus_unregister_dev() into an actual > > lockdep assertion, and opportunistically add curly braces to a multi-line > > for-loop.

Re: [PATCH v2 0/3] KVM: Properly account for guest CPU time

2021-04-15 Thread Sean Christopherson
On Thu, Apr 15, 2021, Wanpeng Li wrote: > On Thu, 15 Apr 2021 at 08:49, Sean Christopherson wrote: > > > > On Wed, Apr 14, 2021, Wanpeng Li wrote: > > > On Wed, 14 Apr 2021 at 01:25, Sean Christopherson > > > wrote: > > > > > > > > On Tu

Re: [PATCH v2 0/3] KVM: Properly account for guest CPU time

2021-04-14 Thread Sean Christopherson
On Wed, Apr 14, 2021, Wanpeng Li wrote: > On Wed, 14 Apr 2021 at 01:25, Sean Christopherson wrote: > > > > On Tue, Apr 13, 2021, Wanpeng Li wrote: > > > The bugzilla https://bugzilla.kernel.org/show_bug.cgi?id=209831 > > > reported that the guest time re

Re: [RFC PATCH 0/7] KVM: Fix tick-based vtime accounting on x86

2021-04-14 Thread Sean Christopherson
On Wed, Apr 14, 2021, Thomas Gleixner wrote: > On Tue, Apr 13 2021 at 11:29, Sean Christopherson wrote: > > This is an alternative to Wanpeng's series[*] to fix tick-based accounting > > on x86. The approach for fixing the bug is identical: defer accounting > > until after

Re: [PATCH v8] x86/sgx: Maintain encl->refcount for each encl->mm_list entry

2021-04-14 Thread Sean Christopherson
On Tue, Apr 13, 2021, Haitao Huang wrote: > On Sun, 07 Feb 2021 16:14:01 -0600, Jarkko Sakkinen > wrote: > > > This has been shown in tests: > > > > [ +0.08] WARNING: CPU: 3 PID: 7620 at kernel/rcu/srcutree.c:374 > > cleanup_srcu_struct+0xed/0x100 > > > > This is essentially a use-after

[RFC PATCH 7/7] KVM: x86: Defer tick-based accounting 'til after IRQ handling

2021-04-13 Thread Sean Christopherson
("x86/kvm: Move context tracking where it belongs") Cc: Thomas Gleixner Cc: Michael Tokarev Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 8 arch/x86/kvm/x86.h | 9 ++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x

[RFC PATCH 6/7] KVM: x86: Consolidate guest enter/exit logic to common helpers

2021-04-13 Thread Sean Christopherson
Move the enter/exit logic in {svm,vmx}_vcpu_enter_exit() to common helpers. In addition to deduplicating code, this will allow tweaking the vtime accounting in the VM-Exit path without splitting logic across x86, VMX, and SVM. No functional change intended. Signed-off-by: Sean Christopherson

[RFC PATCH 5/7] KVM: Move vtime accounting of guest exit to separate helper

2021-04-13 Thread Sean Christopherson
Provide a standalone helper for guest exit vtime accounting so that x86 can defer tick-based accounting until the appropriate time, while still updating context tracking immediately after VM-Exit. No functional change intended. Signed-off-by: Sean Christopherson --- include/linux/kvm_host.h

[RFC PATCH 4/7] context_tracking: KVM: Move guest enter/exit wrappers to KVM's domain

2021-04-13 Thread Sean Christopherson
Move the guest enter/exit wrappers to kvm_host.h so that KVM can manage its context tracking vs. vtime accounting without bleeding too many KVM details into the context tracking code. No functional change intended. Signed-off-by: Sean Christopherson --- include/linux/context_tracking.h | 45

[RFC PATCH 2/7] context_tracking: Move guest enter/exit logic to standalone helpers

2021-04-13 Thread Sean Christopherson
Move guest enter/exit context tracking to standalone helpers, so that the existing wrappers can be moved under KVM. No functional change intended. Signed-off-by: Sean Christopherson --- include/linux/context_tracking.h | 43 +++- 1 file changed, 26 insertions(+), 17

[RFC PATCH 3/7] context_tracking: Consolidate guest enter/exit wrappers

2021-04-13 Thread Sean Christopherson
Consolidate the guest enter/exit wrappers by providing stubs for the context tracking helpers as necessary. This will allow moving the wrappers under KVM without having to bleed too many #ifdefs into the soon-to-be KVM code. No functional change intended. Signed-off-by: Sean Christopherson

[RFC PATCH 1/7] sched/vtime: Move guest enter/exit vtime accounting to separate helpers

2021-04-13 Thread Sean Christopherson
that all callers are wrapped with CONFIG_VIRT_CPU_ACCOUNTING_NATIVE=y. No functional change intended. Suggested-by: Thomas Gleixner Cc: Christian Borntraeger Signed-off-by: Sean Christopherson --- include/linux/context_tracking.h | 17 +++- include/linux/vtime.h| 45

[RFC PATCH 0/7] KVM: Fix tick-based vtime accounting on x86

2021-04-13 Thread Sean Christopherson
it needs to fix the x86 bug. x86 compile tested only, hence the RFC. If folks like the direction and there are no unsolvable issues, I'll cross-compile, properly test on x86, and post an "official" series. Sean Christopherson (7): sched/vtime: Move guest enter/exit vtime accounting t

Re: [PATCH v2 0/3] KVM: Properly account for guest CPU time

2021-04-13 Thread Sean Christopherson
ace the virt time specific helpers at the proper splot > > Suggested-by: Thomas Gleixner > Cc: Thomas Gleixner > Cc: Sean Christopherson > Cc: Michael Tokarev > > Wanpeng Li (3): > context_tracking: Split guest_enter/exit_irqoff > context_tracking: Provide s

[PATCH 3/3] KVM: Add proper lockdep assertion in I/O bus unregister

2021-04-12 Thread Sean Christopherson
Convert a comment above kvm_io_bus_unregister_dev() into an actual lockdep assertion, and opportunistically add curly braces to a multi-line for-loop. Signed-off-by: Sean Christopherson --- virt/kvm/kvm_main.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/virt/kvm

[PATCH 2/3] KVM: Stop looking for coalesced MMIO zones if the bus is destroyed

2021-04-12 Thread Sean Christopherson
to the for-loop, which encompasses many lines but sneaks by without braces due to the guts being a single if statement. Fixes: f65886606c2d ("KVM: fix memory leak in kvm_io_bus_unregister_dev()") Cc: sta...@vger.kernel.org Reported-by: Hao Sun Signed-off-by: Sean Christopherson --- include/linux/

[PATCH 1/3] KVM: Destroy I/O bus devices on unregister failure _after_ sync'ing SRCU

2021-04-12 Thread Sean Christopherson
of the bus to remain valid. Fixes: f65886606c2d ("KVM: fix memory leak in kvm_io_bus_unregister_dev()") Cc: sta...@vger.kernel.org Signed-off-by: Sean Christopherson --- virt/kvm/kvm_main.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/virt/kvm/kvm_mai

[PATCH 0/3] KVM: Fixes and a cleanup for coalesced MMIO

2021-04-12 Thread Sean Christopherson
Fix two bugs that are exposed if unregistered a device on an I/O bus fails due to OOM. Tack on opportunistic cleanup in the related code. Sean Christopherson (3): KVM: Destroy I/O bus devices on unregister failure _after_ sync'ing SRCU KVM: Stop looking for coalesced MMIO zones

Re: [PATCH 2/2] KVM: x86: Fix split-irqchip vs interrupt injection window request

2021-04-12 Thread Sean Christopherson
On Fri, Apr 09, 2021, Lai Jiangshan wrote: > On Fri, Nov 27, 2020 at 7:26 PM Paolo Bonzini wrote: > > > > kvm_cpu_accept_dm_intr and kvm_vcpu_ready_for_interrupt_injection are > > a hodge-podge of conditions, hacked together to get something that > > more or less works. But what is actually

Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

2021-04-12 Thread Sean Christopherson
On Sun, Apr 11, 2021, Len Brown wrote: > On Fri, Apr 9, 2021 at 5:44 PM Andy Lutomirski wrote: > > > > On Fri, Apr 9, 2021 at 1:53 PM Len Brown wrote: > > > > > > On Wed, Mar 31, 2021 at 6:45 PM Andy Lutomirski wrote: > > > > > > > > On Wed, Mar 31, 2021 at 3:28 PM Len Brown wrote: > > > > >

Re: general protection fault in kvm_vm_ioctl_unregister_coalesced_mmio

2021-04-12 Thread Sean Christopherson
On Mon, Apr 12, 2021, Hao Sun wrote: > Crash log: > == > kvm: failed to shrink bus, removing it completely > general protection fault, probably for non-canonical address > 0xdead0100: [#1] PREEMPT SMP > CPU: 3 PID: 7974 Comm: executor Not

Re: [PATCH 5/6] KVM: SVM: pass a proper reason in kvm_emulate_instruction()

2021-04-12 Thread Sean Christopherson
+Aaron On Mon, Apr 12, 2021, David Edmondson wrote: > From: Joao Martins > > Declare various causes of emulation and use them as appropriate. > > Signed-off-by: Joao Martins > Signed-off-by: David Edmondson > --- > arch/x86/include/asm/kvm_host.h | 6 ++ > arch/x86/kvm/svm/avic.c

Re: [PATCH v3] KVM: SVM: Make sure GHCB is mapped before updating

2021-04-09 Thread Sean Christopherson
in a NULL pointer dereference is not encountered. > > Fixes: f1c6366e3043 ("KVM: SVM: Add required changes to support intercepts > under SEV-ES") > Fixes: 647daca25d24 ("KVM: SVM: Add support for booting APs in an SEV-ES > guest") > Signed-off-by: Tom Lendacky > > --- Reviewed-by: Sean Christopherson

Re: [PATCH v4 1/4] KVM: x86: Fix a spurious -E2BIG in KVM_GET_EMULATED_CPUID

2021-04-08 Thread Sean Christopherson
entry.ecx = F(RDPID); > break; > + default: > + goto out; > } > > + /* This check is performed only when func is valid */ Sorry to keep nitpicking and bikeshedding. Funcs aren't really "invalid", KVM just does

Re: [PATCH] x86/kvm: Don't alloc __pv_cpu_mask when !CONFIG_SMP

2021-04-08 Thread Sean Christopherson
On Wed, Apr 07, 2021, Wanpeng Li wrote: > From: Wanpeng Li > > Enable PV TLB shootdown when !CONFIG_SMP doesn't make sense. Let's move > it inside CONFIG_SMP. In addition, we can avoid alloc __pv_cpu_mask when > !CONFIG_SMP and get rid of 'alloc' variable in kvm_alloc_cpumask. ... > +static

Re: [PATCH v2] KVM: SVM: Make sure GHCB is mapped before updating

2021-04-08 Thread Sean Christopherson
On Thu, Apr 08, 2021, Tom Lendacky wrote: > > > On 4/8/21 12:37 PM, Sean Christopherson wrote: > > On Thu, Apr 08, 2021, Tom Lendacky wrote: > >> On 4/8/21 12:10 PM, Sean Christopherson wrote: > >>> On Thu, Apr 08, 2021, Tom Lendacky wrote: > >>>

Re: [PATCH v2] KVM: SVM: Make sure GHCB is mapped before updating

2021-04-08 Thread Sean Christopherson
On Thu, Apr 08, 2021, Tom Lendacky wrote: > On 4/8/21 12:10 PM, Sean Christopherson wrote: > > On Thu, Apr 08, 2021, Tom Lendacky wrote: > >> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > >> index 83e00e524513..7ac67615c070 100644 > >> --- a/ar

Re: [PATCH v2] KVM: SVM: Make sure GHCB is mapped before updating

2021-04-08 Thread Sean Christopherson
> --- > > Changes from v1: > - Added the svm_complete_emulated_msr() path as suggested by Sean > Christopherson > - Add a WARN_ON_ONCE() to the sev_vcpu_deliver_sipi_vector() path > --- > arch/x86/kvm/svm/sev.c | 3 +++ > arch/x86/kvm/svm/svm.c | 2 +- > 2

Re: [PATCH] KVM: X86: Count success and invalid yields

2021-04-08 Thread Sean Christopherson
On Tue, Apr 06, 2021, Wanpeng Li wrote: > From: Wanpeng Li > > To analyze some performance issues with lock contention and scheduling, > it is nice to know when directed yield are successful or failing. > > Signed-off-by: Wanpeng Li > --- > arch/x86/include/asm/kvm_host.h | 2 ++ >

Re: [PATCH] KVM: X86: Do not yield to self

2021-04-08 Thread Sean Christopherson
On Thu, Apr 08, 2021, Wanpeng Li wrote: > From: Wanpeng Li > > If the target is self we do not need to yield, we can avoid malicious > guest to play this. > > Signed-off-by: Wanpeng Li > --- > Rebased on > https://lore.kernel.org/kvm/1617697935-4158-1-git-send-email-wanpen...@tencent.com/ >

Re: [PATCH] KVM: x86: Remove unused function declaration

2021-04-08 Thread Sean Christopherson
On Tue, Apr 06, 2021, Keqian Zhu wrote: > kvm_mmu_slot_largepage_remove_write_access() is decared but not used, > just remove it. > > Signed-off-by: Keqian Zhu Reviewed-by: Sean Christopherson

Re: [PATCH v2 07/17] KVM: x86/mmu: Check PDPTRs before allocating PAE roots

2021-04-08 Thread Sean Christopherson
On Thu, Apr 08, 2021, Paolo Bonzini wrote: > On 08/04/21 17:48, Sean Christopherson wrote: > > Freaking PDPTRs. I was really hoping we could keep the lock and > > pages_available() > > logic outside of the helpers. What if kvm_mmu_load() reads the PDPTR

Re: [PATCH] KVM: vmx: add mismatched size in vmcs_check32

2021-04-08 Thread Sean Christopherson
vel KVM code should never do partial accesses to VMCS fields. KVM handles the split accesses automatically in vmcs_{read,write}64() when running as a 32-bit kernel. With something along those lines: Reviewed-and-tested-by: Sean Christopherson > Signed-off-by: Haiwei Li > --- >

Re: [RFC PATCH] KVM: x86: Support write protect huge pages lazily

2021-04-08 Thread Sean Christopherson
On Thu, Apr 08, 2021, Keqian Zhu wrote: > Hi Ben, > > Do you have any similar idea that can share with us? Doh, Ben is out this week, he'll be back Monday. Sorry for gumming up the works :-/

Re: [PATCH v2 07/17] KVM: x86/mmu: Check PDPTRs before allocating PAE roots

2021-04-08 Thread Sean Christopherson
On Thu, Apr 08, 2021, Paolo Bonzini wrote: > On 08/04/21 13:15, Wanpeng Li wrote: > > I saw this splatting: > > > > BUG: sleeping function called from invalid context at > > arch/x86/kvm/kvm_cache_regs.h:115 > >kvm_pdptr_read+0x20/0x60 [kvm] > >kvm_mmu_load+0x3bd/0x540 [kvm] > > > >

Re: [PATCH 1/7] hyperv: Detect Nested virtualization support for SVM

2021-04-08 Thread Sean Christopherson
On Thu, Apr 08, 2021, Vineeth Pillai wrote: > Hi Vitaly, > > On 4/8/21 7:06 AM, Vitaly Kuznetsov wrote: > > - if (ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED) { > > + /* > > +* AMD does not need enlightened VMCS as VMCB is already a > > +* datastructure in memory. > > Well,

Re: [PATCH 1/7] hyperv: Detect Nested virtualization support for SVM

2021-04-07 Thread Sean Christopherson
On Wed, Apr 07, 2021, Michael Kelley wrote: > From: Vineeth Pillai Sent: Wednesday, April 7, > 2021 7:41 AM > > > > Detect nested features exposed by Hyper-V if SVM is enabled. > > > > Signed-off-by: Vineeth Pillai > > --- > > arch/x86/kernel/cpu/mshyperv.c | 10 +- > > 1 file

Re: [PATCH] KVM: SVM: Make sure GHCB is mapped before updating

2021-04-07 Thread Sean Christopherson
On Wed, Apr 07, 2021, Tom Lendacky wrote: > On 4/7/21 3:08 PM, Sean Christopherson wrote: > > On Wed, Apr 07, 2021, Tom Lendacky wrote: > >> From: Tom Lendacky > >> > >> The sev_vcpu_deliver_sipi_vector() routine will update the GHCB to inform > >&

Re: [PATCH] KVM: SVM: Make sure GHCB is mapped before updating

2021-04-07 Thread Sean Christopherson
ot;) > Signed-off-by: Tom Lendacky Either way: Reviewed-by: Sean Christopherson > --- > arch/x86/kvm/svm/sev.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > index 83e00e524513..13758e3b106d 10

Re: [PATCH 1/1] x86/kvm/svm: Implement support for PSFD

2021-04-07 Thread Sean Christopherson
On Wed, Apr 07, 2021, Ramakrishna Saripalli wrote: > From: Ramakrishna Saripalli > > Expose Predictive Store Forwarding capability to guests. Technically KVM is advertising the capability to userspace, e.g. userspace can expose the feature to the guest without this patch. > Guests enable or

Re: [PATCH v2 8/8] KVM: SVM: Allocate SEV command structures on local stack

2021-04-07 Thread Sean Christopherson
On Wed, Apr 07, 2021, Borislav Petkov wrote: > First of all, I'd strongly suggest you trim your emails when you reply - > that would be much appreciated. > > On Wed, Apr 07, 2021 at 07:24:54AM +0200, Christophe Leroy wrote: > > > @@ -258,7 +240,7 @@ static int sev_issue_cmd(struct kvm *kvm, int

[tip: x86/sgx] x86/sgx: Move provisioning device creation out of SGX driver

2021-04-07 Thread tip-bot2 for Sean Christopherson
The following commit has been merged into the x86/sgx branch of tip: Commit-ID: b3754e5d3da320af2bebb7a690002685c7f5c15c Gitweb: https://git.kernel.org/tip/b3754e5d3da320af2bebb7a690002685c7f5c15c Author:Sean Christopherson AuthorDate:Fri, 19 Mar 2021 20:23:09 +13:00

[tip: x86/sgx] x86/cpufeatures: Add SGX1 and SGX2 sub-features

2021-04-07 Thread tip-bot2 for Sean Christopherson
The following commit has been merged into the x86/sgx branch of tip: Commit-ID: b8921dccf3b25798409d35155b5d127085de72c2 Gitweb: https://git.kernel.org/tip/b8921dccf3b25798409d35155b5d127085de72c2 Author:Sean Christopherson AuthorDate:Fri, 19 Mar 2021 20:22:18 +13:00

[tip: x86/sgx] x86/sgx: Introduce virtual EPC for use by KVM guests

2021-04-07 Thread tip-bot2 for Sean Christopherson
The following commit has been merged into the x86/sgx branch of tip: Commit-ID: 540745ddbc70eabdc7dbd3fcc00fe4fb17cd59ba Gitweb: https://git.kernel.org/tip/540745ddbc70eabdc7dbd3fcc00fe4fb17cd59ba Author:Sean Christopherson AuthorDate:Fri, 19 Mar 2021 20:22:21 +13:00

[tip: x86/sgx] x86/sgx: Add SGX_CHILD_PRESENT hardware error code

2021-04-07 Thread tip-bot2 for Sean Christopherson
The following commit has been merged into the x86/sgx branch of tip: Commit-ID: 231d3dbdda192e3b3c7b79f4c3b0616f6c7f31b7 Gitweb: https://git.kernel.org/tip/231d3dbdda192e3b3c7b79f4c3b0616f6c7f31b7 Author:Sean Christopherson AuthorDate:Fri, 19 Mar 2021 20:22:20 +13:00

[tip: x86/sgx] x86/cpu/intel: Allow SGX virtualization without Launch Control support

2021-04-07 Thread tip-bot2 for Sean Christopherson
The following commit has been merged into the x86/sgx branch of tip: Commit-ID: 332bfc7becf479de8a55864cc5ed0024baea28aa Gitweb: https://git.kernel.org/tip/332bfc7becf479de8a55864cc5ed0024baea28aa Author:Sean Christopherson AuthorDate:Fri, 19 Mar 2021 20:22:58 +13:00

[tip: x86/sgx] x86/sgx: Expose SGX architectural definitions to the kernel

2021-04-07 Thread tip-bot2 for Sean Christopherson
The following commit has been merged into the x86/sgx branch of tip: Commit-ID: 8ca52cc38dc8fdcbdbd0c23eafb19db5e5f5c8d0 Gitweb: https://git.kernel.org/tip/8ca52cc38dc8fdcbdbd0c23eafb19db5e5f5c8d0 Author:Sean Christopherson AuthorDate:Fri, 19 Mar 2021 20:23:03 +13:00

[tip: x86/sgx] x86/sgx: Add SGX2 ENCLS leaf definitions (EAUG, EMODPR and EMODT)

2021-04-07 Thread tip-bot2 for Sean Christopherson
The following commit has been merged into the x86/sgx branch of tip: Commit-ID: 32ddda8e445df3de477db14d386fb3518042224a Gitweb: https://git.kernel.org/tip/32ddda8e445df3de477db14d386fb3518042224a Author:Sean Christopherson AuthorDate:Fri, 19 Mar 2021 20:23:05 +13:00

[tip: x86/sgx] x86/sgx: Add encls_faulted() helper

2021-04-07 Thread tip-bot2 for Sean Christopherson
The following commit has been merged into the x86/sgx branch of tip: Commit-ID: a67136b458e5e63822b19c35794451122fe2bf3e Gitweb: https://git.kernel.org/tip/a67136b458e5e63822b19c35794451122fe2bf3e Author:Sean Christopherson AuthorDate:Fri, 19 Mar 2021 20:23:06 +13:00

[tip: x86/sgx] x86/sgx: Move ENCLS leaf definitions to sgx.h

2021-04-07 Thread tip-bot2 for Sean Christopherson
The following commit has been merged into the x86/sgx branch of tip: Commit-ID: 9c55c78a73ce6e62a1d46ba6e4f242c23c29b812 Gitweb: https://git.kernel.org/tip/9c55c78a73ce6e62a1d46ba6e4f242c23c29b812 Author:Sean Christopherson AuthorDate:Fri, 19 Mar 2021 20:23:04 +13:00

[tip: x86/sgx] x86/sgx: Add helpers to expose ECREATE and EINIT to KVM

2021-04-07 Thread tip-bot2 for Sean Christopherson
The following commit has been merged into the x86/sgx branch of tip: Commit-ID: d155030b1e7c0e448aab22a803f7a71ea2e117d7 Gitweb: https://git.kernel.org/tip/d155030b1e7c0e448aab22a803f7a71ea2e117d7 Author:Sean Christopherson AuthorDate:Fri, 19 Mar 2021 20:23:08 +13:00

Re: [RFC PATCH] KVM: x86: Support write protect huge pages lazily

2021-04-06 Thread Sean Christopherson
+Ben On Tue, Apr 06, 2021, Keqian Zhu wrote: > Hi Paolo, > > I plan to rework this patch and do full test. What do you think about this > idea > (enable dirty logging for huge pages lazily)? Ben, don't you also have something similar (or maybe the exact opposite?) in the hopper? This sounds

Re: [PATCH] KVM: MMU: protect TDP MMU pages only down to required level

2021-04-06 Thread Sean Christopherson
On Tue, Apr 06, 2021, Keqian Zhu wrote: > Hi Paolo, > > I'm just going to fix this issue, and found that you have done this ;-) Ha, and meanwhile I'm having a serious case of deja vu[1]. It even received a variant of the magic "Queued, thanks"[2]. Doesn't appear in either of the 5.12 pull

[PATCH v2 8/8] KVM: SVM: Allocate SEV command structures on local stack

2021-04-06 Thread Sean Christopherson
allocation is larger than the allocation itself. Now that the PSP driver plays nice with vmalloc pointers, putting the data on a virtually mapped stack (CONFIG_VMAP_STACK=y) will not cause explosions. Cc: Brijesh Singh Cc: Tom Lendacky Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/s

[PATCH v2 7/8] crypto: ccp: Use the stack and common buffer for INIT command

2021-04-06 Thread Sean Christopherson
Drop the dedicated init_cmd_buf and instead use a local variable. Now that the low level helper uses an internal buffer for all commands, using the stack for the upper layers is safe even when running with CONFIG_VMAP_STACK=y. Signed-off-by: Sean Christopherson --- drivers/crypto/ccp/sev-dev.c

[PATCH v2 6/8] crypto: ccp: Use the stack and common buffer for status commands

2021-04-06 Thread Sean Christopherson
Drop the dedicated status_cmd_buf and instead use a local variable for PLATFORM_STATUS. Now that the low level helper uses an internal buffer for all commands, using the stack for the upper layers is safe even when running with CONFIG_VMAP_STACK=y. Signed-off-by: Sean Christopherson

[PATCH v2 5/8] crypto: ccp: Use the stack for small SEV command buffers

2021-04-06 Thread Sean Christopherson
Signed-off-by: Sean Christopherson --- drivers/crypto/ccp/sev-dev.c | 122 ++- 1 file changed, 47 insertions(+), 75 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 4aedbdaffe90..bb0d6de071e6 100644 --- a/drivers/crypto/ccp

[PATCH v2 4/8] crypto: ccp: Play nice with vmalloc'd memory for SEV command structs

2021-04-06 Thread Sean Christopherson
Signed-off-by: Sean Christopherson --- drivers/crypto/ccp/sev-dev.c | 28 +++- drivers/crypto/ccp/sev-dev.h | 2 ++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 47a372e07223..4aedbdaffe90

  1   2   3   4   5   6   7   8   9   10   >