Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3122186rwb; Wed, 30 Nov 2022 15:55:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf4A31XCH44/qSGnJ5Fp8EbNfieAAvYTlGDF3I0Bhd04qC7tF97OTLa2whJTTB3eaCF87wIZ X-Received: by 2002:a17:907:c60d:b0:7bf:5fa6:b9b8 with SMTP id ud13-20020a170907c60d00b007bf5fa6b9b8mr15828697ejc.383.1669852519305; Wed, 30 Nov 2022 15:55:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669852519; cv=none; d=google.com; s=arc-20160816; b=xP3G9+VGLr+0IKTUDbd8tpIVvQeXpsiuPHnKtD3tgVp6mglBaLx60YNkSTkehorO2a zhewB5Yarb6BRaJVzg021OT2n98e0pBVtNyjQpzuv/2PJTAYWEy0zZ8BSBR971w7EY84 Ei1wPnTsnhJnvczoIJa1q1HtwkNJYFMNjt61pOQX7hafycj8tS1Scr4k0uA4SOPn04Mr lLYiv9jUoBvy2GvizA4YQulINn++IWUDHrf22rFpw6GFCL3Jk9I5qUKZO5r3Cw7S6MEo Z9KZxtm7BMJ0v1t9FQxpa666GfFpsXLO3osokFP3LwwRIcCyWDM3c+sDgiOKbTVSKmaR XQYw== 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:reply-to:dkim-signature; bh=9siMTxNa3uAP5fZIzNGfC6XHHMwgiKNlJBnmhPRbPro=; b=zURINuUGSpjcVEZq8VF7rwMmHmBOvubh28BYJb6MRdzzfDHrU/iLHIS55vjV99GYGZ nh0lPFv6Y3z9F26MwUl/xgdyVNes+aa7x3eHMigu3DWQbTcwomsh0lczJKB7JskX81tf ho+Uq74QXfQl+6fqR/kvpUhbkcSAYWvq5SvxNAvTX3SgiLiK2ZNOmmrHwmawTnWALG90 6qsgNil0kj9fufP8s3KUAcDpxWlWhP5q9kSRAKYOtFTKzfppMe5lE6YJfHR+DoPUdf5t TAVq96PyimCnS5LDgozwmYHFa/AOcZsnbdbz9LaIOIryKNkY/423iRLHLDp1Rrm/Z3Fe 6GVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ChW1Nps9; 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 ds18-20020a170907725200b0078da414a7cesi2711850ejc.149.2022.11.30.15.54.57; Wed, 30 Nov 2022 15:55:19 -0800 (PST) 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=20210112 header.b=ChW1Nps9; 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 S230085AbiK3XQI (ORCPT + 83 others); Wed, 30 Nov 2022 18:16:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbiK3XPA (ORCPT ); Wed, 30 Nov 2022 18:15:00 -0500 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03784A1A33 for ; Wed, 30 Nov 2022 15:11:15 -0800 (PST) Received: by mail-pj1-x1049.google.com with SMTP id mh8-20020a17090b4ac800b0021348e084a0so3776845pjb.8 for ; Wed, 30 Nov 2022 15:11:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=9siMTxNa3uAP5fZIzNGfC6XHHMwgiKNlJBnmhPRbPro=; b=ChW1Nps965Qp18Q6+pUQJ9HaZg+bsuoNAPERVx5vtZW0btHu7mssz1zq2swGpNBnOO xeSdi4iwUV2bHGTbxVVeaFbSd7hDQi+GikXoUOMA+ds3pfZUeA7jrH6W4f5P6c5pwr9B U3XVYRZQ7E6Yrhd7CzlvGARnYPdmscwvfkiQmHkzv9OBvomDdeXYt/xK1+qhaSsZxp4N N9NxXX+4yvTNEHy1B6JV5V2Zu6j+0V3rnH/CXLtu/bfRs93WfDHZOPYCsGgSMQHV2o0D eDMkxgUR8PhMKsVPRy8wQRrlE6YEWvcusAVfquXtz1XnSeeHga0XG3gUzph6fBCETn2R dxhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9siMTxNa3uAP5fZIzNGfC6XHHMwgiKNlJBnmhPRbPro=; b=DVYXtWwTK4wq9oR/Lk8PWGMP5QK7aOsJsJPUDdIqGVFb0CA32Gpt5z+qMGBNtuBtQm 9FyvjnErtlPQOErxoffAwbiymxXr+2KG6+zL8L3dGwbuYT+MDJi9c3enp7WHvpP7aSGC irUSDaAFHfGI0ybSlIqMqPrRQyRmtckIjYZO/9Fa5VmE3zhV7hp2GptwAVgYwjgJB3gU lJ4IHHdAnA0rpfNGHp+8nFjj6CG2dMfP897FEug8F6Z7x3LcI1JwPz1WR/J237Qfvf00 fVNYOBiG+KGM2x777UZSXnyb4Z9ONuEQdjmBFTNj3OFFob9Jckig8PpqvwujKuGKBAaX +S0w== X-Gm-Message-State: ANoB5pkEo50y/9eWKPuWmlnKaOzRKJsZ87s+0MDiEeJsgYDtf5Hjpuzs +IizU/mW/S8YtdvWvy4NhLdUaiStHV4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90a:43a4:b0:219:1d0a:34a6 with SMTP id r33-20020a17090a43a400b002191d0a34a6mr2520763pjg.1.1669849843212; Wed, 30 Nov 2022 15:10:43 -0800 (PST) Reply-To: Sean Christopherson Date: Wed, 30 Nov 2022 23:09:22 +0000 In-Reply-To: <20221130230934.1014142-1-seanjc@google.com> Mime-Version: 1.0 References: <20221130230934.1014142-1-seanjc@google.com> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog Message-ID: <20221130230934.1014142-39-seanjc@google.com> Subject: [PATCH v2 38/50] KVM: SVM: Check for SVM support in CPU compatibility checks From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Matthew Rosato , Eric Farman , Sean Christopherson , Vitaly Kuznetsov , David Woodhouse , Paul Durrant Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Atish Patra , David Hildenbrand , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Yao , Cornelia Huck , Isaku Yamahata , "=?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?=" , Fabiano Rosas , Michael Ellerman , Kai Huang , Chao Gao , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" 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_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 Check that SVM is supported and enabled in the processor compatibility checks. SVM already checks for support during hardware enabling, i.e. this doesn't really add new functionality. The net effect is that KVM will refuse to load if a CPU doesn't have SVM fully enabled, as opposed to failing KVM_CREATE_VM. Opportunistically move svm_check_processor_compat() up in svm.c so that it can be invoked during hardware enabling in a future patch. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 49ccef9fae81..9f94efcb9aa6 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -543,6 +543,14 @@ static bool kvm_is_svm_supported(void) return true; } +static int __init svm_check_processor_compat(void) +{ + if (!kvm_is_svm_supported()) + return -EIO; + + return 0; +} + void __svm_write_tsc_multiplier(u64 multiplier) { preempt_disable(); @@ -4087,11 +4095,6 @@ svm_patch_hypercall(struct kvm_vcpu *vcpu, unsigned char *hypercall) hypercall[2] = 0xd9; } -static int __init svm_check_processor_compat(void) -{ - return 0; -} - /* * The kvm parameter can be NULL (module initialization, or invocation before * VM creation). Be sure to check the kvm parameter before using it. -- 2.38.1.584.g0f3c55d4c2-goog