Re: [PATCH v13 03/15] iommu/arm-smmu-v3: Maintain a SID->device structure

2021-02-01 Thread Keqian Zhu
Hi Eric, On 2021/2/2 1:19, Auger Eric wrote: > Hi Keqian, > > On 2/1/21 1:26 PM, Keqian Zhu wrote: >> Hi Eric, >> >> On 2020/11/18 19:21, Eric Auger wrote: >>> From: Jean-Philippe Brucker >>> >>> When handling faults from the event or PRI queue, we need to find the >>> struct device associated t

Re: [PATCH v13 05/15] iommu/smmuv3: Get prepared for nested stage support

2021-02-01 Thread Keqian Zhu
Hi Eric, On 2020/11/18 19:21, Eric Auger wrote: > When nested stage translation is setup, both s1_cfg and > s2_cfg are set. > > We introduce a new smmu domain abort field that will be set > upon guest stage1 configuration passing. > > arm_smmu_write_strtab_ent() is modified to write both stage >

Re: [PATCH v13 03/15] iommu/arm-smmu-v3: Maintain a SID->device structure

2021-02-01 Thread Keqian Zhu
Hi Jean, On 2021/2/1 23:15, Jean-Philippe Brucker wrote: > On Mon, Feb 01, 2021 at 08:26:41PM +0800, Keqian Zhu wrote: >>> +static int arm_smmu_insert_master(struct arm_smmu_device *smmu, >>> + struct arm_smmu_master *master) >>> +{ >>> + int i; >>> + int ret = 0; >

Re: [RFC PATCH v2 06/26] KVM: arm64: Factor memory allocation out of pgtable.c

2021-02-01 Thread Quentin Perret
On Monday 01 Feb 2021 at 18:16:08 (+), Will Deacon wrote: > On Fri, Jan 08, 2021 at 12:15:04PM +, Quentin Perret wrote: > > In preparation for enabling the creation of page-tables at EL2, factor > > all memory allocation out of the page-table code, hence making it > > re-usable with any com

Re: [RFC PATCH v2 03/26] arm64: kvm: Add standalone ticket spinlock implementation for use at hyp

2021-02-01 Thread Quentin Perret
On Monday 01 Feb 2021 at 17:28:34 (+), Will Deacon wrote: > On Fri, Jan 08, 2021 at 12:15:01PM +, Quentin Perret wrote: > > From: Will Deacon > > > > We will soon need to synchronise multiple CPUs in the hyp text at EL2. > > The qspinlock-based locking used by the host is overkill for thi

Re: [RFC PATCH v2 11/26] KVM: arm64: Stub CONFIG_DEBUG_LIST at Hyp

2021-02-01 Thread Will Deacon
On Fri, Jan 08, 2021 at 12:15:09PM +, Quentin Perret wrote: > In order to use the kernel list library at EL2, introduce stubs for the > CONFIG_DEBUG_LIST out-of-lines calls. > > Signed-off-by: Quentin Perret > --- > arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- > arch/arm64/kvm/hyp/nvhe/stub.c

Re: [RFC PATCH v2 10/26] KVM: arm64: Introduce an early Hyp page allocator

2021-02-01 Thread Will Deacon
On Fri, Jan 08, 2021 at 12:15:08PM +, Quentin Perret wrote: > diff --git a/arch/arm64/kvm/hyp/nvhe/early_alloc.c > b/arch/arm64/kvm/hyp/nvhe/early_alloc.c > new file mode 100644 > index ..de4c45662970 > --- /dev/null > +++ b/arch/arm64/kvm/hyp/nvhe/early_alloc.c > @@ -0,0 +1,60 @@

Re: [RFC PATCH v2 09/26] KVM: arm64: Allow using kvm_nvhe_sym() in hyp code

2021-02-01 Thread Will Deacon
On Fri, Jan 08, 2021 at 12:15:07PM +, Quentin Perret wrote: > In order to allow the usage of code shared by the host and the hyp in > static inline library function, allow the usage of kvm_nvhe_sym() at el2 typo: functions > by defaulting to the raw symbol name. > > Signed-off-by: Quentin Pe

Re: [RFC PATCH v2 08/26] KVM: arm64: Make kvm_call_hyp() a function call at Hyp

2021-02-01 Thread Will Deacon
On Fri, Jan 08, 2021 at 12:15:06PM +, Quentin Perret wrote: > kvm_call_hyp() has some logic to issue a function call or a hypercall > depending the EL at which the kernel is running. However, all the code > compiled under __KVM_NVHE_HYPERVISOR__ is guaranteed to run only at EL2, > and in this c

Re: [RFC PATCH v2 06/26] KVM: arm64: Factor memory allocation out of pgtable.c

2021-02-01 Thread Will Deacon
On Mon, Feb 01, 2021 at 06:32:52PM +, Quentin Perret wrote: > On Monday 01 Feb 2021 at 18:16:08 (+), Will Deacon wrote: > > On Fri, Jan 08, 2021 at 12:15:04PM +, Quentin Perret wrote: > > > +static struct kvm_pgtable_mm_ops kvm_s2_mm_ops = { > > > + .zalloc_page= stage2_memc

Re: [RFC PATCH v2 07/26] KVM: arm64: Introduce a BSS section for use at Hyp

2021-02-01 Thread Will Deacon
On Fri, Jan 08, 2021 at 12:15:05PM +, Quentin Perret wrote: > Currently, the hyp code cannot make full use of a bss, as the kernel > section is mapped read-only. > > While this mapping could simply be changed to read-write, it would > intermingle even more the hyp and kernel state than they cu

Re: [RFC PATCH v2 06/26] KVM: arm64: Factor memory allocation out of pgtable.c

2021-02-01 Thread Will Deacon
On Fri, Jan 08, 2021 at 12:15:04PM +, Quentin Perret wrote: > In preparation for enabling the creation of page-tables at EL2, factor > all memory allocation out of the page-table code, hence making it > re-usable with any compatible memory allocator. > > No functional changes intended. > > Si

Re: [RFC PATCH v2 05/26] KVM: arm64: Avoid free_page() in page-table allocator

2021-02-01 Thread Will Deacon
On Fri, Jan 08, 2021 at 12:15:03PM +, Quentin Perret wrote: > Currently, the KVM page-table allocator uses a mix of put_page() and > free_page() calls depending on the context even though page-allocation > is always achieved using variants of __get_free_page(). > > Make the code consitent by u

Re: [RFC PATCH v2 04/26] KVM: arm64: Initialize kvm_nvhe_init_params early

2021-02-01 Thread Will Deacon
On Fri, Jan 08, 2021 at 12:15:02PM +, Quentin Perret wrote: > Move the initialization of kvm_nvhe_init_params in a dedicated function > that is run early, and only once during KVM init, rather than every time > the KVM vectors are set and reset. > > This also opens the opportunity for the hype

Re: [RFC PATCH v2 03/26] arm64: kvm: Add standalone ticket spinlock implementation for use at hyp

2021-02-01 Thread Will Deacon
On Fri, Jan 08, 2021 at 12:15:01PM +, Quentin Perret wrote: > From: Will Deacon > > We will soon need to synchronise multiple CPUs in the hyp text at EL2. > The qspinlock-based locking used by the host is overkill for this purpose > and relies on the kernel's "percpu" implementation for the M

Re: [PATCH v13 03/15] iommu/arm-smmu-v3: Maintain a SID->device structure

2021-02-01 Thread Auger Eric
Hi Keqian, On 2/1/21 1:26 PM, Keqian Zhu wrote: > Hi Eric, > > On 2020/11/18 19:21, Eric Auger wrote: >> From: Jean-Philippe Brucker >> >> When handling faults from the event or PRI queue, we need to find the >> struct device associated to a SID. Add a rb_tree to keep track of SIDs. >> >> Signed

Re: [PATCH v13 01/15] iommu: Introduce attach/detach_pasid_table API

2021-02-01 Thread Auger Eric
Hi Keqian, On 2/1/21 12:27 PM, Keqian Zhu wrote: > Hi Eric, > > On 2020/11/18 19:21, Eric Auger wrote: >> In virtualization use case, when a guest is assigned >> a PCI host device, protected by a virtual IOMMU on the guest, >> the physical IOMMU must be programmed to be consistent with >> the gue

Re: [PATCH v13 03/15] iommu/arm-smmu-v3: Maintain a SID->device structure

2021-02-01 Thread Jean-Philippe Brucker
On Mon, Feb 01, 2021 at 08:26:41PM +0800, Keqian Zhu wrote: > > +static int arm_smmu_insert_master(struct arm_smmu_device *smmu, > > + struct arm_smmu_master *master) > > +{ > > + int i; > > + int ret = 0; > > + struct arm_smmu_stream *new_stream, *cur_stream; > >

Re: arm64: gen-hyprel.c:40:10: fatal error: generated/autoconf.h: No such file or directory

2021-02-01 Thread Naresh Kamboju
On Mon, 1 Feb 2021 at 19:15, Marc Zyngier wrote: > > On 2021-02-01 13:38, Naresh Kamboju wrote: > > Linux next 20210201 tag arm64 builds failed. > > kernel config attached to this email. > > > > BAD:next-20210201 > > GOOD: next-20210129 > > > >

Re: [PATCH v2 4/8] KVM: arm64: Generate hyp relocation data

2021-02-01 Thread David Brazdil
Thanks for writing the fix, Marc! There are no corner cases in this code so if it boots, that should be a good indicator that all BE inputs were converted. Just one little thing I noticed below, otherwise: Acked-by: David Brazdil > arch/arm64/kvm/hyp/nvhe/Makefile | 1 + > arch/arm64/kvm/h

Re: arm64: gen-hyprel.c:40:10: fatal error: generated/autoconf.h: No such file or directory

2021-02-01 Thread Marc Zyngier
On 2021-02-01 13:38, Naresh Kamboju wrote: Linux next 20210201 tag arm64 builds failed. kernel config attached to this email. BAD:next-20210201 GOOD: next-20210129 make --silent --keep-going --jobs=8 O=/home/tuxbuild/.cache/tuxmake/builds/1/tmp ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu

Re: [RFC PATCH 0/7] kvm: arm64: Implement SW/HW combined dirty log

2021-02-01 Thread Keqian Zhu
On 2021/2/1 21:17, Marc Zyngier wrote: > On 2021-02-01 13:12, Keqian Zhu wrote: >> Hi Marc, >> >> Do you have time to have a look at this? Thanks ;-) > > Not immediately. I'm busy with stuff that is planned to go > in 5.12, which isn't the case for this series. I'll get to > it eventually. > >

Re: [RFC PATCH 0/7] kvm: arm64: Implement SW/HW combined dirty log

2021-02-01 Thread Marc Zyngier
On 2021-02-01 13:12, Keqian Zhu wrote: Hi Marc, Do you have time to have a look at this? Thanks ;-) Not immediately. I'm busy with stuff that is planned to go in 5.12, which isn't the case for this series. I'll get to it eventually. Thanks, M. -- Jazz is not dead. It just smells funn

Re: [RFC PATCH 0/7] kvm: arm64: Implement SW/HW combined dirty log

2021-02-01 Thread Keqian Zhu
Hi Marc, Do you have time to have a look at this? Thanks ;-) Keqian. On 2021/1/26 20:44, Keqian Zhu wrote: > The intention: > > On arm64 platform, we tracking dirty log of vCPU through guest memory abort. > KVM occupys some vCPU time of guest to change stage2 mapping and mark dirty. > This lead

Re: [PATCH v13 04/15] iommu/smmuv3: Allow s1 and s2 configs to coexist

2021-02-01 Thread Keqian Zhu
Hi Eric, On 2020/11/18 19:21, Eric Auger wrote: > In true nested mode, both s1_cfg and s2_cfg will coexist. > Let's remove the union and add a "set" field in each > config structure telling whether the config is set and needs > to be applied when writing the STE. In legacy nested mode, > only the

Re: [PATCH v13 03/15] iommu/arm-smmu-v3: Maintain a SID->device structure

2021-02-01 Thread Keqian Zhu
Hi Eric, On 2020/11/18 19:21, Eric Auger wrote: > From: Jean-Philippe Brucker > > When handling faults from the event or PRI queue, we need to find the > struct device associated to a SID. Add a rb_tree to keep track of SIDs. > > Signed-off-by: Jean-Philippe Brucker [...] > } > > +static i

Re: [PATCH v2 4/8] KVM: arm64: Generate hyp relocation data

2021-02-01 Thread Marc Zyngier
Hi David, On 2021-02-01 10:42, David Brazdil wrote: Thanks for writing the fix, Marc! There are no corner cases in this code so if it boots, that should be a good indicator that all BE inputs were converted. Just one little thing I noticed below, otherwise: Acked-by: David Brazdil arch/ar

[PATCH v6 16/21] arm64: Make kvm-arm.mode={nvhe, protected} an alias of id_aa64mmfr1.vh=0

2021-02-01 Thread Marc Zyngier
Admitedly, passing id_aa64mmfr1.vh=0 on the command-line isn't that easy to understand, and it is likely that users would much prefer write "kvm-arm.mode=nvhe", or "...=protected". So here you go. This has the added advantage that we can now always honor the "kvm-arm.mode=protected" option, even w

[PATCH v6 13/21] arm64: Allow ID_AA64MMFR1_EL1.VH to be overridden from the command line

2021-02-01 Thread Marc Zyngier
As we want to be able to disable VHE at runtime, let's match "id_aa64mmfr1.vh=" from the command line as an override. This doesn't have much effect yet as our boot code doesn't look at the cpufeature, but only at the HW registers. Signed-off-by: Marc Zyngier Acked-by: David Brazdil Acked-by: Suz

[PATCH v6 11/21] arm64: Extract early FDT mapping from kaslr_early_init()

2021-02-01 Thread Marc Zyngier
As we want to parse more options very early in the kernel lifetime, let's always map the FDT early. This is achieved by moving that code out of kaslr_early_init(). No functionnal change expected. Signed-off-by: Marc Zyngier Acked-by: Catalin Marinas Acked-by: David Brazdil --- arch/arm64/incl

[PATCH v6 21/21] arm64: cpufeatures: Allow disabling of Pointer Auth from the command-line

2021-02-01 Thread Marc Zyngier
In order to be able to disable Pointer Authentication at runtime, whether it is for testing purposes, or to work around HW issues, let's add support for overriding the ID_AA64ISAR1_EL1.{GPI,GPA,API,APA} fields. This is further mapped on the arm64.nopauth command-line alias. Signed-off-by: Marc Z

[PATCH v6 17/21] KVM: arm64: Document HVC_VHE_RESTART stub hypercall

2021-02-01 Thread Marc Zyngier
For completeness, let's document the HVC_VHE_RESTART stub. Signed-off-by: Marc Zyngier Acked-by: David Brazdil --- Documentation/virt/kvm/arm/hyp-abi.rst | 9 + 1 file changed, 9 insertions(+) diff --git a/Documentation/virt/kvm/arm/hyp-abi.rst b/Documentation/virt/kvm/arm/hyp-abi.rst

[PATCH v6 10/21] arm64: cpufeature: Use IDreg override in __read_sysreg_by_encoding()

2021-02-01 Thread Marc Zyngier
__read_sysreg_by_encoding() is used by a bunch of cpufeature helpers, which should take the feature override into account. Let's do that. For a good measure (and because we are likely to need to further down the line), make this helper available to the rest of the non-modular kernel. Code that ne

[PATCH v6 14/21] arm64: Honor VHE being disabled from the command-line

2021-02-01 Thread Marc Zyngier
Finally we can check whether VHE is disabled on the command line, and not enable it if that's the user's wish. Signed-off-by: Marc Zyngier Acked-by: David Brazdil Acked-by: Catalin Marinas --- arch/arm64/kernel/asm-offsets.c | 3 +++ arch/arm64/kernel/hyp-stub.S| 11 +++ 2 files c

[PATCH v6 15/21] arm64: Add an aliasing facility for the idreg override

2021-02-01 Thread Marc Zyngier
In order to map the override of idregs to options that a user can easily understand, let's introduce yet another option array, which maps an option to the corresponding idreg options. Signed-off-by: Marc Zyngier Reviewed-by: Catalin Marinas Acked-by: David Brazdil --- arch/arm64/kernel/idreg-o

[PATCH v6 18/21] arm64: Move "nokaslr" over to the early cpufeature infrastructure

2021-02-01 Thread Marc Zyngier
Given that the early cpufeature infrastructure has borrowed quite a lot of code from the kaslr implementation, let's reimplement the matching of the "nokaslr" option with it. Signed-off-by: Marc Zyngier Acked-by: Catalin Marinas Acked-by: David Brazdil --- arch/arm64/kernel/idreg-override.c |

[PATCH v6 19/21] arm64: cpufeatures: Allow disabling of BTI from the command-line

2021-02-01 Thread Marc Zyngier
In order to be able to disable BTI at runtime, whether it is for testing purposes, or to work around HW issues, let's add support for overriding the ID_AA64PFR1_EL1.BTI field. This is further mapped on the arm64.nobti command-line alias. Signed-off-by: Marc Zyngier Reviewed-by: Catalin Marinas

[PATCH v6 20/21] arm64: Defer enabling pointer authentication on boot core

2021-02-01 Thread Marc Zyngier
From: Srinivas Ramana Defer enabling pointer authentication on boot core until after its required to be enabled by cpufeature framework. This will help in controlling the feature dynamically with a boot parameter. Signed-off-by: Ajay Patil Signed-off-by: Prasad Sodagudi Signed-off-by: Srinivas

[PATCH v6 12/21] arm64: cpufeature: Add an early command-line cpufeature override facility

2021-02-01 Thread Marc Zyngier
In order to be able to override CPU features at boot time, let's add a command line parser that matches options of the form "cpureg.feature=value", and store the corresponding value into the override val/mask pair. No features are currently defined, so no expected change in functionality. Signed-

[PATCH v6 09/21] arm64: cpufeature: Add global feature override facility

2021-02-01 Thread Marc Zyngier
Add a facility to globally override a feature, no matter what the HW says. Yes, this sounds dangerous, but we do respect the "safe" value for a given feature. This doesn't mean the user doesn't need to know what they are doing. Nothing uses this yet, so we are pretty safe. For now. Signed-off-by:

[PATCH v6 08/21] arm64: Move SCTLR_EL1 initialisation to EL-agnostic code

2021-02-01 Thread Marc Zyngier
We can now move the initial SCTLR_EL1 setup to be used for both EL1 and EL2 setup. Signed-off-by: Marc Zyngier Acked-by: Catalin Marinas Acked-by: David Brazdil --- arch/arm64/kernel/head.S | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/head.S b/a

[PATCH v6 07/21] arm64: Simplify init_el2_state to be non-VHE only

2021-02-01 Thread Marc Zyngier
As init_el2_state is now nVHE only, let's simplify it and drop the VHE setup. Signed-off-by: Marc Zyngier Acked-by: David Brazdil Acked-by: Catalin Marinas --- arch/arm64/include/asm/el2_setup.h | 36 +++--- arch/arm64/kernel/head.S | 2 +- arch/arm64/kvm/hyp

[PATCH v6 05/21] arm64: Initialise as nVHE before switching to VHE

2021-02-01 Thread Marc Zyngier
As we are aiming to be able to control whether we enable VHE or not, let's always drop down to EL1 first, and only then upgrade to VHE if at all possible. This means that if the kernel is booted at EL2, we always start with a nVHE init, drop to EL1 to initialise the the kernel, and only then upgra

[PATCH v6 06/21] arm64: Move VHE-specific SPE setup to mutate_to_vhe()

2021-02-01 Thread Marc Zyngier
There isn't much that a VHE kernel needs on top of whatever has been done for nVHE, so let's move the little we need to the VHE stub (the SPE setup), and drop the init_el2_state macro. No expected functional change. Signed-off-by: Marc Zyngier Acked-by: David Brazdil Acked-by: Catalin Marinas

[PATCH v6 04/21] arm64: Provide an 'upgrade to VHE' stub hypercall

2021-02-01 Thread Marc Zyngier
As we are about to change the way a VHE system boots, let's provide the core helper, in the form of a stub hypercall that enables VHE and replicates the full EL1 context at EL2, thanks to EL1 and VHE-EL2 being extremely similar. On exception return, the kernel carries on at EL2. Fancy! Nothing ca

[PATCH v6 03/21] arm64: Turn the MMU-on sequence into a macro

2021-02-01 Thread Marc Zyngier
Turning the MMU on is a popular sport in the arm64 kernel, and we do it more than once, or even twice. As we are about to add even more, let's turn it into a macro. No expected functional change. Signed-off-by: Marc Zyngier Acked-by: Catalin Marinas Acked-by: David Brazdil --- arch/arm64/incl

[PATCH v6 02/21] arm64: Fix outdated TCR setup comment

2021-02-01 Thread Marc Zyngier
The arm64 kernel has long be able to use more than 39bit VAs. Since day one, actually. Let's rewrite the offending comment. Signed-off-by: Marc Zyngier Acked-by: Catalin Marinas Acked-by: David Brazdil --- arch/arm64/mm/proc.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --g

[PATCH v6 01/21] arm64: Fix labels in el2_setup macros

2021-02-01 Thread Marc Zyngier
If someone happens to write the following code: b 1f init_el2_state vhe 1: [...] they will be in for a long debugging session, as the label "1f" will be resolved *inside* the init_el2_state macro instead of after it. Not really what one expects. Instead, rewite the

[PATCH v6 00/21] arm64: Early CPU feature override, and applications to VHE, BTI and PAuth

2021-02-01 Thread Marc Zyngier
It recently came to light that there is a need to be able to override some CPU features very early on, before the kernel is fully up and running. The reasons for this range from specific feature support (such as using Protected KVM on VHE HW, which is the main motivation for this work) to errata wo

Re: [PATCH v13 02/15] iommu: Introduce bind/unbind_guest_msi

2021-02-01 Thread Keqian Zhu
Hi Eric, On 2020/11/18 19:21, Eric Auger wrote: > On ARM, MSI are translated by the SMMU. An IOVA is allocated > for each MSI doorbell. If both the host and the guest are exposed > with SMMUs, we end up with 2 different IOVAs allocated by each. > guest allocates an IOVA (gIOVA) to map onto the gue

Re: [PATCH v13 01/15] iommu: Introduce attach/detach_pasid_table API

2021-02-01 Thread Keqian Zhu
Hi Eric, On 2020/11/18 19:21, Eric Auger wrote: > In virtualization use case, when a guest is assigned > a PCI host device, protected by a virtual IOMMU on the guest, > the physical IOMMU must be programmed to be consistent with > the guest mappings. If the physical IOMMU supports two > translatio