From patchwork Wed Nov 2 23:19:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 14554 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp201606wru; Wed, 2 Nov 2022 16:26:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7q0h1DdnC4y93yfnhpcVQD2XMp6zuyblJIsCyReCn/LlUrnDr3syZSxVqoXl3Gr9qrnzMw X-Received: by 2002:a17:907:31ca:b0:780:2170:e08c with SMTP id xf10-20020a17090731ca00b007802170e08cmr25634179ejb.145.1667431613453; Wed, 02 Nov 2022 16:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667431613; cv=none; d=google.com; s=arc-20160816; b=GFsV3yGjNPN8fnWpxU+/OoORUBIpAA8xXvvUZWx5RfJX1+AsS+71avpOZvqKySBYJE jV5wXrS3HEc7X3V/o72DrLQYaP85AOlTNHqprL6eu4cD0CQjnciS7eiVi8eq9fqTME/B xPMCGPV5VyEl+A/epMroET6RAwJiZJtFebVdAFHla3rf2qBtYPRSy3xzyvut9DivG+sB CpyQ0p0cNNrJ2BD9chj2qF6ABdDRnZIEn67gPi8+GPqraDY/pqlwFKHOJW/hqxGz5njT 9t4d1+dWTlf9tsbdyYlkJbyYkFwuJUEtwnTvv1X1lDT4+2JLYRIQeb5XjoVYM+lqC85B ckHQ== 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=5gvBLFzYAyi/HCXZ+GVBUHE668bhbiWmi3vwDs9Tl6k=; b=G4AAo5840Ond6O/eD8oDwoI1gYlQw5USYuFGPT9cn+oV7SYIvoSsJnNy5NjQqCHH7C abgbw76EIGkpN0rxlqqShq8NWjdiX1u33GeyNP0t1E6uEKcwA7e24jycg7apVl3AVpwm 3jFaLi7KNpiE5DtiWwDXf5YKkfJcx87lOY+tiVTmFOWPQSwgOzdG9eBLgUs1Zyw9J2Lh 9z/4tSgyGqaF8Jt3Rb447iVq3mOYN0Mpe/csIna6FBTjneGVwAigN+XP+yEPeSxt0yx5 E0wX0LoMfMdwFnDinpXVURok4RPjJp5c9P3ymMGp00H8xhBjVeJ0h/P7Wgdrj4PHcRMi irwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=I5bOS6bf; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17-20020a056402351100b00461e3e1a628si18880516edd.110.2022.11.02.16.26.30; Wed, 02 Nov 2022 16:26:53 -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=20210112 header.b=I5bOS6bf; 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 S230150AbiKBXZf (ORCPT + 99 others); Wed, 2 Nov 2022 19:25:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbiKBXYJ (ORCPT ); Wed, 2 Nov 2022 19:24:09 -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 4B6A71147E for ; Wed, 2 Nov 2022 16:20:27 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id f22-20020a635556000000b0046fd05d55cdso100172pgm.1 for ; Wed, 02 Nov 2022 16:20:27 -0700 (PDT) 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=5gvBLFzYAyi/HCXZ+GVBUHE668bhbiWmi3vwDs9Tl6k=; b=I5bOS6bfxLXiEBfjSJmP2kPQXW/SHnwLLTr4Pv1YGOJfWIPhzpIEkiKigvzufOLE8z PySBQSx0d0+tzNvKQjZSy72HymKoAuRoscdVD3mz0rt/jB8Y6EZI0Hs4WYS/QcUkjCkQ w8JCNgcxA3AK/X9od3l54Dm9fYHBQunkNi2G+VlGLZfuFSeGcLjMIp0YguN3Du588HWY UWsywY+dlyhYN95M8oqWM+ViHOjI8pWnpvPSFJCTuFlV7XnGnW9UVxSozj4IBjaVYRja c+tkLJnZPA8seMLOKTKBakZMCiOE4R5iDaDnVWvTgDI/JcgRlH/AKu7MnFyysyA6h5nx w+eQ== 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=5gvBLFzYAyi/HCXZ+GVBUHE668bhbiWmi3vwDs9Tl6k=; b=yVm59BbiDioJNJE7rYHSXO9IfrppwnsWEmAfb/WX+WUlYcVfGiDZqWXM+GdWHvOfc0 rWx2T+yboeVtc4wY6ZwKJVDPFOFJ+y8lIkVIq8/G4eu0bS77qBwMnSwLreWDO41MLiqw 2/j96QImkqDBQN37FU/01ecR0NPg24UtKkAfOKZaKQUAw1T6x1RO69MCV0bkkwLP3iSp 0NjkL5MSPykmqkqmwtWLV1c7gXxpaHqXZtmdUjnUbRjLaAq+yQjThR9958mf0W6E9fk4 ZiL0DrUaWtWHTQqp9azXDpaDkOcM0ElzOi6xmT7YYCoruKC1Jm5wVrUaOcKK+Z1v8nBN Uwtw== X-Gm-Message-State: ACrzQf1TWFChIQvdGotH4iBF8ZcJopyGSfZCv7zSDHZ+/65incjTbQZT Jn5gpfbGn61EsLUe/9xeyqg3V0uOoqM= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:2294:b0:56d:7387:8a06 with SMTP id f20-20020a056a00229400b0056d73878a06mr18916476pfe.17.1667431214429; Wed, 02 Nov 2022 16:20:14 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 2 Nov 2022 23:19:02 +0000 In-Reply-To: <20221102231911.3107438-1-seanjc@google.com> Mime-Version: 1.0 References: <20221102231911.3107438-1-seanjc@google.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221102231911.3107438-36-seanjc@google.com> Subject: [PATCH 35/44] 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 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, Isaku Yamahata , Fabiano Rosas , Michael Ellerman , Chao Gao , Thomas Gleixner , Yuan Yao 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748428771829797324?= X-GMAIL-MSGID: =?utf-8?q?1748428771829797324?= 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 3523d24d004b..efda384d29d4 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -549,6 +549,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(); @@ -4129,11 +4137,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.