linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux-next: manual merge of the kvm-fixes tree with Linus' tree
@ 2022-01-19 22:25 Stephen Rothwell
  2022-01-20 10:47 ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Rothwell @ 2022-01-19 22:25 UTC (permalink / raw)
  To: Paolo Bonzini, KVM
  Cc: Linux Kernel Mailing List, Linux Next Mailing List,
	Marcelo Tosatti, Sean Christopherson

[-- Attachment #1: Type: text/plain, Size: 6799 bytes --]

Hi all,

Today's linux-next merge of the kvm-fixes tree got a conflict in:

  arch/x86/kvm/vmx/posted_intr.c

between commits:

  c95717218add ("KVM: VMX: Drop unnecessary PI logic to handle impossible conditions")
  29802380b679 ("KVM: VMX: Drop pointless PI.NDST update when blocking")
  89ef0f21cf96 ("KVM: VMX: Save/restore IRQs (instead of CLI/STI) during PI pre/post block")
  cfb0e1306a37 ("KVM: VMX: Read Posted Interrupt "control" exactly once per loop iteration")
  baed82c8e489 ("KVM: VMX: Remove vCPU from PI wakeup list before updating PID.NV")
  45af1bb99b72 ("KVM: VMX: Clean up PI pre/post-block WARNs")

from Linus' tree and commit:

  5f02ef741a78 ("KVM: VMX: switch blocked_vcpu_on_cpu_lock to raw spinlock")

from the kvm-fixes tree.

I fixed it up (I think - see below) and can carry the fix as
necessary. This is now fixed as far as linux-next is concerned, but any
non trivial conflicts should be mentioned to your upstream maintainer
when your tree is submitted for merging.  You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.

It may be worth while rebasing this fix on top of Linus' current tree.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/x86/kvm/vmx/posted_intr.c
index 88c53c521094,21ea58d25771..000000000000
--- a/arch/x86/kvm/vmx/posted_intr.c
+++ b/arch/x86/kvm/vmx/posted_intr.c
@@@ -11,23 -11,11 +11,23 @@@
  #include "vmx.h"
  
  /*
 - * We maintain a per-CPU linked-list of vCPU, so in wakeup_handler() we
 - * can find which vCPU should be waken up.
 + * Maintain a per-CPU list of vCPUs that need to be awakened by wakeup_handler()
 + * when a WAKEUP_VECTOR interrupted is posted.  vCPUs are added to the list when
 + * the vCPU is scheduled out and is blocking (e.g. in HLT) with IRQs enabled.
 + * The vCPUs posted interrupt descriptor is updated at the same time to set its
 + * notification vector to WAKEUP_VECTOR, so that posted interrupt from devices
 + * wake the target vCPUs.  vCPUs are removed from the list and the notification
 + * vector is reset when the vCPU is scheduled in.
   */
  static DEFINE_PER_CPU(struct list_head, blocked_vcpu_on_cpu);
 +/*
-  * Protect the per-CPU list with a per-CPU spinlock to handle task migration.
++ * Protect the per-CPU list with a per-CPU raw_spinlock to handle task migration.
 + * When a blocking vCPU is awakened _and_ migrated to a different pCPU, the
 + * ->sched_in() path will need to take the vCPU off the list of the _previous_
 + * CPU.  IRQs must be disabled when taking this lock, otherwise deadlock will
 + * occur if a wakeup IRQ arrives and attempts to acquire the lock.
 + */
- static DEFINE_PER_CPU(spinlock_t, blocked_vcpu_on_cpu_lock);
+ static DEFINE_PER_CPU(raw_spinlock_t, blocked_vcpu_on_cpu_lock);
  
  static inline struct pi_desc *vcpu_to_pi_desc(struct kvm_vcpu *vcpu)
  {
@@@ -129,25 -103,17 +129,25 @@@ static void __pi_post_block(struct kvm_
  	struct pi_desc old, new;
  	unsigned int dest;
  
 -	do {
 -		old.control = new.control = pi_desc->control;
 -		WARN(old.nv != POSTED_INTR_WAKEUP_VECTOR,
 -		     "Wakeup handler not enabled while the VCPU is blocked\n");
 +	/*
 +	 * Remove the vCPU from the wakeup list of the _previous_ pCPU, which
 +	 * will not be the same as the current pCPU if the task was migrated.
 +	 */
- 	spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
++	raw_spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
 +	list_del(&vcpu->blocked_vcpu_list);
- 	spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
++	raw_spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
  
 -		dest = cpu_physical_id(vcpu->cpu);
 +	dest = cpu_physical_id(vcpu->cpu);
 +	if (!x2apic_mode)
 +		dest = (dest << 8) & 0xFF00;
  
 -		if (x2apic_mode)
 -			new.ndst = dest;
 -		else
 -			new.ndst = (dest << 8) & 0xFF00;
 +	WARN(pi_desc->nv != POSTED_INTR_WAKEUP_VECTOR,
 +	     "Wakeup handler not enabled while the vCPU was blocking");
 +
 +	do {
 +		old.control = new.control = READ_ONCE(pi_desc->control);
 +
 +		new.ndst = dest;
  
  		/* set 'NV' to 'notification vector' */
  		new.nv = POSTED_INTR_VECTOR;
@@@ -170,27 -143,45 +170,27 @@@
   */
  int pi_pre_block(struct kvm_vcpu *vcpu)
  {
 -	unsigned int dest;
  	struct pi_desc old, new;
  	struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
 +	unsigned long flags;
  
 -	if (!vmx_can_use_vtd_pi(vcpu->kvm))
 +	if (!vmx_can_use_vtd_pi(vcpu->kvm) ||
 +	    vmx_interrupt_blocked(vcpu))
  		return 0;
  
 -	WARN_ON(irqs_disabled());
 -	local_irq_disable();
 -	if (!WARN_ON_ONCE(vcpu->pre_pcpu != -1)) {
 -		vcpu->pre_pcpu = vcpu->cpu;
 -		raw_spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
 -		list_add_tail(&vcpu->blocked_vcpu_list,
 -			      &per_cpu(blocked_vcpu_on_cpu,
 -				       vcpu->pre_pcpu));
 -		raw_spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->pre_pcpu));
 -	}
 +	local_irq_save(flags);
 +
 +	vcpu->pre_pcpu = vcpu->cpu;
- 	spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->cpu));
++	raw_spin_lock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->cpu));
 +	list_add_tail(&vcpu->blocked_vcpu_list,
 +		      &per_cpu(blocked_vcpu_on_cpu, vcpu->cpu));
- 	spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->cpu));
++	raw_spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, vcpu->cpu));
 +
 +	WARN(pi_desc->sn == 1,
 +	     "Posted Interrupt Suppress Notification set before blocking");
  
  	do {
 -		old.control = new.control = pi_desc->control;
 -
 -		WARN((pi_desc->sn == 1),
 -		     "Warning: SN field of posted-interrupts "
 -		     "is set before blocking\n");
 -
 -		/*
 -		 * Since vCPU can be preempted during this process,
 -		 * vcpu->cpu could be different with pre_pcpu, we
 -		 * need to set pre_pcpu as the destination of wakeup
 -		 * notification event, then we can find the right vCPU
 -		 * to wakeup in wakeup handler if interrupts happen
 -		 * when the vCPU is in blocked state.
 -		 */
 -		dest = cpu_physical_id(vcpu->pre_pcpu);
 -
 -		if (x2apic_mode)
 -			new.ndst = dest;
 -		else
 -			new.ndst = (dest << 8) & 0xFF00;
 +		old.control = new.control = READ_ONCE(pi_desc->control);
  
  		/* set 'NV' to 'wakeup vector' */
  		new.nv = POSTED_INTR_WAKEUP_VECTOR;
@@@ -229,10 -220,10 +229,10 @@@ void pi_wakeup_handler(void
  			blocked_vcpu_list) {
  		struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
  
 -		if (pi_test_on(pi_desc) == 1)
 +		if (pi_test_on(pi_desc))
  			kvm_vcpu_kick(vcpu);
  	}
- 	spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, cpu));
+ 	raw_spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, cpu));
  }
  
  void __init pi_init_cpu(int cpu)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: linux-next: manual merge of the kvm-fixes tree with Linus' tree
  2022-01-19 22:25 linux-next: manual merge of the kvm-fixes tree with Linus' tree Stephen Rothwell
@ 2022-01-20 10:47 ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2022-01-20 10:47 UTC (permalink / raw)
  To: Stephen Rothwell, KVM
  Cc: Linux Kernel Mailing List, Linux Next Mailing List,
	Marcelo Tosatti, Sean Christopherson

On 1/19/22 23:25, Stephen Rothwell wrote:
> It may be worth while rebasing this fix on top of Linus' current tree.

Yes, the next pull request will include a merge commit to avoid the 
conflict.

Paolo


^ permalink raw reply	[flat|nested] 4+ messages in thread

* linux-next: manual merge of the kvm-fixes tree with Linus' tree
@ 2020-03-01 21:05 Stephen Rothwell
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Rothwell @ 2020-03-01 21:05 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář, KVM
  Cc: Linux Next Mailing List, Linux Kernel Mailing List,
	Christoph Hellwig, Linus Torvalds

[-- Attachment #1: Type: text/plain, Size: 723 bytes --]

Hi all,

Today's linux-next merge of the kvm-fixes tree got a conflict in:

  arch/x86/kvm/Makefile

between commit:

  cfe2ce49b9da ("Revert "KVM: x86: enable -Werror"")

from Linus' tree and commit:

  4f337faf1c55 ("KVM: allow disabling -Werror")

from the kvm-fixes tree.

I fixed it up (I just used the latter version) and can carry the fix as
necessary. This is now fixed as far as linux-next is concerned, but any
non trivial conflicts should be mentioned to your upstream maintainer
when your tree is submitted for merging.  You may also want to consider
cooperating with the maintainer of the conflicting tree to minimise any
particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* linux-next: manual merge of the kvm-fixes tree with Linus' tree
@ 2019-11-12 21:00 Stephen Rothwell
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Rothwell @ 2019-11-12 21:00 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář, KVM
  Cc: Linux Next Mailing List, Linux Kernel Mailing List,
	Junaid Shahid, Thomas Gleixner

[-- Attachment #1: Type: text/plain, Size: 1781 bytes --]

Hi all,

Today's linux-next merge of the kvm-fixes tree got a conflict in:

  virt/kvm/kvm_main.c

between commit:

  1aa9b9572b10 ("kvm: x86: mmu: Recovery of shattered NX large pages")

from Linus' tree and commit:

  8a44119a98be ("KVM: Fix NULL-ptr deref after kvm_create_vm fails")

from the kvm-fixes tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc virt/kvm/kvm_main.c
index 4aab3547a165,0dac149ead16..000000000000
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@@ -693,16 -700,7 +718,11 @@@ static struct kvm *kvm_create_vm(unsign
  	INIT_HLIST_HEAD(&kvm->irq_ack_notifier_list);
  #endif
  
- 	if (init_srcu_struct(&kvm->srcu))
- 		goto out_err_no_srcu;
- 	if (init_srcu_struct(&kvm->irq_srcu))
- 		goto out_err_no_irq_srcu;
- 
  	r = kvm_init_mmu_notifier(kvm);
 +	if (r)
 +		goto out_err_no_mmu_notifier;
 +
 +	r = kvm_arch_post_init_vm(kvm);
  	if (r)
  		goto out_err;
  
@@@ -715,15 -713,6 +735,11 @@@
  	return kvm;
  
  out_err:
 +#if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER)
 +	if (kvm->mmu_notifier.ops)
 +		mmu_notifier_unregister(&kvm->mmu_notifier, current->mm);
 +#endif
 +out_err_no_mmu_notifier:
- 	cleanup_srcu_struct(&kvm->irq_srcu);
- out_err_no_irq_srcu:
- 	cleanup_srcu_struct(&kvm->srcu);
- out_err_no_srcu:
  	hardware_disable_all();
  out_err_no_disable:
  	kvm_arch_destroy_vm(kvm);

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-20 10:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19 22:25 linux-next: manual merge of the kvm-fixes tree with Linus' tree Stephen Rothwell
2022-01-20 10:47 ` Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2020-03-01 21:05 Stephen Rothwell
2019-11-12 21:00 Stephen Rothwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).