Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp213042lqb; Thu, 14 Mar 2024 09:14:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUKoho4Xt3y+E9bpQbrn6LVqEJymmuX3uTg+2YwuybF7BHFn3HxXLhBYKrpACOMhZie4Za8VpczOBS0yIzWt/pUwOR39nKnVEo0+1YJ/Q== X-Google-Smtp-Source: AGHT+IHay6mN1/vYCSWH2sm2x44aZXLgSjLrEzTWvvsKwwWP1U0GvM2Bge/e/5t4/gTot/NOYHyK X-Received: by 2002:a17:902:ce0f:b0:1dd:e0df:8bca with SMTP id k15-20020a170902ce0f00b001dde0df8bcamr3008425plg.2.1710432855333; Thu, 14 Mar 2024 09:14:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710432855; cv=pass; d=google.com; s=arc-20160816; b=rBcsbdQGbVRGrFpwY8+p518nE2R8vs2sSIH9IemF/jaYEqwfveph9gfeK72u74S7HS /BjCBK0Y8do0oQ9JEIe2SnkUmeh+kcn8XRh6zLO2a1NLsJ3uxhA59qmNOKJ35uyVEiqQ SdGX3kYv0U29dSwSqAjgTdvhLkEbej5gORRDoP+5s/iL+AweKoYboBEHy9hJoh7OPOhG Wfdv0jaNTmYMDinTH8bghRFEFF6mPVMlgke+A8MFAT2FwXog7PbB1OKx4m5PEiov4xlD 7eCT3qgVTCB46DuW9ttw+V9Zju29z4HT8CTA6SfOzc2AAHTKBmx9Alrna2I9ta9nMiyC qmZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=30NoHngK6GrhQhALRSj65FRbgPx0G5vd6yPjsAaSoEE=; fh=tt0CEY5xhom/IlvDKU6vi+rzDvhB3cKAIKF4sAkibAI=; b=C2DLpp4sS07e0si44LRb1sES5tcbgAJ2BJT5fwVRE1iAxvTA+ggDgGxX/DCZbOsNfe mr09HFmnzdwwwjidM5E4Q2+w5h3YP/Z/cG1HBSlYKVXxE+8BNcNWRvkjGZ0P291nCWCd I4AixWGVOoV2IsnQfdkkbl8WTzD+x+8aQpcfYMPtnRLyDg+jV7D1Ekr18C3ZmqV71l2b ODtk6XbaQHeOmfRkFXCZ+kRAVTcA9Xpmoakbe7+DNFmWbJYCuGbO46jViI+FNMarCdKt yPnRjnPhQaNTtXniFRzCV65b5tNG/u9Lp2/Llu3bRSN88/NcIa5fKBOJ/n2YlCzLcHwm NzuA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lDOc7R17; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-103556-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e11-20020a170902cf4b00b001dc652d7099si1742405plg.240.2024.03.14.09.14.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 09:14:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103556-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lDOc7R17; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-103556-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 002C1282EF5 for ; Thu, 14 Mar 2024 16:14:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BDF8F745E1; Thu, 14 Mar 2024 16:13:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lDOc7R17" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58B1E73522; Thu, 14 Mar 2024 16:13:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710432800; cv=none; b=Zwt0G4fLHXMstMLjsQ0bYtbvPcj1GnBZMUmpHpQaHQSxoVNzEHS8g/e0sT+rO0XaGyU0aLse02XJCJalHisShKRkcg9BHQPMpUHMdluZFPfeT7v3w8YwUtFMzC7YmWXa5LJ5JfPaCy40lrsM/aav8UrIrXGOpywm7stRsmaGbOU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710432800; c=relaxed/simple; bh=FbRU08K/6LuBlZvA1/pbpzTww+NMF1+gxxXYtSCDBds=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fLzkndiQapiyrhsmHsWuAiUFLmYh+UGZDenbaT3yvEccqY00ZHve5SDMyZbgeh9uu0wAkxh5pFRJVPpYOiuO8SGNv8TDqG6iNO5bYtxz6Oq3OmKY6Lm1mZBymGsLjRJN04vTE7teVn75xZeF8T0F0hn0lLF830+rXO7D9JiH6S8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lDOc7R17; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710432799; x=1741968799; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=FbRU08K/6LuBlZvA1/pbpzTww+NMF1+gxxXYtSCDBds=; b=lDOc7R173+2ab93Sp+uHFFeMN0bGeDqESEAb1sqMRg6YJmyoEgvK+kPb A1lvaa+AavUf63/4ME5VMwsZTfT+j4Np3AwPVUbdnklyKPirN8GJ8srjp 88ADlscMAO6vtq64pzlL84bKYbNRjMThaH8emerl7+crBQjrpJ8QrONos e2Px5xJpZqmxZ5kVTRpzmKNaOkdBqC4rzjY7OQEHfZNZeK+7OHv4Vgbyn sSqx1tjBGZgKBy7qlVkUA/Vgubb+J3G9Am18suhOb/YGUf3RpUG7mdwVT NHmEFcwLMUh3oD3I82m6u9LWY70xjmHs0AiXbqeDo92p9Z1/QCQa8RmQ2 w==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="5864936" X-IronPort-AV: E=Sophos;i="6.07,125,1708416000"; d="scan'208";a="5864936" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 09:13:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,125,1708416000"; d="scan'208";a="16941066" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 09:13:17 -0700 Date: Thu, 14 Mar 2024 09:13:17 -0700 From: Isaku Yamahata To: Chao Gao Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 019/130] KVM: x86: Add is_vm_type_supported callback Message-ID: <20240314161317.GN935089@ls.amr.corp.intel.com> References: <6712a8a18abb033b1c32b9b6579ac297e3b00ab6.1708933498.git.isaku.yamahata@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Thu, Mar 14, 2024 at 04:32:20PM +0800, Chao Gao wrote: > >-static bool kvm_is_vm_type_supported(unsigned long type) > >+bool __kvm_is_vm_type_supported(unsigned long type) > > { > > return type == KVM_X86_DEFAULT_VM || > > (type == KVM_X86_SW_PROTECTED_VM && > > IS_ENABLED(CONFIG_KVM_SW_PROTECTED_VM) && tdp_enabled); > > maybe just do: > switch (type) { > case KVM_X86_DEFAULT_VM: > return true; > case KVM_X86_SW_PROTECTED_VM: > return IS_ENABLED(CONFIG_KVM_SW_PROTECTED_VM) && tdp_enabled; > default: > return static_call(kvm_x86_is_vm_type_supported)(type); > } > > There are two benefits > 1) switch/case improves readability a little. > 2) no need to expose __kvm_is_vm_type_supported() The following[1] patch will supersede this patch. Will drop this patch. [1] https://lore.kernel.org/kvm/20240226190344.787149-12-pbonzini@redhat.com/ -- Isaku Yamahata