mbox series

[00/27] KVM: arm64: NV trap forwarding infrastructure

Message ID 20230712145810.3864793-1-maz@kernel.org (mailing list archive)
Headers show
Series KVM: arm64: NV trap forwarding infrastructure | expand

Message

Marc Zyngier July 12, 2023, 2:57 p.m. UTC
As people are getting tired of seeing the full NV series, I've
extracted some of the easy stuff which I'm targeting for 6.6.

This implements the so called "trap forwarding" infrastructure, which
gets used when we take a trap from an L2 guest and that the L1 guest
wants to see the trap for itself.

Most of the series is pretty boring stuff, mostly a long list of
encodings which are mapped to a set of trap bits. I swear they are
correct. Sort of.

The interesting bit is around how we compute the trap result, which is
pretty complex due to the layers of crap the architecture has piled
over the years (a single op can be trapped by multiple coarse grained
trap bits, or a fine grained trap bit, which may itself be conditioned
by another control bit -- madness).

This also results in some rework of both the FGT stuff (for which I
carry a patch from Mark) and newly introduced the HCRX support.

With that (and the rest of the NV series[1]), FGT gets exposed to guests
and the trapping seems to work as expected.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/nv-6.6-WIP

Marc Zyngier (26):
  arm64: Add missing VA CMO encodings
  arm64: Add missing ERX*_EL1 encodings
  arm64: Add missing DC ZVA/GVA/GZVA encodings
  arm64: Add TLBI operation encodings
  arm64: Add AT operation encodings
  arm64: Add debug registers affected by HDFGxTR_EL2
  arm64: Add missing BRB/CFP/DVP/CPP instructions
  arm64: Fix HFGxTR_EL2 field naming
  arm64: Add HDFGRTR_EL2 and HDFGWTR_EL2 layouts
  KVM: arm64: Correctly handle ACCDATA_EL1 traps
  KVM: arm64: Add missing HCR_EL2 trap bits
  KVM: arm64: nv: Add FGT registers
  KVM: arm64: Restructure FGT register switching
  KVM: arm64: nv: Add trap forwarding infrastructure
  KVM: arm64: nv: Add trap forwarding for HCR_EL2
  KVM: arm64: nv: Expose FEAT_EVT to nested guests
  KVM: arm64: nv: Add trap forwarding for MDCR_EL2
  KVM: arm64: nv: Add trap forwarding for CNTHCTL_EL2
  KVM: arm64: nv: Add trap forwarding for HFGxTR_EL2
  KVM: arm64: nv: Add trap forwarding for HFGITR_EL2
  KVM: arm64: nv: Add trap forwarding for HDFGxTR_EL2
  KVM: arm64: nv: Add SVC trap forwarding
  KVM: arm64: nv: Add switching support for HFGxTR/HDFGxTR
  KVM: arm64: nv: Expose FGT to nested guests
  KVM: arm64: Move HCRX_EL2 switch to load/put on VHE systems
  KVM: arm64: nv: Add support for HCRX_EL2

Mark Brown (1):
  arm64: Add feature detection for fine grained traps

 arch/arm64/include/asm/kvm_arm.h        |   50 +
 arch/arm64/include/asm/kvm_host.h       |    7 +
 arch/arm64/include/asm/kvm_nested.h     |    2 +
 arch/arm64/include/asm/sysreg.h         |  270 +++-
 arch/arm64/kernel/cpufeature.c          |   11 +
 arch/arm64/kvm/arm.c                    |    4 +
 arch/arm64/kvm/emulate-nested.c         | 1703 +++++++++++++++++++++++
 arch/arm64/kvm/handle_exit.c            |   12 +
 arch/arm64/kvm/hyp/include/hyp/switch.h |  126 +-
 arch/arm64/kvm/nested.c                 |   11 +-
 arch/arm64/kvm/sys_regs.c               |   15 +
 arch/arm64/kvm/trace_arm.h              |   19 +
 arch/arm64/tools/cpucaps                |    1 +
 arch/arm64/tools/sysreg                 |  141 +-
 14 files changed, 2326 insertions(+), 46 deletions(-)

Comments

Eric Auger July 12, 2023, 3:16 p.m. UTC | #1
Hi Marc,

On 7/12/23 16:57, Marc Zyngier wrote:
> As people are getting tired of seeing the full NV series, I've
> extracted some of the easy stuff which I'm targeting for 6.6.
>
> This implements the so called "trap forwarding" infrastructure, which
> gets used when we take a trap from an L2 guest and that the L1 guest
> wants to see the trap for itself.
>
> Most of the series is pretty boring stuff, mostly a long list of
> encodings which are mapped to a set of trap bits. I swear they are
> correct. Sort of.
>
> The interesting bit is around how we compute the trap result, which is
> pretty complex due to the layers of crap the architecture has piled
> over the years (a single op can be trapped by multiple coarse grained
> trap bits, or a fine grained trap bit, which may itself be conditioned
> by another control bit -- madness).
>
> This also results in some rework of both the FGT stuff (for which I
> carry a patch from Mark) and newly introduced the HCRX support.
>
> With that (and the rest of the NV series[1]), FGT gets exposed to guests
> and the trapping seems to work as expected.
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/nv-6.6-WIP

I have not received patches 10-27 and I do not see them on lore archive
https://lore.kernel.org/all/20230712145810.3864793-1-maz@kernel.org/#r

Thanks

Eric
>
> Marc Zyngier (26):
>   arm64: Add missing VA CMO encodings
>   arm64: Add missing ERX*_EL1 encodings
>   arm64: Add missing DC ZVA/GVA/GZVA encodings
>   arm64: Add TLBI operation encodings
>   arm64: Add AT operation encodings
>   arm64: Add debug registers affected by HDFGxTR_EL2
>   arm64: Add missing BRB/CFP/DVP/CPP instructions
>   arm64: Fix HFGxTR_EL2 field naming
>   arm64: Add HDFGRTR_EL2 and HDFGWTR_EL2 layouts
>   KVM: arm64: Correctly handle ACCDATA_EL1 traps
>   KVM: arm64: Add missing HCR_EL2 trap bits
>   KVM: arm64: nv: Add FGT registers
>   KVM: arm64: Restructure FGT register switching
>   KVM: arm64: nv: Add trap forwarding infrastructure
>   KVM: arm64: nv: Add trap forwarding for HCR_EL2
>   KVM: arm64: nv: Expose FEAT_EVT to nested guests
>   KVM: arm64: nv: Add trap forwarding for MDCR_EL2
>   KVM: arm64: nv: Add trap forwarding for CNTHCTL_EL2
>   KVM: arm64: nv: Add trap forwarding for HFGxTR_EL2
>   KVM: arm64: nv: Add trap forwarding for HFGITR_EL2
>   KVM: arm64: nv: Add trap forwarding for HDFGxTR_EL2
>   KVM: arm64: nv: Add SVC trap forwarding
>   KVM: arm64: nv: Add switching support for HFGxTR/HDFGxTR
>   KVM: arm64: nv: Expose FGT to nested guests
>   KVM: arm64: Move HCRX_EL2 switch to load/put on VHE systems
>   KVM: arm64: nv: Add support for HCRX_EL2
>
> Mark Brown (1):
>   arm64: Add feature detection for fine grained traps
>
>  arch/arm64/include/asm/kvm_arm.h        |   50 +
>  arch/arm64/include/asm/kvm_host.h       |    7 +
>  arch/arm64/include/asm/kvm_nested.h     |    2 +
>  arch/arm64/include/asm/sysreg.h         |  270 +++-
>  arch/arm64/kernel/cpufeature.c          |   11 +
>  arch/arm64/kvm/arm.c                    |    4 +
>  arch/arm64/kvm/emulate-nested.c         | 1703 +++++++++++++++++++++++
>  arch/arm64/kvm/handle_exit.c            |   12 +
>  arch/arm64/kvm/hyp/include/hyp/switch.h |  126 +-
>  arch/arm64/kvm/nested.c                 |   11 +-
>  arch/arm64/kvm/sys_regs.c               |   15 +
>  arch/arm64/kvm/trace_arm.h              |   19 +
>  arch/arm64/tools/cpucaps                |    1 +
>  arch/arm64/tools/sysreg                 |  141 +-
>  14 files changed, 2326 insertions(+), 46 deletions(-)
>
Eric Auger July 12, 2023, 3:29 p.m. UTC | #2
Hi,

On 7/12/23 17:16, Eric Auger wrote:
> Hi Marc,
> 
> On 7/12/23 16:57, Marc Zyngier wrote:
>> As people are getting tired of seeing the full NV series, I've
>> extracted some of the easy stuff which I'm targeting for 6.6.
>>
>> This implements the so called "trap forwarding" infrastructure, which
>> gets used when we take a trap from an L2 guest and that the L1 guest
>> wants to see the trap for itself.
>>
>> Most of the series is pretty boring stuff, mostly a long list of
>> encodings which are mapped to a set of trap bits. I swear they are
>> correct. Sort of.
>>
>> The interesting bit is around how we compute the trap result, which is
>> pretty complex due to the layers of crap the architecture has piled
>> over the years (a single op can be trapped by multiple coarse grained
>> trap bits, or a fine grained trap bit, which may itself be conditioned
>> by another control bit -- madness).
>>
>> This also results in some rework of both the FGT stuff (for which I
>> carry a patch from Mark) and newly introduced the HCRX support.
>>
>> With that (and the rest of the NV series[1]), FGT gets exposed to guests
>> and the trapping seems to work as expected.
>>
>> [1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/nv-6.6-WIP
> 
> I have not received patches 10-27 and I do not see them on lore archive
> https://lore.kernel.org/all/20230712145810.3864793-1-maz@kernel.org/#r

Hum I was too eager to see them. Now I have received everything and they
are all visible on lore.

Sorry for the noise

Eric
> 
> Thanks
> 
> Eric
>>
>> Marc Zyngier (26):
>>   arm64: Add missing VA CMO encodings
>>   arm64: Add missing ERX*_EL1 encodings
>>   arm64: Add missing DC ZVA/GVA/GZVA encodings
>>   arm64: Add TLBI operation encodings
>>   arm64: Add AT operation encodings
>>   arm64: Add debug registers affected by HDFGxTR_EL2
>>   arm64: Add missing BRB/CFP/DVP/CPP instructions
>>   arm64: Fix HFGxTR_EL2 field naming
>>   arm64: Add HDFGRTR_EL2 and HDFGWTR_EL2 layouts
>>   KVM: arm64: Correctly handle ACCDATA_EL1 traps
>>   KVM: arm64: Add missing HCR_EL2 trap bits
>>   KVM: arm64: nv: Add FGT registers
>>   KVM: arm64: Restructure FGT register switching
>>   KVM: arm64: nv: Add trap forwarding infrastructure
>>   KVM: arm64: nv: Add trap forwarding for HCR_EL2
>>   KVM: arm64: nv: Expose FEAT_EVT to nested guests
>>   KVM: arm64: nv: Add trap forwarding for MDCR_EL2
>>   KVM: arm64: nv: Add trap forwarding for CNTHCTL_EL2
>>   KVM: arm64: nv: Add trap forwarding for HFGxTR_EL2
>>   KVM: arm64: nv: Add trap forwarding for HFGITR_EL2
>>   KVM: arm64: nv: Add trap forwarding for HDFGxTR_EL2
>>   KVM: arm64: nv: Add SVC trap forwarding
>>   KVM: arm64: nv: Add switching support for HFGxTR/HDFGxTR
>>   KVM: arm64: nv: Expose FGT to nested guests
>>   KVM: arm64: Move HCRX_EL2 switch to load/put on VHE systems
>>   KVM: arm64: nv: Add support for HCRX_EL2
>>
>> Mark Brown (1):
>>   arm64: Add feature detection for fine grained traps
>>
>>  arch/arm64/include/asm/kvm_arm.h        |   50 +
>>  arch/arm64/include/asm/kvm_host.h       |    7 +
>>  arch/arm64/include/asm/kvm_nested.h     |    2 +
>>  arch/arm64/include/asm/sysreg.h         |  270 +++-
>>  arch/arm64/kernel/cpufeature.c          |   11 +
>>  arch/arm64/kvm/arm.c                    |    4 +
>>  arch/arm64/kvm/emulate-nested.c         | 1703 +++++++++++++++++++++++
>>  arch/arm64/kvm/handle_exit.c            |   12 +
>>  arch/arm64/kvm/hyp/include/hyp/switch.h |  126 +-
>>  arch/arm64/kvm/nested.c                 |   11 +-
>>  arch/arm64/kvm/sys_regs.c               |   15 +
>>  arch/arm64/kvm/trace_arm.h              |   19 +
>>  arch/arm64/tools/cpucaps                |    1 +
>>  arch/arm64/tools/sysreg                 |  141 +-
>>  14 files changed, 2326 insertions(+), 46 deletions(-)
>>
>
Marc Zyngier July 12, 2023, 3:31 p.m. UTC | #3
On Wed, 12 Jul 2023 16:16:59 +0100,
Eric Auger <eric.auger@redhat.com> wrote:
> 
> Hi Marc,
> 
> On 7/12/23 16:57, Marc Zyngier wrote:
> > As people are getting tired of seeing the full NV series, I've
> > extracted some of the easy stuff which I'm targeting for 6.6.
> >
> > This implements the so called "trap forwarding" infrastructure, which
> > gets used when we take a trap from an L2 guest and that the L1 guest
> > wants to see the trap for itself.
> >
> > Most of the series is pretty boring stuff, mostly a long list of
> > encodings which are mapped to a set of trap bits. I swear they are
> > correct. Sort of.
> >
> > The interesting bit is around how we compute the trap result, which is
> > pretty complex due to the layers of crap the architecture has piled
> > over the years (a single op can be trapped by multiple coarse grained
> > trap bits, or a fine grained trap bit, which may itself be conditioned
> > by another control bit -- madness).
> >
> > This also results in some rework of both the FGT stuff (for which I
> > carry a patch from Mark) and newly introduced the HCRX support.
> >
> > With that (and the rest of the NV series[1]), FGT gets exposed to guests
> > and the trapping seems to work as expected.
> >
> > [1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/nv-6.6-WIP
> 
> I have not received patches 10-27 and I do not see them on lore archive
> https://lore.kernel.org/all/20230712145810.3864793-1-maz@kernel.org/#r

You should see them shortly. My server throttles outgoing bursts of
more than 10 emails, which is why the rest still in limbo. It will
eventually time out and spam you for good! ;p

Thanks,

	M.