From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD3DBC433EF for ; Thu, 31 Mar 2022 18:15:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233904AbiCaSRj (ORCPT ); Thu, 31 Mar 2022 14:17:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231908AbiCaSRh (ORCPT ); Thu, 31 Mar 2022 14:17:37 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 426FCFFFAF for ; Thu, 31 Mar 2022 11:15:50 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id s11so298639pfu.13 for ; Thu, 31 Mar 2022 11:15:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=06hKDOCgXqFCyZ353BYB4YZzW90RzyhwrczTGoEeb5k=; b=X7hkkbemNW6OzffrTh46zjMmYQZI5lZm0Ub38jqEkGCEE/cpixyjVrrmsoF3FsnXsN anaSPa36HB0w2TpJV9+XLL1tMIE/J4Zi1HL/jk74EkeTEqgjPJfyuCfwY64DRYF6tIgX d5vOcuA3p5KSB/7lfwJ7KcvmWtY1vgZtqW3YkUwipx/BjtjwtBJX7HTUvSEy0PIoUBap E3PY2m/FrvDJih/t20UMR1eubD1keGuWy8n5o4x77mSvVhrg6gIMa+9RzmK5nRWKFavg AcrCORsky538H7CrhBQXWZwfyUUs5HorGL2D68LY1PEbAmCvdbzSEXv2DxMSiVqRhoyN 2K1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=06hKDOCgXqFCyZ353BYB4YZzW90RzyhwrczTGoEeb5k=; b=7V2PxmSzmoZowj7n8s5Egi6KNYHdX2xjy2UQb31P8RxAUlbZfUxVfu1cgy3u5Bzyf7 LNQ86i6ZHP7m1aqHtXArZE/ZJ09iHHO3nB0/sxEHVbv3Au8yCgLRPCXp2lWjhzwjCUzQ yh3zrBQGDoQ9fiPLUIbMQJP881Eoh+5xESAJ4Oe4WFNTXLdSaXkjJAH+rJNoLkB1Sakl PWI00VQUj9c0YxkW8TVff0tOM4wA4Ig2+8yfYcRYZ62Uf2QKAhYBtwsTfz1xjTcdcImg ZK/pJvKAzPOV0eFaM7iyPAxur9n6pW3Zw1VWGGwILAWpEqiIrfL872jVk8BQqQet09/Z Z2jg== X-Gm-Message-State: AOAM531NrGhyilqYDnv6OKGRRToWL2bklMpvoGXLhWa7LhV8dXXX6Cfk T/zyU+WunHemK5t5TuZh1hXeYw== X-Google-Smtp-Source: ABdhPJxpYpzweixzMbimC/hTnt9mzpF6my3KPDIYHhBu+3h8EzzvnErDnW+dIYybbHm0ctC5iPfDoQ== X-Received: by 2002:a63:443:0:b0:383:f97d:a16b with SMTP id 64-20020a630443000000b00383f97da16bmr11829665pge.297.1648750549267; Thu, 31 Mar 2022 11:15:49 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id j8-20020a17090a060800b001c7936791d1sm56045pjj.7.2022.03.31.11.15.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 11:15:48 -0700 (PDT) Date: Thu, 31 Mar 2022 18:15:44 +0000 From: Sean Christopherson To: Jan Stancek Cc: Bruno Goncalves , kvm , "Bonzini, Paolo" , lkml , CKI Project , Li Wang Subject: Re: RIP: 0010:param_get_bool.cold+0x0/0x2 - LTP read_all_sys - 5.17.0 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.