public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Jan Stancek <jstancek@redhat.com>
Cc: Bruno Goncalves <bgoncalv@redhat.com>, kvm <kvm@vger.kernel.org>,
	"Bonzini, Paolo" <pbonzini@redhat.com>,
	lkml <linux-kernel@vger.kernel.org>,
	CKI Project <cki-project@redhat.com>, Li Wang <liwang@redhat.com>
Subject: Re: RIP: 0010:param_get_bool.cold+0x0/0x2 - LTP read_all_sys - 5.17.0
Date: Thu, 31 Mar 2022 18:15:44 +0000	[thread overview]
Message-ID: <YkXv0NoBjLBYBzX8@google.com> (raw)
In-Reply-To: <CAASaF6yhTpXcWhTyg5VSU6czPPws5+sQ3vR7AWC8xxM7Xm_BGg@mail.gmail.com>

On Wed, Mar 30, 2022, Jan Stancek wrote:
> +CC kvm
> 
> Issue seems to be that nx_huge_pages is not initialized (-1) and
> attempted to be used as boolean when reading
> /sys/module/kvm/parameters/nx_huge_pages

Ugh, CONFIG_UBSAN_BOOL=y complains about a bool not being 0 or 1.  What a pain.

> CONFIG_KVM=Y,  CONFIG_UBSAN=y, but kvm_mmu_module_init() doesn't
> appear to run, since kvm detects no HW support:
> # dmesg |grep kvm
> [    0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00
> [    0.000003] kvm-clock: using sched offset of 1155425753112 cycles
> [    0.000007] clocksource: kvm-clock: mask: 0xffffffffffffffff
> max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns
> [    0.045066] kvm-guest: PV spinlocks enabled
> [    0.705370] clocksource: Switched to clocksource kvm-clock
> [    0.913593] kvm: no hardware support for 'kvm_intel'
> [    0.915574] kvm: no hardware support for 'kvm_amd'
> [    2.284925] systemd[1]: Detected virtualization kvm.
> [    4.158909] Stack Depot allocating hash table with kvmalloc
> [    8.120446] systemd[1]: Detected virtualization kvm.
> 
> Initializing 'nx_huge_pages' to 0 (in out branch) or write to
> /sys/module/kvm/parameters/nx_huge_pages before read makes it go away
> too:
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 02cf0a7e1d14..b3b8b9a22e20 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -8921,6 +8921,7 @@ int kvm_arch_init(void *opaque)
>  out_free_x86_emulator_cache:
>         kmem_cache_destroy(x86_emulator_cache);
>  out:
> +       nx_huge_pages = 0;

This won't help, because nx_huge_pages is deliberately left as -1 if the vendor
module isn't loaded, in which case kvm_arch_init() won't be reached.  This would
also incorrectly disable the mitigation.

We could fix it by adding a proper accessor, but that's rather silly because KVM
doesn't actually need to wait until a vendor module is loaded to finalize its
value (-1 means "auto").  kvm.ko doesn't have its own module_init() hook on x86,
but that's easily solved and I think less gross than having Schrödinger's param.

I'll test and send a patch.

  reply	other threads:[~2022-03-31 18:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CA+QYu4q7K-pkAbMt3br_7O-Lu2OWyieLfyiju0PNEiy5YdKYzg@mail.gmail.com>
2022-03-30 12:46 ` RIP: 0010:param_get_bool.cold+0x0/0x2 - LTP read_all_sys - 5.17.0 Jan Stancek
2022-03-31 18:15   ` Sean Christopherson [this message]
2022-03-31 18:45     ` Sean Christopherson
2022-03-31 19:27       ` Jan Stancek

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=YkXv0NoBjLBYBzX8@google.com \
    --to=seanjc@google.com \
    --cc=bgoncalv@redhat.com \
    --cc=cki-project@redhat.com \
    --cc=jstancek@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liwang@redhat.com \
    --cc=pbonzini@redhat.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