From nobody Fri Mar 14 13:17:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1710332932; cv=none; d=zohomail.com; s=zohoarc; b=j+RIGsLD5wV6wHLTexoNcQWj6wBHMkqnNqPq6ue9pmFso67ghYqU3qK5CbZj/GafNnb0OqykYLGYgnLGdsvj+i/oUC4n+tjwAecrgdUS6YfSnuEs1Hz8NSlIFShPbuo0E/mNbxEDpLLlsYEfuJOwJXFpwpkBc01jo1cFYobDoQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710332932; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GCwOpLYs0LxuV2LN5cgSdDy/7vlzfUoEPoHbwcZNVf0=; b=A6RkuxJep3B96mlvt67YZXIqebCPMmcbt4ciy1rge9M4OtYEb8DB+LGgI1gok/NvmPRhKXZTsa7MxNZMikRXX5KtKBXvrAozWhmi4al2PIxdOIGlVkuHTq21Ox7tFEgJnP9Wyeh4mvPCsZTCuBH2ix/vf68o8PCIHO8EvWqIEDk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1710332932037299.1470314569508; Wed, 13 Mar 2024 05:28:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.692403.1079499 (Exim 4.92) (envelope-from ) id 1rkNil-0005vL-If; Wed, 13 Mar 2024 12:28:35 +0000 Received: by outflank-mailman (output) from mailman id 692403.1079499; Wed, 13 Mar 2024 12:28:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rkNil-0005vE-Ft; Wed, 13 Mar 2024 12:28:35 +0000 Received: by outflank-mailman (input) for mailman id 692403; Wed, 13 Mar 2024 12:28:33 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rkNij-0005e0-Ls for xen-devel@lists.xenproject.org; Wed, 13 Mar 2024 12:28:33 +0000 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [2607:f8b0:4864:20::22f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 34356dca-e135-11ee-afdd-a90da7624cb6; Wed, 13 Mar 2024 13:28:32 +0100 (CET) Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3c21a3120feso2612387b6e.3 for ; Wed, 13 Mar 2024 05:28:32 -0700 (PDT) Received: from georged-x-u.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id ne7-20020a056214424700b00690dbc390dcsm2283874qvb.89.2024.03.13.05.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 05:28:31 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 34356dca-e135-11ee-afdd-a90da7624cb6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1710332911; x=1710937711; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GCwOpLYs0LxuV2LN5cgSdDy/7vlzfUoEPoHbwcZNVf0=; b=XG/MOe8ajsSjz5XAY63g5SIBTY3OkiyOXV/VXim/kI1Kl4M6Vs37ywG5Sr8d3v77xi Bil4WOv/6hdbh2gqmtj+N2PFVEPpdpmi7/VlbH898HXSRWp9DwyqkbH/0U/eThpJmt5K C6Cr48dNj3zP6nPDIkT0wOFXAiwgtIG5m2OsU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710332911; x=1710937711; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GCwOpLYs0LxuV2LN5cgSdDy/7vlzfUoEPoHbwcZNVf0=; b=USOMqE3OJB216yc1cueE3q1Ec9T092w6BB7L57hOIlgF4KmlKbyBTD4v4eaOCQWhfe +ALshh9taJCcaPmZZGFyWwcBeuZPdou8nt9LErnekkB1nTlOr3C0DPvVYm90ygdSNyAN fesgDor5xp0wjuy8nMV74/kP2+n7Ph5O6MD4hCpgJWTag3onquEXm9LdTW1wLO7l+XuA RJSQ5n+Oc1lSS2YFvQEMc02a3NDmc2nEyiR9gD1krXP9mcwFl77UE80oasI98nodeoWZ z1cjXPf69c/eM/x0nD9MF6SB3fKgjHp2ZyQEud6k6yrf95pKw4T5yHB6wuhtA0JhtFJL Soyg== X-Gm-Message-State: AOJu0YzO4TUUOmZ4r9xDBfBkasMKchsWkC12ft7d+apqaTT0ho4Ud4L2 8HVV6Mgqa+UEUFN1X2tpbSA+H4WewD+Smj2XamWsp9sMd3p8sKa4giFRmuWRJBEKNsHSK+5kZxU / X-Google-Smtp-Source: AGHT+IHR9DN+7lcvO4/7WeenkBKRhBNcXU7Vg81kDU+bivxwGjowDiMk22Rx8pE3AMmCbhgbrwU/wg== X-Received: by 2002:a05:6808:3021:b0:3c2:1881:f015 with SMTP id ay33-20020a056808302100b003c21881f015mr14877332oib.15.1710332911502; Wed, 13 Mar 2024 05:28:31 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap Subject: [PATCH v2 1/3] x86: Move SVM features exposed to guest into hvm_max_cpu_policy Date: Wed, 13 Mar 2024 12:24:52 +0000 Message-Id: <20240313122454.965566-2-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240313122454.965566-1-george.dunlap@cloud.com> References: <20240313122454.965566-1-george.dunlap@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1710332933047100001 Content-Type: text/plain; charset="utf-8" Currently (nested) SVM features we're willing to expose to the guest are defined in calculate_host_policy, and stored in host_cpu_policy. This is the wrong place for this; move it into calculate_hvm_max_policy(), and store it in hvm_max_cpu_policy. Signed-off-by: George Dunlap Reviewed-by: Jan Beulich --- v2: - New --- xen/arch/x86/cpu-policy.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c index 2acc27632f..bd047456eb 100644 --- a/xen/arch/x86/cpu-policy.c +++ b/xen/arch/x86/cpu-policy.c @@ -398,19 +398,6 @@ static void __init calculate_host_policy(void) if ( vpmu_mode =3D=3D XENPMU_MODE_OFF ) p->basic.raw[0xa] =3D EMPTY_LEAF; =20 - if ( p->extd.svm ) - { - /* Clamp to implemented features which require hardware support. */ - p->extd.raw[0xa].d &=3D ((1u << SVM_FEATURE_NPT) | - (1u << SVM_FEATURE_LBRV) | - (1u << SVM_FEATURE_NRIPS) | - (1u << SVM_FEATURE_PAUSEFILTER) | - (1u << SVM_FEATURE_DECODEASSISTS)); - /* Enable features which are always emulated. */ - p->extd.raw[0xa].d |=3D ((1u << SVM_FEATURE_VMCBCLEAN) | - (1u << SVM_FEATURE_TSCRATEMSR)); - } - /* 0x000000ce MSR_INTEL_PLATFORM_INFO */ /* probe_cpuid_faulting() sanity checks presence of MISC_FEATURES_ENAB= LES */ p->platform_info.cpuid_faulting =3D cpu_has_cpuid_faulting; @@ -741,6 +728,23 @@ static void __init calculate_hvm_max_policy(void) if ( !cpu_has_vmx ) __clear_bit(X86_FEATURE_PKS, fs); =20 + /*=20 + * Make adjustments to possible (nested) virtualization features expos= ed + * to the guest + */ + if ( p->extd.svm ) + { + /* Clamp to implemented features which require hardware support. */ + p->extd.raw[0xa].d &=3D ((1u << SVM_FEATURE_NPT) | + (1u << SVM_FEATURE_LBRV) | + (1u << SVM_FEATURE_NRIPS) | + (1u << SVM_FEATURE_PAUSEFILTER) | + (1u << SVM_FEATURE_DECODEASSISTS)); + /* Enable features which are always emulated. */ + p->extd.raw[0xa].d |=3D ((1u << SVM_FEATURE_VMCBCLEAN) | + (1u << SVM_FEATURE_TSCRATEMSR)); + } + =20 guest_common_max_feature_adjustments(fs); guest_common_feature_adjustments(fs); =20 --=20 2.25.1