From patchwork Wed Dec 1 17:04:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12694356 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 4945BC433F5 for ; Wed, 1 Dec 2021 17:09:03 +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=MdFkmrOatTo01WhLcL5nqtjoIAh2uykTaVXPVeCZln8=; b=hBItg0hEuV6exUggK/c5HqonWk xVDDc9wc7RvSdfAyRcx3ebOnnNcXgx2LUvf3M6ab+BInXl6TdTGOfARdOTHpzNVbChYYeI+VZUnA7 d86bJ3+Sd0yTOT1deMrcvO7iY0wUYRD7+yHBz1cw9IO3aUgKcoaSJdf1e104oUUwyLkbnipB2RVmW FQakT5JOWfMsLoy72USulthKuMVjXFck/3/7EZbD+IOOkvx1W+NPQBRnjPcnlD/vXJ9n73dkdjY9r Bf+2kZNtGDfke1NVosE0Wdq7Jk5/6QB5bekZEmcQRx6+7p+5E0jL5voUyNte5SmCktpkYnpIKwkIG sbuw6DLQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1msT4o-009THs-3i; Wed, 01 Dec 2021 17:07:26 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1msT2K-009RxW-5e for linux-arm-kernel@lists.infradead.org; Wed, 01 Dec 2021 17:04:53 +0000 Received: by mail-wr1-x44a.google.com with SMTP id q5-20020a5d5745000000b00178abb72486so4461467wrw.9 for ; Wed, 01 Dec 2021 09:04:51 -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=gP7Fa7oF1mk2VL/C80BdOcZ11ucSfvyvrK5tI2TJOao=; b=YIFEpSMiiphVp00kT4SqQiVFlCZjWeW7pHUFlPbzlz6LipVw2aWy7Rd6tb3JUzJM+3 QKIISnMlREKuRhzWfT+DUQt86OHAlAejeH8a+q5aOiFs7nF9U2+bewCuES5TKaRshu2s qH0lsFmh+oO1cw1jDqXHNIc8iZWQ2FkeeVNPRVURvz8RBrMKrSNdu28aFetakrGmqP// ult2AtCbkCkC9p4XjEbc6jcacWZURDLmr7Iv9xCzICqAYxduRH8LXhXBrpLmELev6Puf 5SG+5mVlcaSiNM5tx0UO0lC2C2y3/Zrd77xHXrAIHeEj5kfiRwqdzDjzXaSZxaueQr4u SamA== 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=gP7Fa7oF1mk2VL/C80BdOcZ11ucSfvyvrK5tI2TJOao=; b=Gv0mtXxNmdzoEcLn1pR6OK4WSU/WjWp5TGt8vf5s1UZj7/mDD0Mrl6aCQsrNGchiU/ Mn6T88Blz/mYQq6WEBMNlmVAEELKkqU2lkyipqIJ38E9TJvu8CKqT/8dRqJHxswPDWLH Wg3vyDOJpeuqDVDyMJ37D+w14+1qWzKMOqWFZctxDu99RdjpwgRSQjstpwPv7DOF8QBL pbqjKB4rOaUmU0bQ8J9ysZbLnzOPYWVTD1RtnZejpR4ondAouBcO0m/fpbOpjHQiwyEr xyZa5UBtWorIGRO1JipvzTNir0vlrFfiI4D9ZmmV63T1OdoSWt0B5g4NiuAXtR2zieyV n40w== X-Gm-Message-State: AOAM532aOurTAhe9iaotbsLNEp6d7QEsgmeUppZeLxLBVU8xD7EZvyEl d3sj2SKK07BJ8zbLKwERgZ2Hh9BZKKW+ X-Google-Smtp-Source: ABdhPJxYTjRVBjX0Rb9ACwgvUv8SYqRjTELJGdvUGk2ZT9j9VAZxKEYlzDVuho8VN54x8a7VK7k6aXTc82QW X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:1cab:1a20:2ef1:ddde]) (user=qperret job=sendgmr) by 2002:a05:600c:354f:: with SMTP id i15mr8597282wmq.59.1638378289941; Wed, 01 Dec 2021 09:04:49 -0800 (PST) Date: Wed, 1 Dec 2021 17:04:03 +0000 In-Reply-To: <20211201170411.1561936-1-qperret@google.com> Message-Id: <20211201170411.1561936-10-qperret@google.com> Mime-Version: 1.0 References: <20211201170411.1561936-1-qperret@google.com> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog Subject: [PATCH v3 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 Cc: 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-20211201_090452_240649_82960807 X-CRM114-Status: GOOD ( 12.27 ) 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 Reviewed-by: Andrew Walbran --- 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)