From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68675EB64DC for ; Mon, 3 Jul 2023 16:03:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=V80IyTQi8p/yh6rcpaqZhaOKvGSayx9oZXkLiHe59bo=; b=lbdA+jcOqP80Of jrWlh29s7pia8nlRsFx+QUzNCVNZUQpgyjj/yQzHB2aQZnSRNDppZkCAbnkT89UjWN9yNvLzkxZDI 8DTGj5Ez9bwAS9jP6oGQuSKeh7Lt8b4sYQHzDu50LIT+96XoUpaUL3d4t45qOnpyNmNY4ynpO8BAI +Prm4jdOMEZwyMNolt6QEGQkN+kzqA3f6JE7/HF2yWLxuUpsKwQKw5ogEIdg3SWr8xrtGpilFA60E 6WNv5PR/mubVOHqBOy/NskL6Y06aK/Tqrp9jcYkm3RY8SWoXUuzusQtfq2mGC8+gPQnv3W8qR8vlR f6sgsHCvDsDXbnxJ7mpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qGM0d-00AvZy-08; Mon, 03 Jul 2023 16:02:39 +0000 Received: from out-4.mta1.migadu.com ([2001:41d0:203:375::4]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qGM0Z-00AvYh-2l for linux-arm-kernel@lists.infradead.org; Mon, 03 Jul 2023 16:02:37 +0000 Date: Mon, 3 Jul 2023 09:02:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1688400146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=t/q11Yw81bm/OQ8HuX8KouOM2Sbe1q7F70O7dTD8tWk=; b=n0UBZalHMSH9Zt+sjj5oFszZ60fJ5A1RcL5+NKTaXxXKRJvKI2yn43eca4vpIAnmQFew4Z Su7HoAzWXjeyP0A6GCAQPmVTRdclx0pdGkcaFFcuD2LCtjjPyRZoK8nEJmitu1jp3LZHeU GkDalD/fnx3kZNp18qPreh54joSHz5A= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier Cc: Kristina Martsenko , isaku.yamahata@intel.com, seanjc@google.com, pbonzini@redhat.com, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse Subject: Re: KVM CPU hotplug notifier triggers BUG_ON on arm64 Message-ID: References: <867crhxr9l.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <867crhxr9l.wl-maz@kernel.org> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230703_090236_066130_96DD6D8D X-CRM114-Status: GOOD ( 26.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hey Marc, On Mon, Jul 03, 2023 at 10:45:26AM +0100, Marc Zyngier wrote: > On Sat, 01 Jul 2023 18:42:28 +0100, Oliver Upton wrote: > > Well, one way to hack around the problem would be to just cram > > preempt_{disable,enable}() into kvm_arch_hardware_disable(), but that's > > kinda gross in the context of cpuhp which isn't migratable in the first > > place. Let me have a look... Heh, I should've mentioned I'm on holiday until Thursday. > An alternative would be to replace the preemptible() checks with a one > that looks at the migration state, but I'm not sure that's much better > (it certainly looks more costly). > > There is also the fact that most of our per-CPU accessors are already > using preemption disabling, and this code has a bunch of them. So I'm > not sure there is a lot to be gained from not disabling preemption > upfront. > > Anyway, as I was able to reproduce the issue under NV, I tested the > hack below. If anything, I expect it to be a reasonable fix for > 6.3/6.4, and until we come up with a better approach. Yeah, I'm fine with a hack like this. Do you want to send this out as a patch? -- Thanks, Oliver > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index aaeae1145359..a28c4ffe4932 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -1894,8 +1894,17 @@ static void _kvm_arch_hardware_enable(void *discard) > > int kvm_arch_hardware_enable(void) > { > - int was_enabled = __this_cpu_read(kvm_arm_hardware_enabled); > + int was_enabled; > > + /* > + * Most calls to this function are made with migration > + * disabled, but not with preemption disabled. The former is > + * enough to ensure correctness, but most of the helpers > + * expect the later and will throw a tantrum otherwise. > + */ > + preempt_disable(); > + > + was_enabled = __this_cpu_read(kvm_arm_hardware_enabled); > _kvm_arch_hardware_enable(NULL); > > if (!was_enabled) { > @@ -1903,6 +1912,8 @@ int kvm_arch_hardware_enable(void) > kvm_timer_cpu_up(); > } > > + preempt_enable(); > + > return 0; > } > > > > > -- > Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel