From patchwork Mon Jan 9 06:24:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 9503841 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 C6EAB60757 for ; Mon, 9 Jan 2017 06:28:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7684280D0 for ; Mon, 9 Jan 2017 06:28:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABD8D2815E; Mon, 9 Jan 2017 06:28:18 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 B57BC280D0 for ; Mon, 9 Jan 2017 06:28:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S940020AbdAIG1J (ORCPT ); Mon, 9 Jan 2017 01:27:09 -0500 Received: from outprodmail02.cc.columbia.edu ([128.59.72.51]:52110 "EHLO outprodmail02.cc.columbia.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S939714AbdAIG0J (ORCPT ); Mon, 9 Jan 2017 01:26:09 -0500 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 v096PXoD005357 for ; Mon, 9 Jan 2017 01:26:06 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id 941EC6D for ; Mon, 9 Jan 2017 01:26:06 -0500 (EST) Received: from sendprodmail01.cc.columbia.edu (sendprodmail01.cc.columbia.edu [128.59.72.13]) by hazelnut (Postfix) with ESMTP id 70B916D for ; Mon, 9 Jan 2017 01:26:06 -0500 (EST) Received: from mail-qk0-f199.google.com (mail-qk0-f199.google.com [209.85.220.199]) by sendprodmail01.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096Q6Zj041127 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 9 Jan 2017 01:26:06 -0500 Received: by mail-qk0-f199.google.com with SMTP id c69so110043122qkg.1 for ; Sun, 08 Jan 2017 22:26:06 -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=KL0P3Lmr2YP3l7NNfpmZ0y1XZFp4TdiNNgvHuc0AUKk=; b=Es3lu6X/uU7m709waXsPZfD+2DZrmNiuwr3CVQPO4x3en/vM6O7K/4wT8Y5jyQ9x1i Fl8KhbaxXsqyoiA33UbZVjyFDPlUgVLT61GMBSn1W8bTFoX27ZvG/lCkHlTT7fhlIBVb eLFEzOmRzNjZyndpvBDzCarquzgFHy62XE3WjIoDoyGnJKy1z/KaR3fzDWRR3H+du8N0 6eCP2TLFAiOlMPmwFayQf/HCHUpzXVBLhbLnLRKwAVX9/yhJE/JHJapCcCLt8vz354x6 +P/5QWfP0CUw2tWgm6E3YpLPYhH+bVj1PiqaFAsvsDhGlt1d7JQsvRMhRP9BpkNF0fCX j+Lw== X-Gm-Message-State: AIkVDXI0/79AM/s0gGH7BFuJ5+GLIgpmo3YtCrTMZCjVpsVhM/zwB6CiVHgSGu9FpVmFB4hpnYKn9wZWzapYV/rBHuTyzW62GKctxD95buqtNm06++a2PpwTywZwhBSLmHe1lEjfiAX5O+E= X-Received: by 10.55.135.197 with SMTP id j188mr85501120qkd.71.1483943165693; Sun, 08 Jan 2017 22:26:05 -0800 (PST) X-Received: by 10.55.135.197 with SMTP id j188mr85501108qkd.71.1483943165553; Sun, 08 Jan 2017 22:26:05 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Jan 2017 22:26:04 -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 Cc: jintack@cs.columbia.edu Subject: [RFC 26/55] KVM: arm/arm64: Add VGIC data structures for the nesting Date: Mon, 9 Jan 2017 01:24:22 -0500 Message-Id: <1483943091-1364-27-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.13 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christoffer Dall This adds a couple of extra data structures: The nested_vgic_vX structures contain the data manipulated by the guest hypervisor when it faults/traps on accesses to the GICH_ interface. The shadow_vgic_vX arrays contain the shadow copies of the LRs. That is, it is a modified version of the nested_vgic_vX->vgic_lr. The reason why we need a modified version is that for interrupts with the HW bit set (those for the timer) the interrupt number must be that of the host hardware number, and not the virtual one programmed by the guest hypervisor. The hw_vX_cpu_if pointers point to the registers that the lowvisor (EL2) code actually copied into hardware when switching to the guest, so at init time we set: vgic_cpu->hw_v2_cpu_if = &vcpu->arch.vgic_cpu.vgic_v2; And we should change the vgic-sr function to read the LRs from the hw_v2_lr pointer. Signed-off-by: Christoffer Dall Signed-off-by: Jintack Lim --- include/kvm/arm_vgic.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index 002f092..9a9cb27 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -246,6 +246,26 @@ struct vgic_cpu { unsigned int used_lrs; struct vgic_irq private_irqs[VGIC_NR_PRIVATE_IRQS]; + /* CPU vif control registers for the virtual GICH interface */ + union { + struct vgic_v2_cpu_if nested_vgic_v2; + struct vgic_v3_cpu_if nested_vgic_v3; + }; + + /* + * The shadow vif control register loaded to the hardware when + * running a sted L2 guest with the virtual IMO bit set. + */ + union { + struct vgic_v2_cpu_if shadow_vgic_v2; + struct vgic_v3_cpu_if shadow_vgic_v3; + }; + + union { + struct vgic_v2_cpu_if *hw_v2_cpu_if; + struct vgic_v3_cpu_if *hw_v3_cpu_if; + }; + spinlock_t ap_list_lock; /* Protects the ap_list */ /*