From patchwork Tue Aug 17 08:11:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 12440849 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=-17.4 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, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 B450DC4338F for ; Tue, 17 Aug 2021 08:17:22 +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 7C26360FBF for ; Tue, 17 Aug 2021 08:17:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7C26360FBF 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=pURbQBsLEwP+PPTEWYEeExWQL9kVLNMr5WIONuSdXK0=; b=VTE2YrTvtcaS679OvhPPHp8vBq oGcM5di6bSptMkVWUiR1fgi9yYObpMQbDCmwuXgj6Tl89/V+ICq4YSQWOxDPZJx6g7CUHr9hAEifP xqbStcj+KW0UmapHudU4e3tRkRQBtVtKwNmfuwisKkZt+iFwE5R26VFND1rQQbPH4NYfkwD+nbikt Bra/v73a1ZMmurvNTSe8XWZC8NmLxmwQHib16MdXBdv+tE9NOMNMTck2K9EJffBfCzYN6hnHlLl1l +8wN7c4otVjFHAr0HURebDN99rSKg3KtnYg4SsYEF6ncuYrjOhazOyoAuVtGl+Q0dgrlYuOSZJZ3s aIdfb6FQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mFuFL-001WWe-B8; Tue, 17 Aug 2021 08:14:56 +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 1mFuCR-001VF6-L2 for linux-arm-kernel@lists.infradead.org; Tue, 17 Aug 2021 08:11:57 +0000 Received: by mail-wr1-x44a.google.com with SMTP id t15-20020a5d42cf000000b001565f9c9ee8so4130770wrr.2 for ; Tue, 17 Aug 2021 01:11:54 -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=+LnYz68K0/l+zVlwhzMBHhFllBcdwA8o9zPnuvPdhe0=; b=eNCBRoMkjOMI1w4Bde0MwYe/+fVCHL1uO5oA1/7mvgpVquoq/U7usqWzx9nDuVenns BQi5B7hZi3es7WYC/W87KlBzYklGyJPgnQV7TfmgIoys5AQ4YA6+IunfsZvAIidGmumc XPNo4d52vG8FKOb94+28WQIeUjE2bFAMqVAHwcYCHWKtJC23mfmij3uHJSrBA7NsjnHn OydKvJ4RnpdwTpLfFQ+i/NK/GHDCZP3c5L+oe3KhCnYAiU9B9KOjwd0rQDJccClee7/z 0KtgAGBKfcMOFu2mGsWMrmdAw//fBve6xiM1Yq8lW8dhDvbha/o14XZtd/52XL/ZIk1U Okng== 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=+LnYz68K0/l+zVlwhzMBHhFllBcdwA8o9zPnuvPdhe0=; b=bzsK9J2LMTS/O0H1sAhmP1Rdu/3XYqTSITYna8Jk3kdXXXuQR2fw0fzhENQNAzXUya 5crSmnH8EaMGR5N8J4xE8sPVDHi8L5HvBuNzL2pjinkHVXMomOZw28Us32N1dmIF0hzD zqpVaFYh6JYWZUh30xBVNoaH3b45Zmk97uCpyl9+eq/6H8ddh94T5Eh1/MH8Czi7c+pa XZfFMdRHPvYv/lxsR/I5tETYxda1m4U+1TvZ39OipNAu8pYuDvEUfW4tsaaRSn/AALUS swpqMerCvyVbkyYaTJUw2ysWUUbHAgMEa1X8jvns6VxDAxYvAdqjnil/HZDhCtS74Vo7 S5pg== X-Gm-Message-State: AOAM530K59Vf3ANmhZOLKjmN9xOljHTMl+Cz9OlimkIrQl4FZRVosg8l 6QFvfQCsgESWHJDAy6KSEBoLir8qxA== X-Google-Smtp-Source: ABdhPJyZWFpU/vfGQ67R9j5JsRWqvs8PPjjGpxXblDdr0ny97M2MYAIupQIWIGkVZyPx3cSOzFUeUusJBQ== X-Received: from tabba.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:482]) (user=tabba job=sendgmr) by 2002:a1c:4c:: with SMTP id 73mr2053153wma.139.1629187912994; Tue, 17 Aug 2021 01:11:52 -0700 (PDT) Date: Tue, 17 Aug 2021 09:11:27 +0100 In-Reply-To: <20210817081134.2918285-1-tabba@google.com> Message-Id: <20210817081134.2918285-9-tabba@google.com> Mime-Version: 1.0 References: <20210817081134.2918285-1-tabba@google.com> X-Mailer: git-send-email 2.33.0.rc1.237.g0d66db33f3-goog Subject: [PATCH v4 08/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, oupton@google.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-20210817_011155_742495_B762F972 X-CRM114-Status: GOOD ( 14.56 ) 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. Acked-by: Will Deacon Signed-off-by: Fuad Tabba --- 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;