From patchwork Wed Sep 27 11:25:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ene X-Patchwork-Id: 145394 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2657754vqu; Wed, 27 Sep 2023 07:10:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHmWsU7PY+1tNOHJGEq7TUeVKPKdh7pf2eyqJ0d6leyJ0zlhe6LkulbHR5/Vs0EL8yWDIEB X-Received: by 2002:a05:6808:9a2:b0:3ae:8a9:e44a with SMTP id e2-20020a05680809a200b003ae08a9e44amr2483975oig.31.1695823854789; Wed, 27 Sep 2023 07:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695823854; cv=none; d=google.com; s=arc-20160816; b=uBApondUAwO8/m5l58aVPsn0GmVmq9P2UQsvuIsdByEY/XQyr/9UW6gRWI0adu/avw FXuxvh9Rsh64sZk4lhqCUxVOBqTafi3tH8a5w5Ap1M6U1hu8UFUAY+GdyqQSBTHcK25/ ryNnyNnzn+4HAdT4iUYDZ6h9HOm/OM4eiRrBFyGSx4MLTmyf1tDxxx7hsxN7I0eBVBu+ wJUauf+EKN9ni/t+4KAtaPsas9K6e2r+cW1Q7qaP92Sr4CsqKkbNL2JAIUvV+YyEBpTM dA53iF/3EFZigZEO+ZvRS0rCPCe9/HgjcThrkkQBzaykYzRbpSBzEjPf/q9jq/EEg6vD x2hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=LxbnVeeBsmxebuYPX9n5F7ayQvPWmM0quJncxxttJX8=; fh=yikR9HT1wx5LLj7DvfR9kbE/RatD/mnQgNUS++qRsJM=; b=oGaNvmeMowZiS+/Oi5MwZ9CdKT16dTN+kl+BF67ZYKScmAxRxQyskYfSLb+2s/vzi1 WSbunGWNz9idxIS9G4ll9oO98LKFxIJ1pwDuNqlw+Ky3MH8a233U5ZD6Y76LLMaTHrxc tv8PqnsRMGE4Xn771TRo6UapcpnKxbosFUCF9VTGcD98vVpaeXCusUqm6B0D0Oih3yRw A8esDFX0XjHV8d0joNHoSFSLY9HnQov9Yxk08upI9Y8KX6o6nyfzFp3w74n1i1mlXLfW otBQ1mlkhr7PgWBy3elXnLRlRo+iBcahiozX8dBDIC2ECwLhnbEzgDjc773OS9LGjgHU vR6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=cORnPyxn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id f20-20020a63f114000000b00565db2812a0si16232017pgi.60.2023.09.27.07.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:10:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=cORnPyxn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E834F804C611; Wed, 27 Sep 2023 04:26:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231521AbjI0L0j (ORCPT + 22 others); Wed, 27 Sep 2023 07:26:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231516AbjI0L0J (ORCPT ); Wed, 27 Sep 2023 07:26:09 -0400 Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 652AECC9 for ; Wed, 27 Sep 2023 04:26:01 -0700 (PDT) Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-32323283257so5369910f8f.2 for ; Wed, 27 Sep 2023 04:26:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695813960; x=1696418760; 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=LxbnVeeBsmxebuYPX9n5F7ayQvPWmM0quJncxxttJX8=; b=cORnPyxnYUUDBEx8bFQsUJFhOFPxcisp5LuuwGrzGxDZYmQlbYb2sp29gySnKTpzqQ WZAE3x0kIcTFCrbRRXEZpeprCNaPrvHa7Kul4Vlh+gKKdp3fWzrgMpXWlvuEHJ9cK8rb GXH6Ax6RiiOXxZ3nKhGbEA4K+GWp4B192o2hrNfUzNvBiLCi7lb+RKzQP4jXcwhX7MSX aqQ7CLQeH4tvYIJVKoOeo3x4SJvALRIFNWc45igJw/gNCOZr9ntfV8yfbBoE4WRdIvcn k+lFfUzez+fx27EcTC3HD4D3YNruPFxaA2J7rISMCOKn5lNr75xWf48hmpySDJrDR+Hl HBHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695813960; x=1696418760; 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=LxbnVeeBsmxebuYPX9n5F7ayQvPWmM0quJncxxttJX8=; b=C/7XUlqw6PKK4BITEeJVBMKHD+sCeyWT5XMnXPs4Gi0ypQJLPjwnTLHKWXXSkRhDGk bMp3Fg4O14vSI4+VB9hk7NqCU6IzADiLDlY/YeN0xxk8yd5weAzvr+NjHP3DB90llQbE dYtsCzWOEtRvE8nVMcTQouKgj2Yl2h9PRfXRTmaosg4U9fLtvJC5xby0sIbiOYcat1ZM b1UH7Ew8XdZYpgHoEHF/8aA54h+sDl0p6vHJ/9n+0DOdQS2hVS9gF6wzHckz+mQKRQEc pOJFO6TLD53dkV0mS813Ya/6ahUVR9CoMA8vkgLZf4mYYRZtt2Kg2MyXu6W0PHNPzWNS wudQ== X-Gm-Message-State: AOJu0Yws4SWiteOGieqTK0XUF05mVKbzEcARqsBM95m4P0cFEmNl1V/A QHp7aO+kSeDY3mw5BokU8KZlolwABqkYGp7j1jAKXU99SdUVQKTUm846ppHMO0rBSVVLrWeSRDo YXOjcY/T155RJ1qoneP/MpHGsUQVTJs0qLYvcjP5h7oNBhR0UDdwfAG4sklD72MzyB4CR5TE+7R YDCiRfZBefEw== X-Received: from seb.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:31bd]) (user=sebastianene job=sendgmr) by 2002:adf:ed84:0:b0:317:6e79:423c with SMTP id c4-20020adfed84000000b003176e79423cmr7347wro.3.1695813959676; Wed, 27 Sep 2023 04:25:59 -0700 (PDT) Date: Wed, 27 Sep 2023 11:25:16 +0000 In-Reply-To: <20230927112517.2631674-1-sebastianene@google.com> Mime-Version: 1.0 References: <20230927112517.2631674-1-sebastianene@google.com> X-Mailer: git-send-email 2.42.0.515.g380fc7ccd1-goog Message-ID: <20230927112517.2631674-11-sebastianene@google.com> Subject: [PATCH 10/11] arm64: ptdump: Interpret pKVM ownership annotations From: Sebastian Ene To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, will@kernel.org, ryan.roberts@arm.com, mark.rutland@arm.com, maz@kernel.org, vdonnefort@google.com, Sebastian Ene X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 27 Sep 2023 04:26:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778200194568144496 X-GMAIL-MSGID: 1778200194568144496 Add support for interpretting pKVM invalid stage-2 descriptors that hold ownership information. We use these descriptors to keep track of the memory donations from the host side. Signed-off-by: Sebastian Ene --- arch/arm64/include/asm/kvm_pgtable.h | 7 +++++++ arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 7 ------- arch/arm64/mm/ptdump.c | 10 ++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 913f34d75b29..938baffa7d4d 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -87,6 +87,13 @@ typedef u64 kvm_pte_t; */ #define KVM_INVALID_PTE_LOCKED BIT(10) +/* This corresponds to page-table locking order */ +enum pkvm_component_id { + PKVM_ID_HOST, + PKVM_ID_HYP, + PKVM_ID_FFA, +}; + static inline bool kvm_pte_valid(kvm_pte_t pte) { return pte & KVM_PTE_VALID; diff --git a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h index 9cfb35d68850..cc2c439ffe75 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h +++ b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h @@ -53,13 +53,6 @@ struct host_mmu { }; extern struct host_mmu host_mmu; -/* This corresponds to page-table locking order */ -enum pkvm_component_id { - PKVM_ID_HOST, - PKVM_ID_HYP, - PKVM_ID_FFA, -}; - extern unsigned long hyp_nr_cpus; int __pkvm_prot_finalize(void); diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index 964758d5e76d..45ff4ebae01a 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -272,6 +272,16 @@ static const struct prot_bits stage2_pte_bits[] = { .val = PTE_S2_MEMATTR(MT_S2_FWB_NORMAL) | PTE_VALID, .set = "MEM/NORMAL FWB", .feature_on = is_fwb_enabled, + }, { + .mask = KVM_INVALID_PTE_OWNER_MASK | PTE_VALID, + .val = FIELD_PREP_CONST(KVM_INVALID_PTE_OWNER_MASK, + PKVM_ID_HYP), + .set = "HYP", + }, { + .mask = KVM_INVALID_PTE_OWNER_MASK | PTE_VALID, + .val = FIELD_PREP_CONST(KVM_INVALID_PTE_OWNER_MASK, + PKVM_ID_FFA), + .set = "FF-A", }, { .mask = KVM_PGTABLE_PROT_SW0, .val = KVM_PGTABLE_PROT_SW0,