Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3175271ybb; Mon, 13 Apr 2020 02:18:45 -0700 (PDT) X-Google-Smtp-Source: APiQypKqsIq9Stugy7B805pdCsmFlJSuxxs/s8+k5Rt2gjOXwRXVJfbaQIIFlRCFtdzK2L0fKtwa X-Received: by 2002:a17:906:4cd2:: with SMTP id q18mr15137260ejt.70.1586769525184; Mon, 13 Apr 2020 02:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586769525; cv=none; d=google.com; s=arc-20160816; b=iR5OvR+ESwuWgXkx8j4qvXJHIkghAMwXYp5BH+nW6XvuQ2BzwgUm6SFWnaoBPZTOKE L2r+57AAjI94R4c4qX33esWaS1eTyMF39Y2l7Ey8IsGhieu3R5Pe3alkd6T0nv3orsCv r0GURkkkoSqDiaaHBAuvogGTsmgDi/QoifSm6pEuEqIl+aZF9C0dhdOryCW0O0nHjyZQ Bz28CjIsQv0Z7G6fdoBCC3ml34LUwsLgFBIEG/UifhckK7HNwhGMVQWYWEXXvkWkIPmv Y9PVec4WY5pZL7BhvlqMEfjdM/rAVqE9G7YDPYC+hc6HVqaHpmjJa0UW0BYZpFqUCL59 YBEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=lYN6NWfIRfj/yIGOoBz/hWKpypYJrD0ZyvpeCaMLxg8=; b=DgJaMG1ZffFJq0bk9CHQRjXnyA5i7TJblASTN9y226pXN0/OHcsQQYHNp8AwAG5fs6 gSC/JWyZd1mb5QSMGsqbLyTLkjzyW3Eir6UmAXp7JmKrb0WvSfLu7C/6CFjzUkPC9K1J rdPhDb6HMwFK3bClVUGwFsTthkq7rLQRpoiDfvE5HCj/GtbA85SKhxUAD+cDWLqcNEkM gfxAuFp2LbSYW2lGhcZBRjin7lzd6A/JhtIEWfEFbJ1lpawoNN+65zeuiLwFRRAqeoZe sXC1ZBwh01iHv6Yf29oR8u0k1wX+oo7V4sFSf6T/Ie6v8vWt3Bs9KvKqjFvcyQJfPQbi qe0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Jm26BeDw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 6si129082ejv.70.2020.04.13.02.18.22; Mon, 13 Apr 2020 02:18:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Jm26BeDw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729455AbgDMHuk (ORCPT + 99 others); Mon, 13 Apr 2020 03:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.18]:36560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727480AbgDMHuk (ORCPT ); Mon, 13 Apr 2020 03:50:40 -0400 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5095C008651 for ; Mon, 13 Apr 2020 00:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586764238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=lYN6NWfIRfj/yIGOoBz/hWKpypYJrD0ZyvpeCaMLxg8=; b=Jm26BeDwGw/jilSjNgxFzkLQmOQ3VZQuDsnYgltiBuiWnvjouZ+IiQI5Cd7BHMwI1Gfas0 SlHslx02LN/WA7ZxPsRKnTkchn+0oDMcGK5H/usr/7IgdFHd7djfVHME6RZT4xbQzJ85dN YmoqQ4N+lh+ux4HDEXrznc/pjO1vEwQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-RHGsbDOdMDWecL_D8MqgFA-1; Mon, 13 Apr 2020 03:50:34 -0400 X-MC-Unique: RHGsbDOdMDWecL_D8MqgFA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75B491005513; Mon, 13 Apr 2020 07:50:33 +0000 (UTC) Received: from virtlab511.virt.lab.eng.bos.redhat.com (virtlab511.virt.lab.eng.bos.redhat.com [10.19.152.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0364B5C64E; Mon, 13 Apr 2020 07:50:32 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: ubizjak@gmail.com Subject: [PATCH] KVM: SVM: fix compilation with modular PSP and non-modular KVM Date: Mon, 13 Apr 2020 03:50:31 -0400 Message-Id: <20200413075032.5546-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use svm_sev_enabled() in order to cull all calls to PSP code. Otherwise, compilation fails with undefined symbols if the PSP device driver is compiled as a module and KVM is not. Reported-by: Uros Bizjak Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/sev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 0e3fc311d7da..364ffe32139c 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -1117,7 +1117,7 @@ int __init sev_hardware_setup(void) /* Maximum number of encrypted guests supported simultaneously */ max_sev_asid = cpuid_ecx(0x8000001F); - if (!max_sev_asid) + if (!svm_sev_enabled()) return 1; /* Minimum ASID value that should be used for SEV guest */ @@ -1156,6 +1156,9 @@ int __init sev_hardware_setup(void) void sev_hardware_teardown(void) { + if (!svm_sev_enabled()) + return; + bitmap_free(sev_asid_bitmap); bitmap_free(sev_reclaim_asid_bitmap); -- 2.18.2