From patchwork Tue Feb 27 11:33:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10244929 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 89C1260208 for ; Tue, 27 Feb 2018 11:41:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D54F2434C for ; Tue, 27 Feb 2018 11:41:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7255E28595; Tue, 27 Feb 2018 11:41:46 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 150E92434C for ; Tue, 27 Feb 2018 11:41:45 +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=fjiuXhWbP1GWEysYYDLXG0U3nO8OohquBiIsECkgqW8=; b=Clm9n52fHcZKARl9dfeElJpa6n KIUnAcE2YRdzETSQj2lRhKHcSHsUDanC2cBSaEHyOAMziKQPyzLuYBYMswb2XrGrN7Mh8hnLTI5h4 UHn3eKWp/tAaVK9F2rz+r2I97gBQOILc0OAanxOuWphRwEjuKnDWDt6gximRQaIsooCwSBPuEFWR4 +QULYrpk5HNV8nB50FksFv/ZAtQPCDGVNj+uPRFcaQRR0OOuzCMH4S9A/lN2X12iq4iczPi/t9saC Srz62shYRcVVHv7MLqJgPwa4YkJBRQXfLAfU5j/3WSzuhtg1/V+LD0FaUuzwustTaZZV9M5eEB2wQ zq10mCcQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqdda-00045P-RM; Tue, 27 Feb 2018 11:41:38 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqdWv-0006W7-K7 for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2018 11:34:51 +0000 Received: by mail-wm0-x243.google.com with SMTP id t74so23539668wme.3 for ; Tue, 27 Feb 2018 03:34:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=christofferdall-dk.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=cDxy0xqmMalPFjt5Bc9PYKHeMzbcZ4R8NYuPgSFNL64=; b=HdrmyhaPMi2sunyf+2MtL3QtF9pSUWH7ZAZWoYqFLrBIzJJtj/raSEEv7eXfs78TkQ ZCotv/MAZvpzvJEznz4Qsm/d5bYwgwljNSxPg94GycXRn+gepcLy8QG1gqWj02hZLzLt 7nEjECZoaA8ODaRH/MJpUWWTzH6ZCSQ62o9hReYQwnfqvCUoS1GbFER4Bd19rslZWULC YH9XAMieAqui9N8lF0W+DVrp+KDRzK2x1o3H2dSUI9p3rre8r0ZTOlUO3GV3yiz3ra73 csEy/rpUA/caw5cDoeMeNhxDDEiVs1tnyXW0Hq1bzyY4Z/7WA5BqsplciZRIqDUmBVee 7UgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=cDxy0xqmMalPFjt5Bc9PYKHeMzbcZ4R8NYuPgSFNL64=; b=AspeafWLtHkisphEt5KU3Fsw6hma6KWwjD451ukjccx/u50ao7p8qBIaZQclm7dLzE FC65QV2ypZSuILgGGRuBpxqPLeC0SFgletlUkE/yTBvA58cGbLVnHwfOjjsPsb3BWhfy rGRrleyPJyE8Ce/hRy+cFzOrQx1OvWQYL7lnXYd9/RyM83ZKHHXeiXidsWl8ydCMI6VA Du2MLH9bPPD4tevAb1pPPxBPrOo9aFecxtkHsWJRDOzUtlDalhSPecsl4hwbcuTPPqb0 EJ087zkVQxZhGkfTrSPCIZ8Cd8SqbVRBwXi5xw7efL1AqIGIioVf/TpFArfex4AFX2f4 k9xg== X-Gm-Message-State: APf1xPBOrmPsjLzDgYGuIvXoN8zNu3rq5S/OVZmtqZPWBGKlxxpjLU8a CUBo1bNiGmbHgpS5LhOztOfPpg== X-Google-Smtp-Source: AH8x226bfpie/TSyDYT0hpP7DCJMrYTvOEsoIVnT7VsIxoEFOHptiBEj265looGSiNQxIxEXJW6+Tg== X-Received: by 10.80.137.215 with SMTP id h23mr18376213edh.302.1519731279476; Tue, 27 Feb 2018 03:34:39 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id m1sm9176786ede.39.2018.02.27.03.34.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Feb 2018 03:34:38 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 05/40] KVM: arm64: Move HCR_INT_OVERRIDE to default HCR_EL2 guest flag Date: Tue, 27 Feb 2018 12:33:54 +0100 Message-Id: <20180227113429.637-6-cdall@kernel.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180227113429.637-1-cdall@kernel.org> References: <20180227113429.637-1-cdall@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180227_033445_953738_DC89E04C X-CRM114-Status: GOOD ( 14.97 ) 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: Andrew Jones , kvm@vger.kernel.org, Marc Zyngier , Tomasz Nowicki , Julien Grall , Yury Norov , Dave Martin , Shih-Wei Li 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 when executed at EL1, as long as we ensure that these bits are clear when running the EL1 host, we're OK, because we reset the HCR_EL2 to only have the HCR_RW bit set when returning to EL1 on non-VHE systems. Reviewed-by: Marc Zyngier Signed-off-by: Shih-Wei Li Signed-off-by: Christoffer Dall --- Notes: Changes since v3: - Slightly reworded the commit message 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 1b438c334463..6dd285e979c9 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -83,9 +83,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_TLOR) + HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | HCR_TLOR | \ + 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 579d9a263853..4117717548b0 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -174,8 +174,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) @@ -183,7 +181,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);