Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5890685pxb; Thu, 20 Jan 2022 06:41:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3EV6Z8loCn53rYNg8MsjYjZEklkuH+SXcnCE0DTt1huInZZTjIZCFC1CgjusspZy2rko7 X-Received: by 2002:a17:903:2309:b0:14a:4295:9ea2 with SMTP id d9-20020a170903230900b0014a42959ea2mr38810653plh.72.1642689666816; Thu, 20 Jan 2022 06:41:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642689666; cv=none; d=google.com; s=arc-20160816; b=mAMbDoIdZHeLVretQB/5YFQKJM7sJ7VS1Y4hGP0D3WdrJ1i/oB2oR59zYZtrCqk2Fg xQbP460ffjZXVkSxDzih2BaPJ7ZF9A9a7X7MzlHVct4LhKpRReoZArSugJ/ML2vLd+rA 2UOh3VOy4WAhkNPDeFS3ABkY1KBmjiCZbYD6VGo80IY/Zh9XO3dVCXPqUwjldLbqcusQ ITHfshVJJWSl+BEU9Wv0wA3YLp2dRKehSb9I7G2rRvRjTj9svUXmPowzrHRSEgEafXG0 2FFegzd9BS7UkwXk4nYIE8IY1q/S5Z13qi4k4LrVmhECODOLh5eikW9nezMlECxzCLUQ xeQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=/iYiRxdV8h8DCtfJwTs3F7t5VugwVF+0/gBuDQSHmFU=; b=UN0M/WDik40RWeGAvwnrx+ADgLfOeGYMcVYmOlEyZtx+ZBDQvpSmG/M66b9FrQDLcN TLGnHlkNOK4R2CqzX0+xKPgUbecoYvmZmUB1IyQjYrwnNjPQ7SHPQ7aa3OHtGd6Uop8P iR+fKlbivcvTWvOJec7XoSMKMPlUBORwROpKV9H/gL5cNZtJK+GhyUp4tFu16IjxmeMK 6lXNs5F/Juv2W5I4kd6FTSXsNLhP9UwN3jz0q2Puor+ohSf7ZMCYO3vzZyEtE2cO7Csf WDsDinun2S8q1f9dDqkzre5mcfBiSy/YI7s0osSyveW+bmoRjVVWUp/vRmPxVOcZxE9k ggyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch22si9604007pjb.169.2022.01.20.06.40.54; Thu, 20 Jan 2022 06:41:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345944AbiARPnj (ORCPT + 99 others); Tue, 18 Jan 2022 10:43:39 -0500 Received: from foss.arm.com ([217.140.110.172]:59762 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236135AbiARPnh (ORCPT ); Tue, 18 Jan 2022 10:43:37 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0D2DA1FB; Tue, 18 Jan 2022 07:43:37 -0800 (PST) Received: from C02TD0UTHF1T.local (unknown [10.57.37.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1BA3A3F766; Tue, 18 Jan 2022 07:43:30 -0800 (PST) Date: Tue, 18 Jan 2022 15:43:28 +0000 From: Mark Rutland To: Christian Borntraeger Cc: Sven Schnelle , Heiko Carstens , linux-s390 , Paolo Bonzini , linux-kernel@vger.kernel.org, aleksandar.qemu.devel@gmail.com, alexandru.elisei@arm.com, anup.patel@wdc.com, aou@eecs.berkeley.edu, atish.patra@wdc.com, benh@kernel.crashing.org, bp@alien8.de, catalin.marinas@arm.com, chenhuacai@kernel.org, dave.hansen@linux.intel.com, david@redhat.com, frankja@linux.ibm.com, frederic@kernel.org, gor@linux.ibm.com, imbrenda@linux.ibm.com, james.morse@arm.com, jmattson@google.com, joro@8bytes.org, kvm@vger.kernel.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, nsaenzju@redhat.com, palmer@dabbelt.com, paulmck@kernel.org, paulus@samba.org, paul.walmsley@sifive.com, seanjc@google.com, suzuki.poulose@arm.com, tglx@linutronix.de, tsbogend@alpha.franken.de, vkuznets@redhat.com, wanpengli@tencent.com, will@kernel.org Subject: Re: [PATCH 0/5] kvm: fix latent guest entry/exit bugs Message-ID: <20220118154328.GD17938@C02TD0UTHF1T.local> References: <8aa0cada-7f00-47b3-41e4-8a9e7beaae47@redhat.com> <20220118120154.GA17938@C02TD0UTHF1T.local> <6b6b8a2b-202c-8966-b3f7-5ce35cf40a7e@linux.ibm.com> <20220118131223.GC17938@C02TD0UTHF1T.local> <77e8d214-372b-3f0e-7b4e-5c2d23a4199c@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <77e8d214-372b-3f0e-7b4e-5c2d23a4199c@linux.ibm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 18, 2022 at 03:15:51PM +0100, Christian Borntraeger wrote: > Am 18.01.22 um 14:12 schrieb Mark Rutland: > > On Tue, Jan 18, 2022 at 01:42:26PM +0100, Christian Borntraeger wrote: > > > > > > > > > Am 18.01.22 um 13:02 schrieb Mark Rutland: > > > > On Mon, Jan 17, 2022 at 06:45:36PM +0100, Paolo Bonzini wrote: > > > > > On 1/14/22 16:19, Mark Rutland wrote: > > > > > > I also think there is another issue here. When an IRQ is taken from SIE, will > > > > > > user_mode(regs) always be false, or could it be true if the guest userspace is > > > > > > running? If it can be true I think tha context tracking checks can complain, > > > > > > and it*might* be possible to trigger a panic(). > > > > > > > > > > I think that it would be false, because the guest PSW is in the SIE block > > > > > and switched on SIE entry and exit, but I might be incorrect. > > > > > > > > Ah; that's the crux of my confusion: I had thought the guest PSW would > > > > be placed in the regular lowcore *_old_psw slots. From looking at the > > > > entry asm it looks like the host PSW (around the invocation of SIE) is > > > > stored there, since that's what the OUTSIDE + SIEEXIT handling is > > > > checking for. > > > > > > > > Assuming that's correct, I agree this problem doesn't exist, and there's > > > > only the common RCU/tracing/lockdep management to fix. > > > > > > Will you provide an s390 patch in your next iteration or shall we then do > > > one as soon as there is a v2? We also need to look into vsie.c where we > > > also call sie64a > > > > I'm having a go at that now; my plan is to try to have an s390 patch as > > part of v2 in the next day or so. > > > > Now that I have a rough idea of how SIE and exception handling works on > > s390, I think the structural changes to kvm-s390.c:__vcpu_run() and > > vsie.c:do_vsie_run() are fairly simple. > > > > The only open bit is exactly how/where to identify when the interrupt > > entry code needs to wake RCU. I can add a per-cpu variable or thread > > flag to indicate that we're inside that EQS, or or I could move the irq > > enable/disable into the sie64a asm and identify that as with the OUTSIDE > > macro in the entry asm. > What exactly would the low-level interrupt handler need to do? Having looked around a bit, I think the best bet is to have irqentry_enter() check PF_VCPU in addition to PF_IDLE (which it checks via is_idle_task()), at which point nothing needs to change in the s390 entry code. I'm currently implementing that, let me have a go, and then we can see if that looks ok or whether we should do something else. > CC Sven, Heiko for the entry.S changes. I'll make sure you're all Cc'd when I send out vs with s390 patches. Thanks, Mark.