Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1841458ybv; Fri, 14 Feb 2020 06:59:17 -0800 (PST) X-Google-Smtp-Source: APXvYqzXr6xIpoEJC+Vv7Ax38Qom6LGhKx3Fvm17j+K47VHINFuGxkQvW0S3y5Pwkbr6DmEBa302 X-Received: by 2002:a9d:bb8:: with SMTP id 53mr2395545oth.150.1581692356921; Fri, 14 Feb 2020 06:59:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581692356; cv=none; d=google.com; s=arc-20160816; b=k8gZuqCJuUUAkk4cIxlz0uwjEbhOTKCZXN5nvc0tyBxK+ULXEYvaymX3+qXbRhZHG9 bK7o4tr9NmTrT4fHNiSP77C0ChzEyiaLiqst/Hj5WWC1ycPRwafTfJWoeW0rpFuwIe3J xlDeVFgZPtGpvo0BGT03QoKnVodnyxIMcO2N8BbfPmBWoHvxziXou6PpUSWnG4yEWQfF W+SLJIq7LAcYo4APouW5WtiHCKom61vrOqG7g4GH3I2P8TNYwfPqMb+ml8XCFJm44gmN NbUkxOkXioEOpgyUsHYsiylppaPBEnjEgm3rVP2rt1lNIPMA1ru1Wfev+U/E1iwD2r8U Kwpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BEmTGickxxHyf5ULWo2RPIIU5n4ghzThf5t0CzhjyP4=; b=F0agC16wixOGt21r2orAqXTWAegEVlkRTpfmIlFvzM24fwMA1ih/+j2vcM/oh+ODZu /cLClWaZHcce24ZQo+YQcwMwHzMG+LgKarFRHLWk0bbFJ5m+oA1PcBxDGiknXY1hwKQs 4gvcE0WXw3EAYw2H+gLS5tRLK/vJ9t3LYJfD3TdYPVVT7up2w/9LAlCTTf9+fu95NaZX 7UMUBh75SpTly1AgnDKYscFkXGaw1tQaaJgc+UYwhvTVZlDuMf4lokbZgLqRezriE42P ue5ugx4K+EKIn46bamGvUeHOEAFB2TBdD+LEs1sTTcOa3fL3PRYxpa3mgS5XFfuRyh0c ZBOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sbFhWqEp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11si3162209otp.176.2020.02.14.06.59.04; Fri, 14 Feb 2020 06:59:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sbFhWqEp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387441AbgBNO5u (ORCPT + 99 others); Fri, 14 Feb 2020 09:57:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:51036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729294AbgBNO5t (ORCPT ); Fri, 14 Feb 2020 09:57:49 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2B27724681; Fri, 14 Feb 2020 14:57:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581692268; bh=kNgwkIvSiUh1x+liaoEQl3asDxJlp/aCxRuXoHWWqqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sbFhWqEp8X34b79OW7oH8jWuOYk5kXzxD/xQgaHIfDqorH999nikEFwJERhM1vMWr flKE8V+pXqLDmhhBM2UVeSjGOqGXj0A7krKTBEVCBuZSKER6xgm/O1PyrdkoQiyBEz Kx1eW/csCx5LVyj6fxLTVrYqzXA3O4T1/lrAyfxM= Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j2cPa-0057sw-HN; Fri, 14 Feb 2020 14:57:46 +0000 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lorenzo Pieralisi , Jason Cooper , Robert Richter , Thomas Gleixner , Zenghui Yu , Eric Auger , James Morse , Julien Thierry , Suzuki K Poulose Subject: [PATCH v4 02/20] irqchip/gic-v3: Use SGIs without active state if offered Date: Fri, 14 Feb 2020 14:57:18 +0000 Message-Id: <20200214145736.18550-3-maz@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214145736.18550-1-maz@kernel.org> References: <20200214145736.18550-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, lorenzo.pieralisi@arm.com, jason@lakedaemon.net, rrichter@marvell.com, tglx@linutronix.de, yuzenghui@huawei.com, eric.auger@redhat.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To allow the direct injection of SGIs into a guest, the GICv4.1 architecture has to sacrifice the Active state so that SGIs look a lot like LPIs (they are injected by the same mechanism). In order not to break existing software, the architecture gives offers guests OSs the choice: SGIs with or without an active state. It is the hypervisors duty to honor the guest's choice. For this, the architecture offers a discovery bit indicating whether the GIC supports GICv4.1 SGIs (GICD_TYPER2.nASSGIcap), and another bit indicating whether the guest wants Active-less SGIs or not (controlled by GICD_CTLR.nASSGIreq). A hypervisor not supporting GICv4.1 SGIs would leave nASSGIcap clear, and a guest not knowing about GICv4.1 SGIs (or definitely wanting an Active state) would leave nASSGIreq clear (both being thankfully backward compatible with oler revisions of the GIC). Since Linux is perfectly happy without an active state on SGIs, inform the hypervisor that we'll use that if offered. Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3.c | 10 ++++++++-- include/linux/irqchip/arm-gic-v3.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index cd76435c4a31..73e87e176d76 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -724,6 +724,7 @@ static void __init gic_dist_init(void) unsigned int i; u64 affinity; void __iomem *base = gic_data.dist_base; + u32 val; /* Disable the distributor */ writel_relaxed(0, base + GICD_CTLR); @@ -756,9 +757,14 @@ static void __init gic_dist_init(void) /* Now do the common stuff, and wait for the distributor to drain */ gic_dist_config(base, GIC_LINE_NR, gic_dist_wait_for_rwp); + val = GICD_CTLR_ARE_NS | GICD_CTLR_ENABLE_G1A | GICD_CTLR_ENABLE_G1; + if (gic_data.rdists.gicd_typer2 & GICD_TYPER2_nASSGIcap) { + pr_info("Enabling SGIs without active state\n"); + val |= GICD_CTLR_nASSGIreq; + } + /* Enable distributor with ARE, Group1 */ - writel_relaxed(GICD_CTLR_ARE_NS | GICD_CTLR_ENABLE_G1A | GICD_CTLR_ENABLE_G1, - base + GICD_CTLR); + writel_relaxed(val, base + GICD_CTLR); /* * Set all global interrupts to the boot CPU only. ARE must be diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index 83439bfb6c5b..c29a02678a6f 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -57,6 +57,7 @@ #define GICD_SPENDSGIR 0x0F20 #define GICD_CTLR_RWP (1U << 31) +#define GICD_CTLR_nASSGIreq (1U << 8) #define GICD_CTLR_DS (1U << 6) #define GICD_CTLR_ARE_NS (1U << 4) #define GICD_CTLR_ENABLE_G1A (1U << 1) @@ -90,6 +91,7 @@ #define GICD_TYPER_ESPIS(typer) \ (((typer) & GICD_TYPER_ESPI) ? GICD_TYPER_SPIS((typer) >> 27) : 0) +#define GICD_TYPER2_nASSGIcap (1U << 8) #define GICD_TYPER2_VIL (1U << 7) #define GICD_TYPER2_VID GENMASK(4, 0) -- 2.20.1