From nobody Fri May 10 05:23:04 2024 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1677067260; cv=none; d=zohomail.com; s=zohoarc; b=i+uXsXdmzEHEz50VQkg68b94QY6ukW9AImbEE6cymh1vHre9uTAL16/ttjTT4kx5vqskfZGQmJl5FI/3FlBpHr+pNlsVrQBnAZOfqobfmY7nX3+0697AjVW4597PP4KbtUiqP0fDb/P/jbTzJ2xi5xUF0JZ6fRH1s9zWqWP+2bM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677067260; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3N3piCiGWBTq0LmBNA8fpZwNDzK/IZkQT7MxXOAi4Ls=; b=mEyZlNn1LgNjk1elYuXQgA5YKVtSl+Df/VeNcsPglvXTdegjd4K22DTnJQ2mCETilRIL+FCNDa1D62NphPUuEBflU3/HPgg8WEfbxI8ijO8k6mlHCLRoixCfEfsAhdHtnICcmt3RHo04oissnp9XCyei2kdwnhebhWuY9dHOg7U= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677067260329662.1520450907385; Wed, 22 Feb 2023 04:01:00 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.499398.770533 (Exim 4.92) (envelope-from ) id 1pUnnZ-0000kf-8k; Wed, 22 Feb 2023 12:00:37 +0000 Received: by outflank-mailman (output) from mailman id 499398.770533; Wed, 22 Feb 2023 12:00:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pUnnZ-0000kX-32; Wed, 22 Feb 2023 12:00:37 +0000 Received: by outflank-mailman (input) for mailman id 499398; Wed, 22 Feb 2023 12:00:36 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pUnnY-0000Rg-1U for xen-devel@lists.xenproject.org; Wed, 22 Feb 2023 12:00:36 +0000 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [2a00:1450:4864:20::532]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 81d0e24f-b2a8-11ed-93b6-47a8fe42b414; Wed, 22 Feb 2023 13:00:32 +0100 (CET) Received: by mail-ed1-x532.google.com with SMTP id b12so29314066edd.4 for ; Wed, 22 Feb 2023 04:00:32 -0800 (PST) Received: from uni.router.wind (adsl-161.109.242.137.tellas.gr. [109.242.137.161]) by smtp.googlemail.com with ESMTPSA id br4-20020a170906d14400b008de729c8a03sm2133171ejb.38.2023.02.22.04.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 04:00:31 -0800 (PST) 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: 81d0e24f-b2a8-11ed-93b6-47a8fe42b414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=3N3piCiGWBTq0LmBNA8fpZwNDzK/IZkQT7MxXOAi4Ls=; b=cYDsEaf7/te6v2zDN6IZBxWjfuyyDdqGG4sQ9zaJas4CNh5Gk6qUBaT6M6QNPDSuI4 2dC9qQD0Jzyt3PJRXmItZj7lwxskarHK+cSJvsj7mAZCSuI25DENgApLwztENg62pTAs PQ0xjWoEvJUXLpsR2u6uz5NmfLkRy5B8RYyMkEqMgj922RI0q9mREW+ANql2Apy1ZVak NbYkXVLuak60fJiNYclhEvD3f+mGOmpR+g+8M3tN6bPsM1qnfUAJ2Pioutsj7MhhjLY1 05c+9aq+D0cWC3jUCWnOT0GdLUztO3tjlJGhw0FunEcfDgF69bXaQoOqmLuqgfySTGCN 8b6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=3N3piCiGWBTq0LmBNA8fpZwNDzK/IZkQT7MxXOAi4Ls=; b=blARJ6eisRSgHtxjxOgwnaPsoI0YXCHHJAkyNQjlcc7YFhLD1dvcji38908lyqyF7m fBr0LCIsrSGAWGLfZzeDVdJYlrjYdnDNj0WBhml+SMF890mPcpu2KVe6AoncY4jfbTv7 Kcx3wIgVjKyVPG3di/iVt08PtnS8TnhTbZRTB0IH5Xll6yJwAPghXUqUgsszDOaPaIMn EC09qMowOLxb0y80Ghti4pqb+42a3Lale6aVaFxth3ZNiPbcO7WZTBWn21Pg+6mn+Ar0 p+r7Wo0UX4kz2fT/VNoie1fbp/DrK/OpnTGm9rl99d0YYULRF1ZEEzhs2mJ7lA/ZFdU2 TUGQ== X-Gm-Message-State: AO0yUKXOoC9jaLtIofOsPUy1MJuNaDuebTvsGWZO6GR7PmQFIiESqpiL Njw/F0i8WKn7PWyBKUPmGYIyD5VIA1k= X-Google-Smtp-Source: AK7set+b72Vu/wbcA1IfmKn1TWGG7/7r4g7qVI595O8rmfN6pyzv8OpoHyY52kM6bA3bcvxK5auL2w== X-Received: by 2002:a17:906:805a:b0:873:1b57:b27f with SMTP id x26-20020a170906805a00b008731b57b27fmr14555060ejw.61.1677067231533; Wed, 22 Feb 2023 04:00:31 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 1/9] x86/svm: remove unused forward declaration of struct vcpu from svm.h Date: Wed, 22 Feb 2023 14:00:15 +0200 Message-Id: <20230222120023.3004624-2-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230222120023.3004624-1-burzalodowa@gmail.com> References: <20230222120023.3004624-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1677067261329100005 Content-Type: text/plain; charset="utf-8" Remove forward declaration of struct vcpu, that is a leftover since the removal of svm_update_guest_cr()'s declaration from svm.h. Signed-off-by: Xenia Ragiadakou Fixes: b158e72abe30 ("x86/hvm: CFI hardening for hvm_funcs") Acked-by: Jan Beulich --- Changes in v2: - leave the forward declaration of struct cpu_user_regs in place, suggested by Andrew - add a fixes tag based on Andrew's comment - update commit message xen/arch/x86/include/asm/hvm/svm/svm.h | 1 - 1 file changed, 1 deletion(-) diff --git a/xen/arch/x86/include/asm/hvm/svm/svm.h b/xen/arch/x86/include/= asm/hvm/svm/svm.h index 65e35a4f59..fa39d4d76a 100644 --- a/xen/arch/x86/include/asm/hvm/svm/svm.h +++ b/xen/arch/x86/include/asm/hvm/svm/svm.h @@ -46,7 +46,6 @@ static inline void svm_invlpga(unsigned long linear, uint= 32_t asid) } =20 struct cpu_user_regs; -struct vcpu; =20 unsigned long *svm_msrbit(unsigned long *msr_bitmap, uint32_t msr); void __update_guest_eip(struct cpu_user_regs *regs, unsigned int inst_len); --=20 2.37.2 From nobody Fri May 10 05:23:04 2024 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1677067262; cv=none; d=zohomail.com; s=zohoarc; b=XU2yRwfbV1WvR0Lt/aNVPRx/Yc7PvOIlYLUS56S6jx2tzF6LeKT1oFowHcCL6m5wDu6q338f+bZAqyFRh2vUYPIUnOG1Lw8JCatOhMcJgSj0KXWWu7H1sy2BiCctg777ZK9wgSEacMDwsREp2tQKUUSEFJx3440p3pSnyJN8ZVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677067262; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=doY9xB02Xms2D/8hQa289Ytj+RDMjA/uK7oMTVWbZgo=; b=nMcE1ln9DSlkxjV3B9N00pfJR8/vGhUX6hor23LGfKCrZRFuaP0AIfRXkoez0NYgUE9ecc008djiH3UYiISRwnKYHgvToqyvGR3X5zVtHrk3SlOuAu/wbk9hlpMqwQggDWCkcAk+IZXWsbCBNje8stQzEmRl5grs+0SLOlOyHM8= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677067262226965.7733097657956; Wed, 22 Feb 2023 04:01:02 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.499397.770521 (Exim 4.92) (envelope-from ) id 1pUnnX-0000V6-Vr; Wed, 22 Feb 2023 12:00:35 +0000 Received: by outflank-mailman (output) from mailman id 499397.770521; Wed, 22 Feb 2023 12:00: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 1pUnnX-0000Uz-St; Wed, 22 Feb 2023 12:00:35 +0000 Received: by outflank-mailman (input) for mailman id 499397; Wed, 22 Feb 2023 12:00:34 +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 1pUnnW-0000FF-Fu for xen-devel@lists.xenproject.org; Wed, 22 Feb 2023 12:00:34 +0000 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [2a00:1450:4864:20::52b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 82e0f6a4-b2a8-11ed-a089-e9535cc0f9c3; Wed, 22 Feb 2023 13:00:34 +0100 (CET) Received: by mail-ed1-x52b.google.com with SMTP id b12so29314480edd.4 for ; Wed, 22 Feb 2023 04:00:34 -0800 (PST) Received: from uni.router.wind (adsl-161.109.242.137.tellas.gr. [109.242.137.161]) by smtp.googlemail.com with ESMTPSA id br4-20020a170906d14400b008de729c8a03sm2133171ejb.38.2023.02.22.04.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 04:00:33 -0800 (PST) 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: 82e0f6a4-b2a8-11ed-a089-e9535cc0f9c3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=doY9xB02Xms2D/8hQa289Ytj+RDMjA/uK7oMTVWbZgo=; b=U01QLToEtjBNMZh9WqRp9v+HSVHnkWs+YwojM6x6vSUy6QnYLBIaUFYT6/TpGwGKD2 F7bifHF+YvytZcMjjsv2loVKnPQHL1jFrRC4zN7eWGfDyJRL30yzBFmJ3S7pybshAAye 65TbBN6PMQ1G+vBKN8q6+2VQ7hI6BaTLSND0sGiI1OSBKlqq1kHY9GkdiiveDQnErCmw 4HUyZ506GrbMIKSyMj8J8FpqXL7eZ/r3ow6pMJiK1CqqD5rl5nSjcSs133F7KSEpHee4 6WIZB6iL5wju/lTCdcn+50FtVEXcT7LvezOjLdgKmF+pbZiO/WPFVdMfkQ7G1Xmc9aDg GmwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=doY9xB02Xms2D/8hQa289Ytj+RDMjA/uK7oMTVWbZgo=; b=7mZYGS4XKwjQjFA7Zkuz4OqfNWf1v5wnKSdSlTBHlp9BsqfRuqpikGheETc8Zc0Dss v4zUaMN9kBGDpkf7pOwsT9oAAvuVj6po/GimlOid5f7WiB5HEaxj7fYfUL/SfMHLZrgG j4kHkA4HyqtC+zkuMfW3u4J+uKlEBxBtOnDoJ1XczHc3817yie6oZnJW1VHxKXx8PtQA DJ8QEqJs7DKeylx5wmASFYRYY4PylhAliMkPTwuLUXc8UURemQGzOQeD+cp69knysPCX J8qZjgkIoJ596ILwPjX6Kjpk5xAplCiItDnid/rXhNsVdbhNFdKMZTYesqkiLdBuCoTA mviQ== X-Gm-Message-State: AO0yUKX+mHHwWwtTZX0x9Qj0JOqG/NXz0fBaktvMFBKeI7qqN3vLVX5q +fd04BBncOnorLT45UP7xfQeH8XClgc= X-Google-Smtp-Source: AK7set9bqpqNZCoEv9JQGLkQyFa19l0Q5ZONZVxe7iSweBiYxtsg1iScHoerVH7dvrHpSHxmAUhmVg== X-Received: by 2002:a17:906:f0d1:b0:8b1:3009:536b with SMTP id dk17-20020a170906f0d100b008b13009536bmr14613232ejb.29.1677067233378; Wed, 22 Feb 2023 04:00:33 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 2/9] x86/svm: opencode SVM_PAUSE{FILTER,THRESH}_INIT Date: Wed, 22 Feb 2023 14:00:16 +0200 Message-Id: <20230222120023.3004624-3-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230222120023.3004624-1-burzalodowa@gmail.com> References: <20230222120023.3004624-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1677067263058100007 Content-Type: text/plain; charset="utf-8" Delete the macros SVM_PAUSE{FILTER,THRESH}_INIT from svm.h and opencode their values, since they are used in a single place and using macros is just unnecessary obfuscation. Signed-off-by: Xenia Ragiadakou Acked-by: Jan Beulich --- Changes in v2: - opencode instead of moving the macros in vmcs.c, suggested by Andrew xen/arch/x86/hvm/svm/vmcb.c | 4 ++-- xen/arch/x86/include/asm/hvm/svm/svm.h | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/hvm/svm/vmcb.c b/xen/arch/x86/hvm/svm/vmcb.c index 305d4767e3..ba93375e87 100644 --- a/xen/arch/x86/hvm/svm/vmcb.c +++ b/xen/arch/x86/hvm/svm/vmcb.c @@ -169,11 +169,11 @@ static int construct_vmcb(struct vcpu *v) =20 if ( cpu_has_pause_filter ) { - vmcb->_pause_filter_count =3D SVM_PAUSEFILTER_INIT; + vmcb->_pause_filter_count =3D 4000; vmcb->_general1_intercepts |=3D GENERAL1_INTERCEPT_PAUSE; =20 if ( cpu_has_pause_thresh ) - vmcb->_pause_filter_thresh =3D SVM_PAUSETHRESH_INIT; + vmcb->_pause_filter_thresh =3D 1000; } =20 /* diff --git a/xen/arch/x86/include/asm/hvm/svm/svm.h b/xen/arch/x86/include/= asm/hvm/svm/svm.h index fa39d4d76a..c62d0caa32 100644 --- a/xen/arch/x86/include/asm/hvm/svm/svm.h +++ b/xen/arch/x86/include/asm/hvm/svm/svm.h @@ -95,9 +95,6 @@ extern u32 svm_feature_flags; #define cpu_has_svm_sss cpu_has_svm_feature(SVM_FEATURE_SSS) #define cpu_has_svm_spec_ctrl cpu_has_svm_feature(SVM_FEATURE_SPEC_CTRL) =20 -#define SVM_PAUSEFILTER_INIT 4000 -#define SVM_PAUSETHRESH_INIT 1000 - /* TSC rate */ #define DEFAULT_TSC_RATIO 0x0000000100000000ULL #define TSC_RATIO_RSVD_BITS 0xffffff0000000000ULL --=20 2.37.2 From nobody Fri May 10 05:23:04 2024 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1677067262; cv=none; d=zohomail.com; s=zohoarc; b=ldY8hrqu5u+utRAsgUkqrRvV9EzXfLTZVK1ind+3rwc2Jdk17UTdYbCzflphIJKwt8kNTZV28Xop7xhw9eCxay4novgSgdGLf2edv8quaZwJFOEu8ZjOLu43KJoP7o7XYh/TcHnH6LnjWKNY40J/pIWPm1uWd1seJGIIF1xpG98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677067262; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=58ojOoNDnWoUZmyiyDiKwllMRC7EMTKC77s0cYAKiQs=; b=mZHEMnFtf71HWm43+9Q/2oLTUme59jib35ei3WI9qp6kWPmEVzXW1cKEk3OFiZwnHnbZahuFvXhjAPols8mSsVs19uT76/b7eHf0zg7xO0fsgwQTxQipyWPyDCSXmni1yQBgyk59jHkAQkKrH8CJrZmCxI/Gsoh4JCr7f5teQdA= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677067262843703.6764928716716; Wed, 22 Feb 2023 04:01:02 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.499399.770537 (Exim 4.92) (envelope-from ) id 1pUnnZ-0000np-JB; Wed, 22 Feb 2023 12:00:37 +0000 Received: by outflank-mailman (output) from mailman id 499399.770537; Wed, 22 Feb 2023 12:00:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pUnnZ-0000mK-BX; Wed, 22 Feb 2023 12:00:37 +0000 Received: by outflank-mailman (input) for mailman id 499399; Wed, 22 Feb 2023 12:00:36 +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 1pUnnY-0000FF-6p for xen-devel@lists.xenproject.org; Wed, 22 Feb 2023 12:00:36 +0000 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [2a00:1450:4864:20::530]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 83df4187-b2a8-11ed-a089-e9535cc0f9c3; Wed, 22 Feb 2023 13:00:35 +0100 (CET) Received: by mail-ed1-x530.google.com with SMTP id x10so28531088edd.13 for ; Wed, 22 Feb 2023 04:00:35 -0800 (PST) Received: from uni.router.wind (adsl-161.109.242.137.tellas.gr. [109.242.137.161]) by smtp.googlemail.com with ESMTPSA id br4-20020a170906d14400b008de729c8a03sm2133171ejb.38.2023.02.22.04.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 04:00:34 -0800 (PST) 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: 83df4187-b2a8-11ed-a089-e9535cc0f9c3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=58ojOoNDnWoUZmyiyDiKwllMRC7EMTKC77s0cYAKiQs=; b=XgUEknz8X7C+j8NC9vaUD5dfDiMVudUsOd4Dl75Mpy42/lrlJCoY5c/bn8HRXZCN/A UCYPo5Fn59qpVit5vVufPupjkBxLg+MxTc1Db1xXZv8uwf8Cg87r7/3mv4HHHXvUur2w 2Aj/uXmAoIxis2bMeiq1Mr6J8ERfSqIXMtEh5plPrWqZBbiL/y69UrO7cyBe7Of65vEb 6wIM3A/Qa7g3hppbQSjz6AXQo4DUDxb0uRmEul/x8l1O8mhH9dfqdWz0S8O96ohjTw/s SW6syULDQ09JTTgISRgDhI/9/a9aJsyBEBC0Z3s+8iLQVrF/7Z4x1yWlNYY7ot4yv2FW IjSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=58ojOoNDnWoUZmyiyDiKwllMRC7EMTKC77s0cYAKiQs=; b=19tRrjMjPJrOUEivZlwWMz3QimWnmyrT2v6CJTRg0bl1rqhPtB0b2hgIsJrcfz5s+b 6k5WGym7c0/7JLkPwEYvPdTbWKS688y8RerZGotX1ebolBczUfatxm8tefWQw6afopGY g8BcFWRxMze6dnCv4Y9Diajz72D17l1QZoHKbNkSYLmdtvu5uPls2Sa15t4w5nEOiJbl /djQoWmqOyVJllcu3XOr1KTX3LjrblLeY7wZH3clvowQ2InPucZCKjcu3j8yktxEMjgf YcV74HAqaqrWjaggS8/yJJhnqrCHCXbHKw/0BWPj6tg4CynuaiYdPC/T4n48Xxo/Bxh2 EzGw== X-Gm-Message-State: AO0yUKVnZbWiOStjTq6FYMg3XmfjPvpIJ/cmbs1AwWazJBCJrvNj53aq RK5t3pkNesR40Dw11+bR/AIEXbt8ziw= X-Google-Smtp-Source: AK7set+BMqvFT3yhEj6etKOZAcECpL3SSt3qrQjDUEFp/IysmDyOAD68iIW0dXQxo+QCz7UiqCGVuA== X-Received: by 2002:a17:907:d50c:b0:896:427b:148 with SMTP id wb12-20020a170907d50c00b00896427b0148mr15722125ejc.1.1677067235052; Wed, 22 Feb 2023 04:00:35 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 3/9] x86/svm: move declarations used only by svm code from svm.h to private header Date: Wed, 22 Feb 2023 14:00:17 +0200 Message-Id: <20230222120023.3004624-4-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230222120023.3004624-1-burzalodowa@gmail.com> References: <20230222120023.3004624-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1677067263072100008 Content-Type: text/plain; charset="utf-8" Create a new private header in arch/x86/hvm/svm called svm.h and move there all definitions and declarations that are used solely by svm code. The function svm_invlpga() stays in arch/x86/hvm/svm/svm.h because it is us= ed by arch/x86/hvm/svm/asid.h. Signed-off-by: Xenia Ragiadakou Acked-by: Jan Beulich --- Changes in v2: - new patch, the creation of a private header was suggested by Andrew and = Jan I have not added #ifndef guards as it is a private and it should not be included by other headers. However, this is considered a MISRA-C violation ... I 'm not sure what to do. xen/arch/x86/hvm/svm/nestedsvm.c | 1 + xen/arch/x86/hvm/svm/svm.c | 2 ++ xen/arch/x86/hvm/svm/svm.h | 40 ++++++++++++++++++++++++++ xen/arch/x86/include/asm/hvm/svm/svm.h | 29 ------------------- 4 files changed, 43 insertions(+), 29 deletions(-) create mode 100644 xen/arch/x86/hvm/svm/svm.h diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nested= svm.c index 77f7547360..a341ccc876 100644 --- a/xen/arch/x86/hvm/svm/nestedsvm.c +++ b/xen/arch/x86/hvm/svm/nestedsvm.c @@ -27,6 +27,7 @@ #include /* for local_event_delivery_(en|dis)able */ #include /* p2m_get_pagetable, p2m_get_nestedp2m */ =20 +#include "svm.h" =20 #define NSVM_ERROR_VVMCB 1 #define NSVM_ERROR_VMENTRY 2 diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 9c43227b76..6d394e4fe3 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -55,6 +55,8 @@ =20 #include =20 +#include "svm.h" + void noreturn svm_asm_do_resume(void); =20 u32 svm_feature_flags; diff --git a/xen/arch/x86/hvm/svm/svm.h b/xen/arch/x86/hvm/svm/svm.h new file mode 100644 index 0000000000..b2ec293078 --- /dev/null +++ b/xen/arch/x86/hvm/svm/svm.h @@ -0,0 +1,40 @@ +#include + +static inline void svm_vmload_pa(paddr_t vmcb) +{ + asm volatile ( + ".byte 0x0f,0x01,0xda" /* vmload */ + : : "a" (vmcb) : "memory" ); +} + +static inline void svm_vmsave_pa(paddr_t vmcb) +{ + asm volatile ( + ".byte 0x0f,0x01,0xdb" /* vmsave */ + : : "a" (vmcb) : "memory" ); +} + +struct cpu_user_regs; + +unsigned long *svm_msrbit(unsigned long *msr_bitmap, uint32_t msr); +void __update_guest_eip(struct cpu_user_regs *regs, unsigned int inst_len); + +/* TSC rate */ +#define DEFAULT_TSC_RATIO 0x0000000100000000ULL +#define TSC_RATIO_RSVD_BITS 0xffffff0000000000ULL + +/* EXITINFO1 fields on NPT faults */ +#define _NPT_PFEC_with_gla 32 +#define NPT_PFEC_with_gla (1UL<<_NPT_PFEC_with_gla) +#define _NPT_PFEC_in_gpt 33 +#define NPT_PFEC_in_gpt (1UL<<_NPT_PFEC_in_gpt) + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/include/asm/hvm/svm/svm.h b/xen/arch/x86/include/= asm/hvm/svm/svm.h index c62d0caa32..254de55ee9 100644 --- a/xen/arch/x86/include/asm/hvm/svm/svm.h +++ b/xen/arch/x86/include/asm/hvm/svm/svm.h @@ -22,20 +22,6 @@ =20 #include =20 -static inline void svm_vmload_pa(paddr_t vmcb) -{ - asm volatile ( - ".byte 0x0f,0x01,0xda" /* vmload */ - : : "a" (vmcb) : "memory" ); -} - -static inline void svm_vmsave_pa(paddr_t vmcb) -{ - asm volatile ( - ".byte 0x0f,0x01,0xdb" /* vmsave */ - : : "a" (vmcb) : "memory" ); -} - static inline void svm_invlpga(unsigned long linear, uint32_t asid) { asm volatile ( @@ -45,11 +31,6 @@ static inline void svm_invlpga(unsigned long linear, uin= t32_t asid) "a" (linear), "c" (asid)); } =20 -struct cpu_user_regs; - -unsigned long *svm_msrbit(unsigned long *msr_bitmap, uint32_t msr); -void __update_guest_eip(struct cpu_user_regs *regs, unsigned int inst_len); - /* * PV context switch helpers. Prefetching the VMCB area itself has been s= hown * to be useful for performance. @@ -95,14 +76,4 @@ extern u32 svm_feature_flags; #define cpu_has_svm_sss cpu_has_svm_feature(SVM_FEATURE_SSS) #define cpu_has_svm_spec_ctrl cpu_has_svm_feature(SVM_FEATURE_SPEC_CTRL) =20 -/* TSC rate */ -#define DEFAULT_TSC_RATIO 0x0000000100000000ULL -#define TSC_RATIO_RSVD_BITS 0xffffff0000000000ULL - -/* EXITINFO1 fields on NPT faults */ -#define _NPT_PFEC_with_gla 32 -#define NPT_PFEC_with_gla (1UL<<_NPT_PFEC_with_gla) -#define _NPT_PFEC_in_gpt 33 -#define NPT_PFEC_in_gpt (1UL<<_NPT_PFEC_in_gpt) - #endif /* __ASM_X86_HVM_SVM_H__ */ --=20 2.37.2 From nobody Fri May 10 05:23:04 2024 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1677067260; cv=none; d=zohomail.com; s=zohoarc; b=RaiQoOw5STTszRmjSZh/Mr7Wotrm5jdT41+Nk6dTw4sbZ7dZlrcPhQpBoQ03kom1aT6AvGnVf044FFUXU1yVALz0NYtqD1wSUasj4/facMuPU8mKm80/79DbR4k+5MQXTq8HE9UYsurFIOgu03js4u9ZXej+bv94wIGefu1/YsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677067260; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aCe2e8yII+W8C97Qm8Q6kxpPS0WeF8P3OBexIFC6KlA=; b=HmjVFcm4VUdjGRz4gM8zc0lzeBRAnqLda+uvyV5LJ6Sq6JvPnRhJ19Z7plJVVqi081xFlW6cHDzkHQanoOWChspSIQ1mq76Yyw9/eJe3maopNkv1ce3ewANRIbJuswBoQ5fIB06q+dyIdmJoQs1rWETPsQax72nca+iCoa8IfGE= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677067260170252.2274381168919; Wed, 22 Feb 2023 04:01:00 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.499400.770554 (Exim 4.92) (envelope-from ) id 1pUnnb-0001IZ-QN; Wed, 22 Feb 2023 12:00:39 +0000 Received: by outflank-mailman (output) from mailman id 499400.770554; Wed, 22 Feb 2023 12:00:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pUnnb-0001IO-MY; Wed, 22 Feb 2023 12:00:39 +0000 Received: by outflank-mailman (input) for mailman id 499400; Wed, 22 Feb 2023 12:00:38 +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 1pUnna-0000FF-4v for xen-devel@lists.xenproject.org; Wed, 22 Feb 2023 12:00:38 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8516d8fa-b2a8-11ed-a089-e9535cc0f9c3; Wed, 22 Feb 2023 13:00:37 +0100 (CET) Received: by mail-ed1-x535.google.com with SMTP id cq23so29075164edb.1 for ; Wed, 22 Feb 2023 04:00:37 -0800 (PST) Received: from uni.router.wind (adsl-161.109.242.137.tellas.gr. [109.242.137.161]) by smtp.googlemail.com with ESMTPSA id br4-20020a170906d14400b008de729c8a03sm2133171ejb.38.2023.02.22.04.00.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 04:00:36 -0800 (PST) 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: 8516d8fa-b2a8-11ed-a089-e9535cc0f9c3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=aCe2e8yII+W8C97Qm8Q6kxpPS0WeF8P3OBexIFC6KlA=; b=dg4HMlrrLfJhNwUn9/mdMnmfnt76ucjv2SprMcdN+D8wibUcScNaw+7QrF9+ZbN/2I Qc036yIZMcgPpIM94/CSu9AUt+JFQwOQUn9I2ClizErcdw9dmlUimrq8ZviDqfdOdfbf hJ8eBBeOqmc4Zbk6neR+g4NpauQcvPbXbma92csWVeblK41Q2+/bnMs1fUahlAC/W0ST WcwURF2M5ukOJwIpP/w9oGxfL3Z57NmBcm4RV7h8rLRINYksd+zkXcd/EwYOInE2FRG7 yNpa8F8RQtaKVeyZRW/chA/OVR5papgKpHbTZKxznkc/i6M0G5U9/PwzRecKdltPux0f j4AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=aCe2e8yII+W8C97Qm8Q6kxpPS0WeF8P3OBexIFC6KlA=; b=DdSrKTL+spjYWKnUzeHsWDKi5b7Ia3tBcSBUJqz49RT15evGHfAU/WN4+x89kVaADs 45/8a6Ev2/ueFxlEGEBnRlye4ZxOgG6jHmJnMV3pZ1GqK2acfzhR4dUhNf2GCfRvIe3N BJc6nt3JHScd1auPZR9pkWJk3yPB9V0L18Hs+jeLFkUvuKjNW4ZCY0099ElPIvsnJ6Eq yYZPFZKfIexN9nzBV2ASi7LosSSiX9LUnTmEBxXexkwosGHQm4o3mnHgaftu/8HsIU67 BikzmWCmnwWmzFJX6ttyD87MDbrJNPH90/AGNE0VrDtHw8c9sbtU/SRSI7BpCWJohIvM aNzQ== X-Gm-Message-State: AO0yUKWCRdEvm4WQv08HEODcjI9LdcNuLeQivhdcxevvXDAyrzoH1ZZa +3NcUAavqyDxw+8PRWVx4cVzQk+xrDQ= X-Google-Smtp-Source: AK7set930ay0yKAQ1/kzIMCVr92R/OoyojJ+FncrdszvL6+XOcmcUqEcJWlwxcKm2Dqau3lPSnBk+Q== X-Received: by 2002:a17:906:2a03:b0:883:fe6b:814 with SMTP id j3-20020a1709062a0300b00883fe6b0814mr14576122eje.37.1677067237157; Wed, 22 Feb 2023 04:00:37 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jun Nakajima , Kevin Tian , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 4/9] x86/vmx: remove unused included headers from vmx.h Date: Wed, 22 Feb 2023 14:00:18 +0200 Message-Id: <20230222120023.3004624-5-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230222120023.3004624-1-burzalodowa@gmail.com> References: <20230222120023.3004624-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1677067261174100001 Content-Type: text/plain; charset="utf-8" Do not include the headers: asm/i387.h asm/hvm/trace.h asm/processor.h asm/regs.h because none of the declarations and macro definitions in them is used in this file. Sort the rest of the headers alphabetically. Fix build by including asm/i387.h in vmx.c, needed for vcpu_restore_fpu_laz= y(). Signed-off-by: Xenia Ragiadakou Reviewed-by: Jan Beulich --- Changes in v2: -add a blank line between different types of headers, reported by Andrew -fix english in commit message, reported by Andrew xen/arch/x86/hvm/vmx/vmx.c | 1 + xen/arch/x86/include/asm/hvm/vmx/vmx.h | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 0ec33bcc18..a0297e8c6c 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmx.h b/xen/arch/x86/include/= asm/hvm/vmx/vmx.h index 97d6b810ec..c0ca6d10e3 100644 --- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h @@ -19,14 +19,11 @@ #define __ASM_X86_HVM_VMX_VMX_H__ =20 #include -#include -#include + #include -#include -#include -#include -#include #include +#include +#include =20 extern int8_t opt_ept_exec_sp; =20 --=20 2.37.2 From nobody Fri May 10 05:23:04 2024 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1677067263; cv=none; d=zohomail.com; s=zohoarc; b=lKNT035XgtCF8g9NdojH6b21A2TJ7zXDFkm7jE9I7byzvlWKTy0pA6flW7ERezlp1ClZJeau6B4faMZX4naBOkK9G5WOuOqv2jdvLo7/FMaigCzzoCqiX3KRt91a8uIyjTYxZqmC8dRFbPhaw8EsxE9zIhdsRXbDQuKr8j6ejF4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677067263; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=P2sR+ZHD7PGnYGWl4CAsPoK4VvzcqTimIkDugq8HftE=; b=L0Jxz5+zr8DqqWXJiKHyRH5c/R1JvJmveVEFBLeVuY15gJRpRhgmMym6/IADHPf5ndE7TqkxzoI15Xa2g+dUBTOKfjic0rYq98isjhTeBqGDvjlhiICknG3oSHYsWzpbsxPJA/Fn2Lweinfal/EHuh9fFep4xxnjVRoQ2TtSFbw= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 167706726382471.99326514583481; Wed, 22 Feb 2023 04:01:03 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.499401.770565 (Exim 4.92) (envelope-from ) id 1pUnne-0001cg-A2; Wed, 22 Feb 2023 12:00:42 +0000 Received: by outflank-mailman (output) from mailman id 499401.770565; Wed, 22 Feb 2023 12:00:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pUnne-0001cX-6k; Wed, 22 Feb 2023 12:00:42 +0000 Received: by outflank-mailman (input) for mailman id 499401; Wed, 22 Feb 2023 12:00:41 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pUnnd-0000Rg-7P for xen-devel@lists.xenproject.org; Wed, 22 Feb 2023 12:00:41 +0000 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [2a00:1450:4864:20::52a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8647edfc-b2a8-11ed-93b6-47a8fe42b414; Wed, 22 Feb 2023 13:00:39 +0100 (CET) Received: by mail-ed1-x52a.google.com with SMTP id ee7so14262212edb.2 for ; Wed, 22 Feb 2023 04:00:39 -0800 (PST) Received: from uni.router.wind (adsl-161.109.242.137.tellas.gr. [109.242.137.161]) by smtp.googlemail.com with ESMTPSA id br4-20020a170906d14400b008de729c8a03sm2133171ejb.38.2023.02.22.04.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 04:00:38 -0800 (PST) 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: 8647edfc-b2a8-11ed-93b6-47a8fe42b414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=P2sR+ZHD7PGnYGWl4CAsPoK4VvzcqTimIkDugq8HftE=; b=M6NwNjYAfFKkG6YHT/G1ScixCYFLDYjYUFFAnszuY88+Nvke1Zt5JySwL2EyLwLpk0 4FSGFL4chAga8yGLKycaCHkAMqGFmQ4YlX+2m/UVkrS9iF9dYfJ0+Uoztt3tV0eGSk3e wqpuiVdT8j4I8MW3/FHRADBVPGjoNuZN6i00Ya6Wx/oY79EIdWKEZuCya0tO7aLA5hOE nEWrLfdmLtQjOzFSndc1trvjC63L9ZCGk3LDQzqx/vSq++4T8uGmFQCsP/YSqZkj1tNO Hi5LJg9cka8htYGi8wL2FOArf4k1RtTDz1ZhMTEf5YevcidaWeZ+JReult//u5+q1FWa 5jJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=P2sR+ZHD7PGnYGWl4CAsPoK4VvzcqTimIkDugq8HftE=; b=Odoa8Mu9p9qwEjeiIGMTeXI+Cx2bv/ccYMqvGrpGAq0Pilzkt5CdPUdOQOdzYJbaK/ oadtIc8Ai4O13UAcdEcYILeD1zf9Icp2pdXm3jUDXfQPpwrM4BP4Wqheda9QIqqgOTpB 4SZyxPXR0vA2nzhUxMIlxFUqo4jAbyT7PyHFe3iXIrM6kWjp6qk5jidR+ZasXnwq4fQw 9K4JQ3FW5ID2nA/kuH8FvE8omermCMQLW9ObtzVAox38p6sdhLxtDrbVVieL5x+CvANW VWd4qv5KXeSM8JBxSEJVae91dmm/6THRCPYh58Rtciq3sqkljezUsBXyx/y3efqxg2cS Tqyw== X-Gm-Message-State: AO0yUKWKKpTIARyIrjm1oKB09oliB/roorBZ62l4rTBuXobaH3Vffssj JT7tMwLl3pG0OobBWdrOGkNoQrmBcrA= X-Google-Smtp-Source: AK7set9WAj9zvoGbLC+eMz76L24vUQyCkVdiizLj2utZ4FpQyqvjFHCyKOK6wOsomomX5K61OnzrLA== X-Received: by 2002:a17:907:b609:b0:88e:682e:3a9e with SMTP id vl9-20020a170907b60900b0088e682e3a9emr14679589ejc.61.1677067238949; Wed, 22 Feb 2023 04:00:38 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jun Nakajima , Kevin Tian , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 5/9] x86/vmx: reduce scope of GAS_VMX_OP definition Date: Wed, 22 Feb 2023 14:00:19 +0200 Message-Id: <20230222120023.3004624-6-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230222120023.3004624-1-burzalodowa@gmail.com> References: <20230222120023.3004624-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1677067265086100011 Content-Type: text/plain; charset="utf-8" Since GAS_VMX_OP is used only by vm{read,write}_safe, move its definition just above those functions and undefine it after use. Signed-off-by: Xenia Ragiadakou --- Changes in v2: - none xen/arch/x86/include/asm/hvm/vmx/vmx.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmx.h b/xen/arch/x86/include/= asm/hvm/vmx/vmx.h index c0ca6d10e3..1ba2937c23 100644 --- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h @@ -319,12 +319,6 @@ extern uint8_t posted_intr_vector; #define INVVPID_ALL_CONTEXT 2 #define INVVPID_SINGLE_CONTEXT_RETAINING_GLOBAL 3 =20 -#ifdef HAVE_AS_VMX -# define GAS_VMX_OP(yes, no) yes -#else -# define GAS_VMX_OP(yes, no) no -#endif - static always_inline void __vmptrld(u64 addr) { asm volatile ( @@ -414,6 +408,12 @@ static always_inline void __vmwrite(unsigned long fiel= d, unsigned long value) ); } =20 +#ifdef HAVE_AS_VMX +# define GAS_VMX_OP(yes, no) yes +#else +# define GAS_VMX_OP(yes, no) no +#endif + static inline enum vmx_insn_errno vmread_safe(unsigned long field, unsigned long *value) { @@ -460,6 +460,8 @@ static inline enum vmx_insn_errno vmwrite_safe(unsigned= long field, return ret; } =20 +#undef GAS_VMX_OP + static always_inline void __invept(unsigned long type, uint64_t eptp) { struct { --=20 2.37.2 From nobody Fri May 10 05:23:04 2024 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1677067266; cv=none; d=zohomail.com; s=zohoarc; b=YHKpTtLhq4lEvZldVYw+BvTLy+aohAN1xfqO4Ghtfn9gW61ACnKm+7prDpZaH2ZKValRcBHIAExv4hj8no8eJ3aA80IXpoSRIv3Q+MzX3vRihZ4eC6kJtiDexsDeg+8g7T4sr210ukP6e+20XMjAx82s1eG8ycEjmTEyYWpH7g8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677067266; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Xp171KZwAsQPheQj1isQUJOpmjl0rnTHo3TSkhKp2Vw=; b=KjsQiiPjO6zsbCq/cUkKhCWerZ3A8CoL4e+9gXqP+LRMkSliTdkMMz2jwtbAoa1nx3oKKzsIIjbIrZmUGxCe3Ap923lH6wrLzldNuwkYgEZONtxmzCUQfg3jJavzMrEX6ZCdUT6oLmH7hNYfdw8gJiw5zQFqCihAFq01DH4htUQ= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677067266321877.7806645897218; Wed, 22 Feb 2023 04:01:06 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.499402.770576 (Exim 4.92) (envelope-from ) id 1pUnnh-0001xu-Is; Wed, 22 Feb 2023 12:00:45 +0000 Received: by outflank-mailman (output) from mailman id 499402.770576; Wed, 22 Feb 2023 12:00:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pUnnh-0001xh-Et; Wed, 22 Feb 2023 12:00:45 +0000 Received: by outflank-mailman (input) for mailman id 499402; Wed, 22 Feb 2023 12:00:44 +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 1pUnnf-0000FF-MZ for xen-devel@lists.xenproject.org; Wed, 22 Feb 2023 12:00:44 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 87acfda0-b2a8-11ed-a089-e9535cc0f9c3; Wed, 22 Feb 2023 13:00:41 +0100 (CET) Received: by mail-ed1-x535.google.com with SMTP id cq23so29076041edb.1 for ; Wed, 22 Feb 2023 04:00:41 -0800 (PST) Received: from uni.router.wind (adsl-161.109.242.137.tellas.gr. [109.242.137.161]) by smtp.googlemail.com with ESMTPSA id br4-20020a170906d14400b008de729c8a03sm2133171ejb.38.2023.02.22.04.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 04:00:40 -0800 (PST) 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: 87acfda0-b2a8-11ed-a089-e9535cc0f9c3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=Xp171KZwAsQPheQj1isQUJOpmjl0rnTHo3TSkhKp2Vw=; b=V2rIPUjwGNvwRg78f+GhjCgSIj10KrPxE4n4XoWeMss3nzcqv9ZS1YggLYJXMo2eMI Ax5FYfdARKZTNMSSAhWDNAwG8Cwejtw48khVC7jBJqutZlXzbJWK4m9cCfK5Tt/tpUNR YDhtlHpyyAXfMsnoO+NbtY3DK0n7eExbzB9jROhjrP2w+mKnRcuttZRDsgSVvZQGwwX9 26WJMUUSvyYemYhC12/OgIiHRfQz+5OuidW1cP9GfASOJEt0T54SINYG8x4mtuRFbx+t WlG2tnzP9WxGvpkmbfo4jJrFtEcCXOPXVV5DGBvi2PO8s7AIMU0oruur7db5TgKgObDQ RXSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Xp171KZwAsQPheQj1isQUJOpmjl0rnTHo3TSkhKp2Vw=; b=UJg5s55k5oP5jIOO6QFjvDXjK2DTJ6xWEH0zaz/sAX47PoEcTr2pajt2h56t7EOvoX Q7nOxQX1J8/zaemiMbwLBSbsZ9PagsM8BOH3DPkV76RMNuy6uZ4wg6+KqM8krlhy+/rO 2cDMDDvOccu5oNQaowAiDKLSH+q6xxqUWNVSZM9kQLinyxUXJNyK+AGdlxZYOCg6uBam CQ8TcvumWZdCrFDB90qxBukeZq8+UzFmneBhIrkinDc8X95xjSJhmRchV7K3D+40KsLe D8hMiBqTmpQdpKFQUiSn4H1xppEVPlhGXDMDRHs1ahP7BQv/MgVrPfszE/OkbaY47raX hzbQ== X-Gm-Message-State: AO0yUKV3e7/FznEgqYTWt41orrTIQ3GTXWiJnkm9+OaMudatxLS5uQoB aIAIUzXZYRSpyOBDFskRZCLP1DPAHD0= X-Google-Smtp-Source: AK7set+XvXtK8ytTooDGm52VZHOAV0d8NoMNS9SxIK5Oon99fXTKbbunblABqPQgOWrdOs1hZ8J16w== X-Received: by 2002:a17:907:7f0d:b0:87b:d2b3:67ca with SMTP id qf13-20020a1709077f0d00b0087bd2b367camr18847740ejc.75.1677067241085; Wed, 22 Feb 2023 04:00:41 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jun Nakajima , Kevin Tian , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 6/9] x86/vmx: move declations used only by vmx code from vmx.h to private header Date: Wed, 22 Feb 2023 14:00:20 +0200 Message-Id: <20230222120023.3004624-7-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230222120023.3004624-1-burzalodowa@gmail.com> References: <20230222120023.3004624-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1677067267229100014 Content-Type: text/plain; charset="utf-8" Create a new private header in arch/x86/hvm/vmx/ called vmx.h and move there all definitions and declarations that are used solely by vmx code. EPT related declarations and definitions stay in asm/hvm/vmx/vmx.h because they are used in arch/x86/mm and drivers/passthrough/vtd. Also, __vmread(), used in arch/x86/cpu, and consequently the opcodes stay in asm/hvm/vmx/vmx.h. Take the opportunity to remove a trailing white space from __vmxon(). Signed-off-by: Xenia Ragiadakou --- Changes in v2: - new patch, creation of private header for holding declarations and definitions consumed only by vmx code, suggested by Andrew and Jan I have not added #ifndef guards as it is a private and it should not be included by other headers. However, this is considered a MISRA-C violation ... I 'm not sure what to do. xen/arch/x86/hvm/vmx/intr.c | 2 + xen/arch/x86/hvm/vmx/realmode.c | 2 + xen/arch/x86/hvm/vmx/vmcs.c | 2 + xen/arch/x86/hvm/vmx/vmx.c | 2 + xen/arch/x86/hvm/vmx/vmx.h | 459 ++++++++++++++++++++++++ xen/arch/x86/hvm/vmx/vvmx.c | 2 + xen/arch/x86/include/asm/hvm/vmx/vmx.h | 463 +------------------------ 7 files changed, 479 insertions(+), 453 deletions(-) create mode 100644 xen/arch/x86/hvm/vmx/vmx.h diff --git a/xen/arch/x86/hvm/vmx/intr.c b/xen/arch/x86/hvm/vmx/intr.c index 6a8316de0e..c8db501759 100644 --- a/xen/arch/x86/hvm/vmx/intr.c +++ b/xen/arch/x86/hvm/vmx/intr.c @@ -38,6 +38,8 @@ #include #include =20 +#include "vmx.h" + /* * A few notes on virtual NMI and INTR delivery, and interactions with * interruptibility states: diff --git a/xen/arch/x86/hvm/vmx/realmode.c b/xen/arch/x86/hvm/vmx/realmod= e.c index 4ac93e0810..5591660230 100644 --- a/xen/arch/x86/hvm/vmx/realmode.c +++ b/xen/arch/x86/hvm/vmx/realmode.c @@ -23,6 +23,8 @@ #include #include =20 +#include "vmx.h" + static void realmode_deliver_exception( unsigned int vector, unsigned int insn_len, diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index e1c268789e..bc2acd3063 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -43,6 +43,8 @@ #include #include =20 +#include "vmx.h" + static bool_t __read_mostly opt_vpid_enabled =3D 1; boolean_param("vpid", opt_vpid_enabled); =20 diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index a0297e8c6c..a19ece90fc 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -62,6 +62,8 @@ #include #include =20 +#include "vmx.h" + static bool_t __initdata opt_force_ept; boolean_param("force-ept", opt_force_ept); =20 diff --git a/xen/arch/x86/hvm/vmx/vmx.h b/xen/arch/x86/hvm/vmx/vmx.h new file mode 100644 index 0000000000..ffc19539bc --- /dev/null +++ b/xen/arch/x86/hvm/vmx/vmx.h @@ -0,0 +1,459 @@ +#include + +#include +#include +#include +#include + +extern int8_t opt_ept_exec_sp; + +#define PI_xAPIC_NDST_MASK 0xFF00 + +void vmx_asm_vmexit_handler(struct cpu_user_regs); +void vmx_intr_assist(void); +void noreturn cf_check vmx_do_resume(void); +void cf_check vmx_vlapic_msr_changed(struct vcpu *v); +void vmx_realmode(struct cpu_user_regs *regs); +void vmx_update_debug_state(struct vcpu *v); +void vmx_update_exception_bitmap(struct vcpu *v); +void vmx_update_cpu_exec_control(struct vcpu *v); +void vmx_update_secondary_exec_control(struct vcpu *v); + +#define POSTED_INTR_ON 0 +#define POSTED_INTR_SN 1 +static inline int pi_test_and_set_pir(uint8_t vector, struct pi_desc *pi_d= esc) +{ + return test_and_set_bit(vector, pi_desc->pir); +} + +static inline int pi_test_pir(uint8_t vector, const struct pi_desc *pi_des= c) +{ + return test_bit(vector, pi_desc->pir); +} + +static inline int pi_test_and_set_on(struct pi_desc *pi_desc) +{ + return test_and_set_bit(POSTED_INTR_ON, &pi_desc->control); +} + +static inline void pi_set_on(struct pi_desc *pi_desc) +{ + set_bit(POSTED_INTR_ON, &pi_desc->control); +} + +static inline int pi_test_and_clear_on(struct pi_desc *pi_desc) +{ + return test_and_clear_bit(POSTED_INTR_ON, &pi_desc->control); +} + +static inline int pi_test_on(struct pi_desc *pi_desc) +{ + return pi_desc->on; +} + +static inline unsigned long pi_get_pir(struct pi_desc *pi_desc, int group) +{ + return xchg(&pi_desc->pir[group], 0); +} + +static inline int pi_test_sn(struct pi_desc *pi_desc) +{ + return pi_desc->sn; +} + +static inline void pi_set_sn(struct pi_desc *pi_desc) +{ + set_bit(POSTED_INTR_SN, &pi_desc->control); +} + +static inline void pi_clear_sn(struct pi_desc *pi_desc) +{ + clear_bit(POSTED_INTR_SN, &pi_desc->control); +} + +/* + * Interruption-information format + * + * Note INTR_INFO_NMI_UNBLOCKED_BY_IRET is also used with Exit Qualificati= on + * field for EPT violations, PML full and SPP-related event vmexits. + */ +#define INTR_INFO_VECTOR_MASK 0xff /* 7:0 */ +#define INTR_INFO_INTR_TYPE_MASK 0x700 /* 10:8 */ +#define INTR_INFO_DELIVER_CODE_MASK 0x800 /* 11 */ +#define INTR_INFO_NMI_UNBLOCKED_BY_IRET 0x1000 /* 12 */ +#define INTR_INFO_VALID_MASK 0x80000000 /* 31 */ +#define INTR_INFO_RESVD_BITS_MASK 0x7ffff000 + +/* + * Exit Qualifications for NOTIFY VM EXIT + */ +#define NOTIFY_VM_CONTEXT_INVALID 1u + +/* + * Exit Qualifications for MOV for Control Register Access + */ +enum { + VMX_CR_ACCESS_TYPE_MOV_TO_CR, + VMX_CR_ACCESS_TYPE_MOV_FROM_CR, + VMX_CR_ACCESS_TYPE_CLTS, + VMX_CR_ACCESS_TYPE_LMSW, +}; +typedef union cr_access_qual { + unsigned long raw; + struct { + uint16_t cr:4, + access_type:2, /* VMX_CR_ACCESS_TYPE_* */ + lmsw_op_type:1, /* 0 =3D> reg, 1 =3D> mem */ + :1, + gpr:4, + :4; + uint16_t lmsw_data; + uint32_t :32; + }; +} __transparent__ cr_access_qual_t; + +/* + * Access Rights + */ +#define X86_SEG_AR_SEG_TYPE 0xf /* 3:0, segment type */ +#define X86_SEG_AR_DESC_TYPE (1u << 4) /* 4, descriptor type */ +#define X86_SEG_AR_DPL 0x60 /* 6:5, descriptor privilege le= vel */ +#define X86_SEG_AR_SEG_PRESENT (1u << 7) /* 7, segment present */ +#define X86_SEG_AR_AVL (1u << 12) /* 12, available for system sof= tware */ +#define X86_SEG_AR_CS_LM_ACTIVE (1u << 13) /* 13, long mode active (CS onl= y) */ +#define X86_SEG_AR_DEF_OP_SIZE (1u << 14) /* 14, default operation size */ +#define X86_SEG_AR_GRANULARITY (1u << 15) /* 15, granularity */ +#define X86_SEG_AR_SEG_UNUSABLE (1u << 16) /* 16, segment unusable */ + +extern uint8_t posted_intr_vector; + +#define INVEPT_SINGLE_CONTEXT 1 +#define INVEPT_ALL_CONTEXT 2 + +#define INVVPID_INDIVIDUAL_ADDR 0 +#define INVVPID_SINGLE_CONTEXT 1 +#define INVVPID_ALL_CONTEXT 2 +#define INVVPID_SINGLE_CONTEXT_RETAINING_GLOBAL 3 + +static always_inline void __vmptrld(u64 addr) +{ + asm volatile ( +#ifdef HAVE_AS_VMX + "vmptrld %0\n" +#else + VMPTRLD_OPCODE MODRM_EAX_06 +#endif + /* CF=3D=3D1 or ZF=3D=3D1 --> BUG() */ + UNLIKELY_START(be, vmptrld) + _ASM_BUGFRAME_TEXT(0) + UNLIKELY_END_SECTION + : +#ifdef HAVE_AS_VMX + : "m" (addr), +#else + : "a" (&addr), +#endif + _ASM_BUGFRAME_INFO(BUGFRAME_bug, __LINE__, __FILE__, = 0) + : "memory"); +} + +static always_inline void __vmpclear(u64 addr) +{ + asm volatile ( +#ifdef HAVE_AS_VMX + "vmclear %0\n" +#else + VMCLEAR_OPCODE MODRM_EAX_06 +#endif + /* CF=3D=3D1 or ZF=3D=3D1 --> BUG() */ + UNLIKELY_START(be, vmclear) + _ASM_BUGFRAME_TEXT(0) + UNLIKELY_END_SECTION + : +#ifdef HAVE_AS_VMX + : "m" (addr), +#else + : "a" (&addr), +#endif + _ASM_BUGFRAME_INFO(BUGFRAME_bug, __LINE__, __FILE__, = 0) + : "memory"); +} + +static always_inline void __vmwrite(unsigned long field, unsigned long val= ue) +{ + asm volatile ( +#ifdef HAVE_AS_VMX + "vmwrite %1, %0\n" +#else + VMWRITE_OPCODE MODRM_EAX_ECX +#endif + /* CF=3D=3D1 or ZF=3D=3D1 --> BUG() */ + UNLIKELY_START(be, vmwrite) + _ASM_BUGFRAME_TEXT(0) + UNLIKELY_END_SECTION + : +#ifdef HAVE_AS_VMX + : "r" (field) , "rm" (value), +#else + : "a" (field) , "c" (value), +#endif + _ASM_BUGFRAME_INFO(BUGFRAME_bug, __LINE__, __FILE__, = 0) + ); +} + + +#ifdef HAVE_AS_VMX +# define GAS_VMX_OP(yes, no) yes +#else +# define GAS_VMX_OP(yes, no) no +#endif + +static inline enum vmx_insn_errno vmread_safe(unsigned long field, + unsigned long *value) +{ + unsigned long ret =3D VMX_INSN_SUCCEED; + bool fail_invalid, fail_valid; + + asm volatile ( GAS_VMX_OP("vmread %[field], %[value]\n\t", + VMREAD_OPCODE MODRM_EAX_ECX) + ASM_FLAG_OUT(, "setc %[invalid]\n\t") + ASM_FLAG_OUT(, "setz %[valid]\n\t") + : ASM_FLAG_OUT("=3D@ccc", [invalid] "=3Drm") (fail_inva= lid), + ASM_FLAG_OUT("=3D@ccz", [valid] "=3Drm") (fail_valid), + [value] GAS_VMX_OP("=3Drm", "=3Dc") (*value) + : [field] GAS_VMX_OP("r", "a") (field)); + + if ( unlikely(fail_invalid) ) + ret =3D VMX_INSN_FAIL_INVALID; + else if ( unlikely(fail_valid) ) + __vmread(VM_INSTRUCTION_ERROR, &ret); + + return ret; +} + +static inline enum vmx_insn_errno vmwrite_safe(unsigned long field, + unsigned long value) +{ + unsigned long ret =3D VMX_INSN_SUCCEED; + bool fail_invalid, fail_valid; + + asm volatile ( GAS_VMX_OP("vmwrite %[value], %[field]\n\t", + VMWRITE_OPCODE MODRM_EAX_ECX) + ASM_FLAG_OUT(, "setc %[invalid]\n\t") + ASM_FLAG_OUT(, "setz %[valid]\n\t") + : ASM_FLAG_OUT("=3D@ccc", [invalid] "=3Drm") (fail_inva= lid), + ASM_FLAG_OUT("=3D@ccz", [valid] "=3Drm") (fail_valid) + : [field] GAS_VMX_OP("r", "a") (field), + [value] GAS_VMX_OP("rm", "c") (value)); + + if ( unlikely(fail_invalid) ) + ret =3D VMX_INSN_FAIL_INVALID; + else if ( unlikely(fail_valid) ) + __vmread(VM_INSTRUCTION_ERROR, &ret); + + return ret; +} + +#undef GAS_VMX_OP + + +static always_inline void __invept(unsigned long type, uint64_t eptp) +{ + struct { + uint64_t eptp, rsvd; + } operand =3D { eptp }; + + /* + * If single context invalidation is not supported, we escalate to + * use all context invalidation. + */ + if ( (type =3D=3D INVEPT_SINGLE_CONTEXT) && + !cpu_has_vmx_ept_invept_single_context ) + type =3D INVEPT_ALL_CONTEXT; + + asm volatile ( +#ifdef HAVE_AS_EPT + "invept %0, %1\n" +#else + INVEPT_OPCODE MODRM_EAX_08 +#endif + /* CF=3D=3D1 or ZF=3D=3D1 --> BUG() */ + UNLIKELY_START(be, invept) + _ASM_BUGFRAME_TEXT(0) + UNLIKELY_END_SECTION + : +#ifdef HAVE_AS_EPT + : "m" (operand), "r" (type), +#else + : "a" (&operand), "c" (type), +#endif + _ASM_BUGFRAME_INFO(BUGFRAME_bug, __LINE__, __FILE__, = 0) + : "memory" ); +} + +static always_inline void __invvpid(unsigned long type, u16 vpid, u64 gva) +{ + struct __packed { + u64 vpid:16; + u64 rsvd:48; + u64 gva; + } operand =3D {vpid, 0, gva}; + + /* Fix up #UD exceptions which occur when TLBs are flushed before VMXO= N. */ + asm volatile ( "1: " +#ifdef HAVE_AS_EPT + "invvpid %0, %1\n" +#else + INVVPID_OPCODE MODRM_EAX_08 +#endif + /* CF=3D=3D1 or ZF=3D=3D1 --> BUG() */ + UNLIKELY_START(be, invvpid) + _ASM_BUGFRAME_TEXT(0) + UNLIKELY_END_SECTION "\n" + "2:" + _ASM_EXTABLE(1b, 2b) + : +#ifdef HAVE_AS_EPT + : "m" (operand), "r" (type), +#else + : "a" (&operand), "c" (type), +#endif + _ASM_BUGFRAME_INFO(BUGFRAME_bug, __LINE__, __FILE__, = 0) + : "memory" ); +} + +static inline void ept_sync_all(void) +{ + __invept(INVEPT_ALL_CONTEXT, 0); +} + +static inline void vpid_sync_vcpu_gva(struct vcpu *v, unsigned long gva) +{ + int type =3D INVVPID_INDIVIDUAL_ADDR; + + /* + * If individual address invalidation is not supported, we escalate to + * use single context invalidation. + */ + if ( likely(cpu_has_vmx_vpid_invvpid_individual_addr) ) + goto execute_invvpid; + + type =3D INVVPID_SINGLE_CONTEXT; + + /* + * If single context invalidation is not supported, we escalate to + * use all context invalidation. + */ + if ( !cpu_has_vmx_vpid_invvpid_single_context ) + type =3D INVVPID_ALL_CONTEXT; + +execute_invvpid: + __invvpid(type, v->arch.hvm.n1asid.asid, (u64)gva); +} + +static inline void vpid_sync_all(void) +{ + __invvpid(INVVPID_ALL_CONTEXT, 0, 0); +} + +static inline void __vmxoff(void) +{ + asm volatile ( + VMXOFF_OPCODE + : : : "memory" ); +} + +static inline int __vmxon(u64 addr) +{ + int rc; + + asm volatile ( + "1: " VMXON_OPCODE MODRM_EAX_06 "\n" + " setna %b0 ; neg %0\n" /* CF=3D=3D1 or ZF=3D=3D1 --> rc =3D -1 = */ + "2:\n" + ".section .fixup,\"ax\"\n" + "3: sub $2,%0 ; jmp 2b\n" /* #UD or #GP --> rc =3D -2 */ + ".previous\n" + _ASM_EXTABLE(1b, 3b) + : "=3Dq" (rc) + : "0" (0), "a" (&addr) + : "memory"); + + return rc; +} + +int cf_check vmx_guest_x86_mode(struct vcpu *v); +unsigned int vmx_get_cpl(void); +void vmx_inject_extint(int trap, uint8_t source); +void vmx_inject_nmi(void); + +void update_guest_eip(void); + +void vmx_pi_per_cpu_init(unsigned int cpu); +void vmx_pi_desc_fixup(unsigned int cpu); + +void vmx_sync_exit_bitmap(struct vcpu *v); + +#define APIC_INVALID_DEST 0xffffffff + +/* #VE information page */ +typedef struct { + u32 exit_reason; + u32 semaphore; + u64 exit_qualification; + u64 gla; + u64 gpa; + u16 eptp_index; +} ve_info_t; + +/* VM-Exit instruction info for LIDT, LGDT, SIDT, SGDT */ +typedef union idt_or_gdt_instr_info { + unsigned long raw; + struct { + unsigned long scaling :2, /* bits 0:1 - Scaling */ + :5, /* bits 6:2 - Undefined */ + addr_size :3, /* bits 9:7 - Address size */ + :1, /* bit 10 - Cleared to 0 */ + operand_size :1, /* bit 11 - Operand size */ + :3, /* bits 14:12 - Undefined */ + segment_reg :3, /* bits 17:15 - Segment register */ + index_reg :4, /* bits 21:18 - Index register */ + index_reg_invalid :1, /* bit 22 - Index register invalid */ + base_reg :4, /* bits 26:23 - Base register */ + base_reg_invalid :1, /* bit 27 - Base register invalid */ + instr_identity :1, /* bit 28 - 0:GDT, 1:IDT */ + instr_write :1, /* bit 29 - 0:store, 1:load */ + :34; /* bits 30:63 - Undefined */ + }; +} idt_or_gdt_instr_info_t; + +/* VM-Exit instruction info for LLDT, LTR, SLDT, STR */ +typedef union ldt_or_tr_instr_info { + unsigned long raw; + struct { + unsigned long scaling :2, /* bits 0:1 - Scaling */ + :1, /* bit 2 - Undefined */ + reg1 :4, /* bits 6:3 - Reg1 */ + addr_size :3, /* bits 9:7 - Address size */ + mem_reg :1, /* bit 10 - Mem/Reg */ + :4, /* bits 14:11 - Undefined */ + segment_reg :3, /* bits 17:15 - Segment register */ + index_reg :4, /* bits 21:18 - Index register */ + index_reg_invalid :1, /* bit 22 - Index register invalid */ + base_reg :4, /* bits 26:23 - Base register */ + base_reg_invalid :1, /* bit 27 - Base register invalid */ + instr_identity :1, /* bit 28 - 0:LDT, 1:TR */ + instr_write :1, /* bit 29 - 0:store, 1:load */ + :34; /* bits 31:63 - Undefined */ + }; +} ldt_or_tr_instr_info_t; + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c index 674cdabb07..0bda8430b9 100644 --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -29,6 +29,8 @@ #include #include =20 +#include "vmx.h" + static DEFINE_PER_CPU(u64 *, vvmcs_buf); =20 static void nvmx_purge_vvmcs(struct vcpu *v); diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmx.h b/xen/arch/x86/include/= asm/hvm/vmx/vmx.h index 1ba2937c23..c81d76e4eb 100644 --- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h +++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h @@ -20,13 +20,9 @@ =20 #include =20 -#include -#include #include #include =20 -extern int8_t opt_ept_exec_sp; - typedef union { struct { u64 r : 1, /* bit 0 - Read permission */ @@ -77,71 +73,8 @@ typedef enum { #define EPTE_RWX_MASK 0x7 #define EPTE_FLAG_MASK 0x7f =20 -#define PI_xAPIC_NDST_MASK 0xFF00 - -void vmx_asm_vmexit_handler(struct cpu_user_regs); -void vmx_intr_assist(void); -void noreturn cf_check vmx_do_resume(void); -void cf_check vmx_vlapic_msr_changed(struct vcpu *v); struct hvm_emulate_ctxt; void vmx_realmode_emulate_one(struct hvm_emulate_ctxt *hvmemul_ctxt); -void vmx_realmode(struct cpu_user_regs *regs); -void vmx_update_debug_state(struct vcpu *v); -void vmx_update_exception_bitmap(struct vcpu *v); -void vmx_update_cpu_exec_control(struct vcpu *v); -void vmx_update_secondary_exec_control(struct vcpu *v); - -#define POSTED_INTR_ON 0 -#define POSTED_INTR_SN 1 -static inline int pi_test_and_set_pir(uint8_t vector, struct pi_desc *pi_d= esc) -{ - return test_and_set_bit(vector, pi_desc->pir); -} - -static inline int pi_test_pir(uint8_t vector, const struct pi_desc *pi_des= c) -{ - return test_bit(vector, pi_desc->pir); -} - -static inline int pi_test_and_set_on(struct pi_desc *pi_desc) -{ - return test_and_set_bit(POSTED_INTR_ON, &pi_desc->control); -} - -static inline void pi_set_on(struct pi_desc *pi_desc) -{ - set_bit(POSTED_INTR_ON, &pi_desc->control); -} - -static inline int pi_test_and_clear_on(struct pi_desc *pi_desc) -{ - return test_and_clear_bit(POSTED_INTR_ON, &pi_desc->control); -} - -static inline int pi_test_on(struct pi_desc *pi_desc) -{ - return pi_desc->on; -} - -static inline unsigned long pi_get_pir(struct pi_desc *pi_desc, int group) -{ - return xchg(&pi_desc->pir[group], 0); -} - -static inline int pi_test_sn(struct pi_desc *pi_desc) -{ - return pi_desc->sn; -} - -static inline void pi_set_sn(struct pi_desc *pi_desc) -{ - set_bit(POSTED_INTR_SN, &pi_desc->control); -} - -static inline void pi_clear_sn(struct pi_desc *pi_desc) -{ - clear_bit(POSTED_INTR_SN, &pi_desc->control); -} =20 /* * Exit Reasons @@ -212,60 +145,6 @@ static inline void pi_clear_sn(struct pi_desc *pi_desc) #define EXIT_REASON_NOTIFY 75 /* Remember to also update VMX_PERF_EXIT_REASON_SIZE! */ =20 -/* - * Interruption-information format - * - * Note INTR_INFO_NMI_UNBLOCKED_BY_IRET is also used with Exit Qualificati= on - * field for EPT violations, PML full and SPP-related event vmexits. - */ -#define INTR_INFO_VECTOR_MASK 0xff /* 7:0 */ -#define INTR_INFO_INTR_TYPE_MASK 0x700 /* 10:8 */ -#define INTR_INFO_DELIVER_CODE_MASK 0x800 /* 11 */ -#define INTR_INFO_NMI_UNBLOCKED_BY_IRET 0x1000 /* 12 */ -#define INTR_INFO_VALID_MASK 0x80000000 /* 31 */ -#define INTR_INFO_RESVD_BITS_MASK 0x7ffff000 - -/* - * Exit Qualifications for NOTIFY VM EXIT - */ -#define NOTIFY_VM_CONTEXT_INVALID 1u - -/* - * Exit Qualifications for MOV for Control Register Access - */ -enum { - VMX_CR_ACCESS_TYPE_MOV_TO_CR, - VMX_CR_ACCESS_TYPE_MOV_FROM_CR, - VMX_CR_ACCESS_TYPE_CLTS, - VMX_CR_ACCESS_TYPE_LMSW, -}; -typedef union cr_access_qual { - unsigned long raw; - struct { - uint16_t cr:4, - access_type:2, /* VMX_CR_ACCESS_TYPE_* */ - lmsw_op_type:1, /* 0 =3D> reg, 1 =3D> mem */ - :1, - gpr:4, - :4; - uint16_t lmsw_data; - uint32_t :32; - }; -} __transparent__ cr_access_qual_t; - -/* - * Access Rights - */ -#define X86_SEG_AR_SEG_TYPE 0xf /* 3:0, segment type */ -#define X86_SEG_AR_DESC_TYPE (1u << 4) /* 4, descriptor type */ -#define X86_SEG_AR_DPL 0x60 /* 6:5, descriptor privilege le= vel */ -#define X86_SEG_AR_SEG_PRESENT (1u << 7) /* 7, segment present */ -#define X86_SEG_AR_AVL (1u << 12) /* 12, available for system sof= tware */ -#define X86_SEG_AR_CS_LM_ACTIVE (1u << 13) /* 13, long mode active (CS onl= y) */ -#define X86_SEG_AR_DEF_OP_SIZE (1u << 14) /* 14, default operation size */ -#define X86_SEG_AR_GRANULARITY (1u << 15) /* 15, granularity */ -#define X86_SEG_AR_SEG_UNUSABLE (1u << 16) /* 16, segment unusable */ - #define VMCALL_OPCODE ".byte 0x0f,0x01,0xc1\n" #define VMCLEAR_OPCODE ".byte 0x66,0x0f,0xc7\n" /* reg/opcode: /6 = */ #define VMLAUNCH_OPCODE ".byte 0x0f,0x01,0xc2\n" @@ -284,8 +163,6 @@ typedef union cr_access_qual { #define MODRM_EAX_07 ".byte 0x38\n" /* [EAX], with reg/opcode: /7 */ #define MODRM_EAX_ECX ".byte 0xc1\n" /* EAX, ECX */ =20 -extern uint8_t posted_intr_vector; - #define cpu_has_vmx_ept_exec_only_supported \ (vmx_ept_vpid_cap & VMX_EPT_EXEC_ONLY_SUPPORTED) =20 @@ -299,70 +176,6 @@ extern uint8_t posted_intr_vector; #define cpu_has_vmx_ept_invept_single_context \ (vmx_ept_vpid_cap & VMX_EPT_INVEPT_SINGLE_CONTEXT) =20 -#define EPT_2MB_SHIFT 16 -#define EPT_1GB_SHIFT 17 -#define ept_has_2mb(c) ((c >> EPT_2MB_SHIFT) & 1) -#define ept_has_1gb(c) ((c >> EPT_1GB_SHIFT) & 1) - -#define INVEPT_SINGLE_CONTEXT 1 -#define INVEPT_ALL_CONTEXT 2 - -#define cpu_has_vmx_vpid_invvpid_individual_addr \ - (vmx_ept_vpid_cap & VMX_VPID_INVVPID_INDIVIDUAL_ADDR) -#define cpu_has_vmx_vpid_invvpid_single_context \ - (vmx_ept_vpid_cap & VMX_VPID_INVVPID_SINGLE_CONTEXT) -#define cpu_has_vmx_vpid_invvpid_single_context_retaining_global \ - (vmx_ept_vpid_cap & VMX_VPID_INVVPID_SINGLE_CONTEXT_RETAINING_GLOBAL) - -#define INVVPID_INDIVIDUAL_ADDR 0 -#define INVVPID_SINGLE_CONTEXT 1 -#define INVVPID_ALL_CONTEXT 2 -#define INVVPID_SINGLE_CONTEXT_RETAINING_GLOBAL 3 - -static always_inline void __vmptrld(u64 addr) -{ - asm volatile ( -#ifdef HAVE_AS_VMX - "vmptrld %0\n" -#else - VMPTRLD_OPCODE MODRM_EAX_06 -#endif - /* CF=3D=3D1 or ZF=3D=3D1 --> BUG() */ - UNLIKELY_START(be, vmptrld) - _ASM_BUGFRAME_TEXT(0) - UNLIKELY_END_SECTION - : -#ifdef HAVE_AS_VMX - : "m" (addr), -#else - : "a" (&addr), -#endif - _ASM_BUGFRAME_INFO(BUGFRAME_bug, __LINE__, __FILE__, = 0) - : "memory"); -} - -static always_inline void __vmpclear(u64 addr) -{ - asm volatile ( -#ifdef HAVE_AS_VMX - "vmclear %0\n" -#else - VMCLEAR_OPCODE MODRM_EAX_06 -#endif - /* CF=3D=3D1 or ZF=3D=3D1 --> BUG() */ - UNLIKELY_START(be, vmclear) - _ASM_BUGFRAME_TEXT(0) - UNLIKELY_END_SECTION - : -#ifdef HAVE_AS_VMX - : "m" (addr), -#else - : "a" (&addr), -#endif - _ASM_BUGFRAME_INFO(BUGFRAME_bug, __LINE__, __FILE__, = 0) - : "memory"); -} - static always_inline void __vmread(unsigned long field, unsigned long *val= ue) { asm volatile ( @@ -386,215 +199,20 @@ static always_inline void __vmread(unsigned long fie= ld, unsigned long *value) ); } =20 -static always_inline void __vmwrite(unsigned long field, unsigned long val= ue) -{ - asm volatile ( -#ifdef HAVE_AS_VMX - "vmwrite %1, %0\n" -#else - VMWRITE_OPCODE MODRM_EAX_ECX -#endif - /* CF=3D=3D1 or ZF=3D=3D1 --> BUG() */ - UNLIKELY_START(be, vmwrite) - _ASM_BUGFRAME_TEXT(0) - UNLIKELY_END_SECTION - : -#ifdef HAVE_AS_VMX - : "r" (field) , "rm" (value), -#else - : "a" (field) , "c" (value), -#endif - _ASM_BUGFRAME_INFO(BUGFRAME_bug, __LINE__, __FILE__, = 0) - ); -} - -#ifdef HAVE_AS_VMX -# define GAS_VMX_OP(yes, no) yes -#else -# define GAS_VMX_OP(yes, no) no -#endif - -static inline enum vmx_insn_errno vmread_safe(unsigned long field, - unsigned long *value) -{ - unsigned long ret =3D VMX_INSN_SUCCEED; - bool fail_invalid, fail_valid; - - asm volatile ( GAS_VMX_OP("vmread %[field], %[value]\n\t", - VMREAD_OPCODE MODRM_EAX_ECX) - ASM_FLAG_OUT(, "setc %[invalid]\n\t") - ASM_FLAG_OUT(, "setz %[valid]\n\t") - : ASM_FLAG_OUT("=3D@ccc", [invalid] "=3Drm") (fail_inva= lid), - ASM_FLAG_OUT("=3D@ccz", [valid] "=3Drm") (fail_valid), - [value] GAS_VMX_OP("=3Drm", "=3Dc") (*value) - : [field] GAS_VMX_OP("r", "a") (field)); - - if ( unlikely(fail_invalid) ) - ret =3D VMX_INSN_FAIL_INVALID; - else if ( unlikely(fail_valid) ) - __vmread(VM_INSTRUCTION_ERROR, &ret); - - return ret; -} - -static inline enum vmx_insn_errno vmwrite_safe(unsigned long field, - unsigned long value) -{ - unsigned long ret =3D VMX_INSN_SUCCEED; - bool fail_invalid, fail_valid; - - asm volatile ( GAS_VMX_OP("vmwrite %[value], %[field]\n\t", - VMWRITE_OPCODE MODRM_EAX_ECX) - ASM_FLAG_OUT(, "setc %[invalid]\n\t") - ASM_FLAG_OUT(, "setz %[valid]\n\t") - : ASM_FLAG_OUT("=3D@ccc", [invalid] "=3Drm") (fail_inva= lid), - ASM_FLAG_OUT("=3D@ccz", [valid] "=3Drm") (fail_valid) - : [field] GAS_VMX_OP("r", "a") (field), - [value] GAS_VMX_OP("rm", "c") (value)); - - if ( unlikely(fail_invalid) ) - ret =3D VMX_INSN_FAIL_INVALID; - else if ( unlikely(fail_valid) ) - __vmread(VM_INSTRUCTION_ERROR, &ret); - - return ret; -} - -#undef GAS_VMX_OP - -static always_inline void __invept(unsigned long type, uint64_t eptp) -{ - struct { - uint64_t eptp, rsvd; - } operand =3D { eptp }; - - /* - * If single context invalidation is not supported, we escalate to - * use all context invalidation. - */ - if ( (type =3D=3D INVEPT_SINGLE_CONTEXT) && - !cpu_has_vmx_ept_invept_single_context ) - type =3D INVEPT_ALL_CONTEXT; - - asm volatile ( -#ifdef HAVE_AS_EPT - "invept %0, %1\n" -#else - INVEPT_OPCODE MODRM_EAX_08 -#endif - /* CF=3D=3D1 or ZF=3D=3D1 --> BUG() */ - UNLIKELY_START(be, invept) - _ASM_BUGFRAME_TEXT(0) - UNLIKELY_END_SECTION - : -#ifdef HAVE_AS_EPT - : "m" (operand), "r" (type), -#else - : "a" (&operand), "c" (type), -#endif - _ASM_BUGFRAME_INFO(BUGFRAME_bug, __LINE__, __FILE__, = 0) - : "memory" ); -} - -static always_inline void __invvpid(unsigned long type, u16 vpid, u64 gva) -{ - struct __packed { - u64 vpid:16; - u64 rsvd:48; - u64 gva; - } operand =3D {vpid, 0, gva}; - - /* Fix up #UD exceptions which occur when TLBs are flushed before VMXO= N. */ - asm volatile ( "1: " -#ifdef HAVE_AS_EPT - "invvpid %0, %1\n" -#else - INVVPID_OPCODE MODRM_EAX_08 -#endif - /* CF=3D=3D1 or ZF=3D=3D1 --> BUG() */ - UNLIKELY_START(be, invvpid) - _ASM_BUGFRAME_TEXT(0) - UNLIKELY_END_SECTION "\n" - "2:" - _ASM_EXTABLE(1b, 2b) - : -#ifdef HAVE_AS_EPT - : "m" (operand), "r" (type), -#else - : "a" (&operand), "c" (type), -#endif - _ASM_BUGFRAME_INFO(BUGFRAME_bug, __LINE__, __FILE__, = 0) - : "memory" ); -} +#define EPT_2MB_SHIFT 16 +#define EPT_1GB_SHIFT 17 +#define ept_has_2mb(c) ((c >> EPT_2MB_SHIFT) & 1) +#define ept_has_1gb(c) ((c >> EPT_1GB_SHIFT) & 1) =20 -static inline void ept_sync_all(void) -{ - __invept(INVEPT_ALL_CONTEXT, 0); -} +#define cpu_has_vmx_vpid_invvpid_individual_addr \ + (vmx_ept_vpid_cap & VMX_VPID_INVVPID_INDIVIDUAL_ADDR) +#define cpu_has_vmx_vpid_invvpid_single_context \ + (vmx_ept_vpid_cap & VMX_VPID_INVVPID_SINGLE_CONTEXT) +#define cpu_has_vmx_vpid_invvpid_single_context_retaining_global \ + (vmx_ept_vpid_cap & VMX_VPID_INVVPID_SINGLE_CONTEXT_RETAINING_GLOBAL) =20 void ept_sync_domain(struct p2m_domain *p2m); =20 -static inline void vpid_sync_vcpu_gva(struct vcpu *v, unsigned long gva) -{ - int type =3D INVVPID_INDIVIDUAL_ADDR; - - /* - * If individual address invalidation is not supported, we escalate to - * use single context invalidation. - */ - if ( likely(cpu_has_vmx_vpid_invvpid_individual_addr) ) - goto execute_invvpid; - - type =3D INVVPID_SINGLE_CONTEXT; - - /* - * If single context invalidation is not supported, we escalate to - * use all context invalidation. - */ - if ( !cpu_has_vmx_vpid_invvpid_single_context ) - type =3D INVVPID_ALL_CONTEXT; - -execute_invvpid: - __invvpid(type, v->arch.hvm.n1asid.asid, (u64)gva); -} - -static inline void vpid_sync_all(void) -{ - __invvpid(INVVPID_ALL_CONTEXT, 0, 0); -} - -static inline void __vmxoff(void) -{ - asm volatile ( - VMXOFF_OPCODE - : : : "memory" ); -} - -static inline int __vmxon(u64 addr) -{ - int rc; - - asm volatile (=20 - "1: " VMXON_OPCODE MODRM_EAX_06 "\n" - " setna %b0 ; neg %0\n" /* CF=3D=3D1 or ZF=3D=3D1 --> rc =3D -1 = */ - "2:\n" - ".section .fixup,\"ax\"\n" - "3: sub $2,%0 ; jmp 2b\n" /* #UD or #GP --> rc =3D -2 */ - ".previous\n" - _ASM_EXTABLE(1b, 3b) - : "=3Dq" (rc) - : "0" (0), "a" (&addr) - : "memory"); - - return rc; -} - -int cf_check vmx_guest_x86_mode(struct vcpu *v); -unsigned int vmx_get_cpl(void); - -void vmx_inject_extint(int trap, uint8_t source); -void vmx_inject_nmi(void); - void ept_walk_table(struct domain *d, unsigned long gfn); bool_t ept_handle_misconfig(uint64_t gpa); int epte_get_entry_emt(struct domain *d, gfn_t gfn, mfn_t mfn, @@ -603,13 +221,6 @@ void setup_ept_dump(void); /* Locate an alternate p2m by its EPTP */ unsigned int p2m_find_altp2m_by_eptp(struct domain *d, uint64_t eptp); =20 -void update_guest_eip(void); - -void vmx_pi_per_cpu_init(unsigned int cpu); -void vmx_pi_desc_fixup(unsigned int cpu); - -void vmx_sync_exit_bitmap(struct vcpu *v); - #ifdef CONFIG_HVM void vmx_pi_hooks_assign(struct domain *d); void vmx_pi_hooks_deassign(struct domain *d); @@ -618,8 +229,6 @@ static inline void vmx_pi_hooks_assign(struct domain *d= ) {} static inline void vmx_pi_hooks_deassign(struct domain *d) {} #endif =20 -#define APIC_INVALID_DEST 0xffffffff - /* EPT violation qualifications definitions */ typedef union ept_qual { unsigned long raw; @@ -635,56 +244,4 @@ typedef union ept_qual { #define EPT_L4_PAGETABLE_SHIFT 39 #define EPT_PAGETABLE_ENTRIES 512 =20 -/* #VE information page */ -typedef struct { - u32 exit_reason; - u32 semaphore; - u64 exit_qualification; - u64 gla; - u64 gpa; - u16 eptp_index; -} ve_info_t; - -/* VM-Exit instruction info for LIDT, LGDT, SIDT, SGDT */ -typedef union idt_or_gdt_instr_info { - unsigned long raw; - struct { - unsigned long scaling :2, /* bits 0:1 - Scaling */ - :5, /* bits 6:2 - Undefined */ - addr_size :3, /* bits 9:7 - Address size */ - :1, /* bit 10 - Cleared to 0 */ - operand_size :1, /* bit 11 - Operand size */ - :3, /* bits 14:12 - Undefined */ - segment_reg :3, /* bits 17:15 - Segment register */ - index_reg :4, /* bits 21:18 - Index register */ - index_reg_invalid :1, /* bit 22 - Index register invalid */ - base_reg :4, /* bits 26:23 - Base register */ - base_reg_invalid :1, /* bit 27 - Base register invalid */ - instr_identity :1, /* bit 28 - 0:GDT, 1:IDT */ - instr_write :1, /* bit 29 - 0:store, 1:load */ - :34; /* bits 30:63 - Undefined */ - }; -} idt_or_gdt_instr_info_t; - -/* VM-Exit instruction info for LLDT, LTR, SLDT, STR */ -typedef union ldt_or_tr_instr_info { - unsigned long raw; - struct { - unsigned long scaling :2, /* bits 0:1 - Scaling */ - :1, /* bit 2 - Undefined */ - reg1 :4, /* bits 6:3 - Reg1 */ - addr_size :3, /* bits 9:7 - Address size */ - mem_reg :1, /* bit 10 - Mem/Reg */ - :4, /* bits 14:11 - Undefined */ - segment_reg :3, /* bits 17:15 - Segment register */ - index_reg :4, /* bits 21:18 - Index register */ - index_reg_invalid :1, /* bit 22 - Index register invalid */ - base_reg :4, /* bits 26:23 - Base register */ - base_reg_invalid :1, /* bit 27 - Base register invalid */ - instr_identity :1, /* bit 28 - 0:LDT, 1:TR */ - instr_write :1, /* bit 29 - 0:store, 1:load */ - :34; /* bits 31:63 - Undefined */ - }; -} ldt_or_tr_instr_info_t; - #endif /* __ASM_X86_HVM_VMX_VMX_H__ */ --=20 2.37.2 From nobody Fri May 10 05:23:04 2024 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1677067266; cv=none; d=zohomail.com; s=zohoarc; b=SouJDNrWRbmyGUN0uMiOQi1qo9WCLivDF+UJT6eypAhSRvyAQOoDLvOw/mvbiwGrRl3p4PLNIT8ovnKgVqnHfPlnsrt5D9pr8/E5tRAxliyGNiI/+eEkPU3CXIKOE2uMi7unhj/1WhfYyoyW7a9N/d89hCFAtZ5CElUklXibDEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677067266; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SKxkFC3sN6rYFx1RlFQZ9txKMSWy7NH5dDU5vh7uVoo=; b=EgGveLHaRIZ63gBcYG3NAGWaWfIoE8dra76lJfGmOfwuPdxEPbzkj21t+53QBDna9W3S8IZYsNF0YCDhzFXAveWOWLNY5bZdXTt6VMXU1Ksc989u/dktbf2nU6Ra8vV2Y7e7aIvdMDeI4duRlfDp8W9dAstCcIcn0E6dIqOFiHk= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677067266371598.2010606114912; Wed, 22 Feb 2023 04:01:06 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.499403.770587 (Exim 4.92) (envelope-from ) id 1pUnnj-0002HS-8v; Wed, 22 Feb 2023 12:00:47 +0000 Received: by outflank-mailman (output) from mailman id 499403.770587; Wed, 22 Feb 2023 12:00:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pUnnj-0002GG-21; Wed, 22 Feb 2023 12:00:47 +0000 Received: by outflank-mailman (input) for mailman id 499403; Wed, 22 Feb 2023 12:00:44 +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 1pUnng-0000FF-Mt for xen-devel@lists.xenproject.org; Wed, 22 Feb 2023 12:00:44 +0000 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [2a00:1450:4864:20::52e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8883b747-b2a8-11ed-a089-e9535cc0f9c3; Wed, 22 Feb 2023 13:00:43 +0100 (CET) Received: by mail-ed1-x52e.google.com with SMTP id ec43so28829560edb.8 for ; Wed, 22 Feb 2023 04:00:43 -0800 (PST) Received: from uni.router.wind (adsl-161.109.242.137.tellas.gr. [109.242.137.161]) by smtp.googlemail.com with ESMTPSA id br4-20020a170906d14400b008de729c8a03sm2133171ejb.38.2023.02.22.04.00.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 04:00:42 -0800 (PST) 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: 8883b747-b2a8-11ed-a089-e9535cc0f9c3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=SKxkFC3sN6rYFx1RlFQZ9txKMSWy7NH5dDU5vh7uVoo=; b=J81GmpsXZP2HRFHWTgxdOsCjFZt6sh4CSK0sZBxmDwDPphpUwhC26DPxjU8/7GW0gr 3XQ814zmWzwrG9g0L1qXQxaXccQAoDig8IFJUeojrZgG5RPbUvTMPnyCwNE8Crm6UYSY p+RariflHrAUBLtFNzk0ZEb/0lWJx4zSBGy/0wGqrGCC1BRJKEoWSTyoyRVaEtwy1+O5 vDJij+1ELHohRVPFd0d89787ovEUPH5lct+h83C2F+t6LrAYTGuDGJkWm64iO1TpuK5r Xb1kMzbBARwWZTqbbOOFv9alFzexxtA0QSpB/jtCSewO2AfuwhGmOf7MkrzklSg0IPO3 nTPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=SKxkFC3sN6rYFx1RlFQZ9txKMSWy7NH5dDU5vh7uVoo=; b=OVRRpCgzZ/SGG+ay/wDhVEoZ67U8zeY0XkYtp6tv33nnlXl1xZjqj7+8r4fiEZwhoP M72JP3v+Pu824lUcd53BtbTgdE/CcbeTTYhuvYjGW3lZ8hwSxz098oLTusap2+H5BozC KJZQKCrJCsRQbfRguxdvS+XktAGezhe14niLZju4Q4GVDFc86kSj6Tb2muRua+FwxYHW 3F/GLP6xAZ0/EqkqI4djgL9K3uGgKVqCCvhsXuUP/GYKMo6+v0fkl6BVHIEVDB+mi9u3 8YV2bVetzh2QgLpfmcQrC43Xt4WA+MsaYSmNrl4tg8NuYOGio9ZIerNhZFInPLGSYo4m WMEg== X-Gm-Message-State: AO0yUKWMK5R5lwI8bGVKK5psdCDxFb2NpkX20Ljfwf2rimRHp/qxNp4u U2ne3S5aELnazx87sE3SFjXs74qbyks= X-Google-Smtp-Source: AK7set+YnkscDNljbkWncdvh7jiPZpconVrnLmKRsDczVFSkH1Me8CeCLNUYgI4azccPXUjZuLz3Dg== X-Received: by 2002:a17:906:5651:b0:884:fd73:8053 with SMTP id v17-20020a170906565100b00884fd738053mr14837658ejr.9.1677067242727; Wed, 22 Feb 2023 04:00:42 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jun Nakajima , Kevin Tian , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 7/9] x86/vmx: remove unused included headers from vmx.c Date: Wed, 22 Feb 2023 14:00:21 +0200 Message-Id: <20230222120023.3004624-8-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230222120023.3004624-1-burzalodowa@gmail.com> References: <20230222120023.3004624-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1677067267108100013 Content-Type: text/plain; charset="utf-8" Do not include the headers: asm/hvm/vpic.h asm/hvm/vpt.h asm/io.h asm/mce.h asm/mem_sharing.h asm/regs.h public/arch-x86/cpuid.h public/hvm/save.h because none of the declarations and macro definitions in them is used. Sort the rest of the headers alphabetically. Signed-off-by: Xenia Ragiadakou --- Changes in v2: -add a blank line between different types of hesders xen/arch/x86/hvm/vmx/vmx.c | 56 +++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index a19ece90fc..a6ec0a11fb 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -15,52 +15,46 @@ * this program; If not, see . */ =20 +#include #include +#include #include +#include #include #include -#include +#include #include -#include #include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include #include -#include +#include +#include #include -#include -#include -#include +#include #include #include +#include +#include #include -#include +#include +#include #include -#include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include #include -#include +#include +#include +#include + +#include +#include =20 #include "vmx.h" =20 --=20 2.37.2 From nobody Fri May 10 05:23:04 2024 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1677067769; cv=none; d=zohomail.com; s=zohoarc; b=m33VIccbd42UxZWvxpGuqrHl7h2u4vXhjsW9AZF2Ho18XGqXMY9f3hUN2s06qiN/GY+Wj6/x5ygSSOmz2MSmSwXqMFYN/flK/qSswc2lYSlkDxM9MNsU1yo2iieu8w8T157G2HJ6JfieGfh93WbZ/ZHukYHCFdxdtqDEMp0D5jY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677067769; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PT+Ksue1+E+w99TtdgjOaQagRH8S4XRZ2zbUy1hdUfQ=; b=OI06bFeZ/mhBGqcvJN+1PWNHOUtaVaQruZMTl4L+N+eJCgwZWITDgCqhVCzpPxjsobIv9FA8PkEte9tgHwmWhr3E9ISMzUntldn5vsww17iV+rKiSYoCe/AvFhZMca/AmqR+aYpS34bAAOlY6I5I8XWiG3nqZ9pkP8edsssNXeo= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677067769519312.06520070674514; Wed, 22 Feb 2023 04:09:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.499443.770609 (Exim 4.92) (envelope-from ) id 1pUnvn-0005b6-HS; Wed, 22 Feb 2023 12:09:07 +0000 Received: by outflank-mailman (output) from mailman id 499443.770609; Wed, 22 Feb 2023 12:09:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pUnvn-0005az-Ei; Wed, 22 Feb 2023 12:09:07 +0000 Received: by outflank-mailman (input) for mailman id 499443; Wed, 22 Feb 2023 12:09:06 +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 1pUnnl-0000FF-Nx for xen-devel@lists.xenproject.org; Wed, 22 Feb 2023 12:00:49 +0000 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [2a00:1450:4864:20::52b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8b2bd9db-b2a8-11ed-a089-e9535cc0f9c3; Wed, 22 Feb 2023 13:00:47 +0100 (CET) Received: by mail-ed1-x52b.google.com with SMTP id f13so28811679edz.6 for ; Wed, 22 Feb 2023 04:00:47 -0800 (PST) Received: from uni.router.wind (adsl-161.109.242.137.tellas.gr. [109.242.137.161]) by smtp.googlemail.com with ESMTPSA id br4-20020a170906d14400b008de729c8a03sm2133171ejb.38.2023.02.22.04.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 04:00:44 -0800 (PST) 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: 8b2bd9db-b2a8-11ed-a089-e9535cc0f9c3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=PT+Ksue1+E+w99TtdgjOaQagRH8S4XRZ2zbUy1hdUfQ=; b=f7sBEFlAiFt8BwckZZSAdepoiq4oPj8xdQ25kOFg8ZFxw4Rq+BOXv9OJkt4tUbntr1 QtzNdDALpmqPGQpYMCymeEg5BhzqbQ3QRrXUd2sRXeXJNPyCTemMQHe9z8KAqmkYnHbs hyhjweiZ1laGMgfRcSU4ugBtrGN6eH09NaL6w8G4fitImlR15Ap/e5Z7pzboDe0fCum8 HmY+J8Q2zTTxCDhDU4rYUZD40uHFtnDg+YX6LKIEF8OkgYXV+NDaS3rpvf+dmLYGAbq6 DijIzH8G9aARQpZXompCj1KQS5pLJJVABd1sAFSGabcTi0hUziSJqkzzwjFHwj3Q1f2U eEoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=PT+Ksue1+E+w99TtdgjOaQagRH8S4XRZ2zbUy1hdUfQ=; b=W6oAqxKHmB9DiAWUu+SPzHEKe/rQUI1Ka8H79Yfg/MF8pbF2jSKOGaStuEVX3tUSvH +0MdswclU2ZzHZ8RN/ZjlJcL3BXqMXjZtoMVBQY1j7QaeE9BUBBf6DnKtqqrzFZSHtlC 5w2nw3UanSxjf7Z1QxAKKoD3GDqa/aJmKXLbS/wSaYdeXvd3fVwpDdKzymtL3jwdGMqg 1OK7pCEagZRkM3qMrm68ueyoBys3pjMuWVCJj7FCvZMWKQ8uihyyO+jUgz/qbCg3EHuS Ry/cZTUaHRbEvSzRp2OmkOm+52oF6L+GHSDmjt8n+tFSOAenN3xeGn5S53W8VpOwBJe3 0lww== X-Gm-Message-State: AO0yUKViKX1LYldRYWSeRCJTKknJk4urIvYAIPaSyda1c53SrXvWgYTl 2zQH96ENoJf4e1RZArV9dtwO0Yewfvk= X-Google-Smtp-Source: AK7set95xEBEhwxinuF+Ewg4dWtI1668L/9cwbJv7N/Z2epvwFWWYJuaPofhaYeDX2KLOElA8zTF2Q== X-Received: by 2002:a17:906:248c:b0:878:5f35:b8d6 with SMTP id e12-20020a170906248c00b008785f35b8d6mr16771158ejb.51.1677067244443; Wed, 22 Feb 2023 04:00:44 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jun Nakajima , Kevin Tian , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 8/9] x86/vmx: declare nvmx_enqueue_n2_exceptions() static Date: Wed, 22 Feb 2023 14:00:22 +0200 Message-Id: <20230222120023.3004624-9-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230222120023.3004624-1-burzalodowa@gmail.com> References: <20230222120023.3004624-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1677067771184100001 Content-Type: text/plain; charset="utf-8" Reduce the scope of nvmx_enqueue_n2_exceptions() to static because it is us= ed only in this file. Take the opportunity to remove a trailing space. Signed-off-by: Xenia Ragiadakou Reviewed-by: Jan Beulich --- Changes in v2: - none xen/arch/x86/hvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index a6ec0a11fb..5b210e0db4 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1908,7 +1908,7 @@ static void cf_check vmx_update_guest_efer(struct vcp= u *v) vmx_set_msr_intercept(v, MSR_EFER, VMX_MSR_R); } =20 -void nvmx_enqueue_n2_exceptions(struct vcpu *v,=20 +static void nvmx_enqueue_n2_exceptions(struct vcpu *v, unsigned long intr_fields, int error_code, uint8_t source) { struct nestedvmx *nvmx =3D &vcpu_2_nvmx(v); --=20 2.37.2 From nobody Fri May 10 05:23:04 2024 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1677067269; cv=none; d=zohomail.com; s=zohoarc; b=ktQj2AioxqsT3GPyEey28F2MznHM2OylJL9vuErBAMUjsUKgoe1fvTJgbyz6f+UOiMq0GJqt+mKzNSGste4gccQD/hHyO4eRCdnBv93e1GU32JsPYj/BuTeVmZ54RVDqAdjSxJYZQAPwe6fUbWhD0P6uAiznhIQiKpJUrt1ylSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677067269; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6pd1IsfmVUdREn+72l4bwA5xZ7W4U+B+UhoBSO74jgE=; b=kFKI6c9h4iNZtoo3vOn/5/6GTjD56IUzQJal8M8f8lo0rxqC9kOwAYknFyedFgz1a1mDhSmygs3mgM0tJL4nFBoP20NpLPDixgujVgTqwua60Nn0DrQ3ILtWtPEshj8YbnCb3dKHPijEt0ZV+TfgjmgC0ga+llf4jIlOm192Lfo= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677067269528135.8837070305657; Wed, 22 Feb 2023 04:01:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.499405.770598 (Exim 4.92) (envelope-from ) id 1pUnnk-0002Yg-Ms; Wed, 22 Feb 2023 12:00:48 +0000 Received: by outflank-mailman (output) from mailman id 499405.770598; Wed, 22 Feb 2023 12:00:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pUnnk-0002Y7-FW; Wed, 22 Feb 2023 12:00:48 +0000 Received: by outflank-mailman (input) for mailman id 499405; Wed, 22 Feb 2023 12:00:47 +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 1pUnnj-0000FF-ED for xen-devel@lists.xenproject.org; Wed, 22 Feb 2023 12:00:47 +0000 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [2a00:1450:4864:20::52c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8a9eec1c-b2a8-11ed-a089-e9535cc0f9c3; Wed, 22 Feb 2023 13:00:46 +0100 (CET) Received: by mail-ed1-x52c.google.com with SMTP id s26so29310229edw.11 for ; Wed, 22 Feb 2023 04:00:46 -0800 (PST) Received: from uni.router.wind (adsl-161.109.242.137.tellas.gr. [109.242.137.161]) by smtp.googlemail.com with ESMTPSA id br4-20020a170906d14400b008de729c8a03sm2133171ejb.38.2023.02.22.04.00.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 04:00:46 -0800 (PST) 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: 8a9eec1c-b2a8-11ed-a089-e9535cc0f9c3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=6pd1IsfmVUdREn+72l4bwA5xZ7W4U+B+UhoBSO74jgE=; b=jWyKf+veZsmd3eCAewTS++qu/E0UeyXv9OpPq7y1RFbQ1VWOh9rgxLvwCbBtlc1OZH P7u/sImEOhlCZo8JeXMB+yoEec4K++xBh86QakWRy39nmkWPebjnDWTGAe0WIs1NaVeD MsocwW0MKPFgZD+vSRdeiRf+itlYRYln7FCaOTgwJ9sCSfNlAGdT2J7U5KWGxkFOsWe4 NX6iYuAIPjG0PCHZ/mmbM1qGBahuRbe5XY0m3TBmV1ymDewmmbmbQ3iFumTT8ASr71XU 9rYiXTv2qoLlLiNanWUXKVxFJJcAa+92G+vHFXmSS66XoIZxJTU8WXZ0KHjj7jGMD6+X NhVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=6pd1IsfmVUdREn+72l4bwA5xZ7W4U+B+UhoBSO74jgE=; b=4p/T2o9YBvcEWVfIKCVUT26P/6bgMhCSWJg/xEmHkuWSOWSGn58S+imM/fXh7yw2/5 V+RtcZXfhoGe+cKOHUvjUtsqGmmVaq2jSvH9MtM3alhn2eact3DsJMIKV730cc7J3qnB ZUVrA4QPMbDR/pJlb4vpltPoedICf/KHyhxGGi1HNNFaRH3u/cb8ssFQVWreQaDEideD 9N5TiQj+r+wi5RWCTQRlirxI84UIRoTMDfoie9oBWTQuKp/2MPOhtEiOF+8KL21omfXg rVGoA3E4H+mH+D+ieiVO24nlHpRH7+K5bUQ+cMZWLVEuV7UKGQlDou6jAOmoxln1s+RZ VSwg== X-Gm-Message-State: AO0yUKUp7iJr5EtgcdPWmdz86eK20W7cTKfGIjovf41JD2fP6KGepatF AQ0TK0p0W/mVwoSEzkvOF0p/cN5P+70= X-Google-Smtp-Source: AK7set+0rv8noKcn8UZ+q7u6JZExNgzfSC62/oG5lYFS8qdKZbCXE6opqMRYfhM4q7OAxWihjU8TNA== X-Received: by 2002:a17:907:ea2:b0:88d:33fe:3306 with SMTP id ho34-20020a1709070ea200b0088d33fe3306mr21202519ejc.31.1677067246331; Wed, 22 Feb 2023 04:00:46 -0800 (PST) From: Xenia Ragiadakou To: xen-devel@lists.xenproject.org Cc: Jun Nakajima , Kevin Tian , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 9/9] x86/vmx: move vmx_update_debug_state() in vmcs.c and declare it static Date: Wed, 22 Feb 2023 14:00:23 +0200 Message-Id: <20230222120023.3004624-10-burzalodowa@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230222120023.3004624-1-burzalodowa@gmail.com> References: <20230222120023.3004624-1-burzalodowa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1677067271097100001 Content-Type: text/plain; charset="utf-8" Move vmx_update_debug_state() in vmcs.c because it is used only in this file and limit its scope to this file by declaring it static and removing its declaration from private vmx.h Signed-off-by: Xenia Ragiadakou --- Changes in v2: - remove it from the private vmx.h header instead of the global one xen/arch/x86/hvm/vmx/vmcs.c | 12 ++++++++++++ xen/arch/x86/hvm/vmx/vmx.c | 12 ------------ xen/arch/x86/hvm/vmx/vmx.h | 1 - 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index bc2acd3063..1492f85213 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -1868,6 +1868,18 @@ void vmx_vmentry_failure(void) =20 void noreturn vmx_asm_do_vmentry(void); =20 +static void vmx_update_debug_state(struct vcpu *v) +{ + if ( v->arch.hvm.debug_state_latch ) + v->arch.hvm.vmx.exception_bitmap |=3D 1U << TRAP_int3; + else + v->arch.hvm.vmx.exception_bitmap &=3D ~(1U << TRAP_int3); + + vmx_vmcs_enter(v); + vmx_update_exception_bitmap(v); + vmx_vmcs_exit(v); +} + void cf_check vmx_do_resume(void) { struct vcpu *v =3D current; diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 5b210e0db4..ada36d6923 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1610,18 +1610,6 @@ static void cf_check vmx_update_host_cr3(struct vcpu= *v) vmx_vmcs_exit(v); } =20 -void vmx_update_debug_state(struct vcpu *v) -{ - if ( v->arch.hvm.debug_state_latch ) - v->arch.hvm.vmx.exception_bitmap |=3D 1U << TRAP_int3; - else - v->arch.hvm.vmx.exception_bitmap &=3D ~(1U << TRAP_int3); - - vmx_vmcs_enter(v); - vmx_update_exception_bitmap(v); - vmx_vmcs_exit(v); -} - static void cf_check vmx_update_guest_cr( struct vcpu *v, unsigned int cr, unsigned int flags) { diff --git a/xen/arch/x86/hvm/vmx/vmx.h b/xen/arch/x86/hvm/vmx/vmx.h index ffc19539bc..7d4ecf6d59 100644 --- a/xen/arch/x86/hvm/vmx/vmx.h +++ b/xen/arch/x86/hvm/vmx/vmx.h @@ -14,7 +14,6 @@ void vmx_intr_assist(void); void noreturn cf_check vmx_do_resume(void); void cf_check vmx_vlapic_msr_changed(struct vcpu *v); void vmx_realmode(struct cpu_user_regs *regs); -void vmx_update_debug_state(struct vcpu *v); void vmx_update_exception_bitmap(struct vcpu *v); void vmx_update_cpu_exec_control(struct vcpu *v); void vmx_update_secondary_exec_control(struct vcpu *v); --=20 2.37.2