From patchwork Thu Dec 7 17:06:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10100323 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 34B9C60360 for ; Thu, 7 Dec 2017 17:16:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AA7028464 for ; Thu, 7 Dec 2017 17:16:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F759284CE; Thu, 7 Dec 2017 17:16:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 744CF28468 for ; Thu, 7 Dec 2017 17:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=DQq/G5nxtRQHSuV62nDwTZMUU7mnfgdwczuFrmHoSHM=; b=a2diJ1wdRYp+mxaelGIwNhQFje kNVs7K4Gl8LsQk5rLfWsMTbIJ7Oa5Cv6j4z2gGJlztkxQIkLesHQWlyAUtFor3yHBVdJjN1BODWsm sUcg/ZGI1ggHgO0mOUGjuZ/+r8FgxFFYMyx0KUKNZ38q2RgWfteeflBjjHdNsHyPzhf6GtNc/uEle Vh3e+Y5H5grsHT89N6RuUZjZ+2e0AYID+Vt/LP21gWf8gdQDEX9kviDkjspFHoV246IZzjJGOg/Oy 6G2l/MgUEc/7xhkP23Ws1bHKGAc4sCQfajNXCJpzj6+ug/1meBrxF0cxQUXGUThdMmhB6pr+l7Vc5 S3A52P7Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eMzmo-0005Ql-K1; Thu, 07 Dec 2017 17:16:38 +0000 Received: from mail-wm0-f66.google.com ([74.125.82.66]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eMzeP-0003Z8-T1 for linux-arm-kernel@lists.infradead.org; Thu, 07 Dec 2017 17:08:51 +0000 Received: by mail-wm0-f66.google.com with SMTP id f206so14076445wmf.5 for ; Thu, 07 Dec 2017 09:07:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=E6BZlWfTp2Adppe1p7dVKERh7GEj+Gcr5aXepgRWt3o=; b=WCDoW1rDW1qM4gTp8nUlqQAlPnYUylupnWYWHVCVf/ZOXOytIUC668ZJFzPAd+c3bp bXNxB5wu4LmvcUzLFaCibPWRWZlpxuXCtZfl3NMKy71vUUmcthXlGbU1T/kRAW73e9kg +vHvuiyNUVZ4kUkxG6FxxAOk80tvmZ1Z3aImg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=E6BZlWfTp2Adppe1p7dVKERh7GEj+Gcr5aXepgRWt3o=; b=jucCqx3Gq1kolnLd5ndWBNDq9PfFw3wtVzMe8cNBl1Xe9IJFdRTERPSSa5UBpyreiu 66SoUbtm1fytSo/6STmmyX6zeOHehZx1wGUsSyTA7eDVvNnoP4mqgFYi8dDnibmUS/S1 l+Mg8EuKX1Zwr5F2dXc5YGxqtJQglACBbYXeLFQq2vxqjd7ybTB8vNLcu/nZ8emdPc+P FVzPmBwxO5pqcZ+815wORUzRY0UHDMH7dQvGAnZjKNTDu275yUwu5jZo4Zz3s3IBIz2c 2Pagn/iYsDB5dIR7wTUAfUazbZluf8RS/CXAsDR3Rd1/KVVxHElU+Vu+VLyHcOB7fGpF X4hA== X-Gm-Message-State: AJaThX4HNZFwnoo6mW9U/iAYXXakUH3KWhgHCWnzoycRk2s5+3weD9p3 J+58JCifAfiabXonuCOIjQIevQ== X-Google-Smtp-Source: AGs4zMbZqxs8rZjnWBp5EvfYrDDQAV4hUBVKD45JxWFsSsjZ9g1yK2sQVH1cMbFj5pvJYT18wNJb3g== X-Received: by 10.80.183.38 with SMTP id g35mr44813422ede.231.1512666455193; Thu, 07 Dec 2017 09:07:35 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id a16sm2868270edd.19.2017.12.07.09.07.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Dec 2017 09:07:34 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 34/36] KVM: arm/arm64: Handle VGICv3 save/restore from the main VGIC code on VHE Date: Thu, 7 Dec 2017 18:06:28 +0100 Message-Id: <20171207170630.592-35-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171207170630.592-1-christoffer.dall@linaro.org> References: <20171207170630.592-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171207_090759_138930_3CBFD22D X-CRM114-Status: GOOD ( 12.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Andrew Jones , Christoffer Dall , Shih-Wei Li , kvm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Just like we can program the GICv2 hypervisor control interface directly from the core vgic code, we can do the same for the GICv3 hypervisor control interface on VHE systems. We do this by simply calling the save/restore functions when we have VHE and we can then get rid of the save/restore function calls from the VHE world switch function. Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/switch.c | 3 --- virt/kvm/arm/vgic/vgic.c | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index a7de1436a0e6..947684312079 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -386,8 +386,6 @@ int kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu) activate_traps_vhe(vcpu); __activate_vm(vcpu->kvm); - __vgic_restore_state(vcpu); - sysreg_restore_guest_state_vhe(guest_ctxt); __debug_switch_to_guest(vcpu); @@ -399,7 +397,6 @@ int kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu) } while (fixup_guest_exit(vcpu, &exit_code)); sysreg_save_guest_state_vhe(guest_ctxt); - __vgic_save_state(vcpu); deactivate_traps_vhe(vcpu); diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index 5bf0804e79b4..636200cace55 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "vgic.h" @@ -754,6 +755,8 @@ static inline void vgic_save_state(struct kvm_vcpu *vcpu) { if (!static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif)) vgic_v2_save_state(vcpu); + else if (has_vhe()) + __vgic_v3_save_state(vcpu); } /* Sync back the hardware VGIC state into our emulation after a guest's run. */ @@ -778,6 +781,8 @@ static inline void vgic_restore_state(struct kvm_vcpu *vcpu) { if (!static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif)) vgic_v2_restore_state(vcpu); + else if (has_vhe()) + __vgic_v3_restore_state(vcpu); } /* Flush our emulation state into the GIC hardware before entering the guest. */