From patchwork Wed Dec 15 16:12:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12696305 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 E042DC433EF for ; Wed, 15 Dec 2021 16:30:32 +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:References: Mime-Version:Message-Id: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=LLoVFpI5Lkw0vCze/fcBfFWeWMVq1MIWkMsxIg8WGOw=; b=C0DClYj14+QKusgod5RqwKLXUf Z2UzlXWfsi5a+2St5jFj7CdVAx4rFaWQCZV4oEFdKh8W59HkSPZL+7Tco46/5ptWmtfOwj+F5uODy GzNNpfTHx37LSExivk1EidOlAGaJvh9EUjwACH6IDgFo2seS/csNxVwvQcVwrhLidH7peofl+mxBq uJKWK4uyoEHC4oB7k0/2H3JretRbxV3lTl4MF2W4fEVlbEMWmXQdxuNycUzGyKFEmsTI0o7Uo44Nt /sFRwN5/i6NYNgt4yexXC2ImVGKZTNam7NbMDu05h8jFQMb6IpL9/vb2DvXliJruaSEFszLepE9G8 XIx2rzwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxX9A-001iYc-OK; Wed, 15 Dec 2021 16:28:53 +0000 Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxWtz-001cCC-IP for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 16:13:13 +0000 Received: by mail-wm1-x349.google.com with SMTP id n31-20020a05600c3b9f00b0034440f99123so2247050wms.7 for ; Wed, 15 Dec 2021 08:13:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=8rgSQfxqCRM7uaw93tRPVu2i1VyDlU+SgH6AjdwelFg=; b=oL/4mToqyjfnEM6iyT67/BqZZr2PNLhiYQmR5ckr4IxYAMm3DJ8qXK8tH50bG1H1m/ vRkewaRsNmYjaDXv7YrXRz5/gziGd7MhVs8Mhinsx5SvjCflWGkam/TtMjX3Z++skB00 mruR2m7aZDYO9w3PkO3k2QmQKHrfBeUsyKS4zwIOQ7k491fnzDsEEcIJ12VpQB8r32sY JygdFvcfEU4MjPLHsd4oSD1/xBooRBb9m7s7Tt5nyCGm3S7W3rsmxZr5xl6Dw832HU1d ZS1OMoGsa1TLOGXwEo3GKHhFA9Q7xYLD1FNoNEikntrurFNYroaXlmDvYvmz+Br7YqwS 9OVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=8rgSQfxqCRM7uaw93tRPVu2i1VyDlU+SgH6AjdwelFg=; b=KXZBbJxsG8unkIvXZ4Ty1IMfODNkA7q7736wnYe1kxHHUwrRjDnYGiXTMIHKII/yd7 bFB1p/cKCq1ldkAoiCI5UaVt5ATkdqCeXF2d8+9ARdTdQtmvh59InNbwfCMiqk6qjtgA 5gF8P0lN1+JkPPnBAvlJeiM+LPMrM6NWO6SB4Q+L3E0AREwtp9UU1GMlH+lrggj6Q/Ya 6nJQ/dtBATombFlggjxhz0tgM1lC8gMu5ryOeTVWLloMbpvUhR2XzTk2kJtItU+V4cn4 Eq1hD7Euw2u8mdRwJ+WFVKQ0kNHmsRZjictepEKTVjYhWZ49PJ5hw2CdgZCnFmpZAYI2 MLqg== X-Gm-Message-State: AOAM531rErlpEglvQwIzngSO2/2vrQJeb7kNMVkXaDFHUN9NPZvywCIC Sk0T9lO7UFLjtOvEOMzP+Cm7/nVRcW44 X-Google-Smtp-Source: ABdhPJxXvEycf99ECGUzXgk4Cq7sONC0HLtF5x7Y6YaPQ6+CwNHwdN/fgrDRTjcwDTjmSjH4G+ePR4js0bD1 X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:fc03:4f5b:4e9b:3ec1]) (user=qperret job=sendgmr) by 2002:a05:6000:168e:: with SMTP id y14mr4991297wrd.331.1639584789556; Wed, 15 Dec 2021 08:13:09 -0800 (PST) Date: Wed, 15 Dec 2021 16:12:25 +0000 In-Reply-To: <20211215161232.1480836-1-qperret@google.com> Message-Id: <20211215161232.1480836-9-qperret@google.com> Mime-Version: 1.0 References: <20211215161232.1480836-1-qperret@google.com> X-Mailer: git-send-email 2.34.1.173.g76aa8bc2d0-goog Subject: [PATCH v4 08/14] KVM: arm64: Extend pkvm_page_state enumeration to handle absent pages From: Quentin Perret To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon Cc: qperret@google.com, qwandor@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kernel-team@android.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_081311_820251_4661FCCE X-CRM114-Status: GOOD ( 11.71 ) 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 From: Will Deacon Explicitly name the combination of SW0 | SW1 as reserved in the pte and introduce a new PKVM_NOPAGE meta-state which, although not directly stored in the software bits of the pte, can be used to represent an entry for which there is no underlying page. This is distinct from an invalid pte, as stage-2 identity mappings for the host are created lazily and so an invalid pte there is the same as a valid mapping for the purposes of ownership information. This state will be used for permission checking during page transitions in later patches. Reviewed-by: Andrew Walbran Signed-off-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h index b58c910babaf..56445586c755 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h +++ b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h @@ -24,6 +24,11 @@ enum pkvm_page_state { PKVM_PAGE_OWNED = 0ULL, PKVM_PAGE_SHARED_OWNED = KVM_PGTABLE_PROT_SW0, PKVM_PAGE_SHARED_BORROWED = KVM_PGTABLE_PROT_SW1, + __PKVM_PAGE_RESERVED = KVM_PGTABLE_PROT_SW0 | + KVM_PGTABLE_PROT_SW1, + + /* Meta-states which aren't encoded directly in the PTE's SW bits */ + PKVM_NOPAGE, }; #define PKVM_PAGE_STATE_PROT_MASK (KVM_PGTABLE_PROT_SW0 | KVM_PGTABLE_PROT_SW1)