|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 03/28] ARM: GICv3: allocate LPI pending and property table
On 27/02/17 11:34, Andre Przywara wrote: Hi, Hi Andre, "Yes, will fix" to everything not explicitly mentioned below. On 06/02/17 16:26, Julien Grall wrote:Hi Andre, On 30/01/17 18:31, Andre Przywara wrote: Please have in mind that distribution will ship one version of Xen for all the platforms. There is no sensible default value and I don't see how a distribution will be able to pick-up one. So I still don't see the point of this default option. + Xen itself does not know how many LPIs domains will ever need + beforehand. + This can be overriden on the command line with the max_lpi_bitss/overriden/overridden/+ parameter. + endmenu menu "ARM errata workaround via the alternative framework" diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 5f4ff23..4ccf2eb 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -19,6 +19,7 @@ obj-y += gic.o obj-y += gic-v2.o obj-$(CONFIG_HAS_GICV3) += gic-v3.o obj-$(CONFIG_HAS_ITS) += gic-v3-its.o +obj-$(CONFIG_HAS_ITS) += gic-v3-lpi.o obj-y += guestcopy.o obj-y += hvm.o obj-y += io.o diff --git a/xen/arch/arm/gic-v3-lpi.c b/xen/arch/arm/gic-v3-lpi.c new file mode 100644 index 0000000..e2fc901 --- /dev/null +++ b/xen/arch/arm/gic-v3-lpi.c @@ -0,0 +1,129 @@ +/* + * xen/arch/arm/gic-v3-lpi.c + * + * ARM GICv3 Locality-specific Peripheral Interrupts (LPI) support + * + * Copyright (C) 2016,2017 - ARM Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <xen/config.h>xen/config.h is not necessary. One instruction can make a lot of differences when a function is executed hundred times. And I was thinking about it before, my rationale for not doing it was: - We need both the number and the shift, and it's much easier to get the number from the bits than the other way around. But you only need the number of bits in the initialization. I don't care if the ITS initialization is little slower than the invert. - The bits are the real source of the information (from TYPER). So? It is fine to use another way to store the value in Xen if it makes easier to use in most of the places. This will also be less confusing for the users. - Having a number would always raise the question whether we need to make sure that there is more than one bit set in there and how to deal with it. It is not difficult to handle that. Also, I find the naming "id_bits" confusing because you store the number of bits to encode the max LPI ID and not the number of bits to encode the number of LPI.
We tend to avoid pointless {} in Xen.
Also, on the previous version it was mentioned this should be an error and then replace by a BUG_ON().I don't see how this would be an actual bug. Yes, the code as it is right now calls this only once, but it wouldn't hurt if we call this multiple times. And I am always a bit wary of crashing the system if we could just carry on instead, but ...Please do the change.... however you like. The question is not whether it would hurt to call this code twice but if it makes sense. It does not make sense to try to allocate the pendtable twice for the same CPU. So it is ever happening it means this is a programming error, hence a BUG_ON makes sense here. Another solution is having an ASSERT(this_cpu(pending_table) == NULL); at the beginning of the function. + + reg |= GICR_PENDBASER_PTZ; + + ASSERT(!(virt_to_maddr(pendtable) & ~GENMASK(51, 16)));I don't understand the purpose of this ASSERT. The bits 15:0 should always be zero otherwise this would be a bug in the memory allocator. For bits 64:52, the architecture so far only support up to 52 bits.You complained about using a mask on the address before, which I can understand. However we are writing to a register described in the spec here and should observe that the address only goes into bits [51:16]. Any other bits should not be touched or we are getting weird errors. So somehow I have to make sure we comply with this. This could either be a mask or an ASSERT. If the assert never fires: great. Nothing to worry about here. But I think this matches the ASSERT idea: we rely on this address being 4K aligned and not exceeding 52 bits worth of address bits, so we should check these assumptions. ASSERT are only for debug build. However, nothing prevent the Xen allocator to differ between non-debug and debug build. So you may end up to never allocate address that are invalid for the GIC in non-debug build. By keeping this ASSERT, you will make our life more difficult to extend the number of physical address supported if ARM decides to bump it.This GICR register is limited to 52 bits of physical address space according to the spec. If we ever upgrade the address size, the GIC spec would need to be upgraded as well, so chances are we either need to touch that code here anyways or we use a GICv5 or the like from the beginning. I am quite convinced it will make our life more difficult. But I am not going to fight for an ASSERT, there are more important stuff to fix. :) Why don't you just disable LPIs here? AFAIK, it should just be writel_relaxed(reg & ~GICR_CTLR_ENABLE_LPIS, GICR_CTLR);Please don't shoot the messenger, but: GICv3 spec 8.11.2 "GICR_CTLR, Redistributor Control Register": Enable_LPIs, bit [0]: "... When a write changes this bit from 0 to 1, this bit becomes RES1 and the Redistributor must load the LPI Pending table from memory to check for any pending interrupts." Read: LPIs are so great that you can't disable them anymore once you have enabled them. How this would work with kexec? Yes, this is a bit weird, even has nasty side effects. In that case, I would prefer to have either a panic or make the CPU unusable to avoid having weird behavior afterwards. [...]
Can we have a comment on top of NR_IRQS explaining why LPIs are not taken into account? Cheers, -- Julien Grall _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |