From patchwork Mon Jul 19 16:03:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 12386189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9820BC636C9 for ; Mon, 19 Jul 2021 16:12:59 +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 6A954613CC for ; Mon, 19 Jul 2021 16:12:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A954613CC Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@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=BpMzdAuRRRF6WdPlBqwWdlm3QS6cYQqOaUvBMhI3TvA=; b=lpj/HkhBoG63uYDSiTf2Q0D4k9 hEl7tSFmErV0oEVaBThroMR3WrVLZBdyK5gGb/GzZZwIXyFpQIugp2iH7f/MI5Iu+FjfluSah1vEs I4iDpoLSvjiELN3CF3k2u+B5Vxn6dD3pSomAdfo+bDWDm3ytAbg25we7lj2cvSOuyJvwWK5enIyM3 MBMTcn8v8cKFPilwA6rITDzSF19rdmG3tF3mVNLRbZ5+Zye7z7KU9rGAIct6eAV1csmuOb8VgvH0s 9MZ8pbvgqn9Nb/ODPccfBvNnf71cBqQmA8+rTuvDw3vwrU0M6i/yDtikXZuvMGQIvHzHYVgnTqmOU BTasLZ5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5Vqu-00ANig-8G; Mon, 19 Jul 2021 16:10:44 +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 1m5VkT-00AKhk-Ag for linux-arm-kernel@lists.infradead.org; Mon, 19 Jul 2021 16:04:06 +0000 Received: by mail-wr1-x449.google.com with SMTP id 32-20020adf82a30000b029013b21c75294so8954212wrc.14 for ; Mon, 19 Jul 2021 09:04:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=U8tD0ZWRxueOiZnXn8UX8nsv6z5g8QfT23T+iieg6fI=; b=ea29I0iVbjUEGeftel12Gbq366g83QtA8E8r2Uz+6IHkJ5UWd79gUIX3JA3bLyJe2D QopBkuDzcKVtOEKFgcYrOrqaG1U79giGVajM4WVon/jAnyPxWl7lSRLHkf5bUKq7hgqI qYrGlejOsSSAggxfvj3GQmg9m+MadgXLM2jZmKxePlf5wMrQg7oXbwV1tsjyrjq2MRA6 FvMoXKvos5kv9fcrVWa87rlDj4y5EvS+eYCN+qe3HXSpqhRo9Kq1RukOmpGNRgkw1sAf vmRE9+AgJ5UoMmzOf5n3YI7T6NGPJw9OgUFVbWdHiFjEvWuFY/8WIPBGjuVN8OxaTsLr z+AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=U8tD0ZWRxueOiZnXn8UX8nsv6z5g8QfT23T+iieg6fI=; b=G3ssK6DAj8WRB6taH2+DkqAZMlOGrGluwJ1Q+gKr4mB44+Ez5O8mfFuuPkh2xZmrZp +8dIOdJzl3/AN1suTHPq/s5/wG7gglLU70oBmujxDmPDj7oinVdq0WAlw2IjpdIGnntd TQFbSMkVvVQTqAmexlCrt27+rZByPZ5FfRe1Yv73yr9yasYqoxQG7BwxoW3vPAAU6ijp frqm/qnstTBN3jO3x72vPr2/MoOZDUWn9ZgoTIYko5AzKgpYywktYfOI0HZYHpyCL7D/ akdODPc6Ps7DGfxR+7j1v8AaSgePLLqad3PwLQhbsl+d8jrVNToPolcq9zRgM9HWJnfm /3Zg== X-Gm-Message-State: AOAM530cCuCnTqSpZ/+MxG0gyWCJSZKcA6UJaUxupWdc6jnsIW1nv/31 biOJlwhKFj9QdLBC1lE6hsf9O2PDwA== X-Google-Smtp-Source: ABdhPJyZIExAAOBCez1kX40oKv+JGxZhb6d/02I7dL1PYFLCOK6saRJUulsso2zHWmJh0mrJepqqSzq7lA== X-Received: from tabba.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:482]) (user=tabba job=sendgmr) by 2002:a5d:4ccb:: with SMTP id c11mr30162930wrt.331.1626710642525; Mon, 19 Jul 2021 09:04:02 -0700 (PDT) Date: Mon, 19 Jul 2021 17:03:38 +0100 In-Reply-To: <20210719160346.609914-1-tabba@google.com> Message-Id: <20210719160346.609914-8-tabba@google.com> Mime-Version: 1.0 References: <20210719160346.609914-1-tabba@google.com> X-Mailer: git-send-email 2.32.0.402.g57bb445576-goog Subject: [PATCH v3 07/15] KVM: arm64: Track value of cptr_el2 in struct kvm_vcpu_arch From: Fuad Tabba To: kvmarm@lists.cs.columbia.edu Cc: maz@kernel.org, will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, mark.rutland@arm.com, christoffer.dall@arm.com, pbonzini@redhat.com, drjones@redhat.com, qperret@google.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, tabba@google.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210719_090405_478551_849C39AA X-CRM114-Status: GOOD ( 15.33 ) 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 Track the baseline guest value for cptr_el2 in struct kvm_vcpu_arch, similar to the other registers that control traps. Use this value when setting cptr_el2 for the guest. Currently this value is unchanged (CPTR_EL2_DEFAULT), but future patches will set trapping bits based on features supported for the guest. No functional change intended. Signed-off-by: Fuad Tabba Acked-by: Will Deacon --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/hyp/nvhe/switch.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 76462c6a91ee..ac67d5699c68 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -290,6 +290,7 @@ struct kvm_vcpu_arch { /* Values of trap registers for the guest. */ u64 hcr_el2; u64 mdcr_el2; + u64 cptr_el2; /* Values of trap registers for the host before guest entry. */ u64 mdcr_el2_host; diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index e9a2b8f27792..14b12f2c08c0 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1104,6 +1104,7 @@ static int kvm_arch_vcpu_ioctl_vcpu_init(struct kvm_vcpu *vcpu, } vcpu_reset_hcr(vcpu); + vcpu->arch.cptr_el2 = CPTR_EL2_DEFAULT; /* * Handle the "start in power-off" case. diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c index 1778593a08a9..86f3d6482935 100644 --- a/arch/arm64/kvm/hyp/nvhe/switch.c +++ b/arch/arm64/kvm/hyp/nvhe/switch.c @@ -41,7 +41,7 @@ static void __activate_traps(struct kvm_vcpu *vcpu) ___activate_traps(vcpu); __activate_traps_common(vcpu); - val = CPTR_EL2_DEFAULT; + val = vcpu->arch.cptr_el2; val |= CPTR_EL2_TTA | CPTR_EL2_TAM; if (!update_fp_enabled(vcpu)) { val |= CPTR_EL2_TFP | CPTR_EL2_TZ;