From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43F3037E2ED for ; Fri, 24 Apr 2026 08:49:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777020561; cv=none; b=ZUCOmPxXCxPI+E5KPIPcPOKpZ9x9v9yOo9Nza4cDkGNyPlJCd2JBc5C42mtw0cnBX4UAXuA2j4ihADDL6kIVvrlXvDBuq/rQWo/9kS4LefRTcH2oywdUd6pYWHp+23wdeTZDNTjw+G6TgJFpvATDr5dr+0zN0nw6CUvhypcWGXE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777020561; c=relaxed/simple; bh=Z/tTC496ywitVhvJ/ad7HqkXUo6IunUgRhcenzo55AU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bpskUr26N+6vNqo7FMjm2IITC/ucuh8K0s6YJtn3CNu7XXsuP/RovGeX0BBTvwlOhcbx9D1O77KdwlPzSQLuZhbqPZVX4jCtYojmXxWXRdYxGzZC9zPVsj5wPFzIswrNS4t9frvYrc/owokjSuOFub3AF0DAdFrFtwWmzS5IYMI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tabba.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=luBy/Wxs; arc=none smtp.client-ip=209.85.221.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--tabba.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="luBy/Wxs" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-441243ba35fso3073804f8f.0 for ; Fri, 24 Apr 2026 01:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777020556; x=1777625356; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=tqPUzeIZ3aoS8p3NlrhVF5/x2KSp4t36eDNrPTZ/mqs=; b=luBy/WxsU7kH2VBWKU+u30hQ/mEtrFgmVo5Z0ouPbCaaBBWuP9alQdyR1nceUfLrTt VNd4dOO7NGNtn50UowKsEcJbCbChDFrs8ntMXOFfRAefsOz39MYqA221XrJhiMo0x8ZF +sMZR9TtlgbTZ6b1njtq0iyaw2gHQqxl7Rq1pCO1xFUuDccpUKXu6qRrtRrj4NiIiwmx j4+KWublenCDxhsPTnmUYIBIw48ZaqZcxi248HQ2okuwp/+GwiYebgW1IQRJcVaYCAih zc32CT8K5kqvFvZgZKvU3Rbo69awQzg0QZY9RI5Jp+ttJd0BFvDA0LniGjH7AJlrqhKm yPMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777020556; x=1777625356; 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=tqPUzeIZ3aoS8p3NlrhVF5/x2KSp4t36eDNrPTZ/mqs=; b=PcFeOYes/PU1zVOZZJglWxBfe88rZTQHbourvniMyOjrlUn3WTsf/0Prkurb/Hjy41 BjqEiLRPiDmd5gKaRjG/tG3zdrfVoM6aM5WgxMo7Nm1vwqWdSvPMES7gjXr+3r27Ore9 uPSBuQL+elm5pklStEx8LXv5NyhiPvUPTvWo2Ynz00r+NohnkCLZ5Nk0ve+WS5TUg92f N5kaVjx9lmwnpKolNNW7O96LIV52P0wf5qNfcXRFFKHQImWyOiGdQEEpxJ3oh5H2OXLH qg8GcyapG7OEvCfEPRDVZwhtemNM9b1lIL7ENo0SmjOXA+pLtNQaZ7efUUZBc49aA99l 8WCQ== X-Forwarded-Encrypted: i=1; AFNElJ/3ipeNzilbv+NxEnnO5je/wA5Lot1AyEvGeJ1HaLn1PhNI/aVG+zSY3D4csqWdmJ1Tn1F6ml+9mgNk/54=@vger.kernel.org X-Gm-Message-State: AOJu0YzqQU6F8uhzSVfrIzI82hW/LiJ5hdGA66KFY2fdX7jQGy0TZ6Yd 10gqvNgFsVk5M70H0FtkB4aR2RJ9GAFXRcRwwkXL0qDX2MSrVVkQMyXtF4h09caVD0urYhZEdWE f3Q== X-Received: from wma12.prod.google.com ([2002:a05:600c:890c:b0:485:40d2:1ebf]) (user=tabba job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:c090:b0:488:c744:49b with SMTP id 5b1f17b1804b1-488fb74a53dmr326821365e9.7.1777020555512; Fri, 24 Apr 2026 01:49:15 -0700 (PDT) Date: Fri, 24 Apr 2026 09:49:08 +0100 In-Reply-To: <20260424084908.370776-1-tabba@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260424084908.370776-1-tabba@google.com> X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260424084908.370776-7-tabba@google.com> Subject: [PATCH 6/6] KVM: arm64: Fix initialisation order in __pkvm_init_finalise() From: Fuad Tabba To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: tabba@google.com, catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, oupton@kernel.org, qperret@google.com, suzuki.poulose@arm.com, joey.gouly@arm.com, yuzenghui@huawei.com Content-Type: text/plain; charset="UTF-8" From: Quentin Perret fix_host_ownership() walks the hypervisor's stage-1 page-table to adjust the host's stage-2 accordingly. Any such adjustment that requires cache maintenance operations depends on the per-CPU hyp fixmap being present. However, fix_host_ownership() is currently called before fix_hyp_pgtable_refcnt() and hyp_create_fixmap(), so the fixmap does not yet exist when it runs. This is benign today because the host stage-2 starts empty and no CMOs are needed, but it becomes a latent crash as soon as fix_host_ownership() is extended to operate on a non-empty page-table. Reorder the calls so that fix_hyp_pgtable_refcnt() and hyp_create_fixmap() complete before fix_host_ownership() is invoked. Fixes: 0d16d12eb26e ("KVM: arm64: Fix-up hyp stage-1 refcounts for all pages mapped at EL2") Signed-off-by: Quentin Perret Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/nvhe/setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/setup.c b/arch/arm64/kvm/hyp/nvhe/setup.c index d8e5b563fd3d..d461981616d9 100644 --- a/arch/arm64/kvm/hyp/nvhe/setup.c +++ b/arch/arm64/kvm/hyp/nvhe/setup.c @@ -312,10 +312,6 @@ void __noreturn __pkvm_init_finalise(void) }; pkvm_pgtable.mm_ops = &pkvm_pgtable_mm_ops; - ret = fix_host_ownership(); - if (ret) - goto out; - ret = fix_hyp_pgtable_refcnt(); if (ret) goto out; @@ -324,6 +320,10 @@ void __noreturn __pkvm_init_finalise(void) if (ret) goto out; + ret = fix_host_ownership(); + if (ret) + goto out; + ret = hyp_ffa_init(ffa_proxy_pages); if (ret) goto out; -- 2.54.0.rc2.544.gc7ae2d5bb8-goog