From patchwork Thu Oct 12 10:41:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10001643 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 58D7860325 for ; Thu, 12 Oct 2017 10:51:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B07528C7E for ; Thu, 12 Oct 2017 10:51:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FA7D28D6D; Thu, 12 Oct 2017 10:51:38 +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=ham 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 C1A3328C7E for ; Thu, 12 Oct 2017 10:51:37 +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=olJKjiyjwXJgUzYdiAc26DGqrVFSSWpGQCcptc/M0Kw=; b=u08NUQxtAL73pGursbcSrq1VNS yQR1dNTq4Egr0aj/H5V02HFki/WeXmdzf8zuLOo2UDJq4ORRSHvMhS2L8ZCOG9p1R4l9i1YnI0RYA wc8A8z7JLvS6I+dyiicyjftYbRdTIrF+eFB5DEPFzse+UsFISM7CkZ1XzuKmG6ktb754tnFnwHGi5 oGhA8dq8ukjiFOsFfYI1R4+zbCvZfwW4P/kFRPwL+kAkxrsVLA7AGhz+a0b+mBKB9zjcVMSS4Kv0R NvhLNjotC/kAVIm/0YWtz/R+q/zw3875mFbWFAqL2h/5hUKkxQBhqq0y9uDUt7law+wNYnrXTDZoa Rb26yndw==; 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 1e2b5D-0000x3-FR; Thu, 12 Oct 2017 10:51:19 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e2axw-0000PW-Ds for linux-arm-kernel@bombadil.infradead.org; Thu, 12 Oct 2017 10:43:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=tVmQOYyBmqv2dFGhpLgOtFNCaJQ9ZGb0z1VFsanHN8I=; b=jEhSlcbmzo5n9YVZpAVdgK9g0 FimQBuYFucnIjTqJkfT0QCYflYgB4y+OQYkxTkmpIK/6g/AwF/poKUwIvIHkvik3aMCYQ9ZSr5giP ovX7/uQilaBytpJrmuFgMewkCuHWpF5gZAWa7suRpPC+DI18QeR/BCQT75t5Iv6Lj0rKtBcAzZ5Y2 HwC6d3FJjGFTNiQyFhvnzI+KgRJudDYkmlM0r8AeHFT8U/keDgggVhnjgX63TdOJdOsv1KvJckMZp B6/rLOJh3F/CcV6v8YNDg1KsxjaOC4GWtelSWZ0oQrtobTv9fLu5BowIn0iCAUiYjaxH6iosPamaW WA2Ch+7Jg==; Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e2ax0-0005MC-5i for linux-arm-kernel@lists.infradead.org; Thu, 12 Oct 2017 10:42:51 +0000 Received: by mail-wm0-x236.google.com with SMTP id u138so12162253wmu.4 for ; Thu, 12 Oct 2017 03:42:30 -0700 (PDT) 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=tVmQOYyBmqv2dFGhpLgOtFNCaJQ9ZGb0z1VFsanHN8I=; b=CUWpZdZWorlHcB9Z9EIShani8sjctoPEcfUxHzNThDDmFRF6iZrXEdrBbaaTFhmWSo P2WA+OsF+0s1cP4OcjKUJwozs2jmbM+Xsdhi1tSHON5y/zjPgLYn+75TalRMsQt9qNvr VAIW3yTH046Q2eEOgkRDXpj9LqikudmCPJIY0= 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=tVmQOYyBmqv2dFGhpLgOtFNCaJQ9ZGb0z1VFsanHN8I=; b=M1s5WlnnP5tAFBL5rEHsyRcCYtA8QO8IiDSbJVYvtHQp5TjKlsjvcmhSyt8WDowW3k p34z/OTfcXAiptFSle4t8T6nUhz7/rRD7VgVnfgAaCxntoII8UnjavGqyK4SNi6BKM6f qIoQn0U+gQoMuplkIHgZ9bKaQQ+Ksy5MirImI8mFmJMKRtQQFL6C2bsk4yzde17unF2q 7fROdWdP4+DU74T4u7GebRybcwLL3WGz3eV3utAhHCrwrfVUT+8BfcEjHWcmHIl8FyFk pWXqem29lIeRe7Wq41pgytQgZgWzTfj2gbehJCBVKIELWvrN2if+1Lqi8cXV24Ms7xCs sIQg== X-Gm-Message-State: AMCzsaV7WIjQp7lLEvAbok2zWcuUC02JswbC3EQNxMRQAa6f8LMgnP3n oM0Z3PTgy5dyeRA8Eab9uU27IQ== X-Google-Smtp-Source: AOwi7QAgnOlHmulIs0SEJBm45g5W913FjpHjAvL2j8zgtjDZMX9Sm7bVAE5Zw1E8NUb5Nch2Q/EiGQ== X-Received: by 10.80.182.181 with SMTP id d50mr2470423ede.47.1507804948893; Thu, 12 Oct 2017 03:42:28 -0700 (PDT) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id g49sm4798603edc.31.2017.10.12.03.42.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Oct 2017 03:42:28 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH 34/37] KVM: arm/arm64: Handle VGICv3 save/restore from the main VGIC code on VHE Date: Thu, 12 Oct 2017 12:41:38 +0200 Message-Id: <20171012104141.26902-35-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171012104141.26902-1-christoffer.dall@linaro.org> References: <20171012104141.26902-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171012_114250_223577_85EA055D X-CRM114-Status: GOOD ( 15.28 ) 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 , 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 | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index 90da506..0cdf6ae 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -366,8 +366,6 @@ int kvm_vcpu_run(struct kvm_vcpu *vcpu) activate_traps_vhe(vcpu); __activate_vm(vcpu); - __vgic_restore_state(vcpu); - sysreg_restore_guest_state_vhe(guest_ctxt); __debug_switch_to_guest(vcpu); @@ -380,7 +378,6 @@ int kvm_vcpu_run(struct kvm_vcpu *vcpu) goto again; 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 790fd66..f0072f7 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -689,6 +689,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. */ @@ -711,6 +713,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. */