From nobody Sun May 12 08:53:42 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=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1708945711; cv=none; d=zohomail.com; s=zohoarc; b=Z8lWBgVnDPW6SfZiYYx1YQ8j2AT0ONpUpUK2wI5Wm1iiarc6n56SmyLfuI4DaxIjRfYcrIHIY3zrBI/1wRFYY9SObKmadH/eGgIhHvqRKcd1raZmfuXzCJOrpK9NdekcOZeV8rt+37aYinCC1McfQ4AiOXejZbGRZglaYYEdlIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708945711; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JwcqS4buxW/Jeygm8zvIbxwG10HttMJtYAWj5OZTXl0=; b=AdbbJckRnh0KfVTN6rVAl2mrBSzUtTWZaxTwETHbU/arfdR2hsXSxNNbSQ2M7ihgqkJ3KT/AQs08tlanZfOefq5FXcDjLZMo/sQmQbCkv8CoEpcCVGeTHfvXjGlcyz4y40L/kdDPslG94+Ujd/7giQpsijsNpP2wjFEnHF1J+X0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1708945711441774.1587832603079; Mon, 26 Feb 2024 03:08:31 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.685459.1066213 (Exim 4.92) (envelope-from ) id 1reYqC-0002mF-1W; Mon, 26 Feb 2024 11:08:12 +0000 Received: by outflank-mailman (output) from mailman id 685459.1066213; Mon, 26 Feb 2024 11:08:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1reYqB-0002m8-Td; Mon, 26 Feb 2024 11:08:11 +0000 Received: by outflank-mailman (input) for mailman id 685459; Mon, 26 Feb 2024 11:08:11 +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 1reYqB-0002Xk-7v for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 11:08:11 +0000 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [2a00:1450:4864:20::12a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 530829cc-d497-11ee-98f5-efadbce2ee36; Mon, 26 Feb 2024 12:08:09 +0100 (CET) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-512aafb3ca8so2794424e87.3 for ; Mon, 26 Feb 2024 03:08:09 -0800 (PST) Received: from localhost ([213.195.118.74]) by smtp.gmail.com with ESMTPSA id ma6-20020a0562145b0600b0068fa5e5c245sm2789775qvb.84.2024.02.26.03.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 03:08:08 -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: 530829cc-d497-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1708945689; x=1709550489; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JwcqS4buxW/Jeygm8zvIbxwG10HttMJtYAWj5OZTXl0=; b=ZziypYdtto2mnD9xS444oMHwY/08n7H+rCSLTqnKJ7dlehlZZ6+Rtvr7AVUEngYHRK h5jElp6SQiyQqSioSZOST7oIiMO9yAXrbfU42ayN6Isoi+afYEaGqKKvtKMqHrdaNI+Q bYDWuPLzGzqI+02WXicdtzBeJfdCWHfJOyamU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708945689; x=1709550489; 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=JwcqS4buxW/Jeygm8zvIbxwG10HttMJtYAWj5OZTXl0=; b=YTan8m1+VGzodByfiwu1A9slrzg7QmqsRvKpCWH4u+bO+FJTljcYRAyqntIQZilDTI Qk3SHMsM8WcIU7EP9L39faLR4QeQJVsYDdy0fc/MJivnZnj5oJSNpYImvVH5xmj62TLY U6csZJDJcVAxoNbzlGhB0mvrscvHoVY02ZGvTSx5Key0x/N1nLp2/FIju4U61hsI26a1 5V+iBTJLlBNCtrkGYRubdjSy7oduodL9I9mSzu3fmrpr8eiEJEDBy7ZHKMItpesmMTaI 6RyX93zLRJUpagsPVNJ4b6BZNI+qqXhrID6758aYEtPSRsq7ypf8aiRSb4j4aPOc09SO Oqiw== X-Gm-Message-State: AOJu0Yz4Pdv2YQB7YVuJb8DudW9QjMZS+1cszMH8KW2b1AiDOkScCwuE wSIRMWJLFVIbU6CHzLMJvIWoaUENJC6sZbCoForJlAAa8zpeH0CMYZloBzkGacDt+7JPJnZtAu/ A X-Google-Smtp-Source: AGHT+IEckDKUWpABW+/YnVGbsKMeCnsqI4GOJxHp/u6i3Fib9QKC799WoK3U/L4+dpF6VaORefjJrw== X-Received: by 2002:a05:6512:3f04:b0:512:d5c7:60d9 with SMTP id y4-20020a0565123f0400b00512d5c760d9mr5437819lfa.3.1708945689250; Mon, 26 Feb 2024 03:08:09 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v3 1/4] x86/spec: print the built-in SPECULATIVE_HARDEN_* options Date: Mon, 26 Feb 2024 12:07:45 +0100 Message-ID: <20240226110748.80254-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240226110748.80254-1-roger.pau@citrix.com> References: <20240226110748.80254-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1708945713862100001 Just like it's done for INDIRECT_THUNK and SHADOW_PAGING. Reported-by: Jan Beulich Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since v2: - New in this version. --- xen/arch/x86/spec_ctrl.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c index 421fe3f640df..9f5ed8772533 100644 --- a/xen/arch/x86/spec_ctrl.c +++ b/xen/arch/x86/spec_ctrl.c @@ -466,13 +466,25 @@ static void __init print_details(enum ind_thunk thunk) (e21a & cpufeat_mask(X86_FEATURE_SBPB)) ? " SBPB" = : ""); =20 /* Compiled-in support which pertains to mitigations. */ - if ( IS_ENABLED(CONFIG_INDIRECT_THUNK) || IS_ENABLED(CONFIG_SHADOW_PAG= ING) ) + if ( IS_ENABLED(CONFIG_INDIRECT_THUNK) || IS_ENABLED(CONFIG_SHADOW_PAG= ING) || + IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_ARRAY) || + IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH) || + IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_GUEST_ACCESS) ) printk(" Compiled-in support:" #ifdef CONFIG_INDIRECT_THUNK " INDIRECT_THUNK" #endif #ifdef CONFIG_SHADOW_PAGING " SHADOW_PAGING" +#endif +#ifdef CONFIG_SPECULATIVE_HARDEN_ARRAY + " SPECULATIVE_HARDEN_ARRAY" +#endif +#ifdef CONFIG_SPECULATIVE_HARDEN_BRANCH + " SPECULATIVE_HARDEN_BRANCH" +#endif +#ifdef CONFIG_SPECULATIVE_HARDEN_GUEST_ACCESS + " SPECULATIVE_HARDEN_GUEST_ACCESS" #endif "\n"); =20 --=20 2.43.0 From nobody Sun May 12 08:53:42 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=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1708945718; cv=none; d=zohomail.com; s=zohoarc; b=N8hM3he9wS/L599XIrxYtFqxU4DixWWXIIaIYULyFVIz/vEJBaPQ4CJCmOkDuymde4mPwca4M5MAOzvewQM8ayHvi889qG8zLiRenKwrdTUIm21h/LSXM5/STKOyknllO8vy/7PayTyJ1mkxoQsoxXAZ0tEernFRls2qIivnmCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708945718; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FaG0bjtk7lVLtBaV15USC2Ji0PDyjB7kZA+T0Bke/cE=; b=VH81sCy/klfmJu+7k+I8doOcdJ5SlGZUSifuEgZklr0+wCQljqlqZmzw5VPJVJv6IzrVfnvXtnjhb1ixMkKT3vL4gj4AH2Z+pRp8UoE5sVHfjuPTSDbPZuC/GFIHs1Ps2vU/+6ENq7QdbcucIofo6PFM2HCaY1BSdg3aXnZuEhg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1708945718718178.69603756840172; Mon, 26 Feb 2024 03:08:38 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.685460.1066223 (Exim 4.92) (envelope-from ) id 1reYqK-00036l-8G; Mon, 26 Feb 2024 11:08:20 +0000 Received: by outflank-mailman (output) from mailman id 685460.1066223; Mon, 26 Feb 2024 11:08:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1reYqK-00036c-4L; Mon, 26 Feb 2024 11:08:20 +0000 Received: by outflank-mailman (input) for mailman id 685460; Mon, 26 Feb 2024 11:08:18 +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 1reYqI-00035d-UT for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 11:08:18 +0000 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [2a00:1450:4864:20::12f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 583520df-d497-11ee-8a58-1f161083a0e0; Mon, 26 Feb 2024 12:08:18 +0100 (CET) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-5129cdae3c6so3760009e87.1 for ; Mon, 26 Feb 2024 03:08:18 -0800 (PST) Received: from localhost ([213.195.118.74]) by smtp.gmail.com with ESMTPSA id fu38-20020a05622a5da600b0042e09c6b82dsm2307513qtb.24.2024.02.26.03.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 03:08:17 -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: 583520df-d497-11ee-8a58-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1708945697; x=1709550497; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FaG0bjtk7lVLtBaV15USC2Ji0PDyjB7kZA+T0Bke/cE=; b=GjQqKov/KDH+XwcOwCVE/7RKe2qdo3GOuUFaqPVBNajMNRN7nNnkT71ZCH722hGP85 e5B/sLGa7nGjqtlic5N3wkSNH7ISghBIwWe1vat0IUGDjA0qbAUD9Tntk2tipt6cAyuV f8gjviYzs52kHkIYmsVk5FCfjcJEyZyeYqJeE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708945697; x=1709550497; 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=FaG0bjtk7lVLtBaV15USC2Ji0PDyjB7kZA+T0Bke/cE=; b=QOslzMYtuyC95td2cPoltgsqdPkzPUKnwhccYw8Y4uf/pv+jpj0lZMp5Gd/3RIG03H Ljta99vfh9lPjQguqW11XI7HuXRFI9F9a3bjkUFyOih6WEvk7x3acAN0BPF7NrvPlhy5 Obzs4YXUrd6LWXfs5QEKfNHiAxfsSeG3fq/Ra4OqENl1x7VH3ehwCbNY5Vk/aEf2cMMV 1sY6VJgO9i5q88Dj4RdRbkNH+qGfDYiqkv+w39X5ZGuWvMZ2eYorY29GhGFf5qPw0gBw 0eTOng33W47YMMSrMLkqSMnI2ngE1haXD547D+45mwW4aztdg3sPQ1c1Fblf+c+xl1E5 drhg== X-Gm-Message-State: AOJu0YzuQIOIZIFaEmbIKQ+KDp9kUC+8w5AtXmWNJXbRNqy+/fBlWG8v MgHpu0cS2Ef27jsSIbeohPhU6TcnuvPxshMZnCqEyk5K++m4JNMgA9b0P2cFbG0Qm/qc8PRUkeK z X-Google-Smtp-Source: AGHT+IFPk5TtQYJAUBadwwKI9KWtZ6T+v6n4ml3De9qHFqqBKDwnBmu3W5XhiQJ1B4vi/ShY2A3JTQ== X-Received: by 2002:ac2:4c49:0:b0:512:ec53:5915 with SMTP id o9-20020ac24c49000000b00512ec535915mr4959845lfk.15.1708945697370; Mon, 26 Feb 2024 03:08:17 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v3 2/4] x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled Date: Mon, 26 Feb 2024 12:07:46 +0100 Message-ID: <20240226110748.80254-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240226110748.80254-1-roger.pau@citrix.com> References: <20240226110748.80254-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1708945720663100001 The current logic to handle the BRANCH_HARDEN option will report it as enab= led even when build-time disabled. Fix this by only allowing the option to be s= et when support for it is built into Xen. Fixes: 2d6f36daa086 ('x86/nospec: Introduce CONFIG_SPECULATIVE_HARDEN_BRANC= H') Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since v2: - Use IS_ENABLED() in the parser. Changes since v1: - Use no_config_param(). --- xen/arch/x86/spec_ctrl.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c index 9f5ed8772533..5fae80774519 100644 --- a/xen/arch/x86/spec_ctrl.c +++ b/xen/arch/x86/spec_ctrl.c @@ -50,7 +50,8 @@ static int8_t __initdata opt_psfd =3D -1; int8_t __ro_after_init opt_ibpb_ctxt_switch =3D -1; int8_t __read_mostly opt_eager_fpu =3D -1; int8_t __read_mostly opt_l1d_flush =3D -1; -static bool __initdata opt_branch_harden =3D true; +static bool __initdata opt_branch_harden =3D + IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH); =20 bool __initdata bsp_delay_spec_ctrl; uint8_t __read_mostly default_xen_spec_ctrl; @@ -268,7 +269,16 @@ static int __init cf_check parse_spec_ctrl(const char = *s) else if ( (val =3D parse_boolean("l1d-flush", s, ss)) >=3D 0 ) opt_l1d_flush =3D val; else if ( (val =3D parse_boolean("branch-harden", s, ss)) >=3D 0 ) - opt_branch_harden =3D val; + { + if ( IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH) ) + opt_branch_harden =3D val; + else + { + no_config_param("SPECULATIVE_HARDEN_BRANCH", "spec-ctrl", = s, + ss); + rc =3D -EINVAL; + } + } else if ( (val =3D parse_boolean("srb-lock", s, ss)) >=3D 0 ) opt_srb_lock =3D val; else if ( (val =3D parse_boolean("unpriv-mmio", s, ss)) >=3D 0 ) --=20 2.43.0 From nobody Sun May 12 08:53:42 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=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1708945725; cv=none; d=zohomail.com; s=zohoarc; b=gGfxb+7kYXAe/D1uCaaDqmst8aR7xCyAXgXt2v3BF8IW/QC3e5aGggleRkpcUdAe+HF8WEGU2AnfzGLyQLLc0VXSPtucPYjyKoM3XbWWCmo3YPzQEKRkD3LIPtXr5McIC+OZj7udZ84+Hfs/xbHAU+S7lkFgEHPAl8eY7eW37N4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708945725; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zWSZ24uDxhCSDRWaKYJOr2WehsNuND623TZwFKk5HHU=; b=JBJkdV2ElsxopPUB7QWWtOvgTE3Qg4oFp09ZV3QiWk9jCasGXwuelxLK68RURTFoyEAaEbx3fj73pipVagtEXxPin5xquCvIT9AznNQqugbJdOCShN3oO0Vh3TXJPLo1rWVuFJazbj+PGx9TySMVSgs6vMWjJr9SlH5bT2palZ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 170894572505847.33757022305667; Mon, 26 Feb 2024 03:08:45 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.685461.1066232 (Exim 4.92) (envelope-from ) id 1reYqP-0003SV-Ea; Mon, 26 Feb 2024 11:08:25 +0000 Received: by outflank-mailman (output) from mailman id 685461.1066232; Mon, 26 Feb 2024 11:08:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1reYqP-0003SK-BW; Mon, 26 Feb 2024 11:08:25 +0000 Received: by outflank-mailman (input) for mailman id 685461; Mon, 26 Feb 2024 11:08:24 +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 1reYqO-0002Xk-2U for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 11:08:24 +0000 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [2a00:1450:4864:20::12b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5a9cc593-d497-11ee-98f5-efadbce2ee36; Mon, 26 Feb 2024 12:08:22 +0100 (CET) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-512f7332252so1722541e87.0 for ; Mon, 26 Feb 2024 03:08:22 -0800 (PST) Received: from localhost ([213.195.118.74]) by smtp.gmail.com with ESMTPSA id ld24-20020a056214419800b0068f455083fbsm2742951qvb.63.2024.02.26.03.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 03:08:21 -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: 5a9cc593-d497-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1708945701; x=1709550501; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zWSZ24uDxhCSDRWaKYJOr2WehsNuND623TZwFKk5HHU=; b=TcMy4VK5VBR+/SP4mO7gEKd0UgW1hminCLShU0J2lu6yzQQoI6OZG8fN24GmoJqEhL 6x8T+VK5oaghG/XcDPYjcfNfxaqWHKHuhQ51SaG/OyFurmpfHrVT3dFCWi3PTVtnX9Kh P2lKxxiV9xfYupovw/Q8BmdegVVpYokt1fYCE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708945701; x=1709550501; 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=zWSZ24uDxhCSDRWaKYJOr2WehsNuND623TZwFKk5HHU=; b=ShBSMwGYPZOUtIcmBJffzCNfDOx3W2jL6rrqYWhiiEN4MqKawGcaXIrxABwg1jr92h 3QMrwzpaUHHmVW89t9nPqt/PbjW9QFUqgMz+eJUrj5wdSqzMuXYfFuTE8Ue785gn8GSB Wwhg6VJRatzeyfWyjNLMDnpG+M8Ra1/QBKthX9tfN/qxeLac+oAaOMTDfn6G6cHguP5q gUlizzkcis40Pr5TaN6+wb0ysjOVTgvS2YAWBHDnpXP0i4AodIEaTIwKCEH0AtpdFU6F feRVOb9KgWx/dSBKtRxfDCvCHXNpk/9oux7nF4dtxOrMs7rFDv1mB8CLdvls6EEogAB5 50mw== X-Gm-Message-State: AOJu0YyMXC5qYg/p0nZxCIYnCsZAfp5rFiBG3sbzrsPLQ+/s2rTkzf7O DAGmVex/jRefkKMbOQ2+CrB2lrQyyitOZL5pRSIW+8RzOxyaJRcNfXcUWlU92ZqFg5fhe2f8icB + X-Google-Smtp-Source: AGHT+IGqLUlMwqmEZc3pqD5QmoarnCv1FcAFbGiWLBw2Z/t+HGZkzTaCjkDsRXX7aggBuRmHYwlyWw== X-Received: by 2002:a05:6512:3e0c:b0:512:b0a7:2943 with SMTP id i12-20020a0565123e0c00b00512b0a72943mr5349358lfv.5.1708945701487; Mon, 26 Feb 2024 03:08:21 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v3 3/4] x86/spec: fix INDIRECT_THUNK option to only be set when build-enabled Date: Mon, 26 Feb 2024 12:07:47 +0100 Message-ID: <20240226110748.80254-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240226110748.80254-1-roger.pau@citrix.com> References: <20240226110748.80254-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1708945725935100001 Attempt to provide a more helpful error message when the user attempts to s= et spec-ctrl=3Dbti-thunk option but the support is build-time disabled. While there also adjust the command line documentation to mention CONFIG_INDIRECT_THUNK instead of INDIRECT_THUNK. Reported-by: Andrew Cooper Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since v2: - Adjust documentation. - Use IS_ENABLED() instead of #ifdef. Changes since v1: - New in this version. --- docs/misc/xen-command-line.pandoc | 10 +++++----- xen/arch/x86/spec_ctrl.c | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index be76be8d5365..02896598df6f 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -2417,11 +2417,11 @@ guests to use. performance reasons dom0 is unprotected by default. If it is necessary = to protect dom0 too, boot with `spec-ctrl=3Dibpb-entry`. =20 -If Xen was compiled with INDIRECT_THUNK support, `bti-thunk=3D` can be use= d to -select which of the thunks gets patched into the `__x86_indirect_thunk_%re= g` -locations. The default thunk is `retpoline` (generally preferred), with t= he -alternatives being `jmp` (a `jmp *%reg` gadget, minimal overhead), and -`lfence` (an `lfence; jmp *%reg` gadget). +If Xen was compiled with `CONFIG_INDIRECT_THUNK` support, `bti-thunk=3D` c= an be +used to select which of the thunks gets patched into the +`__x86_indirect_thunk_%reg` locations. The default thunk is `retpoline` +(generally preferred), with the alternatives being `jmp` (a `jmp *%reg` ga= dget, +minimal overhead), and `lfence` (an `lfence; jmp *%reg` gadget). =20 On hardware supporting IBRS (Indirect Branch Restricted Speculation), the `ibrs=3D` option can be used to force or prevent Xen using the feature its= elf. diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c index 5fae80774519..ca82b9e41ccd 100644 --- a/xen/arch/x86/spec_ctrl.c +++ b/xen/arch/x86/spec_ctrl.c @@ -241,7 +241,12 @@ static int __init cf_check parse_spec_ctrl(const char = *s) { s +=3D 10; =20 - if ( !cmdline_strcmp(s, "retpoline") ) + if ( !IS_ENABLED(CONFIG_INDIRECT_THUNK) ) + { + no_config_param("INDIRECT_THUNK", "spec-ctrl=3Dbti-thunk",= s, ss); + rc =3D -EINVAL; + } + else if ( !cmdline_strcmp(s, "retpoline") ) opt_thunk =3D THUNK_RETPOLINE; else if ( !cmdline_strcmp(s, "lfence") ) opt_thunk =3D THUNK_LFENCE; --=20 2.43.0 From nobody Sun May 12 08:53:42 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=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1708945726; cv=none; d=zohomail.com; s=zohoarc; b=ZtVbaL/kwdtDIEvFnwYHXZu3Fr7BAtChM+zFeMr/6D0J//FmCq9rtr+JRU9krypiBXussBo7hLh6UwSJ2wAToYrRP6G3RfCWOcjwjPcutI3uGypT+vw3zvkryutAPmzs8IHUKQvn/pOtiuxHjROhmFFWN25yKDs/Kkb1rYhnqi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708945726; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=I2Df+PSqWP8Z0LteWDeQlgnr9scPhyhGzqXAiWsgtFg=; b=dPezV/AeTdO1wKNTJk2LP4ahrruE+95BJmRDiBP6qMn6zMQdma9vauPBCI8NsCtLYz9jnTOjZESg+3/IM0ONO36rXtlyFJ3ZorqHG4etHuyWwS5pjFNgK/Rgr8WD7ZWD1CP42CvvX1tWyXahAcPe3hfK84t5hmKPtbgqgER4UJY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17089457267581009.8834607445727; Mon, 26 Feb 2024 03:08:46 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.685462.1066242 (Exim 4.92) (envelope-from ) id 1reYqT-0003rF-Mk; Mon, 26 Feb 2024 11:08:29 +0000 Received: by outflank-mailman (output) from mailman id 685462.1066242; Mon, 26 Feb 2024 11:08:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1reYqT-0003qC-Ja; Mon, 26 Feb 2024 11:08:29 +0000 Received: by outflank-mailman (input) for mailman id 685462; Mon, 26 Feb 2024 11:08:28 +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 1reYqR-0002Xk-Un for xen-devel@lists.xenproject.org; Mon, 26 Feb 2024 11:08:27 +0000 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [2a00:1450:4864:20::12b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5cfb0afe-d497-11ee-98f5-efadbce2ee36; Mon, 26 Feb 2024 12:08:26 +0100 (CET) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-512f892500cso908892e87.3 for ; Mon, 26 Feb 2024 03:08:26 -0800 (PST) Received: from localhost ([213.195.118.74]) by smtp.gmail.com with ESMTPSA id bz8-20020ad44c08000000b0068fa89a5df6sm2764913qvb.124.2024.02.26.03.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 03:08:25 -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: 5cfb0afe-d497-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1708945706; x=1709550506; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I2Df+PSqWP8Z0LteWDeQlgnr9scPhyhGzqXAiWsgtFg=; b=LYowHfAL46cSddsX8MFdRfo8+6nFN+ulhfWopCXTsEFjX4bzTxcS5BOJsQ5hAxuNp4 G89C8XI0gywT8Zko3cQR69ZdMFUG+4wBtT8dJPfT8wyVACakHmA2ZvYsCOnmjXenyzPu R1FfkepzdA7BloLzrzJTC+hAWkFYERSy0Wi+k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708945706; x=1709550506; 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=I2Df+PSqWP8Z0LteWDeQlgnr9scPhyhGzqXAiWsgtFg=; b=GuszTtn1tQncMx8SCcb8hKcB79ix4u2EB1L3WXJd0GiG5Vprld0k9Ici9NhtEIHS8X VroDDQqxNUuys1RKgRL6kDHf5Z/K0PKXu2uyxjCcY1KSecuiOBBVNTvF2uTGpUn5epz1 p1l2qsuIcgKOLhG94apshhtU2KkjfjxszLwXclpgIcVKxbX9GCojBrczNSJxS5VvQaf8 h/WulDR6Qxk3mMM2Ils1i51TOJyDoyizcs523ncbNpLXZ8BhaObabm8bFTFnibMJ4D9P 2kNUP2POhmweK13vZ4Q3r7MKZKwkpD0xtowK0YfXYXDI3LuOJxE3ESkhRd5vQCjfhgAH HowA== X-Gm-Message-State: AOJu0YyHNDVfMS8wf4wiUMGNCzdFJrcxQb1WGzuTyfAZXlvHQkg9PPYh T+JBaPfpKbaDHDdnbG/nUBwgLXnnONr+dnSOh1A8fdkwU2aDtU+BXZ8xKQXZPQ5To+BX9+3eMhi 0 X-Google-Smtp-Source: AGHT+IGo89SrYhBxTQ17xHUpFuNstG50fnkQUUi+pj40NDP//NHqEV1iJBMH9pNUOb5sFudl/c3IzQ== X-Received: by 2002:a05:6512:2523:b0:512:d8ad:b454 with SMTP id be35-20020a056512252300b00512d8adb454mr4854028lfb.61.1708945705952; Mon, 26 Feb 2024 03:08:25 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v3 4/4] x86/spec: do not print thunk option selection if not built-in Date: Mon, 26 Feb 2024 12:07:48 +0100 Message-ID: <20240226110748.80254-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240226110748.80254-1-roger.pau@citrix.com> References: <20240226110748.80254-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1708945727902100003 Now that the thunk built-in enable is printed as part of the "Compiled-in support:" line, avoid printing anything in "Xen settings:" if the thunk is disabled at build time. Note the BTI-Thunk option printing is also adjusted to print a colon in the same way the other options on the line do. Requested-by: Jan Beulich Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since v3: - New in this version. --- xen/arch/x86/spec_ctrl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c index ca82b9e41ccd..e8b0e62adba4 100644 --- a/xen/arch/x86/spec_ctrl.c +++ b/xen/arch/x86/spec_ctrl.c @@ -504,11 +504,12 @@ static void __init print_details(enum ind_thunk thunk) "\n"); =20 /* Settings for Xen's protection, irrespective of guests. */ - printk(" Xen settings: BTI-Thunk %s, SPEC_CTRL: %s%s%s%s%s, Other:%s%= s%s%s%s%s\n", - thunk =3D=3D THUNK_NONE ? "N/A" : - thunk =3D=3D THUNK_RETPOLINE ? "RETPOLINE" : - thunk =3D=3D THUNK_LFENCE ? "LFENCE" : - thunk =3D=3D THUNK_JMP ? "JMP" : "?", + printk(" Xen settings: %s%sSPEC_CTRL: %s%s%s%s%s, Other:%s%s%s%s%s%s\= n", + thunk !=3D THUNK_NONE ? "BTI-Thunk: " : "", + thunk =3D=3D THUNK_NONE ? "" : + thunk =3D=3D THUNK_RETPOLINE ? "RETPOLINE, " : + thunk =3D=3D THUNK_LFENCE ? "LFENCE, " : + thunk =3D=3D THUNK_JMP ? "JMP, " : "?, ", (!boot_cpu_has(X86_FEATURE_IBRSB) && !boot_cpu_has(X86_FEATURE_IBRS)) ? "No" : (default_xen_spec_ctrl & SPEC_CTRL_IBRS) ? "IBRS+" : "IBRS-", --=20 2.43.0