Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp685314rdd; Tue, 9 Jan 2024 17:15:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhBNhuEcIHHUNx8xGkAqh791jcyLSUe1YNwbJnWhQGYjtAOQu7rMgoUuXKFI/Y/8aHgC/9 X-Received: by 2002:a05:6a20:3c94:b0:197:6f20:6fc3 with SMTP id b20-20020a056a203c9400b001976f206fc3mr156551pzj.53.1704849347448; Tue, 09 Jan 2024 17:15:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704849347; cv=none; d=google.com; s=arc-20160816; b=xMKc1RzJI58tUw/TDSyWp+O+BGraJtm9j/W/rdEP/gZQJ4/HHKcV8VbAaAw2satq5x pwLVXXzZaHBdR6A60RLxOiojqKEmiRSK6YP8fmqm7sxT8p+7wZ/qEw3/+e4e3YDLK1qM RjGoBSXXwjSz3Aym/ZSgHByF0ju4Mdh1lR2glw63ERkXhICds/vrEYPb8hxexebiZ64T erpc5KsESb7Fg18YsNSIkG6i7iwOmV6wOdtYgnLN1/eCLy7qI9xeQuKZ5rHNsGD7M+PO pFi6rRfBJfmUHOT84myNEFqOVgpTKvVMzpu/OaEK+3QpVF+NzsbXv9TYB3wt2ODeJmm3 voZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:reply-to:dkim-signature; bh=mORrEHldp2qawKkikf9wfX27vt6z2DPQ9oCLXkJKW8A=; fh=Hz5ZtsslrwNufuvBvBuVyf4bO5TQGalYKkzdbvTluiY=; b=MHuZJNV1ifcZTroNOnh0RQYG8VBNfEbdrF8FlQLx7l1UOpegBLCXc9DULyj1eiFKk5 YGZ+AMkp7xPCAk+Qhc94YdwpZUrpT1Pi2Xma8R2/1Xi5F5cu8TrZnSDbiE+ncq1gTTGj 9brEXddPxSRRgVUsCZqMsYUBYgvTBxlgo6fa8MFQ+LoPkX4qlnQPcTr7NhSrMImcMJDO fA6PUhrG9oENuceg+gDYSdcz37ikqypaqx/6alkddDATWPQ2B9IjXvvWmU5UvzoBOHOQ 1fniX9XWsvpNndpNvC+H1/eJP2sID/PCGMyxHfiFBBm7ZdUXU2dyjQlEkTdl3TlpwtEr 1rbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="j1Dq/0sU"; spf=pass (google.com: domain of linux-kernel+bounces-21615-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21615-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id jj17-20020a170903049100b001d3ec4811d9si2429121plb.328.2024.01.09.17.15.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 17:15:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21615-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="j1Dq/0sU"; spf=pass (google.com: domain of linux-kernel+bounces-21615-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21615-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1F86D2879BE for ; Wed, 10 Jan 2024 01:15:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0571217E4; Wed, 10 Jan 2024 01:15:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="j1Dq/0sU" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 D35DE81F 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 Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dbdb46770d7so4566339276.1 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=u+Pk/2LMQUBUDRV1bUvumZLAZOEbWHU73kafM8NWa2qu3d4tJxnR+6C0p8PWF2QsWV vH/C3tr8xwLZH9oBqb0q4TSLXGmqyjvypU75Gjd3YukG7ydAboZagTsxD9OT9pCZmArd 6T54x6aigyMNUqFXGG45Bc5xUfF2rVKUqCl0vlywChSSznNNS3RyqchMCNw0WZb0bW2w jnSETI935HqpzPbnG9t7fm32cSRJpdS4KOJzhiwNruwXl3ZvUN2WFhshLga6iorXglQc JSInn7xCHbnpWVW401OifOVs2PG7owu/RShzAMvT7Jjy26oHl6KrfViO1ixlOZ5rVvnq rprw== X-Gm-Message-State: AOJu0Yz4NZ4CPWzOlDxdbGKv09sRrrjTjf/+z+R3llQIfgRhRjdBKhrF EnyOC2409UOy+JJrfg56CAGdHcVyMpmmo2R/7g== 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: linux-kernel@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 Content-Type: text/plain; charset="UTF-8" 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 -- 2.43.0.472.g3155946c3a-goog