Re: [PATCH v2] KVM: arm64: Don't acquire RCU read lock for exclusive table walks

2022-11-15 Thread Oliver Upton
On Wed, Nov 16, 2022 at 03:08:49AM +, Marc Zyngier wrote: > I'm not crazy about this sort of parameters. I think it would make a > lot more sense to pass a pointer to the walker structure and do the > flag check inside the helper. > > That way, we avoid extra churn if/when we need extra state

Re: [PATCH v4 02/16] KVM: arm64: PMU: Align chained counter implementation with architecture pseudocode

2022-11-15 Thread Reiji Watanabe
On Sun, Nov 13, 2022 at 8:38 AM Marc Zyngier wrote: > > Ricardo recently pointed out that the PMU chained counter emulation > in KVM wasn't quite behaving like the one on actual hardware, in > the sense that a chained counter would expose an overflow on > both halves of a chained counter, while

Re: [PATCH v2] KVM: arm64: Don't acquire RCU read lock for exclusive table walks

2022-11-15 Thread Marc Zyngier
On Tue, 15 Nov 2022 22:55:02 +, Oliver Upton wrote: > > Marek reported a BUG resulting from the recent parallel faults changes, > as the hyp stage-1 map walker attempted to allocate table memory while > holding the RCU read lock: > > BUG: sleeping function called from invalid context at >

Re: [PATCH 33/44] KVM: x86: Do VMX/SVM support checks directly in vendor code

2022-11-15 Thread Sean Christopherson
On Tue, Nov 15, 2022, Huang, Kai wrote: > On Wed, 2022-11-02 at 23:19 +, Sean Christopherson wrote: > > +static bool __init kvm_is_vmx_supported(void) > > +{ > > + if (!cpu_has_vmx()) { > > + pr_err("CPU doesn't support VMX\n"); > > + return false; > > + } > > + > > +

Re: [PATCH 13/44] KVM: x86: Serialize vendor module initialization (hardware setup)

2022-11-15 Thread Huang, Kai
On Wed, 2022-11-02 at 23:18 +, Sean Christopherson wrote: > Acquire a new mutex, vendor_module_lock, in kvm_x86_vendor_init() while > doing hardware setup to ensure that concurrent calls are fully serialized. > KVM rejects attempts to load vendor modules if a different module has > already

Re: [RFC PATCH 04/12] KVM: arm64: Add kvm_pgtable_stage2_split()

2022-11-15 Thread Oliver Upton
On Tue, Nov 15, 2022 at 03:27:18PM -0800, Ricardo Koller wrote: > On Tue, Nov 15, 2022 at 03:03:42PM -0800, Ricardo Koller wrote: > > On Mon, Nov 14, 2022 at 08:54:52PM +, Oliver Upton wrote: [...] > > > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > > > > index

Re: [RFC PATCH 04/12] KVM: arm64: Add kvm_pgtable_stage2_split()

2022-11-15 Thread Ricardo Koller
On Tue, Nov 15, 2022 at 03:03:42PM -0800, Ricardo Koller wrote: > On Mon, Nov 14, 2022 at 08:54:52PM +, Oliver Upton wrote: > > Hi Ricardo, > > > > On Sat, Nov 12, 2022 at 08:17:06AM +, Ricardo Koller wrote: > > > > [...] > > > > > +/** > > > + * kvm_pgtable_stage2_split() - Split a

Re: [RFC PATCH 04/12] KVM: arm64: Add kvm_pgtable_stage2_split()

2022-11-15 Thread Ricardo Koller
On Mon, Nov 14, 2022 at 08:54:52PM +, Oliver Upton wrote: > Hi Ricardo, > > On Sat, Nov 12, 2022 at 08:17:06AM +, Ricardo Koller wrote: > > [...] > > > +/** > > + * kvm_pgtable_stage2_split() - Split a range of huge pages into leaf PTEs > > pointing > > + * to

[PATCH v2] KVM: arm64: Don't acquire RCU read lock for exclusive table walks

2022-11-15 Thread Oliver Upton
Marek reported a BUG resulting from the recent parallel faults changes, as the hyp stage-1 map walker attempted to allocate table memory while holding the RCU read lock: BUG: sleeping function called from invalid context at include/linux/sched/mm.h:274 in_atomic(): 0, irqs_disabled(): 0,

Re: [PATCH 33/44] KVM: x86: Do VMX/SVM support checks directly in vendor code

2022-11-15 Thread Huang, Kai
On Wed, 2022-11-02 at 23:19 +, Sean Christopherson wrote: > +static bool __init kvm_is_vmx_supported(void) > +{ > + if (!cpu_has_vmx()) { > + pr_err("CPU doesn't support VMX\n"); > + return false; > + } > + > + if

Re: [PATCH 38/44] KVM: Disable CPU hotplug during hardware enabling

2022-11-15 Thread Sean Christopherson
On Tue, Nov 15, 2022, Sean Christopherson wrote: > On Thu, Nov 10, 2022, Huang, Kai wrote: > > On Thu, 2022-11-10 at 01:33 +, Huang, Kai wrote: > > > > @@ -9283,7 +9283,13 @@ static int > > > > kvm_x86_check_processor_compatibility(struct kvm_x86_init_ops *ops) > > > >   int cpu =

Re: [PATCH 38/44] KVM: Disable CPU hotplug during hardware enabling

2022-11-15 Thread Sean Christopherson
On Thu, Nov 10, 2022, Huang, Kai wrote: > On Thu, 2022-11-10 at 01:33 +, Huang, Kai wrote: > > > @@ -9283,7 +9283,13 @@ static int > > > kvm_x86_check_processor_compatibility(struct kvm_x86_init_ops *ops) > > >   int cpu = smp_processor_id(); > > >   struct cpuinfo_x86 *c = _data(cpu); > > >  

Re: [PATCH v5 08/14] KVM: arm64: Protect stage-2 traversal with RCU

2022-11-15 Thread Oliver Upton
On Tue, Nov 15, 2022 at 10:47:37AM -0800, Ricardo Koller wrote: > On Wed, Nov 09, 2022 at 11:55:31PM +, Oliver Upton wrote: > > On Wed, Nov 09, 2022 at 09:53:45PM +, Sean Christopherson wrote: > > > On Mon, Nov 07, 2022, Oliver Upton wrote: > > > > Use RCU to safely walk the stage-2 page

Re: [PATCH v5 08/14] KVM: arm64: Protect stage-2 traversal with RCU

2022-11-15 Thread Ricardo Koller
On Wed, Nov 09, 2022 at 11:55:31PM +, Oliver Upton wrote: > On Wed, Nov 09, 2022 at 09:53:45PM +, Sean Christopherson wrote: > > On Mon, Nov 07, 2022, Oliver Upton wrote: > > > Use RCU to safely walk the stage-2 page tables in parallel. Acquire and > > > release the RCU read lock when

Re: [PATCH 1/1] KVM: arm64: Use a separate function for hyp stage-1 walks

2022-11-15 Thread Oliver Upton
Hey Will, On Tue, Nov 15, 2022 at 01:25:34PM +, Will Deacon wrote: [...] > On Mon, Nov 14, 2022 at 08:11:27PM +, Oliver Upton wrote: > > +int kvm_pgtable_hyp_walk(struct kvm_pgtable *pgt, u64 addr, u64 size, > > +struct kvm_pgtable_walker *walker); > > Hmm, this

Re: [PATCH 1/1] KVM: arm64: Use a separate function for hyp stage-1 walks

2022-11-15 Thread Will Deacon
On Mon, Nov 14, 2022 at 08:11:27PM +, Oliver Upton wrote: > A subsequent change to the page table walkers adds RCU protection for > walking stage-2 page tables. KVM uses a global lock to serialize hyp > stage-1 walks, meaning RCU protection is quite meaningless for > protecting hyp stage-1

Re: [PATCH 10/44] KVM: VMX: Clean up eVMCS enabling if KVM initialization fails

2022-11-15 Thread Vitaly Kuznetsov
Sean Christopherson writes: > On Thu, Nov 03, 2022, Vitaly Kuznetsov wrote: >> Sean Christopherson writes: >> > + /* >> > + * Reset everything to support using non-enlightened VMCS access later >> > + * (e.g. when we reload the module with enlightened_vmcs=0) >> > + */ >> > +