Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4895992pxj; Tue, 22 Jun 2021 10:20:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5V9OwiZ3PaMpMpHrFWWoWrAHo7yyIAw3225dw3BN9NLMSP68z5p6uGG39MqUIVV2X8/jU X-Received: by 2002:a92:7b07:: with SMTP id w7mr3328492ilc.308.1624382401360; Tue, 22 Jun 2021 10:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624382401; cv=none; d=google.com; s=arc-20160816; b=pPm85HKvv5galWd/RiZNifeGPHJK4wLdZQhqAswNEDndX6UxMo8W2jdYIazm38tTAX zuv0n8S+Tduw089QFHi4xr7XIfbpl8dKRNJDClE4PrioV1MFIwCDDDsR+RYsZb7pUuz8 P6PKsic1lYJmDKPEP5YRD9298VQL7tl7mmQgCMqXOXcB4+5BCDIHDTIL0pvkiB042ZCT mkAXKWxqI8VN2q6zetAT3xrkw1fJvVA0BxShONCdM7NACYmW5aEvSFKTLwz1Xe0fOgjx UkhAGZxSOp99OLwCEW2eThkXdz4AcrmbZ5b8x5IknUaumOdkKWutLd8W8PLyBG+/ovcN 99Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=jgkvZYSSzjJVoE4KJKulp6fmziB3eWidYOHiWvBp+mg=; b=L6QPiCm2XiTkF7vTZhw93BQ/hzs/5pjnnnCzEQ6cW0QNqBIRVhPp8HB1UNsIh3P/wC +nxPUGO5pYkMD12+ya3XrqxzyLKkdHPlpoXbEYXOMfvW958TcAzhxw1tcZeoDJD0B+43 AV04oJ7RhAPOzPErai34LFiDLn547BGm9CUpBufqcmOyjvjLHxjQAU6uvcRz/F8aJTMQ StQ14xc8NeMxMHWZl46HOdfjxmT6Nst+okek7RcUm+SMH5G/iYGYgdDoyJNGJeGhuZ/Y JP0svA+lKf6vMFpRMg0pDpe4gE2NNMatDjWmENX6/mJEBwKm6rVTl5v94DOtaTI6XfCp 8s5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id a6si6211309ilv.63.2021.06.22.10.19.48; Tue, 22 Jun 2021 10:20:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231189AbhFVRUO (ORCPT + 99 others); Tue, 22 Jun 2021 13:20:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:39410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbhFVRUO (ORCPT ); Tue, 22 Jun 2021 13:20:14 -0400 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 796AA61166; Tue, 22 Jun 2021 17:17:58 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lvk28-009Drp-FA; Tue, 22 Jun 2021 18:17:56 +0100 Date: Tue, 22 Jun 2021 18:17:55 +0100 Message-ID: <87tulpbyyk.wl-maz@kernel.org> From: Marc Zyngier To: Boqun Feng Cc: Thomas Gleixner , linux-kernel@vger.kernel.org, Arnd Bergmann , Bjorn Helgaas , Linux ARM , Catalin Marinas , Will Deacon , Sunil Muthuswamy Subject: Re: [RFC 2/2] irqchip/gic-v3-its: Introduce virtual ITS In-Reply-To: <20210622155313.3819952-3-boqun.feng@gmail.com> References: <20210622155313.3819952-1-boqun.feng@gmail.com> <20210622155313.3819952-3-boqun.feng@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: boqun.feng@gmail.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, arnd@arndb.de, bhelgaas@google.com, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, sunilmut@microsoft.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 22 Jun 2021 16:53:13 +0100, Boqun Feng wrote: > > GICv3 allows supporting LPI without an ITS, and in order to support > such a platform, a virtual ITS is introduced. The virtual ITS has the > same software part as a real ITS: having an irq domain, maintaining > ->collections and maintaining the list of devices. The only difference > is the virtual ITS doesn't have a backed ITS therefore it cannot issue > ITS commands nor set up device tables. The virtual ITS only manages LPIs > and the LPIs are configured via DirectLPI interfaces. That's not a virtual ITS. Not at all. It isn't even the shadow of an ITS. This is... something else. > > And currently the virtual ITS is initialized only if there is no ITS in > the system and yet DirectLPI is support. > > The virtual ITS approach provides the support for LPI without an ITS and > reuses as much exisiting code as possible, and is the preparation for > virtual PCI support on ARM64 Hyper-V guests. There is no translation, no isolation. This is a yet another sorry excuse for a hack. Why can't the Hyper-V folks implement the architecture, only the architecture, and all of it? > > Co-developed-by: Sunil Muthuswamy > Signed-off-by: Boqun Feng > --- > drivers/irqchip/irq-gic-v3-its.c | 114 ++++++++++++++++++++++++++++--- > 1 file changed, 106 insertions(+), 8 deletions(-) > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index 1916ac5d6371..4f2600377039 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -117,9 +117,16 @@ struct its_node { > int vlpi_redist_offset; > }; > > +/* > + * LPI can be supported without ITS, in which case, a virtual its_node is > + * initialized to allow configuring LPI with the DirectLPI approach. > + */ > +static struct its_node *virtual_its_node; > + > #define is_v4(its) (!!((its)->typer & GITS_TYPER_VLPIS)) > #define is_v4_1(its) (!!((its)->typer & GITS_TYPER_VMAPP)) > #define device_ids(its) (FIELD_GET(GITS_TYPER_DEVBITS, (its)->typer) + 1) > +#define is_virtual(its) ((its) == virtual_its_node) And you can only have one? > > #define ITS_ITT_ALIGN SZ_256 > > @@ -1096,6 +1103,10 @@ void name(struct its_node *its, \ > unsigned long flags; \ > u64 rd_idx; \ > \ > + /* Virtual ITS doesn't support ITS commands */ \ > + if (is_virtual(its)) \ > + return; \ > + \ Oh gawd... > raw_spin_lock_irqsave(&its->lock, flags); \ > \ > cmd = its_allocate_entry(its); \ > @@ -1464,7 +1475,8 @@ static void lpi_update_config(struct irq_data *d, u8 clr, u8 set) > > lpi_write_config(d, clr, set); > if (gic_rdists->has_direct_lpi && > - (is_v4_1(its_dev->its) || !irqd_is_forwarded_to_vcpu(d))) > + (is_v4_1(its_dev->its) || !irqd_is_forwarded_to_vcpu(d) || > + is_virtual(its_dev->its))) > direct_lpi_inv(d); > else if (!irqd_is_forwarded_to_vcpu(d)) > its_send_inv(its_dev, its_get_event_id(d)); > @@ -1690,6 +1702,10 @@ static void its_irq_compose_msi_msg(struct irq_data *d, struct msi_msg *msg) > u64 addr; > > its = its_dev->its; > + > + /* Virtual ITS doesn't have ->get_msi_base function, skip */ > + if (!its->get_msi_base) > + return; So how do you target a redistributor? If you are going to use DirectLPI, this should hit the GICR_SETLPIR for the relevant redistributor. Actually, how do you target another redistributor? You can't send a MOVI, and you don't change the target address. And even if you could, how do you move the pending state from one pending table to another? Which means you probably have some other, non architectural stuff somewhere else. [...] I'll stop here. I'm not taking this hack built on top of the ITS code. Not now, not ever. If you really want to implement something that is outside of the scope of the architecture, do it outside of the GICv3 code, because this is just pretending to follow the architecture. Or even better, get the Hyper-V folks to implement a *real* virtual ITS, in the hypervisor. Yes, this is hard. M. -- Without deviation from the norm, progress is not possible.