Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1189657rdb; Fri, 16 Feb 2024 07:53:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU2ktf53iN+BQ1619BqlMNlqKCXHwOcIIUtJK2UIvO8nD6v41cUQW0eNUm+SERhvc5+o1VgJfzxXJyiBvBA/HtsXoJ4G2YtegjzN0nxIQ== X-Google-Smtp-Source: AGHT+IEtElXSozRW3052YjYvS9Dtl+shmPokaEoEDrAX8h02Xu7S9GRrC92ELmFhVfiWGFBLO+l0 X-Received: by 2002:a05:6a20:3e0b:b0:19e:9af8:40e3 with SMTP id m11-20020a056a203e0b00b0019e9af840e3mr4146992pzc.16.1708098821733; Fri, 16 Feb 2024 07:53:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708098821; cv=pass; d=google.com; s=arc-20160816; b=0Ch+6leQBA9xQ2RWWLgJwUp8t/LrN4E65LQ8vnk3attA5yspyt5tXpCYLZeTyZkJIr 4O1v5BY0rIRfDi0+mlQnG1qhEZL2OKy3Ix9LdZ5VwM/pwKS5iUYXKHDBQXocjCLuhoCn kkrW1PfPCYRGpMNzDlNbILoEA89OztcQ08HrHUX7jhFlcVsW65lnNdGCNWidi9TYg8vk 6L7OUODrwqZRjfNU86foxHQvrz+jOvv3KLPaB9H2gHQabCDKMSo5Qke+QmIJQ8I/RRmh 0CqToHYlZBk1b6ZYSl4TgEe9Lorc8e+hbfwrkdCfourfKejZ0a5e+Zoj3O+u2CAmjmvy /O+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=vdWqN4twnny7sh0kB73t0EmMejLUnVRIUmMC6P4B0Co=; fh=2uWLk+h/YJIdskxJ+TcqnxnXXkx4iPJ7PBK973TztpQ=; b=N32MN2XFkqCY/SwMnGNEMMYUNTk2uKrdLQKUpnb34wLNv3pNl3kXDEO6oiIs6KwyW9 Y4n7e3Qyvw0LUZOLcHmYsWwwrqqe5YaNPvRnSXPI6BTArkYGjgTx201eNCRmpPpqCpHR vYsIminisuvxlE04iT4ustkgtbVj6eE9a61PrSOoPoNsl/7SSdsFpN5Nc+z2QwNrcMZC 6WurhytqdGwAG4ARu7aDaaQ5J7DdK9OytotOIgPwphjBmOR1BuzBJ/V72PZz/yLmJVHO r0mqqUTK9tt5FmTAyOw4CxIIeUlZ4y8KoAAT1c6ACmeQyP/Bo9Q7osPVgKIn19a3fOBy +SbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hvc00JVY; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-68908-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68908-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 hq10-20020a056a00680a00b006e11d368356si97624pfb.202.2024.02.16.07.53.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 07:53:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68908-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=hvc00JVY; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-68908-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68908-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 9FFAF2842DF for ; Fri, 16 Feb 2024 15:53:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD30912FF99; Fri, 16 Feb 2024 15:52:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hvc00JVY" Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.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 E41E712FB07 for ; Fri, 16 Feb 2024 15:52:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708098757; cv=none; b=T7dCK46hElTcMM/U9xUkuJdS+lxWiOwLl62LSRsCFMP+V+KB4FGumtkE9oEOeqrWkfp2KEhD1iL8nv8jWxVlu0GT4HK2xGRPpGJetIf/trle8v6UZnNaO+J/zZMAArQ3mK9Ry2vB3A9K0w66FmuSp1Mh9lF0or7tEg2wTWG50tE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708098757; c=relaxed/simple; bh=Twfvqn5z2TPQUG3mCx7eOkQhXIYHDRrgU1d+jAxcuDQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=KeKzU1cpleEiHa25W0hxVsaNe+YnCqd2mDTcxtpMBB9dt7HhkCmuzGB5nV2FYFKMSYwSRM2L/OcYZKsS8KsTsWWFdUG2WZfVPiP/yTZl71eM+RUG4k4eN7rYKVQB0tQlHQC8Ld6DcJun99BdbgZr9O/iJ2gwyUqew2DWcjqSA9Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hvc00JVY; arc=none smtp.client-ip=209.85.215.201 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-pg1-f201.google.com with SMTP id 41be03b00d2f7-5dcbb769a71so1552758a12.3 for ; Fri, 16 Feb 2024 07:52:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708098754; x=1708703554; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=vdWqN4twnny7sh0kB73t0EmMejLUnVRIUmMC6P4B0Co=; b=hvc00JVY9QTiNJqrNSc9ww1n6V66a9ToFhqNn+QVc2hFHv9CJ6kl7fuFuU91Wpo9V5 AOCQ23wjPxaSVZ9fbzmTAfUlNhiX6nzvr6qmqmlarf1sT2G9/M8ahxG0T4/HOX1pwKyt Ax1X4TNQfp8gFyCudeWba74kxXywGXaUm2sZN3k7Hu7zf+wOVlrIYKPj/ewPyq3Mrzoa 58i6se1eDpBM+th90UaVbSHE68Fci2xO4ngxX5kOopyDQkfNbH1yXd91RfyN3apqurfX daI5BHm9rXCiweNWm7SUN4yth5rOCv4esCUEdSJahGAgEn+ejMzNp19HOI/jVYYEH7Ed 08pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708098754; x=1708703554; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vdWqN4twnny7sh0kB73t0EmMejLUnVRIUmMC6P4B0Co=; b=eChAi6kXcFYp+wsKnLd/bJSgU0YgFPkfW90eLEyW2FhMOk2xSemPhGSkuqls9neien 0Cv5KXgwwNn3SfZ0fXxMpRMD5ayWG0pPlAG1rezPjOUG0tVxl7ReMY35ws4wbO6r7V2K GlZREvrTMybP2WOY2z9CaRvserrzlUDJoUykyHTXI9hYxZ8+XKRTMSOunKwj7FwUGPIJ kRDZUls1YMwHoZseim8npwaJlbIpfB4/5sSW6ywrs1lEq5zPTKPfY84zfIGBshbIVHN5 D155iUmrV/Ojv3ZvXPRiohZJrkIHTHYI77Pa5RjCteN509EvPQWtJrN7mEII55Lo6sCL 1OTQ== X-Forwarded-Encrypted: i=1; AJvYcCXdAcMjFjUA4CT8TQwQmZTdUONERPAm9zUHDJd3wBsJhMAw68bVbGL64J7M+KfpqhKH9IOdc4Zjb4oCN3nNm39yzDCc0eCzaZNBDA7p X-Gm-Message-State: AOJu0YwTQUft6cuUHCUemz+ClcWAqCgEm2ANc+yqTF8qT90LWP/DKGxz nFbLG+pxpXCZu1ObjAMxwKIpOPjs6N5ibb4DV88fnEppOtVQ4ioLyPQV2xKAe9YzujQBr7s5mFG /Fg== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a02:a09:b0:5dc:23a4:3a with SMTP id cm9-20020a056a020a0900b005dc23a4003amr13383pgb.7.1708098754138; Fri, 16 Feb 2024 07:52:34 -0800 (PST) Date: Fri, 16 Feb 2024 07:52:32 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240215152916.1158-1-paul@xen.org> <20240215152916.1158-22-paul@xen.org> <23e7ec31a67a73fe94b2b04dbca26ea5ca1ea238.camel@infradead.org> Message-ID: Subject: Re: [PATCH v13 21/21] KVM: pfncache: rework __kvm_gpc_refresh() to fix locking issues From: Sean Christopherson To: paul@xen.org Cc: David Woodhouse , Paolo Bonzini , Jonathan Corbet , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Sven Schnelle , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Shuah Khan , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Fri, Feb 16, 2024, Paul Durrant wrote: > On 16/02/2024 13:04, David Woodhouse wrote: > > On Thu, 2024-02-15 at 15:29 +0000, Paul Durrant wrote: > > > From: David Woodhouse > > > > > > This function can race with kvm_gpc_deactivate(), which does not take > > > the ->refresh_lock. This means kvm_gpc_deactivate() can wipe the ->pfn > > > and ->khva fields, and unmap the latter, while hva_to_pfn_retry() has > > > temporarily dropped its write lock on gpc->lock. > > > > Let's drop this from your series for now, as it's contentious. > > > > Sean didn't like calling it a 'fix', which I had conceded and reworked > > the commit message. It was on the list somewhere, and also in > > https://git.infradead.org/users/dwmw2/linux.git/commitdiff/f19755000a7 > > > > I *also* think we should do this simpler one: > > https://git.infradead.org/users/dwmw2/linux.git/commitdiff/cc69506d19a > > ... which almost makes the first one unnecessary, but I think we should > > do it *anyway* because the rwlock abuse it fixes is kind of awful. > > > > And while we still can't actually *identify* the race condition that > > led to a dereference of a NULL gpc->khva while holding the read lock > > and gpc->valid and gpc->active both being true... I'll eat my hat if > > cleaning up and simplifying the locking (and making it self-contained) > > *doesn't* fix it. Heh, I'm not taking that bet. > > But either way, it isn't really part of your series. The only reason it > > was tacked on the end was because it would have merge conflicts with > > your series, which had been outstanding for months already. > > > > So drop this one, and I'll work this bit out with Sean afterwards. FWIW, I'm not opposed to overhauling the gpc locking, I agree it's a mess. I just want to proceed slower than I would for a fix, it's a lot to digest. > Ok. Sean, I assume that since this is the last patch in the series it's > superfluous for me to post a v14 just for this? Correct, definitely no need for a new version.