Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Itaru Kitayama <itaru.kitayama@linux.dev>
To: Marc Zyngier <maz@kernel.org>
Cc: kvmarm@lists.linux.dev
Subject: Re: KVM selftest for L2 guest execution fails
Date: Thu, 31 Jul 2025 06:40:05 +0900	[thread overview]
Message-ID: <62C3AF76-E7B5-491E-AD1C-A8F9BF8C153F@linux.dev> (raw)
In-Reply-To: <861ppx9893.wl-maz@kernel.org>

Hi Marc,

> On Jul 30, 2025, at 21:24, Marc Zyngier <maz@kernel.org> wrote:
> 
> On Wed, 30 Jul 2025 07:44:48 +0100,
> Itaru Kitayama <itaru.kitayama@linux.dev> wrote:
>> 
>> Hi,
>> My small kvm sefltest tested on the kvmarm/next with NV2+VHE on FVP fails:
>> 
>> # ./arm64/test5
>> Random seed: 0x6b8b4567
>> ==== Test Assertion Failure ====
>>  lib/kvm_util.c:1746: !ret
>>  pid=257 tid=257 errno=11 - Resource temporarily unavailable
>> sh: line 1: addr2line: command not found
>>  KVM_RUN failed, rc: -1 errno: 11 (Resource temporarily unavailable)
>> 
>> Below is the test code, am I doing still wrong?
> 
> Quite a lot is wrong there.
> 
>> 
>> Thanks,
>> Itaru.
>> 
>> // SPDX-License-Identifier: GPL-2.0-only
>> 
>> #include "test_util.h"
>> #include "kvm_util.h"
>> #include "processor.h"
>> #include "ucall.h"
>> 
>> #define GUEST_SYNC_VAL 0x1234
>> #define UCALL_GPA 0x500000
>> 
>> static void l1_guest_code(void)
>> {
>>        /*
>>        * Set up HCR_EL2 to enable virtualization and nested support:
>>        *   - HCR_EL2.VM  = 1 (enable stage-2 translation)
>>        *   - HCR_EL2.NV  = 1 (trap to EL2 on guest HVC, SMC, WFI, etc.)
>>        *   - HCR_EL2.TGE = 1 (trap general exceptions in EL1 to EL2)
> 
> You really want to read the spec again -- this is not what this means.
> 
>>        */
>>       uint64_t hcr = (1UL << 0)   |  // VM
>>                      (1UL << 27)  |  // TGE
>>                      (1UL << 31);    // NV
> 
> - You enable S2 translation, and yet don't setup anything related to it
> 
> - You have TGE set, and yet (try to) return to EL1
> 
> - You set NV, and yet don't have a VNCR_EL2 populated
> 
> I don't know what you are trying to do here, but this is pretty badly
> thought out.
> 
> I'd suggest you start by having a simple L2, without making use of NV
> at all in the guest. You will still have to have a stage-2 and a
> correct HCR_EL2 configuration -- none of which is as trivial as this
> test suggests.
> 
> Once that is actually working, you can go wild and enable NV. But not
> before.

Thanks for your comments. Will follow your suggestions.

Itaru. 

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



      reply	other threads:[~2025-07-30 21:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-30  6:44 KVM selftest for L2 guest execution fails Itaru Kitayama
2025-07-30 12:24 ` Marc Zyngier
2025-07-30 21:40   ` Itaru Kitayama [this message]

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=62C3AF76-E7B5-491E-AD1C-A8F9BF8C153F@linux.dev \
    --to=itaru.kitayama@linux.dev \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    /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