From nobody Sun Feb 8 23:03:58 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.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 2A10F306B21 for ; Tue, 30 Dec 2025 23:02:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767135736; cv=none; b=NZ2Vbk920O8vK7YG0I7Y/XWI70EhvFAC3NmgmGh01jXJsoNiSji52TXPE15goQsA2tjtYQujJSmXNXZTUMDnQBMlmFhTt7FqhRvrJy7xBH49ofAMANegjrYzmwRs8h4r7CtBIjkesWLSl91tyHYB/rzjuwWQUmUamSuUNGWPTmo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767135736; c=relaxed/simple; bh=2ZolxtbeL/TfZv1wuBul5eMq3hwecEq8h3mFaMWxBTA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=noNsK8YQhygkwcTHwOsJRxyMS18dPhPiz5azx92cEYyh3CkSfdkjKNQjrPmBbn+o117nfLtIS0RK6E2Yxd+Bvdss8mHaQfsdvi/hVftX26mO19PAkZepWhNhSQrmBRRXb6rNAYPntJ1C3lBeaTV2NFwBwcadQi47cRNEgIqqbi0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=A7rTKwVw; arc=none smtp.client-ip=209.85.216.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--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="A7rTKwVw" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-34a9bb41009so16720359a91.3 for ; Tue, 30 Dec 2025 15:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1767135733; x=1767740533; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=aempC3xup8zdxs82u0niExWKRbrEWWiY7rS3u4Pr19E=; b=A7rTKwVwsRCeC0uteG3QsCqrQL5vkk7PzZI2Sv1a0R2/DY5MO3fNN84Bm+k1Ga1X87 sG3MgvdCQ6aFgRopYw4JVEh0ns96otmmF+KyrKtsm4wCtGtWLdEODZoH5tnfP8MSy+EQ aCm4NyUDp8wougXheksx4Hhvhr2TomuR97XY1yLbJy+GC/5ibBxDTVACMvlb3hSyZQOE uZ7XcT87GUqgTjik4HDORNqwATaJloIEyOEzZKn4ktaoBJHY+SwrywpMT45R9PO8Ap7v XInNRUV/JeqfBmCt8oH+KM/0EJHbxyq8AtrxrX58b2FrK/CXoGYqJt6swbbOTyQkDlXg n1sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767135733; x=1767740533; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aempC3xup8zdxs82u0niExWKRbrEWWiY7rS3u4Pr19E=; b=goTwQBUC2L6xEuQaizi7r1BDeMSpUUNA+QBP73tUZeqDC0ecPoXYvqHGBTPBMGeD3U MnOpdsVEQWF30aN0IO7jID01ANdV5DTzlYiy1rvBwB+6kxIsLAOsYn8TlqQuKxmDuZxP Hz/s4HGZsQAj2LshUJapqUNQ+tGtEk7NPu9m6fqSuUoZjNlgKdakEIaCoBm9tjwbQ+QU FlXN7E5nlAyiUUirjG4qpd1+hJUZo0PCJHsYlLdbZ7Uztd3hiIA5uOQVKC/E2NJbS2+7 jTZeuSpSU97m+honSyOUzxsjShefglcOaRsgG36YIRNYF9OnnjcEKIwNZlMfFozVfItP zR0w== X-Forwarded-Encrypted: i=1; AJvYcCVCc38fuXRXqRAuOQULRpu8uQSQpQ9edsLm4AAIdu0WyxxMIUyFDj9nJxowqiPv66vmTd0+XdzaRvt16FI=@vger.kernel.org X-Gm-Message-State: AOJu0YwPTLN9KxSMciaQCqDkH6FRUDW+aH3XfQ/5dHW2wtdlIdGehZxo Ut3h6/yDTVaMbbmjTPqtq+BznyTY86c0qixOsZEejmzhwMG64tWvomJurfcrTVWFJKjPkHW6PKz g1xiOWg== X-Google-Smtp-Source: AGHT+IF1//ZF8YQZFDW338R6CLvvv/Jhm6bfFusPZNwPuigVsAoIaoiYhFuoR4zT4Z2vqbXSCzOrQaND/Kk= X-Received: from pjbpm1.prod.google.com ([2002:a17:90b:3c41:b0:34a:b3a0:78b9]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:52:b0:34c:94f0:fc09 with SMTP id 98e67ed59e1d1-34e92139d60mr28142377a91.10.1767135733534; Tue, 30 Dec 2025 15:02:13 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 30 Dec 2025 15:01:41 -0800 In-Reply-To: <20251230230150.4150236-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251230230150.4150236-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.351.gbe84eed79e-goog Message-ID: <20251230230150.4150236-13-seanjc@google.com> Subject: [PATCH v4 12/21] KVM: selftests: Add a stage-2 MMU instance to kvm_vm From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Huacai Chen , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Sean Christopherson Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, loongarch@lists.linux.dev, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Yosry Ahmed Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a stage-2 MMU instance so that architectures that support nested virtualization (more specifically, nested stage-2 page tables) can create and track stage-2 page tables for running L2 guests. Plumb the structure into common code to avoid cyclical dependencies, and to provide some line of sight to having common APIs for creating stage-2 mappings. As a bonus, putting the member in common code justifies using stage2_mmu instead of tdp_mmu for x86. Signed-off-by: Sean Christopherson Reviewed-by: Yosry Ahmed --- tools/testing/selftests/kvm/include/kvm_util.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing= /selftests/kvm/include/kvm_util.h index c1497515fa6a..371d55e0366e 100644 --- a/tools/testing/selftests/kvm/include/kvm_util.h +++ b/tools/testing/selftests/kvm/include/kvm_util.h @@ -116,7 +116,12 @@ struct kvm_vm { uint32_t dirty_ring_size; uint64_t gpa_tag_mask; =20 + /* + * "mmu" is the guest's stage-1, with a short name because the vast + * majority of tests only care about the stage-1 MMU. + */ struct kvm_mmu mmu; + struct kvm_mmu stage2_mmu; =20 struct kvm_vm_arch arch; =20 --=20 2.52.0.351.gbe84eed79e-goog