From patchwork Tue Oct 19 12:12:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12569749 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3191C433EF for ; Tue, 19 Oct 2021 12:19:03 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 761FF61360 for ; Tue, 19 Oct 2021 12:19:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 761FF61360 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=T/kXQFGsRTRKr/Nc9clUCKzQDcIzHv+BEdIb18pGZYI=; b=JYR8wMo0OrqChIRTesTwh6LBKf stDx/d6rEu0fmdCGItK/IdWJq3ANEWr8mFMV2up1i9o//67znGzzxar5x4RkpheCqIOcM5bz2NChf 3AA6Pt9pKvAXMxwi7//wj5wjMFCcouYD7RXGGHegMNScY5oHIQhAd8zUHFD/ILS5BLTO3ZqeaIyAC olV8j72VMd7lBnxezXv24F2RVDsqWpXtB+mh6tKQyVDf73CHK07+Xjn5bIxDJAVBwzI3iCq70upQz URGPcrDhqRJGYBEyS9FqibzA+snf+sxDkIrb7EKjRTnmKDR9seewyPXVIv2uVnPvWJzwDjlgxqGTC pp+jx+kQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mco3V-00179m-JX; Tue, 19 Oct 2021 12:17:22 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcnzl-0015Hw-Rp for linux-arm-kernel@lists.infradead.org; Tue, 19 Oct 2021 12:13:31 +0000 Received: by mail-wr1-x449.google.com with SMTP id r16-20020adfbb10000000b00160958ed8acso10048963wrg.16 for ; Tue, 19 Oct 2021 05:13:29 -0700 (PDT) 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=lFnO3V1vcCaxCQp+VktMJcKCn5jbqprlvSckwnNsC2I=; b=UesM75tSQOr45py6fmGldxnFZ9qhEpvDJtfc4apxLzl+vaSpskjZwXcD+vvH4lZb71 As8F+7i1zzMOpoNT7YUGxMUVpiB8c0NDcbRvtlAROdU3IQYsujSlMzJLH9nvz+6DLVHK vJRzQS7wBFHQO3YkY6Xec9Pwo6xYZSj30VNWKHbaOabamzLvVtuZDneBjv1pLT8mGCYX DcoRFa8C8Iwqa1uNt0xjG6wxks4HeuMis1JBBY2eEu5k9YvLWHzHgOOhKtYnx5KcDzGR +xuNnU1Xky1kYEkg3hTbTL4NVyJOzh3NB457XGrqSEC0sX/d9IlZuLvuuYTnTBcm4Y1m ZRwA== 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=lFnO3V1vcCaxCQp+VktMJcKCn5jbqprlvSckwnNsC2I=; b=D0z9KovJkQCxeDmlnPwMLq9LfC1cWBA3HUz0E5QZwya6UxZlME/c//nKE7qYS/MWMB t/2EDUSaOsy1+Xju7UsALZEx956dTEF/K94U4JFopu+v6kasXz2IIHTmUFIWjcnO4DY8 T0l6xWvoP6fgVWBph1DSQ8rCsF824nDKSV2AEj2Wb+iGTln8+yhPnuL/EaO6d9Y+H9r1 28FiQ9hN9ZgG7g+iuzHjmFDrcIzCpTw87ozHj2zWoLYEqWVbtNc3UtOtxLTlgo6oVYFU 7c+JIWL/pBX8V6RmE8rEMG1kOAc3SYq3eP+77Uy8+KlccgR1Mw/IJ7FX88VbVWG3DGPr NqvA== X-Gm-Message-State: AOAM532xfy6dXYRkQUgdIMp4ZAmU/MElYoSaKBmuVlWOF7ZaNRENmjqC RSEg248ANA0IU0ty4yTb3RlG7ml81dDV X-Google-Smtp-Source: ABdhPJzM8Yi1zkltqsZIknAWVlvpJd+76GDP3lU7clYj1DZGyxNzgbxFRtOLXsCPKmvrYy6VEEMSHUHhKXXR X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:59ca:401f:83a8:de6d]) (user=qperret job=sendgmr) by 2002:a7b:c441:: with SMTP id l1mr5486888wmi.69.1634645607924; Tue, 19 Oct 2021 05:13:27 -0700 (PDT) Date: Tue, 19 Oct 2021 13:12:58 +0100 In-Reply-To: <20211019121304.2732332-1-qperret@google.com> Message-Id: <20211019121304.2732332-10-qperret@google.com> Mime-Version: 1.0 References: <20211019121304.2732332-1-qperret@google.com> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog Subject: [PATCH v2 09/15] 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 , Fuad Tabba , David Brazdil , Andrew Walbran Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kernel-team@android.com, qperret@google.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211019_051329_944663_F5FA4722 X-CRM114-Status: GOOD ( 12.58 ) 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. 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)