From patchwork Wed Jan 10 01:15:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13515576 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D49D6EC7 for ; Wed, 10 Jan 2024 01:15:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="j1Dq/0sU" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-5e6fe91c706so61044057b3.2 for ; Tue, 09 Jan 2024 17:15:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704849336; x=1705454136; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=mORrEHldp2qawKkikf9wfX27vt6z2DPQ9oCLXkJKW8A=; b=j1Dq/0sU3fi7kMu99PU9AsJyFwxIKVtslB3d+bqQb7WIPf/f/pIA33ykBOWUFs94bq mGff7EpnhIOUPcx7k4lIaBx+po8G63fh/eQX+hWdIzR2WKlXCOBmhZUC7c5TWXLJnkbF RUjZVE4lYOe/5Ur3MkbYhvcdOHLGjf9WzQzh7TkaDyPC5qVdpHd/KCYmCdFI08XBVXhZ 5MXuVsDMfGEul2/kKyuQwPXsTMAmWTUBiuFRMJq8o44/BZAU1pTafn2vIB9ajnP5RtgK uS0qO/VVnJQSWpy9qzehqFqtnE/GIRdjXUmiwb8nMF/WGO/H2TDyasBiWyVsbW2K/fR/ ar3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704849336; x=1705454136; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mORrEHldp2qawKkikf9wfX27vt6z2DPQ9oCLXkJKW8A=; b=aD2XyD2tD8PW4baQAUqGeLdx1gspZBCsYsuGB23fHbt0K3xyECtu/qODLmX3v5Fthr IiNv2FFtEFOvM9cnlghcEmB1qfXY6p7fUxmFN9dXh98cI+JIpYBmDe0cXjdwKZ5X4dn+ maVX2HQqxN8Uleay3slJUtrlNdps4h5OGJ3bxP6x8l0fjqLinQ7umA0D4fBY9j9tFjsT YJ17HB9rzIaeZS3mbQRUPnB4fLTnxzqAz9dvaGzrxevuWRH4A+yiIUiBAin5xIWUk0pO g3oDkOuV1/P+N4QleVDSIkQOGjeCNAiW5RVB7O9WrsdesMgR9T1kn96qG2kW+FotbO+L kB9w== X-Gm-Message-State: AOJu0YwuyFgPZQjUadt4jYUR+Q6vwexIJ6aVZO3SZGHZs3dSARk5vtzw I/Aq0/CMG7gIwgmCDca8Xpg2jAED1OwVQH9u2w== X-Google-Smtp-Source: AGHT+IFH/3iIKuhgJURtlanPFm1lyxsjMB85egFxSZXFz5VcqFxHpgjXvUYrMgAahsBcBHntAZu8fNpdp6o= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1348:b0:dbc:c697:63bd with SMTP id g8-20020a056902134800b00dbcc69763bdmr99703ybu.0.1704849335881; Tue, 09 Jan 2024 17:15:35 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 9 Jan 2024 17:15:29 -0800 Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20240110011533.503302-1-seanjc@google.com> Subject: [PATCH 0/4] KVM: Async #PF fixes and cleanups From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , Xu Yilun , Sean Christopherson Fix a use-after-module-unload bug in the async #PF code by ensuring all workqueue items fully complete before tearing down vCPUs. Do a bit of cleanup to try and make the code slightly more readable. Side topic, I'm pretty s390's flic_set_attr() is broken/racy. The async #PF code assumes that only the vCPU can invoke kvm_clear_async_pf_completion_queue(), as there are multiple assets that are effectively protected by vcpu->mutex. I don't any real world VMMs trigger the race(s), but AFAICT it's a bug. I think/assume taking all vCPUs' mutexes would plug the hole? Sean Christopherson (4): KVM: Always flush async #PF workqueue when vCPU is being destroyed KVM: Put mm immediately after async #PF worker completes remote gup() KVM: Get reference to VM's address space in the async #PF worker KVM: Nullify async #PF worker's "apf" pointer as soon as it might be freed include/linux/kvm_host.h | 1 - virt/kvm/async_pf.c | 79 ++++++++++++++++++++++++++++------------ 2 files changed, 55 insertions(+), 25 deletions(-) base-commit: 1c6d984f523f67ecfad1083bb04c55d91977bb15