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: 10100197 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 5C95F60360 for ; Thu, 7 Dec 2017 17:07:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46DE2284B5 for ; Thu, 7 Dec 2017 17:07:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BBFB284DE; Thu, 7 Dec 2017 17:07:41 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7229284B5 for ; Thu, 7 Dec 2017 17:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756630AbdLGRHh (ORCPT ); Thu, 7 Dec 2017 12:07:37 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37105 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756557AbdLGRHg (ORCPT ); Thu, 7 Dec 2017 12:07:36 -0500 Received: by mail-wm0-f67.google.com with SMTP id f140so14080638wmd.2 for ; Thu, 07 Dec 2017 09:07:35 -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=OOYQHhNcrzuMmSW1UeON+keRACydL72FhCO/ZV+VtGwRYSLNsMJU70wWNX8pIpo+xJ b57W7CuxZsZYvwEWjHiPS03GhZCg3/wRJZFYn62Jmb2FuODlIJvTjzZBOmBgtRV/yRud WNjIVUt2o9oMbiWggnU+9i/iR9QkjOydQnsFRXrpQA/uwQ8ZNtWunG7Qfu3FlHXNoe03 9vvq+PtAwh71leHi97ZgIMv7BNZmvmI07+f3cqb6Hkhl0TiO4vlYEt/wlbVOlcVBgAhk ndI4/wUi20vDkCr/2O5R+ZCG9Nkz7i++lsA73FJo1QIQ0nFL0dYYkvQhv4VMoq75UMCq K2HA== X-Gm-Message-State: AJaThX6S6sXlWzCrDCX+TBfZ0aHPhEnWBd76O2DP8dCafJJobAqHwQoz BkjcziyRdp5s4zAD/Ao+Lfrkow== 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 Cc: kvm@vger.kernel.org, Marc Zyngier , Shih-Wei Li , Andrew Jones , Christoffer Dall 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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. */