From patchwork Mon Feb 12 14:47:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13553377 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 AEA81C4829B for ; Mon, 12 Feb 2024 14:48:07 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TWnAdQWkDMzLBPzjEZq674M42cS6FAUoLiYnyf2fvKU=; b=wFUw8ltpOeIo3q arB0dtuOiv5FizfhjbapSavoJcARx3esPClsS7V7L90HcmvMczAeM+GrjyGEXup7w2OYCZfXMotWd tlpFOfWlBKPMUfpNQ3+KlCMXM37CwAnAGH9iYXHw3Owek2S/dVXgGHeceg+KhV9dM2alYf1CTam9s cV7wB+UjiagVEeApPMqrM8oQ/2MgVxrXCZYOl3QMytNyQUtUikDZyndUkWWyyl6fuevzygTjmGL7R yE6mRwwXQi6L26skXOREruj2c8TZszLQaQYMpzAET4K7M8nkBV74b+Tihl/px+voZSHZCO4N5g7Tu eoUOvQkUGlqPksHtt5MQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZXbA-00000005qGE-24M5; Mon, 12 Feb 2024 14:47:56 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZXb7-00000005qFM-3vsp for linux-arm-kernel@lists.infradead.org; Mon, 12 Feb 2024 14:47:55 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4A41360AC9; Mon, 12 Feb 2024 14:47:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0E6AC43399; Mon, 12 Feb 2024 14:47:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707749272; bh=e2C7pn2jEG5y+mAGuphlZridsZxMj3//yLEbi5gFAnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JbtkfR5CeQ4t6M7uN+V3IeG/JQPymb4VhfrnKlHy6Pyk5RE8xJsasB6Csp7BOwfaO WXDhFLUO0MTDS/W1+efQq6tNeq3QvSUPhIlc20y6PPevgqxvBxfdXV44aG2qgGEYnt q8x0s674ORBQ25NYVIk363iSvp5ERnYAhN1N+nlkoGZhNXsDUJc9Wh+nyInBalnPPJ Lqm+zSGUdeINdUfTFGRvktow0BYqLyDL8k7r+anEhJyDjkyedZ3jwQcRAqmgOWxjYi 15fg5C9a5mfLW7YWGpwY6vC4oRZOL1oupsfDblyduP1jR+l4npZ1LVEiRWrMkcfq4A HdBqmmWG3QyBw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rZXb4-002SFp-K9; Mon, 12 Feb 2024 14:47:50 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Catalin Marinas , Will Deacon , Marek Szyprowski Subject: [PATCH 2/2] arm64: cpufeatures: Only check for NV1 if NV is present Date: Mon, 12 Feb 2024 14:47:36 +0000 Message-Id: <20240212144736.1933112-3-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212144736.1933112-1-maz@kernel.org> References: <20240212144736.1933112-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, m.szyprowski@samsung.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240212_064754_050699_BECDAC19 X-CRM114-Status: GOOD ( 11.23 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We handle ID_AA64MMFR4_EL1.E2H0 being 0 as NV1 being present. However, this is only true if FEAT_NV is implemented. Add the required check to has_nv1(), avoiding spuriously advertising NV1 on HW that doesn't have NV at all. Fixes: da9af5071b25 ("arm64: cpufeature: Detect HCR_EL2.NV1 being RES0") Signed-off-by: Marc Zyngier Reported-by: Marek Szyprowski Signed-off-by: Marc Zyngier Reviewed-by: Suzuki K Poulose Tested-by: Marek Szyprowski --- arch/arm64/kernel/cpufeature.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 2f8958f27e9e..3421b684d340 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1812,8 +1812,9 @@ static bool has_nv1(const struct arm64_cpu_capabilities *entry, int scope) {} }; - return !(has_cpuid_feature(entry, scope) || - is_midr_in_range_list(read_cpuid_id(), nv1_ni_list)); + return (this_cpu_has_cap(ARM64_HAS_NESTED_VIRT) && + !(has_cpuid_feature(entry, scope) || + is_midr_in_range_list(read_cpuid_id(), nv1_ni_list))); } #if defined(ID_AA64MMFR0_EL1_TGRAN_LPA2) && defined(ID_AA64MMFR0_EL1_TGRAN_2_SUPPORTED_LPA2)