From patchwork Tue Oct 22 14:40:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 13845759 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 63E5ED2C561 for ; Tue, 22 Oct 2024 14:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ebytSZ4fnQtkutJ1QsmMdjHFA2gtzeW0MTM2G6KKgWc=; b=gSyT2EFbcSQ2J8WbpEADUlEV5k dsIFe5W6bWMEhekdqmoEhbe9WwMLTxH4scbxg1Sety4uGkSZwsONxAfYWOwkp+jXMpnOc5kemctqi vOQssth9+XJc78B7RYaFSH/vhZPjJ2bddZQfJvacsiAg0fCF0mCElU5929aCpU7F24M2HcQzVjxvN /+/wxRY1ORAr4gTb1Hz7OoUGQvz3nrvKTMqtKZGuWM7MUuFOlCZ8sHg4VE34nRXzypiXJkSkaiUke wYtYdsWCK1sNegnZCJnUxhieEGsbWaiFe223ZrgKDCJZKZ1ex4qhtWZI+EsvLvgdFWgBIw6jVbp+x lIueQfow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t3G6a-0000000B8nj-3ee3; Tue, 22 Oct 2024 14:43:28 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t3G3c-0000000B8NN-1PCL for linux-arm-kernel@lists.infradead.org; Tue, 22 Oct 2024 14:40:25 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 2E4EE5C5D77; Tue, 22 Oct 2024 14:40:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E95D5C4CEE6; Tue, 22 Oct 2024 14:40:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729608023; bh=OiX1pDTPcyDAhIHmZUWZEV/cXKJscPtv9OwJmaPy9FU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j5nJ4K2QIKNRJ5BkEJxD0f10CqsAhVH4tcBG9F2N/jNw2LKura2LxDK7WvRB8WP5c qWK0KBXuOK3mOdJIL4KYtfj+al/tLdqPBCS6M9UHMoA37KQlTpJS6TdWXtPQIP4pcV 8sJ6NGr2ZQsit08QglOHZEvAKxrCsv2Z009mNtPXw3iDunqXIUGtg6kC8WqS7a0IAm Ucvlp4aR5XlOYwF2gkp1wWsVRuhF7jvzIQohvHS4b5HswzNuqdtNgSUZeky6vf5qiz 69Bep19I7KJIYaWgDqkvqiNcRPhzw7mwHAEcKwhHu3lCItT64fxisgvRGs7WxNEk29 DA3JZ6JuoUMdQ== From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: Will Deacon , Marc Zyngier , Oliver Upton , Joey Gouly , Fuad Tabba , kvmarm@lists.linux.dev Subject: [PATCH 1/2] KVM: arm64: Just advertise SEIS as 0 when emulating ICC_CTLR_EL1 Date: Tue, 22 Oct 2024 15:40:15 +0100 Message-Id: <20241022144016.27350-2-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20241022144016.27350-1-will@kernel.org> References: <20241022144016.27350-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241022_074024_437805_B6D2144E X-CRM114-Status: GOOD ( 10.75 ) 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 ICC_CTLR_EL1 accesses from a guest are trapped and emulated on systems with broken SEIS support and without FEAT_GICv3_TDIR. On such systems, we mask SEIS support in 'kvm_vgic_global_state.ich_vtr_el2' and so the value of ICC_CTLR_EL1.SEIS visible to the guest is always zero. Simplify the ICC_CTLR_EL1 read emulation to return 0 for the SEIS field, rather than reading an always-zero value from the global state. Cc: Marc Zyngier Cc: Oliver Upton Signed-off-by: Will Deacon Reviewed-by: Marc Zyngier --- arch/arm64/kvm/hyp/vgic-v3-sr.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/vgic-v3-sr.c b/arch/arm64/kvm/hyp/vgic-v3-sr.c index 18d4677002b1..3f9741e51d41 100644 --- a/arch/arm64/kvm/hyp/vgic-v3-sr.c +++ b/arch/arm64/kvm/hyp/vgic-v3-sr.c @@ -1012,9 +1012,6 @@ static void __vgic_v3_read_ctlr(struct kvm_vcpu *vcpu, u32 vmcr, int rt) val = ((vtr >> 29) & 7) << ICC_CTLR_EL1_PRI_BITS_SHIFT; /* IDbits */ val |= ((vtr >> 23) & 7) << ICC_CTLR_EL1_ID_BITS_SHIFT; - /* SEIS */ - if (kvm_vgic_global_state.ich_vtr_el2 & ICH_VTR_SEIS_MASK) - val |= BIT(ICC_CTLR_EL1_SEIS_SHIFT); /* A3V */ val |= ((vtr >> 21) & 1) << ICC_CTLR_EL1_A3V_SHIFT; /* EOImode */ From patchwork Tue Oct 22 14:40:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 13845760 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 E5887D2C561 for ; Tue, 22 Oct 2024 14:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UchMTSxw9yq6mFSVUIzQcW/nv9Z53w0Q8U5+8aG4Yoc=; b=s9aQKcQm/n86LThh91CLHtKrrg 0Of9mT4vmGiz35NexPYGzysAohRES+wF99bdMODLIOcPt5hapBRfr7VbmZBWctMBWpvvEdgSOpgwu 2yC0vl6Vfps9umDg7M0esC+fa0N2Syu4JYP64QfIcx9SNbiWO3ooQp5p5v5RKKw0sczuZSKdnbrwo p3Xt1Jk8lHLQRmO7NoLnfWxzx6vmWY87OQAaHxQG4m0kGFMsfi/e8/xODSfYTX8g6xvayCNxdNLKW RG7uqS0laKJl8baxL4TSbcV/tSCWgHIFg059XjsSTor5Dqq7HZDO+eiDppqNSh5DdxZmYlyEuYDFd Iqg2hibw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t3G84-0000000B93O-0n1M; Tue, 22 Oct 2024 14:45:00 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t3G3e-0000000B8Nw-1V23 for linux-arm-kernel@lists.infradead.org; Tue, 22 Oct 2024 14:40:28 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 59470A43CBA; Tue, 22 Oct 2024 14:40:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB93AC4CEC7; Tue, 22 Oct 2024 14:40:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729608025; bh=Alv9dWrIr7MfCsksp8/aH8Z898+iDvie7akcrAqRG+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fX28e2+JJqYbWXSriya9TLncm0MwdS7FDoH26Og2tXBerGEmDAtwfVPC9X1FRvoqc qg46ih8q92cQo2005+D9nQxu0gM2PUx5AO3gYG8XfuUpsFy0wPT1hYFr4ILgLwIomn Pge+ftB+jUta0GKA8I9MrHVHkc0/ntJZrIxbSyh8Il7413aiyW1uHlzmmA0Jhk31RP MqTAuW/KHxcDMLzVwKd8njy+rUl3SccKw6R7teC9QgZbv/9aLzIqQj9YsNa8h3WzKr W3RYv1f3AxWPvGxEvYYzbUkuMvl1bMc7AUzsu/P+4P++wAeBdnG/OdM+venLAzg7RJ 1vgJoEjIfgzkA== From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: Will Deacon , Marc Zyngier , Oliver Upton , Joey Gouly , Fuad Tabba , kvmarm@lists.linux.dev Subject: [PATCH 2/2] KVM: arm64: Don't map 'kvm_vgic_global_state' at EL2 with pKVM Date: Tue, 22 Oct 2024 15:40:16 +0100 Message-Id: <20241022144016.27350-3-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20241022144016.27350-1-will@kernel.org> References: <20241022144016.27350-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241022_074026_482006_066C169D X-CRM114-Status: GOOD ( 13.02 ) 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 Now that 'kvm_vgic_global_state' is no longer needed for ICC_CTLR_EL1 emulation on machines with a broken SEIS implementation, drop the pKVM hypervisor mapping of the page. Cc: Marc Zyngier Cc: Oliver Upton Signed-off-by: Will Deacon Reviewed-by: Marc Zyngier --- arch/arm64/kvm/hyp/nvhe/setup.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/setup.c b/arch/arm64/kvm/hyp/nvhe/setup.c index 174007f3fadd..8fec099c2775 100644 --- a/arch/arm64/kvm/hyp/nvhe/setup.c +++ b/arch/arm64/kvm/hyp/nvhe/setup.c @@ -95,7 +95,6 @@ static int recreate_hyp_mappings(phys_addr_t phys, unsigned long size, { void *start, *end, *virt = hyp_phys_to_virt(phys); unsigned long pgt_size = hyp_s1_pgtable_pages() << PAGE_SHIFT; - enum kvm_pgtable_prot prot; int ret, i; /* Recreate the hyp page-table using the early page allocator */ @@ -148,22 +147,6 @@ static int recreate_hyp_mappings(phys_addr_t phys, unsigned long size, } pkvm_create_host_sve_mappings(); - - /* - * Map the host sections RO in the hypervisor, but transfer the - * ownership from the host to the hypervisor itself to make sure they - * can't be donated or shared with another entity. - * - * The ownership transition requires matching changes in the host - * stage-2. This will be done later (see finalize_host_mappings()) once - * the hyp_vmemmap is addressable. - */ - prot = pkvm_mkstate(PAGE_HYP_RO, PKVM_PAGE_SHARED_OWNED); - ret = pkvm_create_mappings(&kvm_vgic_global_state, - &kvm_vgic_global_state + 1, prot); - if (ret) - return ret; - return 0; }