From patchwork Wed Oct 13 15:58:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12556231 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07744C433EF for ; Wed, 13 Oct 2021 16:02:35 +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 BDDA4610FE for ; Wed, 13 Oct 2021 16:02:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BDDA4610FE 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=ZXmHG0fFYNvldsToc7iP4S3ScFX6dmTYjdazzsxqy54=; b=y7mAEiLS0YnAs2mMd47EdYkNb6 mSYi3IW+xMocPx/MH8CWGqVAnelYg9BLOySyiQ5MIMBOCDqprD7d6IGhpgc2k0vIg+gdHwJDA/j00 trSlOER+XgydmlsdKpxqhukByvAHTB5FFkUBfm13LbLBRV0MulOnRigFVYeGCzitsEpf7wEN7OrV/ NNhQpt02FidcHE3X77Mr8RTBs8YkesELsUrbUHXGAjnGqLG/DGpziKRslQqPZnxrxf63P6D4zYX1u 91W2+ml026K2ndbIsevInDd9mq52yDb1nZd26gI8q0U/IuqoLbAW1IC2LSiCWh+ww9U4ps/LIhJx2 OCqNiwhg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1magfM-00HTbH-HZ; Wed, 13 Oct 2021 15:59:40 +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 1mageR-00HTJp-Pa for linux-arm-kernel@lists.infradead.org; Wed, 13 Oct 2021 15:58:45 +0000 Received: by mail-wr1-x449.google.com with SMTP id y12-20020a056000168c00b00160da4de2c7so2365595wrd.5 for ; Wed, 13 Oct 2021 08:58:42 -0700 (PDT) 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=iQjX5L75EMSut/e9QkKC3PVYtpB1oumW2lPsA0BXgHk=; b=mIk1w2jkpInjOJapgg2EiBV4rNZgsgrkxTvKv+siczoD6/bFepkA9l4SOTN6PbyrSN dXPXzsv4EPi6k9JSC+NkQy/OdGLmYCDnMOgDmY2x8FF0X86XBBp4Zlcbuy0UoaXz8kNl yNBxqZRo1LBPUkBWUDCARpwsXE05CCl0Izy/SIBc7Fjm85eoeEDoAtMV3PNd9rxKM0P0 Pxw1YjskOHOCj8VoF4X7ujJ2Esn8W3QuG9E1FlEL9i2WuxPaTuGTl/4yWFNdPCfsNl62 tjkH4AxtP48/1CYZlrScJ0diYkB2Lqr0HocWPwK3xLr8Twzo7r+apNgU2NSKioYMwf5/ Xg9A== 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=iQjX5L75EMSut/e9QkKC3PVYtpB1oumW2lPsA0BXgHk=; b=4crkvyrKD9A8wV1XwcXWSgtbX9PsjAPMAuICkgEoWMu2+yqbsYMflJbwgu9n3IvsX1 bJw0B4Fc6/vCYSxrlbc0nvkKmgB6NZeIW6mndl03C7wSiKhnLLWFuGEgAO9HmpFYTRc+ Z6vcyQ5ezcIiiY+tEXJhv9mrzwmeMdz2P79q1Um+/2wNQa/dnB6y7eGz7x78T9dpe9e/ i4hglCJKlVhf/x+xU7N45qpwU/ddZGWKG8K9j0oq56j7yzIDzG9kvfCf+tRz4ZahROsE OLeCqWjO/fpIJpppVMwXjwemqxNXLCwY9xIypdDgjMolwf3UWogxvaLNwsmByLT3Mxcs mu1g== X-Gm-Message-State: AOAM532Z6NhEPmQ6hgz9vk2Ht1e3RbXfLZbHyWF0x77gY4UrNg5V9Gx9 ggju9o6MLmTAlUvCqsV9js0Uek0rzdRa X-Google-Smtp-Source: ABdhPJwXfk8TYTriRHD8Ql+PrifVU/oKyaCUyxffX3kvDsKbnn5ZL+GaraV62M5Cs5X0Y7S/AKPg00V749ll X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:65b5:73d3:1558:b9ae]) (user=qperret job=sendgmr) by 2002:a05:6000:2af:: with SMTP id l15mr6285646wry.296.1634140721007; Wed, 13 Oct 2021 08:58:41 -0700 (PDT) Date: Wed, 13 Oct 2021 16:58:18 +0100 In-Reply-To: <20211013155831.943476-1-qperret@google.com> Message-Id: <20211013155831.943476-4-qperret@google.com> Mime-Version: 1.0 References: <20211013155831.943476-1-qperret@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [PATCH 03/16] KVM: arm64: Avoid remapping the SVE state in the hyp stage-1 From: Quentin Perret To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Fuad Tabba , David Brazdil 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-20211013_085843_876619_AFD3512F X-CRM114-Status: GOOD ( 13.55 ) 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 We currently map the SVE state into the hypervisor stage-1 on VCPU_RUN, when the vCPU thread's PID has changed. However, this only needs to be done during the first VCPU_RUN as the SVE state doesn't depend on thread-specific data, so move the create_hyp_mapping() call to kvm_vcpu_first_run_init(). Suggested-by: Marc Zyngier Signed-off-by: Quentin Perret --- arch/arm64/kvm/arm.c | 12 ++++++++++++ arch/arm64/kvm/fpsimd.c | 11 ----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index fe102cd2e518..c33d8c073820 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -618,6 +618,18 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu) if (ret) return ret; + if (vcpu->arch.sve_state) { + void *sve_end; + + sve_end = vcpu->arch.sve_state + vcpu_sve_state_size(vcpu); + + ret = create_hyp_mappings(vcpu->arch.sve_state, sve_end, + PAGE_HYP); + if (ret) + return ret; + } + + ret = kvm_arm_pmu_v3_enable(vcpu); return ret; diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c index 5621020b28de..62c0d78da7be 100644 --- a/arch/arm64/kvm/fpsimd.c +++ b/arch/arm64/kvm/fpsimd.c @@ -43,17 +43,6 @@ int kvm_arch_vcpu_run_map_fp(struct kvm_vcpu *vcpu) if (ret) goto error; - if (vcpu->arch.sve_state) { - void *sve_end; - - sve_end = vcpu->arch.sve_state + vcpu_sve_state_size(vcpu); - - ret = create_hyp_mappings(vcpu->arch.sve_state, sve_end, - PAGE_HYP); - if (ret) - goto error; - } - vcpu->arch.host_thread_info = kern_hyp_va(ti); vcpu->arch.host_fpsimd_state = kern_hyp_va(fpsimd); error: