From patchwork Thu Dec 7 17:05:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10100195 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 4D1146056F for ; Thu, 7 Dec 2017 17:07:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3675D284B5 for ; Thu, 7 Dec 2017 17:07:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B2FA284DE; Thu, 7 Dec 2017 17:07: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=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 69A65284B5 for ; Thu, 7 Dec 2017 17:07: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=3yzsOjdMvOfPETjNxibrNDTXa7Se5Rv9Ns6LcZzqVNo=; b=MvQYUmjljrf4l37kldvRu9yFUQ WYOa7HeUgWowL+Ux0wgKS7P4pHLhH1uphvsDLn0YJ9xAC9pBb96B6pjCzmUD4qRF+yh5DiXHWvZHG GK9gvXcsV9qch4MGxP03o8/lgiPr0LdnP38sFkEP1enAVChWEUWHh9cx4ESpUx0gQnNyz7mS/SbBB 7PfRaYxpGp/KROV2vphkJpm35fcv1y8Ad/Mm3JH7p70Zzp+D7LXtIBwCeyq9/49ve6SNafjxSPY8r 9tP9XeV4y8qX+l4/6VOwGdicA8N1JRJlpQ4Z9eBMedkNjalpbqcXABGBhecNUJDBC8RXxvaYbiOsr 0ZNYxNAg==; 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 1eMzdw-0003Ov-GH; Thu, 07 Dec 2017 17:07:28 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eMzdV-0002h4-F2 for linux-arm-kernel@lists.infradead.org; Thu, 07 Dec 2017 17:07:03 +0000 Received: by mail-wm0-x244.google.com with SMTP id b76so14239675wmg.1 for ; Thu, 07 Dec 2017 09:06:44 -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=3l7j3On+3gImWG8u8u/XAlOL0nLfosuCknt7xTUnbm8=; b=M2h7/w7APu3TjVaeem6Lu1+LHOIvF2N4cR/7eIWuN9NBkHly43cB1vSA1CagO1MCRv Ei9APUbEMnCW4VemrK5c4M3vHYccxHqiOMO+mdOL3WAc/3qqSZpidQgs0TgNFfhKSjIX Ctpw5hDIJBSq8dQYWDXp+wGyEYPKG3JjVxu8o= 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=3l7j3On+3gImWG8u8u/XAlOL0nLfosuCknt7xTUnbm8=; b=tB5nEEYuY1fXSdFGTQkDWZ0KgmtpTQeXxqPMbKg6+7ReXjJCHPuHW+ieYOyXngwvlD C0hmHq5h8ZNMwEeBfZLK/PYd+CfY+D83O/cK5EYuxuokpjBRTL+DJOcK8xMNdx8yQNiL w+996rReWRA461CMlRSyFm7n62jSuhdvKiNacKfca05uX3u+l/mIiFUdR7ALs2kXRttY o9mdyvvXN7HReg3xPoCdqBZJiwMKYEVhpLw4HT2XPqIvReLMxoscpt7yqF48MM5kLevI scjva+6WDM2ezPJRD9fokyC02X8KINY5xtD+2weFItvoDgW/GCtsyr0feUpHY8CSBsSL NjJA== X-Gm-Message-State: AKGB3mJx4UhWjPz7eDbCDoYHYZwnwdfV/pifh+lcAEj2uK2isqDzhcdC RVIpvf5r5K9EVk8TcpVk43J+uA== X-Google-Smtp-Source: AGs4zMZFddNc3aV0afz5ZJBNfWofPAbTv6IQwq1tQyJCFO3DbDMlb+L7h4xeYhmJ+wGDba7eArPxYg== X-Received: by 10.80.141.141 with SMTP id r13mr13720820edh.122.1512666402916; Thu, 07 Dec 2017 09:06:42 -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.06.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Dec 2017 09:06:41 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 03/36] KVM: arm64: Move HCR_INT_OVERRIDE to default HCR_EL2 guest flag Date: Thu, 7 Dec 2017 18:05:57 +0100 Message-Id: <20171207170630.592-4-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_090701_699094_50A868A8 X-CRM114-Status: GOOD ( 12.84 ) 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 From: Shih-Wei Li We always set the IMO and FMO bits in the HCR_EL2 when running the guest, regardless if we use the vgic or not. By moving these flags to HCR_GUEST_FLAGS we can avoid one of the extra save/restore operations of HCR_EL2 in the world switch code, and we can also soon get rid of the other one. This is safe, because even though the IMO and FMO bits control both taking the interrupts to EL2 and remapping ICC_*_EL1 to ICV_*_EL1 executed at EL1, as long as we ensure that these bits are clear when running the EL1 host, as defined in the HCR_HOST_[VHE_]FLAGS, we're OK. Reviewed-by: Marc Zyngier Signed-off-by: Shih-Wei Li Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/kvm_arm.h | 4 ++-- arch/arm64/kvm/hyp/switch.c | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 715d395ef45b..656deeb17bf2 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -79,9 +79,9 @@ */ #define HCR_GUEST_FLAGS (HCR_TSC | HCR_TSW | HCR_TWE | HCR_TWI | HCR_VM | \ HCR_TVM | HCR_BSU_IS | HCR_FB | HCR_TAC | \ - HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW) + HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | \ + HCR_FMO | HCR_IMO) #define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF) -#define HCR_INT_OVERRIDE (HCR_FMO | HCR_IMO) #define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H) /* TCR_EL2 Registers bits */ diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index 71700ecee308..f6189d08753e 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -167,8 +167,6 @@ static void __hyp_text __vgic_save_state(struct kvm_vcpu *vcpu) __vgic_v3_save_state(vcpu); else __vgic_v2_save_state(vcpu); - - write_sysreg(read_sysreg(hcr_el2) & ~HCR_INT_OVERRIDE, hcr_el2); } static void __hyp_text __vgic_restore_state(struct kvm_vcpu *vcpu) @@ -176,7 +174,6 @@ static void __hyp_text __vgic_restore_state(struct kvm_vcpu *vcpu) u64 val; val = read_sysreg(hcr_el2); - val |= HCR_INT_OVERRIDE; val |= vcpu->arch.irq_lines; write_sysreg(val, hcr_el2);