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 0D263EB64DC for ; Mon, 10 Jul 2023 18:20:49 +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=RsLHw5RpocLm9HP8uaz2bJRAzj5LgtSN4/t56lHkCEo=; b=EcDKOtvow2JJi8 4fDDSYDvjkd2XHGLF2ovB9gARQC6gJ48kBuDzVTcOsjQxBn1c62qIhkmfLAmSMSNxktcOlQCAMmCv cu3r0TlIXDuRmAT/tY9ADZ9WYs3k84jdcdqw/348HzfrvyLMHANpBm67/kSwhQN8ijTCMHYDM39vE u+gNZmsRmLhtgZreCvX6vv/DuNATk/k6t9lWO5U0MVeC1nOf7QO2ooWd/lCGJINezqQUQfBBdPzgd InQEDCBeAvC4+m1fKT4JoPOJIuCyhjCoHLczU8FGCgxaWrxDnhYxploDf0W7qfsLQUEolTTSBUgCA hVcwTNEEkTS1AkMKCkAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qIvUh-00CRbq-1K; Mon, 10 Jul 2023 18:20:19 +0000 Received: from out-44.mta0.migadu.com ([91.218.175.44]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qIvUd-00CRZi-1g for linux-arm-kernel@lists.infradead.org; Mon, 10 Jul 2023 18:20:18 +0000 Date: Mon, 10 Jul 2023 18:20:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1689013210; 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=wNcS4LcXjclyiMnp2lcR18guJknTcpMsuoMft6tKMEA=; b=RU4KVaAw3Efkc7dyApbjO+sTH6Da8PxYZGerahiVixKa+H69hg5zx88ni2oDstRBqIRuL9 HbEvG5Cpb/4FJagudsdHmOlaCzXxowVs5trw7H3Ud049AhvT+baF+FxrtNnirqHb6HuPcB 7CcHiWHHJ40HYDPS1HAcg/k2k7oaxwo= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Sean Christopherson Cc: Marc Zyngier , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu , isaku.yamahata@intel.com, pbonzini@redhat.com, Kristina Martsenko , stable@vger.kernek.org Subject: Re: [PATCH] KVM: arm64: Disable preemption in kvm_arch_hardware_enable() Message-ID: References: <20230703163548.1498943-1-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230710_112016_005744_6BA93CA9 X-CRM114-Status: GOOD ( 20.69 ) 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 On Mon, Jul 10, 2023 at 11:04:08AM -0700, Sean Christopherson wrote: > On Mon, Jul 03, 2023, Marc Zyngier wrote: > > 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); > > IMO, this_cpu_has_cap() is at fault. Who ever said otherwise? > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index 7d7128c65161..b862477de2ce 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -3193,7 +3193,9 @@ static void __init setup_boot_cpu_capabilities(void) > > bool this_cpu_has_cap(unsigned int n) > { > - if (!WARN_ON(preemptible()) && n < ARM64_NCAPS) { > + __this_cpu_preempt_check("has_cap"); > + > + if (n < ARM64_NCAPS) { This is likely sufficient, but to Marc's point we have !preemptible() checks littered about, it just so happens that this_cpu_has_cap() is the first to get called. We need to make sure there aren't any other checks that'd break under hotplug. While I'd normally like to see the 'right' fix fully fleshed out for something like this, the bug is ugly enough where I'd rather take a hack for the time being. -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel