linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
Cc: Miguel Luis <miguel.luis@oracle.com>,
	"kvmarm@lists.linux.dev" <kvmarm@lists.linux.dev>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Andre Przywara <andre.przywara@arm.com>,
	Chase Conklin <chase.conklin@arm.com>,
	Christoffer Dall <christoffer.dall@arm.com>,
	Darren Hart <darren@os.amperecomputing.com>,
	Jintack Lim <jintack@cs.columbia.edu>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	James Morse <james.morse@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	Zenghui Yu <yuzenghui@huawei.com>
Subject: Re: [PATCH v11 00/43] KVM: arm64: Nested Virtualization support (FEAT_NV2 only)
Date: Fri, 24 Nov 2023 10:19:21 +0000	[thread overview]
Message-ID: <868r6nzc5y.wl-maz@kernel.org> (raw)
In-Reply-To: <134912e4-beed-4ab6-8ce1-33e69ec382b3@os.amperecomputing.com>

On Fri, 24 Nov 2023 09:50:33 +0000,
Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com> wrote:
> 
> 
> 
> On 23-11-2023 10:14 pm, Marc Zyngier wrote:
> > On Thu, 23 Nov 2023 16:21:48 +0000,
> > Miguel Luis <miguel.luis@oracle.com> wrote:
> >> 
> >> Hi Marc,
> >> 
> >> On 21/11/2023 18:02, Marc Zyngier wrote:
> >>> On Tue, 21 Nov 2023 16:49:52 +0000,
> >>> Miguel Luis <miguel.luis@oracle.com> wrote:
> >>>> Hi Marc,
> >>>> 
> >>>>> On 20 Nov 2023, at 12:09, Marc Zyngier <maz@kernel.org> wrote:
> >>>>> 
> >>>>> This is the 5th drop of NV support on arm64 for this year, and most
> >>>>> probably the last one for this side of Christmas.
> >>>>> 
> >>>>> For the previous episodes, see [1].
> >>>>> 
> >>>>> What's changed:
> >>>>> 
> >>>>> - Drop support for the original FEAT_NV. No existing hardware supports
> >>>>>   it without FEAT_NV2, and the architecture is deprecating the former
> >>>>>   entirely. This results in fewer patches, and a slightly simpler
> >>>>>   model overall.
> >>>>> 
> >>>>> - Reorganise the series to make it a bit more logical now that FEAT_NV
> >>>>>   is gone.
> >>>>> 
> >>>>> - Apply the NV idreg restrictions on VM first run rather than on each
> >>>>>   access.
> >>>>> 
> >>>>> - Make the nested vgic shadow CPU interface a per-CPU structure rather
> >>>>>   than per-vcpu.
> >>>>> 
> >>>>> - Fix the EL0 timer fastpath
> >>>>> 
> >>>>> - Work around the architecture deficiencies when trapping WFI from a
> >>>>>   L2 guest.
> >>>>> 
> >>>>> - Fix sampling of nested vgic state (MISR, ELRSR, EISR)
> >>>>> 
> >>>>> - Drop the patches that have already been merged (NV trap forwarding,
> >>>>>   per-MMU VTCR)
> >>>>> 
> >>>>> - Rebased on top of 6.7-rc2 + the FEAT_E2H0 support [2].
> >>>>> 
> >>>>> The branch containing these patches (and more) is at [3]. As for the
> >>>>> previous rounds, my intention is to take a prefix of this series into
> >>>>> 6.8, provided that it gets enough reviewing.
> >>>>> 
> >>>>> [1] https://lore.kernel.org/r/20230515173103.1017669-1-maz@kernel.org
> >>>>> [2] https://lore.kernel.org/r/20231120123721.851738-1-maz@kernel.org
> >>>>> [3] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/nv-6.8-nv2-only
> >>>>> 
> >>>> While I was testing this with kvmtool for 5.16 I noted the following on dmesg:
> >>>> 
> >>>> [  803.014258] kvm [19040]: Unsupported guest sys_reg access at: 8129fa50 [600003c9]
> >>>>                  { Op0( 3), Op1( 5), CRn( 1), CRm( 0), Op2( 2), func_read },
> >>>> 
> >>>> This is CPACR_EL12.
> >>> CPACR_EL12 is redirected to VNCR[0x100]. It really shouldn't trap...
> >>> 
> >>>> Still need yet to debug.
> >>> Can you disassemble the guest around the offending PC?
> >> 
> >> [ 1248.686350] kvm [7013]: Unsupported guest sys_reg access at: 812baa50 [600003c9]
> >>                  { Op0( 3), Op1( 5), CRn( 1), CRm( 0), Op2( 2), func_read },
> >> 
> >>   12baa00:    14000008     b    0x12baa20
> >>   12baa04:    d000d501     adrp    x1, 0x2d5c000
> >>   12baa08:    91154021     add    x1, x1, #0x550
> >>   12baa0c:    f9400022     ldr    x2, [x1]
> >>   12baa10:    f9400421     ldr    x1, [x1, #8]
> >>   12baa14:    8a010042     and    x2, x2, x1
> >>   12baa18:    d3441c42     ubfx    x2, x2, #4, #4
> >>   12baa1c:    b4000082     cbz    x2, 0x12baa2c
> >>   12baa20:    d2a175a0     mov    x0, #0xbad0000                 // #195887104
> >>   12baa24:    f2994220     movk    x0, #0xca11
> >>   12baa28:    d69f03e0     eret
> >>   12baa2c:    d2c00080     mov    x0, #0x400000000               // #17179869184
> >>   12baa30:    f2b10000     movk    x0, #0x8800, lsl #16
> >>   12baa34:    f2800000     movk    x0, #0x0
> >>   12baa38:    d51c1100     msr    hcr_el2, x0
> >>   12baa3c:    d5033fdf     isb
> >>   12baa40:    d53c4100     mrs    x0, sp_el1
> >>   12baa44:    9100001f     mov    sp, x0
> >>   12baa48:    d538d080     mrs    x0, tpidr_el1
> >>   12baa4c:    d51cd040     msr    tpidr_el2, x0
> >>   12baa50:    d53d1040     mrs    x0, cpacr_el12
> >>   12baa54:    d5181040     msr    cpacr_el1, x0
> >>   12baa58:    d53dc000     mrs    x0, vbar_el12
> >>   12baa5c:    d518c000     msr    vbar_el1, x0
> >>   12baa60:    d53c1120     mrs    x0, mdcr_el2
> >>   12baa64:    9272f400     and    x0, x0, #0xffffffffffffcfff
> >>   12baa68:    9266f400     and    x0, x0, #0xfffffffffcffffff
> >>   12baa6c:    d51c1120     msr    mdcr_el2, x0
> >>   12baa70:    d53d2040     mrs    x0, tcr_el12
> >>   12baa74:    d5182040     msr    tcr_el1, x0
> >>   12baa78:    d53d2000     mrs    x0, ttbr0_el12
> >>   12baa7c:    d5182000     msr    ttbr0_el1, x0
> >>   12baa80:    d53d2020     mrs    x0, ttbr1_el12
> >>   12baa84:    d5182020     msr    ttbr1_el1, x0
> >>   12baa88:    d53da200     mrs    x0, mair_el12
> >>   12baa8c:    d518a200     msr    mair_el1, x0
> >>   12baa90:    d5380761     mrs    x1, s3_0_c0_c7_3
> >>   12baa94:    d3400c21     ubfx    x1, x1, #0, #4
> >>   12baa98:    b4000141     cbz    x1, 0x12baac0
> >>   12baa9c:    d53d2060     mrs    x0, s3_5_c2_c0_3
> > 
> > OK, this is suspiciously close to the location Ganapatrao was having
> > issues with. Are you running on the same hardware?
> > 
> > In any case, we should never take a trap for this access. Can you dump
> > HCR_EL2 at the point where the guest traps (in switch.c)?
> > 
> 
> I have dumped HCR_EL2 before entry to L1 in both V11 and V10.
> on V10 HCR_EL2=0x2743c827c263f
> on V11 HCR_EL2=0x27c3c827c263f
> 
> on V11 the function vcpu_el2_e2h_is_set(vcpu) is returning false
> resulting in NV1 bit set along with NV and NV2.
> AFAIK, For L1 to be in VHE, NV1 bit should be zero and NV=NV2=1.
> 
> I could boot L1 then L2, if I hack vcpu_el2_e2h_is_set to return true.
> There could be a bug in V11 or E2H0 patchset resulting in
> vcpu_el2_e2h_is_set() returning false?

The E2H0 series should only force vcpu_el2_e2h_is_set() to return
true, but not set it to false. Can you dump the *guest's* version of
HCR_EL2 at this point?

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-11-24 10:19 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20 13:09 [PATCH v11 00/43] KVM: arm64: Nested Virtualization support (FEAT_NV2 only) Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 01/43] arm64: cpufeatures: Restrict NV support to FEAT_NV2 Marc Zyngier
2023-11-21  9:07   ` Ganapatrao Kulkarni
2023-11-21  9:27     ` Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 02/43] KVM: arm64: nv: Hoist vcpu_has_nv() into is_hyp_ctxt() Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 03/43] KVM: arm64: nv: Compute NV view of idregs as a one-off Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 04/43] KVM: arm64: nv: Drop EL12 register traps that are redirected to VNCR Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 05/43] KVM: arm64: nv: Add non-VHE-EL2->EL1 translation helpers Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 06/43] KVM: arm64: nv: Add include containing the VNCR_EL2 offsets Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 07/43] KVM: arm64: Introduce a bad_trap() primitive for unexpected trap handling Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 08/43] KVM: arm64: nv: Add EL2_REG_VNCR()/EL2_REG_REDIR() sysreg helpers Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 09/43] KVM: arm64: nv: Map VNCR-capable registers to a separate page Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 10/43] KVM: arm64: nv: Handle virtual EL2 registers in vcpu_read/write_sys_reg() Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 11/43] KVM: arm64: nv: Handle HCR_EL2.E2H specially Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 12/43] KVM: arm64: nv: Handle CNTHCTL_EL2 specially Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 13/43] KVM: arm64: nv: Save/Restore vEL2 sysregs Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 14/43] KVM: arm64: nv: Respect virtual HCR_EL2.TWX setting Marc Zyngier
2023-11-20 13:09 ` [PATCH v11 15/43] KVM: arm64: nv: Respect virtual CPTR_EL2.{TFP,FPEN} settings Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 16/43] KVM: arm64: nv: Configure HCR_EL2 for FEAT_NV2 Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 17/43] KVM: arm64: nv: Support multiple nested Stage-2 mmu structures Marc Zyngier
2024-01-23  9:55   ` Ganapatrao Kulkarni
2024-01-23 14:26     ` Marc Zyngier
2024-01-25  8:14       ` Ganapatrao Kulkarni
2024-01-25  8:58         ` Marc Zyngier
2024-01-31  9:39           ` Ganapatrao Kulkarni
2024-01-31 13:50             ` Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 18/43] KVM: arm64: nv: Implement nested Stage-2 page table walk logic Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 19/43] KVM: arm64: nv: Handle shadow stage 2 page faults Marc Zyngier
2024-01-17 14:53   ` Joey Gouly
2024-01-17 15:53     ` Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 20/43] KVM: arm64: nv: Restrict S2 RD/WR permissions to match the guest's Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 21/43] KVM: arm64: nv: Unmap/flush shadow stage 2 page tables Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 22/43] KVM: arm64: nv: Set a handler for the system instruction traps Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 23/43] KVM: arm64: nv: Trap and emulate AT instructions from virtual EL2 Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 24/43] KVM: arm64: nv: Trap and emulate TLBI " Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 25/43] KVM: arm64: nv: Hide RAS from nested guests Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 26/43] KVM: arm64: nv: Add handling of EL2-specific timer registers Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 27/43] KVM: arm64: nv: Sync nested timer state with FEAT_NV2 Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 28/43] KVM: arm64: nv: Publish emulated timer interrupt state in the in-memory state Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 29/43] KVM: arm64: nv: Load timer before the GIC Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 30/43] KVM: arm64: nv: Nested GICv3 Support Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 31/43] KVM: arm64: nv: Don't block in WFI from nested state Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 32/43] KVM: arm64: nv: vgic: Allow userland to set VGIC maintenance IRQ Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 33/43] KVM: arm64: nv: Fold GICv3 host trapping requirements into guest setup Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 34/43] KVM: arm64: nv: Deal with broken VGIC on maintenance interrupt delivery Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 35/43] KVM: arm64: nv: Add handling of FEAT_TTL TLB invalidation Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 36/43] KVM: arm64: nv: Invalidate TLBs based on shadow S2 TTL-like information Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 37/43] KVM: arm64: nv: Tag shadow S2 entries with nested level Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 38/43] KVM: arm64: nv: Allocate VNCR page when required Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 39/43] KVM: arm64: nv: Fast-track 'InHost' exception returns Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 40/43] KVM: arm64: nv: Fast-track EL1 TLBIs for VHE guests Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 41/43] KVM: arm64: nv: Use FEAT_ECV to trap access to EL0 timers Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 42/43] KVM: arm64: nv: Accelerate EL0 timer read accesses when FEAT_ECV is on Marc Zyngier
2023-11-20 13:10 ` [PATCH v11 43/43] KVM: arm64: nv: Allow userspace to request KVM_ARM_VCPU_NESTED_VIRT Marc Zyngier
2023-11-21  8:51 ` [PATCH v11 00/43] KVM: arm64: Nested Virtualization support (FEAT_NV2 only) Ganapatrao Kulkarni
2023-11-21  9:08   ` Marc Zyngier
2023-11-21  9:26     ` Ganapatrao Kulkarni
2023-11-21  9:41       ` Marc Zyngier
2023-11-22 11:10         ` Ganapatrao Kulkarni
2023-11-22 11:39           ` Marc Zyngier
2023-11-21 16:49 ` Miguel Luis
2023-11-21 19:02   ` Marc Zyngier
2023-11-23 16:21     ` Miguel Luis
2023-11-23 16:44       ` Marc Zyngier
2023-11-24  9:50         ` Ganapatrao Kulkarni
2023-11-24 10:19           ` Marc Zyngier [this message]
2023-11-24 12:34             ` Ganapatrao Kulkarni
2023-11-24 12:51               ` Marc Zyngier
2023-11-24 13:22                 ` Ganapatrao Kulkarni
2023-11-24 14:32                   ` Marc Zyngier
2023-11-27  7:26                     ` Ganapatrao Kulkarni
2023-11-27  9:22                       ` Marc Zyngier
2023-11-27 10:59                         ` Ganapatrao Kulkarni
2023-11-27 11:45                           ` Marc Zyngier
2023-11-27 12:18                             ` Ganapatrao Kulkarni
2023-11-27 13:57                               ` Marc Zyngier
2023-12-18 12:39 ` Marc Zyngier
2023-12-18 19:51   ` Oliver Upton
2023-12-19 10:32 ` (subset) " Marc Zyngier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=868r6nzc5y.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=chase.conklin@arm.com \
    --cc=christoffer.dall@arm.com \
    --cc=darren@os.amperecomputing.com \
    --cc=gankulkarni@os.amperecomputing.com \
    --cc=james.morse@arm.com \
    --cc=jintack@cs.columbia.edu \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=miguel.luis@oracle.com \
    --cc=oliver.upton@linux.dev \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=suzuki.poulose@arm.com \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).