Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp78782rdh; Tue, 6 Feb 2024 20:28:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUr5nZdc3RVSq7xioi47OYtHKJF2h/Mkcsa50ZljDxRBTvoHkIJUTLSGl1nPJc/gPtVqEwL33dM6sJpPB95Lr4bqzuufIOgBhPdosmhGQ== X-Google-Smtp-Source: AGHT+IEeB3eEyRu39se+dnYVCbDpTif+i2V9LjHYV9QGFN5VnklGtuGhp5ijqlBB+kxZN1JAfi19 X-Received: by 2002:a05:6214:5287:b0:68c:9b63:bc5e with SMTP id kj7-20020a056214528700b0068c9b63bc5emr5401895qvb.59.1707280119095; Tue, 06 Feb 2024 20:28:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707280119; cv=pass; d=google.com; s=arc-20160816; b=eNvNA+hDu4DtoQOWB545Ly8Mb1TlEe5WguIap5/Uli+sZFoFwQhiGmrd1mRL/gAGNT gjBWmAmkotxjdeEvNGk7bFQJ31OvIr13L+VlUSDsFyBB1+kBAbYgMw8qV3ljyvcNkgKo gpRa8WZUySWFWhu+2K64ANcH1vNgYoqbybIynl//kLHAZbQA+3hg5vgjviYCH2TAgrNO yCsbEttgU30d9MtYiddDDvnjcPlRHiFcK5eMv20jzq9zdTh9RZ9mY1k93fERfp1d+jx3 o9gBbjpZa4WEZU6ceODupwNXjioNoKufxhBR/BYJt9biocA0s01PiZAiD2/WaQt13Vut Ct2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:date:dkim-signature; bh=0u5NrceOYzCOKx+73MFK71e5+5At+9gEeFz068cC2z4=; fh=1cuyGLttepPvUuq/WogSyaMU8PHSKsfeWdzK0xwvLVc=; b=CrZ2JszfKhSNODTUSyLsYuIMiMXOt/qrmSIoM23SoYCAe3m83ssorpbJGLx5MEQ7fZ yk9KGofo9PcuY+vm7vVqzSdp/CcGz4pljEEKIo35uJM7jKm5H7tE9iWHMAsOSUhwpoFz Ebt56t/5EFvtoGNyj9bAWiYI5nuu6Y3tQh68DH3wA6HJNS7keA1XVs8fO3hKIiZVXFl2 irXMyfu1uJpGv+8rOxih1BhQMDcACyBI3lUldy2hxRz8d+sFgR6Q4ZsloURqgUUXA5bY RU8VtMaM3TYX38M2PRKSREP6BFdZgjJiB/OvZmBRo9np+kLTXODWlymX5ASDr481Df7C b3Lg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lJXwqnRt; 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-55933-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55933-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCV6H5QJL+r8eiqL8s599kLqpehs0hQ8OGEnedwNahgzZwzD5noOe/cxdRDsIGJrL98YNgHkEbZMN2aAzX7BGVLmoL9osv00Rt6koo+EWg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r9-20020a0cf809000000b0068c886a3295si402189qvn.487.2024.02.06.20.28.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 20:28:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55933-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lJXwqnRt; 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-55933-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55933-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D5F481C254EB for ; Wed, 7 Feb 2024 04:28:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C05914A81; Wed, 7 Feb 2024 04:28:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lJXwqnRt" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.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 2416A12E47 for ; Wed, 7 Feb 2024 04:28:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707280108; cv=none; b=WX4b8/1c8YhohbUc0QVMxf1b2GjWvybq8HXqBUgcIBrUdajdqEinJi7WvyQ8fvDVd0wFTim+vtGTvWln/j47IDY8T3/1brLb8hygxwh6dDomQiPYBxXj8sw9dP9CIfMe1ifEKt6Zg5gAsFz8hPXghJW2we0NAaFOuNRoBmkUKFY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707280108; c=relaxed/simple; bh=8ehiZ8S594GAV53sSwBEcddx0O0RVISkZMdA4sB4qk4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=N46C4bi5NMBNQ3KkWumuzLe8d8XXtuBILuCeBS92hcOXdhynm+ZSvv6bPvkwC94feyq8MG4F2Id6oTitoKTx/1DCeo/qfYE7CCtrGtuEUztbt6Gw+c8d+CBuCgsYbig5KTRoQIVXvYz5UDJMBr++8SwCGT9r+BlNZ7grAWRtf+E= 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=lJXwqnRt; arc=none smtp.client-ip=209.85.219.202 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-f202.google.com with SMTP id 3f1490d57ef6-dbe9e13775aso366252276.1 for ; Tue, 06 Feb 2024 20:28:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707280106; x=1707884906; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=0u5NrceOYzCOKx+73MFK71e5+5At+9gEeFz068cC2z4=; b=lJXwqnRt/Rd5HzRKLKv87BbwzNTlLTsWB60Eoc+PpbivhvYpL/AsoLiW4UVTxl1GZJ uHRBSf6hJr6kds0ZHRxAnoGsb+T3oGgJ9oVaG3tqh00zJPceRpsL92mwp8WcIQ42T7hA giHuKsGwpHM5fXJAlZ2jAZHCecvmAdEc4W9ap/6Kjgq7IINLdKm/MiP4hMf3rCIg4vgF 72hTCBnjmOi4muZr5AfnFjKoBve66IY1+xoxP2fw2b5VI9jQwRWE4iPGlesg8ijjj2Mq UCCm4+zLhxwji1mGb6W97QarCPSThE0GjN+WrvRu5xubg9ZvD5ZRmT8AIQPw3BSgAiPs F9HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707280106; x=1707884906; h=content-transfer-encoding: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=0u5NrceOYzCOKx+73MFK71e5+5At+9gEeFz068cC2z4=; b=UGmUmfWq9QUNh+m6eIBiDeGd5cGhk5Vpt98ztfdW/NIXGnVk9u+IAybrN+7lWBQ5ty bIXKKJynu1+hujV9jJ1IxZqBvBaq9gXr4rkC5J0h7IvCxINy8+fc+Z3flWzXWzjqpGrK z9BqCabaqYHhjd5O0wdsWpaCQCkl4Qav7OyqlbZRgPWKfRW5hrpVRIccE6vdHUhd/q51 SChDIN0oiubWY5qxx+Y70iySNTTRXAx+VJ460AC18otsmw3w8TDuWcoeHKF18E4DXfCX CjbYxtAU9V0XyMlMu2+lIG7Kfl+gXPTu+uj+YX8vNUZiojOpc1q0oAlYTmoZOk8fwLum BZgw== X-Forwarded-Encrypted: i=1; AJvYcCVCbxUWlPecHBlZ8x4/Wpen4YVtx6vMji502R3bS5QfVcaWKv+TKBA3bEpqxmJ2ipnCrf71uK/8FILcdgnpagCvEPqYuxIG+wAU62rd X-Gm-Message-State: AOJu0YxNDkCzyDrkU6+0fj/a1KpzZMv3DUABrIahv1Yqw/1jx/EOGtB1 fCSvbftpsqcpCpn/E8sTG51ZgOZ5I7DOTK7u5O2JL/1sABkY6OlSumqGlPjiiICp3p4yM3HqJb3 ZEQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:11ce:b0:dc7:4b9:fbc6 with SMTP id n14-20020a05690211ce00b00dc704b9fbc6mr968233ybu.10.1707280106249; Tue, 06 Feb 2024 20:28:26 -0800 (PST) Date: Tue, 6 Feb 2024 20:28:24 -0800 In-Reply-To: <165f07deb8d1e082756e6cae21a25b0060c18f85.camel@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <19a1ac538e6cb1b479122df677909fb49fedbb28.camel@infradead.org> <165f07deb8d1e082756e6cae21a25b0060c18f85.camel@infradead.org> Message-ID: Subject: Re: [PATCH v3] KVM: x86: Use fast path for Xen timer delivery From: Sean Christopherson To: David Woodhouse , g@google.com Cc: kvm , Paul Durrant , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 06, 2024, David Woodhouse wrote: > On Tue, 2024-02-06 at 18:58 -0800, Sean Christopherson wrote: > > On Tue, Feb 06, 2024, David Woodhouse wrote: > > > On Tue, 2024-02-06 at 10:41 -0800, Sean Christopherson wrote: > > > >=20 > > > > This has an obvious-in-hindsight recursive deadlock bug.=C2=A0 If K= VM actually needs > > > > to inject a timer IRQ, and the fast path fails, i.e. the gpc is inv= alid, > > > > kvm_xen_set_evtchn() will attempt to acquire xen.xen_lock, which is= already held > > >=20 > > > Hm, right. In fact, kvm_xen_set_evtchn() shouldn't actually *need* th= e > > > xen_lock in an ideal world; it's only taking it in order to work arou= nd > > > the fact that the gfn_to_pfn_cache doesn't have its *own* self- > > > sufficient locking. I have patches for that... > > >=20 > > > I think the *simplest* of the "patches for that" approaches is just t= o > > > use the gpc->refresh_lock to cover all activate, refresh and deactiva= te > > > calls. I was waiting for Paul's series to land before sending that on= e, > > > but I'll work on it today, and double-check my belief that we can the= n > > > just drop xen_lock from kvm_xen_set_evtchn(). > >=20 > > While I definitely want to get rid of arch.xen.xen_lock, I don't want t= o address > > the deadlock by relying on adding more locking to the gpc code.=C2=A0 I= want a teeny > > tiny patch that is easy to review and backport.=C2=A0 Y'all are *proabl= y* the only > > folks that care about Xen emulation, but even so, that's not a valid re= ason for > > taking a roundabout way to fixing a deadlock. >=20 > I strongly disagree. I get that you're reticent about fixing the gpc > locking, but what I'm proposing is absolutely *not* a 'roundabout way > to fixing a deadlock'. The kvm_xen_set_evtchn() function shouldn't > *need* that lock; it's only taking it because of the underlying problem > with the gpc itself, which needs its caller to do its locking for it. >=20 > The solution is not to do further gymnastics with the xen_lock. I agree that's the long term solution, but I am not entirely confident that= a big overhaul is 6.9 material at this point. Squeezing an overhaul into 6.8 (an= d if we're being nitpicky, backporting to 6.7) is out of the question.