Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp715886pxb; Fri, 8 Jan 2021 16:52:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8scQfIv8y2YMN/JQ+Z7YZwuEbX3p6PdGU8m+GDoNOUzhgbwMMkg6aJ/OQKH+SlzjixnX6 X-Received: by 2002:a50:a694:: with SMTP id e20mr6986152edc.261.1610153567674; Fri, 08 Jan 2021 16:52:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610153567; cv=none; d=google.com; s=arc-20160816; b=PjsHaq2CDKAFMcfOXu4NaLciyGhIcAv006OLdrOYK4LcUkNYton+V7QomtrNSFV/FQ 2MPjyPArls8IaOpyXUxjokPPk0oV4etqyAi1cgZ/eaFK/TYOszrmE+oYj81u2AqAEsXt 9Vj2IZmcosr3VX8Mc8lHM3mvCcqF0PkMdiICATfKqYAY5JpczmvMk3jEYglyArnZ3PzD Suptk46iDCc6Q3q8/G8lAg3BEL890xGpu6oAhCQ39u1Fyd6pwgKwRRGMuPsSnVCcj8ti fC4SAMVSLsVx3HIve42P3fXUVpY+Q9EfoC2rvg+ke91xr1JLyQXMW1VjN0cmRe2I4wnq qNBg== 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:references:mime-version :message-id:in-reply-to:date:reply-to:sender:dkim-signature; bh=jYzoDTNoVvtxiYfXr7ZVMmi5PaPZLOefqEPk2ReBEho=; b=GBm7BujqH3wU5GFFfCKzhOsanC+wnfye1l9r6uNlvtY9C5LJPpVenA5X2U0IQBHW1X lQ9mppubShNNiMO8DQ2LAa5ZG6iT4KKWcgEzAismUizQTbiow70rBt4K42+yyvtUi5nX am/QnaUVQhdY+O6x/oOF3fA/0rLg7aUtftKy6IZmuRx2f41orHxnAwaR+lHwgIWf8P2C zQc3lmfyR2gqWKyjoMtr4JWxPDYvj6WDaNkGDIegKcz+h5Xxps8UzBMFpscaSkFO295s w5h9+lH+DxO8GOpyGrfd/3ii0EIoLSQeG4GMF9P3T2+AoSTPQOUdSunCAZbECamVAG9A E3EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rYTHs6Vt; spf=pass (google.com: 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kq6si3903707ejb.300.2021.01.08.16.52.24; Fri, 08 Jan 2021 16:52:47 -0800 (PST) Received-SPF: pass (google.com: 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=@google.com header.s=20161025 header.b=rYTHs6Vt; spf=pass (google.com: 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726908AbhAIAth (ORCPT + 99 others); Fri, 8 Jan 2021 19:49:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726893AbhAIAtg (ORCPT ); Fri, 8 Jan 2021 19:49:36 -0500 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 581CFC0617A5 for ; Fri, 8 Jan 2021 16:48:03 -0800 (PST) Received: by mail-qt1-x849.google.com with SMTP id i1so9504968qtw.4 for ; Fri, 08 Jan 2021 16:48:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=jYzoDTNoVvtxiYfXr7ZVMmi5PaPZLOefqEPk2ReBEho=; b=rYTHs6VtOzbi6t9kEubz4Bd+X+LSpeh5CRREL9KKvWx45B0x4J0JqtXf703AejLdtZ oZd0vk11Abhc/dNaTO6AwGRfWUzPa+15qfOmKU3HE7R5rmTdbuOlJEndJ9HeBFcLKLCx d5OdbCJAuc7xXDH1++YnlhT/Wjk3cDchoMS3Yqhfprh7iobuflp11tBHw1a+E+j06SE2 fdJP6K2FCEV09r1EqKSirOXpb2Bt+orJYtoE1AIdrGg+cmynp9ZM2KT0aShabNNamBGE lAryM1BjRSsxC9owM+IXltC9RJRskBjuF6PV4Mwyh532wHel/6LvgcsYD3s6n6ldH7L3 YFqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=jYzoDTNoVvtxiYfXr7ZVMmi5PaPZLOefqEPk2ReBEho=; b=flZfyM0UTFnpv4K3vJbm9LHFBRNChtn1EMAeoo0C+UWSoMtzU1vB5xwlTaCVQX/CJd fFoDEuPSrnCypjBjVINBzCdFxbpI/Vk3qbjqvqb+nh/qo56FfJnDVbLkhx/SvIpdYqb+ Z52SyXYANBt/Yjf+JZ9MDNxlhp7paeP74LmDcJCVAn7Sxn2QSoJk0whVc7ORSNUh+zS0 7dV9SSNSi/y+IMngz7kTzYUUh65iwtlreWGItiCU1bS+/9XuSyeq632Ygp88goLYFWct 3Qi/9o3R8teWOkmboB95g5k2gpsJsPJVLZkckAS24UfIf9MJPT+nhF6F1/Q/Yb3czxs3 VnKw== X-Gm-Message-State: AOAM532bwCOyRYoDsXL7TeC7SeCmLkJDb0uFvP9LwFfLJjgCUceEJ3BS NVIkfQKgoM098/unSjWejtagR+DLJ/s= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:1ea0:b8ff:fe73:50f5]) (user=seanjc job=sendgmr) by 2002:a0c:fa11:: with SMTP id q17mr6347369qvn.55.1610153282514; Fri, 08 Jan 2021 16:48:02 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 8 Jan 2021 16:47:12 -0800 In-Reply-To: <20210109004714.1341275-1-seanjc@google.com> Message-Id: <20210109004714.1341275-12-seanjc@google.com> Mime-Version: 1.0 References: <20210109004714.1341275-1-seanjc@google.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH 11/13] KVM: SVM: Drop redundant svm_sev_enabled() helper From: Sean Christopherson To: Paolo Bonzini , Dave Hansen , Andy Lutomirski , Peter Zijlstra Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky , Borislav Petkov , Brijesh Singh Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace calls to svm_sev_enabled() with direct checks on sev_enabled, or in the case of svm_mem_enc_op, simply drop the call to svm_sev_enabled(). This effectively replaces checks against a valid max_sev_asid with checks against sev_enabled. sev_enabled is forced off by sev_hardware_setup() if max_sev_asid is invalid, all call sites are guaranteed to run after sev_hardware_setup(), and all of the checks care about SEV being fully enabled (as opposed to intentionally handling the scenario where max_sev_asid is valid but SEV enabling fails due to OOM). Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/sev.c | 6 +++--- arch/x86/kvm/svm/svm.h | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 8c34c467a09d..1b9174a49b65 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -1052,7 +1052,7 @@ int svm_mem_enc_op(struct kvm *kvm, void __user *argp) struct kvm_sev_cmd sev_cmd; int r; - if (!svm_sev_enabled() || !sev_enabled) + if (!sev_enabled) return -ENOTTY; if (!argp) @@ -1314,7 +1314,7 @@ void __init sev_hardware_setup(void) void sev_hardware_teardown(void) { - if (!svm_sev_enabled()) + if (!sev_enabled) return; bitmap_free(sev_asid_bitmap); @@ -1325,7 +1325,7 @@ void sev_hardware_teardown(void) int sev_cpu_init(struct svm_cpu_data *sd) { - if (!svm_sev_enabled()) + if (!sev_enabled) return 0; sd->sev_vmcbs = kmalloc_array(max_sev_asid + 1, sizeof(void *), diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 4eb4bab0ca3e..8cb4395b58a0 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -569,11 +569,6 @@ void svm_vcpu_unblocking(struct kvm_vcpu *vcpu); extern unsigned int max_sev_asid; -static inline bool svm_sev_enabled(void) -{ - return IS_ENABLED(CONFIG_KVM_AMD_SEV) ? max_sev_asid : 0; -} - void sev_vm_destroy(struct kvm *kvm); int svm_mem_enc_op(struct kvm *kvm, void __user *argp); int svm_register_enc_region(struct kvm *kvm, -- 2.30.0.284.gd98b1dd5eaa7-goog