From patchwork Mon Jan 9 06:24:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 90348 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp707894qgi; Sun, 8 Jan 2017 22:31:04 -0800 (PST) X-Received: by 10.84.217.133 with SMTP id p5mr19889829pli.164.1483943464817; Sun, 08 Jan 2017 22:31:04 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id h67si87634221pgc.72.2017.01.08.22.31.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Jan 2017 22:31:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org 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 1cQTTx-0002OL-2V; Mon, 09 Jan 2017 06:31:01 +0000 Received: from outprodmail02.cc.columbia.edu ([128.59.72.51]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cQTPZ-0002Hz-4g for linux-arm-kernel@lists.infradead.org; Mon, 09 Jan 2017 06:26:35 +0000 Received: from hazelnut (hazelnut.cc.columbia.edu [128.59.213.250]) by outprodmail02.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096Q9BD006310 for ; Mon, 9 Jan 2017 01:26:12 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id 99E9181 for ; Mon, 9 Jan 2017 01:26:12 -0500 (EST) Received: from sendprodmail03.cc.columbia.edu (sendprodmail03.cc.columbia.edu [128.59.72.15]) by hazelnut (Postfix) with ESMTP id 7E83A80 for ; Mon, 9 Jan 2017 01:26:12 -0500 (EST) Received: from mail-qt0-f200.google.com (mail-qt0-f200.google.com [209.85.216.200]) by sendprodmail03.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096QCZP057362 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 9 Jan 2017 01:26:12 -0500 Received: by mail-qt0-f200.google.com with SMTP id t56so77866345qte.3 for ; Sun, 08 Jan 2017 22:26:12 -0800 (PST) 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=Gs1UV6Ku2IsQfeYTkTl40ApkODh9SOIO00ajzDH9+1I=; b=OuYDNWK0AvdPWOAdl6b8bMq0f4gC2itaNg/I/a2mqHzu24kv/j7DtYeb2XtxeMxyrw n3xlN9xYiAsUq2mauph2dyRStbsYC51Koj2CDGDLlABDLIvt4gDBST18KsyiJoKLR9TQ OFRkQ0zBjtJKE6diMuGSZCtq+Eqa3bl2o/9bFoZaott8T4bcAZskOIwRaFn9XAi1vhk2 AzMbxerpNtaSPwHco/wjGJTHdVEpl5CVaCM3FmMZFVQqce8QOr15ioWl0cXDUYuS59wR ETXP3n+Jt8ch3QHJZQ6xbFLeJ2M3+RB1fSGC9MHpg3ei1Za/EnwLSdj3LWGpDgDj7yvC 0QoA== X-Gm-Message-State: AIkVDXIB8UWv/ddKc4by4oCBAlk1q1ageVWahM9PqQ6OjU8lPUcqAIRNi+Vp1nvgdZmmwNnw3iSPkZYIfRzNjzd6iEQuZQNGnRiIGgfBhRH5zK0NeCJDS3QVkyL3QLMugDK9swzJkApgDLSIe0Wt35rfwxvLjGxPkmsWVw== X-Received: by 10.55.214.207 with SMTP id p76mr84415524qkl.241.1483943172143; Sun, 08 Jan 2017 22:26:12 -0800 (PST) X-Received: by 10.55.214.207 with SMTP id p76mr84415504qkl.241.1483943171981; Sun, 08 Jan 2017 22:26:11 -0800 (PST) Received: from jintack.cs.columbia.edu ([2001:18d8:ffff:16:21a:4aff:feaa:f900]) by smtp.gmail.com with ESMTPSA id h3sm8623257qtc.6.2017.01.08.22.26.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Jan 2017 22:26:11 -0800 (PST) From: Jintack Lim To: christoffer.dall@linaro.org, marc.zyngier@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, vladimir.murzin@arm.com, suzuki.poulose@arm.com, mark.rutland@arm.com, james.morse@arm.com, lorenzo.pieralisi@arm.com, kevin.brodsky@arm.com, wcohen@redhat.com, shankerd@codeaurora.org, geoff@infradead.org, andre.przywara@arm.com, eric.auger@redhat.com, anna-maria@linutronix.de, shihwei@cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC 31/55] KVM: arm/arm64: Inject maintenance interrupts to the guest hypervisor Date: Mon, 9 Jan 2017 01:24:27 -0500 Message-Id: <1483943091-1364-32-git-send-email-jintack@cs.columbia.edu> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu> References: <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu> X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.78 on 128.59.72.15 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170108_222629_706931_CE63303F X-CRM114-Status: GOOD ( 12.50 ) X-Spam-Score: -5.3 (-----) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-5.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source [209.85.216.200 listed in dnsbl.sorbs.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [128.59.72.51 listed in list.dnswl.org] -3.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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: jintack@cs.columbia.edu MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org From: Christoffer Dall If we exit a nested VM with a pending maintenance interrupt from the GIC, then we need to forward this to the guest hypervisor so that it can re-sync the appropriate LRs and sample level triggered interrupts again. Signed-off-by: Christoffer Dall Signed-off-by: Jintack Lim --- arch/arm64/kvm/context.c | 3 +++ include/kvm/arm_vgic.h | 2 ++ virt/kvm/arm/vgic/vgic-v2-nested.c | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/kvm/context.c b/arch/arm64/kvm/context.c index 7a94c9d..a93ffe4 100644 --- a/arch/arm64/kvm/context.c +++ b/arch/arm64/kvm/context.c @@ -140,6 +140,9 @@ static void sync_shadow_el1_state(struct kvm_vcpu *vcpu, bool setup) void kvm_arm_setup_shadow_state(struct kvm_vcpu *vcpu) { struct kvm_cpu_context *ctxt = &vcpu->arch.ctxt; + + vgic_handle_nested_maint_irq(vcpu); + if (unlikely(vcpu_mode_el2(vcpu))) { ctxt->hw_pstate = *vcpu_cpsr(vcpu) & ~PSR_MODE_MASK; diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index 484f6b1..fc882d6 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -315,9 +315,11 @@ int kvm_vgic_inject_mapped_irq(struct kvm *kvm, int cpuid, unsigned int intid, #ifdef CONFIG_KVM_ARM_NESTED_HYP void vgic_v2_setup_shadow_state(struct kvm_vcpu *vcpu); void vgic_v2_restore_shadow_state(struct kvm_vcpu *vcpu); +void vgic_handle_nested_maint_irq(struct kvm_vcpu *vcpu); #else static inline void vgic_v2_setup_shadow_state(struct kvm_vcpu *vcpu) { } static inline void vgic_v2_restore_shadow_state(struct kvm_vcpu *vcpu) { } +static inline void vgic_handle_nested_maint_irq(struct kvm_vcpu *vcpu) { } #endif #define irqchip_in_kernel(k) (!!((k)->arch.vgic.in_kernel)) diff --git a/virt/kvm/arm/vgic/vgic-v2-nested.c b/virt/kvm/arm/vgic/vgic-v2-nested.c index a992da5..85f646b 100644 --- a/virt/kvm/arm/vgic/vgic-v2-nested.c +++ b/virt/kvm/arm/vgic/vgic-v2-nested.c @@ -300,6 +300,22 @@ void vgic_v2_restore_shadow_state(struct kvm_vcpu *vcpu) vgic_cpu->nested_vgic_v2 = vgic_cpu->shadow_vgic_v2; } +void vgic_handle_nested_maint_irq(struct kvm_vcpu *vcpu) +{ + struct vgic_v2_cpu_if *cpu_if = vcpu_nested_if(vcpu); + + /* + * If we exit a nested VM with a pending maintenance interrupt from the + * GIC, then we need to forward this to the guest hypervisor so that it + * can re-sync the appropriate LRs and sample level triggered interrupts + * again. + */ + if (vcpu_el2_imo_is_set(vcpu) && !vcpu_mode_el2(vcpu) && + (cpu_if->vgic_hcr & GICH_HCR_EN) && + vgic_mmio_read_v2_misr(vcpu, 0, 0)) + kvm_inject_nested_irq(vcpu); +} + void vgic_init_nested(struct kvm_vcpu *vcpu) { vgic_v2_setup_shadow_state(vcpu);