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 935CAEB64D9 for ; Mon, 10 Jul 2023 22:14:10 +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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Ph8kAwL+ssVRVU8k2XTkibtdfXQPY4FjZ8frMhmOLw4=; b=ZgUZrfkVajDVotifpT0gbPYUts wMcs71yxErZHD+UAT5gIsJLMyyyngqppG/bcJd5DX6LI8SC0Ex0inT09z9Ww/RoeYimR66o/Z+j56 VBNL6kdb/LGppXVf77/klhW4wzevtqNkzTYS+BXCYrOFOeEOczM9mTL6pXMBLOr51BxFinkdOmKgA GEAfGCUR0aAHdlUVC2s6CoxDvgLp5XAjK4L3N5iduN72oBauP6l3CvsjpLSeKx73aM4qf+bL2X1mp 78XDl1UuCFE7iuo7SYrfGsCdMHXLRonmjYtn6kz7nSGAp3nJLNKoJlsEBZ1Itdj/ljWIeUdOo93om 3kOBl0xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qIz8V-00CpkB-2B; Mon, 10 Jul 2023 22:13:39 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qIz8R-00Cpj8-2e for linux-arm-kernel@lists.infradead.org; Mon, 10 Jul 2023 22:13:37 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-c78d98b0213so2756915276.2 for ; Mon, 10 Jul 2023 15:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689027212; x=1691619212; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=VhyuhUu7ArHYZFjkYslfHWi7GXr3zNNFUwoXSJr15Gs=; b=STVcaaR6HH1MmFncFyTKauvrHE7UvRNbNSVW/i5IKGtGvhl2UQnGE0vFR8gJ66Uk2c pWD9/7AWt0Iqe8hrimzxYspFm62Tpuf0XaR47UwByAWC2rQ0T6kPQCe8oLGEGk2MMwkv rBmWDcKgO+1vIm/903NAi1T6/+F83sjnYUCBHkfmOJZxODUEirpiNccdSuOM2hW0217K OlU7wM3kxncMAm2W+HP6uuGbfTIlJjhGRCFIXTnESPbtqbxag+pdinbQYT2Zj96mVyvK gugeJt7F2/3TjWMxVge86PJm6T+A3+F3MQhVXNhtRqdv1t9Vs+Kv55CAEUsXVZc2WS7i fOKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689027212; x=1691619212; 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=VhyuhUu7ArHYZFjkYslfHWi7GXr3zNNFUwoXSJr15Gs=; b=FJm6KRHxfWRFGk1XEsRzfCHBw0NXsTVz/nElxvGm6PMrN1w+1MK4sexQdhIGcKW4DX O40hTtHnf8NvSiLdyTQSx/7BMGQmQmmRy0pBeQGJk1AQydOPAiqwtx9NA4bRtoY+GCKt JEErtLuRjm83XFQIUvpXiluuhuc5Eb/eoed93eq2yi4A1RjjgFiP3djUOAvXcl0Smyl/ PFhItZZ8cSZzMToxcDXZmZYOGVoY97RJ85+o9mW7bqUb6wGfucaHesj0EEAVw0wjOHAG /4d5XRhZb/bVXS335DAcF0tf4AGipnWhFqXgvimFi+Qtz2J3GJEFTS9Cuba6rk9uq3T7 gn/A== X-Gm-Message-State: ABy/qLbPHSOUScOnR8mz10C3qJtHYXMBjFpgB8lYEBW+38A8waQxQEhD te2zLNHJpawGxoFWB2a2xzXmX2uLBQo= X-Google-Smtp-Source: APBJJlGicNB3k+jdZ6LQfesOWoW0KcNW9IGPTA9A/vbsEkgluZUxiXkGaHoqNIMT3Y4Zm0AQCJca26jhABo= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:c05:0:b0:c70:d138:51b1 with SMTP id 5-20020a250c05000000b00c70d13851b1mr42859ybm.12.1689027212157; Mon, 10 Jul 2023 15:13:32 -0700 (PDT) Date: Mon, 10 Jul 2023 15:13:30 -0700 In-Reply-To: Mime-Version: 1.0 References: <20230703163548.1498943-1-maz@kernel.org> Message-ID: Subject: Re: [PATCH] KVM: arm64: Disable preemption in kvm_arch_hardware_enable() From: Sean Christopherson To: Oliver Upton 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230710_151335_868532_D68CE498 X-CRM114-Status: GOOD ( 22.06 ) 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, Oliver Upton wrote: > 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? Sorry, should have phrased that as "should be fixed". > > 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. Ah, "we" is all of arm64. E.g. this pattern in arch/arm64/kernel/cpu_errata.c is splattered all over the place. WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible()); AFAICT, the only issue in KVM proper is the BUG_ON() in kvm_vgic_init_cpu_hardware(). Sadly, a hack-a-fix for stable probably does make sense :-( _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel