From patchwork Fri Nov 8 14:42:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 11234997 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C52EB1599 for ; Fri, 8 Nov 2019 14:43:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4A022245A for ; Fri, 8 Nov 2019 14:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728691AbfKHOnE (ORCPT ); Fri, 8 Nov 2019 09:43:04 -0500 Received: from foss.arm.com ([217.140.110.172]:44644 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727673AbfKHOnE (ORCPT ); Fri, 8 Nov 2019 09:43:04 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DA65346A; Fri, 8 Nov 2019 06:43:03 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.197.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BD1F73F719; Fri, 8 Nov 2019 06:43:02 -0800 (PST) From: Andre Przywara To: Andrew Jones , Paolo Bonzini Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Marc Zyngier , Alexandru Elisei Subject: [kvm-unit-tests PATCH 10/17] arm: gic: Check for writable IGROUPR registers Date: Fri, 8 Nov 2019 14:42:33 +0000 Message-Id: <20191108144240.204202-11-andre.przywara@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191108144240.204202-1-andre.przywara@arm.com> References: <20191108144240.204202-1-andre.przywara@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When both groups are avaiable to the non-secure side, the MMIO group registers need to be writable, so that the group that an IRQ belongs to can be programmed. Check that the group can be flipped, after having established that both groups are usable. Signed-off-by: Andre Przywara --- arm/gic.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arm/gic.c b/arm/gic.c index c882a24..485ca4f 100644 --- a/arm/gic.c +++ b/arm/gic.c @@ -683,6 +683,7 @@ static bool gicv3_check_security(void *gicd_base) static void test_irq_group(void *gicd_base) { bool is_gicv3 = (gic_version() == 3); + u32 reg; report_prefix_push("GROUP"); gic_enable_defaults(); @@ -692,6 +693,16 @@ static void test_irq_group(void *gicd_base) if (!gicv3_check_security(gicd_base)) return; } + + /* + * On a security aware GIC in non-secure world the IGROUPR registers + * are RAZ/WI. KVM emulates a single-security-state GIC, so both + * groups are available and the IGROUPR registers are writable. + */ + reg = gic_get_irq_group(SPI_IRQ); + gic_set_irq_group(SPI_IRQ, !reg); + report("IGROUPR is writable", gic_get_irq_group(SPI_IRQ) != reg); + gic_set_irq_group(SPI_IRQ, reg); } static void spi_send(void)