Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp137553rwb; Thu, 27 Jul 2023 10:24:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlE6Exfes25k+6fgjF71dVjSuOrcHWwBhyY2/G81/eL+Ubz9gRjClgHmwfiAMAyzCIQfh5Lg X-Received: by 2002:a05:6a20:7348:b0:134:eee2:f9ce with SMTP id v8-20020a056a20734800b00134eee2f9cemr5959794pzc.11.1690478667666; Thu, 27 Jul 2023 10:24:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690478667; cv=none; d=google.com; s=arc-20160816; b=cb5XgjbkuQPlqcYQ4eNN/DSFUXH4tAxYWXlU/5h8PEEGESxbkPbIdz/Ft60ixdoTmp MRWeD0UVjvvGXTlPgSwwqH4fZSS8iSWOXrh0B7wbwZ/fcsklMpYdocrUxrlPNdDH/hYE BQx6sAw+7V88Jsmthm+vJORx2rJacOyhTUxfdhK72aP0IeKg6JFa4i1fX4T4lbv7gY2e 7zUhUds84n/dU/qwEO6HsFqn9Zx6RNdZug0uVL8XsnI3zPb/xqPe9jcOAJaQNhmFsjsd lGbndwF/0yZwiin7Q1ya2dcjwvOk2beycns30Rt9anFLR5p+VeBm5dbVaFC0YXlXl5on 9mmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=08PPmSmbVOI5lp9VMb7/YRIHpnsubNB5bxPFF/tGfQM=; fh=iA9qT0EJTXI92gQ1ljocMFQRm+GzjAukVos0/kpf9So=; b=hOTzbuvrV/k9Dj5APhIMS9wyMyyhE5BGGccrtEY3bsbL4Omo5BtAIs7hakBDXtIRGq tHhKZdww89QDnC0vpW/DPZEtGB7UC/migjOIEMWw2TmqzyRW1v6R0mAD23q0MYydx/tD 2k6EO0r4KRliUYDOXTz0xYClWr5VUT1oSk/r3KMshyXwSkZBmbwB/i3AChD+dlnW7USO g8Jd432cRkrindhyqCQRTTTKVlVcuQqMat+aatcXWBKNienBdfniEDY3YhNEcuuHlIJU v8CgnrsSDqc+57/2sjMmytb7Z7NPxb7jgvphJ8Olp3/L9IxGl8xodLN22DHCpdN6a2x0 M2Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=O3VZNy1x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j1-20020a635501000000b00557807d78e2si1466527pgb.555.2023.07.27.10.24.15; Thu, 27 Jul 2023 10:24:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=O3VZNy1x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233577AbjG0Qj5 (ORCPT + 99 others); Thu, 27 Jul 2023 12:39:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232979AbjG0Qj4 (ORCPT ); Thu, 27 Jul 2023 12:39:56 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC3432D5F for ; Thu, 27 Jul 2023 09:39:54 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-55be4f03661so987007a12.1 for ; Thu, 27 Jul 2023 09:39:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690475994; x=1691080794; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=08PPmSmbVOI5lp9VMb7/YRIHpnsubNB5bxPFF/tGfQM=; b=O3VZNy1xI6kpXEi28VVpZj98iHJw8jkNqum1WsxYb9mFxYKvkMhyFMvT3sBxtnCPuz SDWBqXgWnDc17jVqffzqjHLrZfkoSx9ZmemZszDZHhxDp2c2z/7SG1gnFLmqFKxDp3FH 3rfP0Ct33uL6CjFYQlSrEvJ9XP5oBf9RYxsmueBUAVTZHhgjtoAxYiprxvzQgtfevo1i Ijo6mIUMJuJH3cEYhdauKp5dv1Ybs62fqWL6UmvqRJcPfTMKk+YevVlgVg/BQoI5SdBE 9AnvZUseK2/UCtOKfh+LOPosSSS9UL5b9EbcntVYG2BrYXznAG9pAjumML+FXVYsFN/X PbjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690475994; x=1691080794; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=08PPmSmbVOI5lp9VMb7/YRIHpnsubNB5bxPFF/tGfQM=; b=Fa/fN18nCcq9JSI+KmwOSE21SBSWHRdOWwghSq95WhkXrsqUzM7uTCUsms+Bx5CAnf OedYAWRAm5orD5i48IFlGG1T2U4KJ97QINwxk4ai/0AoKdOgkVc2AJwilFKiDAWHFdwB 1zWTRvJAy31GNNgeqNOw47NK907+cOpQQa8ptEP/0SO3rnkvucO370//CLhi3Tf4B103 o/OrOKqASjhAxbZPvWr3Bisr6/S7GoC+D1LhVRahuwB5+SkX+FC/wMVFeGgI0tEq7lxp o9w0t/bZsRuz6YIR1laX4r5pEaM0KAP8jYde3epWliA5UUFV45sgW+J98u1mt5yemW+N MLGg== X-Gm-Message-State: ABy/qLYqQNzDe9HMsfQkKJILMA9NsqHpnNfNqRO5+AJu/01EXSVqIXEU QkgiqCdmihy6XlDPBj5IP44sI384KrI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:a746:0:b0:563:4dac:e580 with SMTP id w6-20020a63a746000000b005634dace580mr25609pgo.9.1690475994353; Thu, 27 Jul 2023 09:39:54 -0700 (PDT) Date: Thu, 27 Jul 2023 09:39:53 -0700 In-Reply-To: <20230725091611.GA3766257@hirez.programming.kicks-ass.net> Mime-Version: 1.0 References: <20230721201859.2307736-1-seanjc@google.com> <20230721201859.2307736-15-seanjc@google.com> <20230724212150.GH3745454@hirez.programming.kicks-ass.net> <20230725091611.GA3766257@hirez.programming.kicks-ass.net> Message-ID: Subject: Re: [PATCH v4 14/19] KVM: SVM: Check that the current CPU supports SVM in kvm_is_svm_supported() From: Sean Christopherson To: Peter Zijlstra Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Andrew Cooper , Kai Huang , Chao Gao Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 25, 2023, Peter Zijlstra wrote: > On Mon, Jul 24, 2023 at 02:40:03PM -0700, Sean Christopherson wrote: > > On Mon, Jul 24, 2023, Peter Zijlstra wrote: > > > On Fri, Jul 21, 2023 at 01:18:54PM -0700, Sean Christopherson wrote: > > > > Check "this" CPU instead of the boot CPU when querying SVM support so that > > > > the per-CPU checks done during hardware enabling actually function as > > > > intended, i.e. will detect issues where SVM isn't support on all CPUs. > > > > > > Is that a realistic concern? > > > > It's not a concern in the sense that it should never happen, but I know of at > > least one example where VMX on Intel completely disappeared[1]. The "compatibility" > > checks are really more about the entire VMX/SVM feature set, the base VMX/SVM > > support check is just an easy and obvious precursor to the full compatibility > > checks. > > > > Of course, SVM doesn't currently have compatibility checks on the full SVM feature > > set, but that's more due to lack of a forcing function than a desire to _not_ have > > them. Intel CPUs have a pesky habit of bugs, ucode updates, and/or in-field errors > > resulting in VMX features randomly appearing or disappearing. E.g. there's an > > ongoing buzilla (sorry) issue[2] where a user is only able to load KVM *after* a > > suspend+resume cycle, because TSC scaling only shows up on one socket immediately > > after boot, which is then somehow resolved by suspend+resume. > > > > [1] 009bce1df0bb ("x86/split_lock: Don't write MSR_TEST_CTRL on CPUs that aren't whitelisted") > > [2] https://bugzilla.kernel.org/show_bug.cgi?id=217574 > > Is that using late loading of ucode? Not sure, though I don't think that is relevant for this particular bug. > Anything that changes *any* feature flag must be early ucode load, there is > no other possible way since einux does feature enumeration early, and > features are fixed thereafter. > > This is one of the many reasons late loading is a trainwreck. > > Doing suspend/resume probably re-loads the firmware Ya, it does. > and re-does the feature enumeration -- I didn't check. The reported ucode revision is the same before and after resume, and is consistent across all CPUs. KVM does the per-CPU feature enumeration (for sanity checks) everytime userspace attempts to load KVM (the module), so the timing of the ucode patch load _shouldn't_ matter. The user is running quite old ucode for their system, so the current theory is that old buggy ucode is to blame.