From patchwork Mon Feb 26 11:07:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13571973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27481C54E49 for ; Mon, 26 Feb 2024 11:08:23 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 Just like it's done for INDIRECT_THUNK and SHADOW_PAGING. Reported-by: Jan Beulich Signed-off-by: Roger Pau Monné 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" : ""); /* Compiled-in support which pertains to mitigations. */ - if ( IS_ENABLED(CONFIG_INDIRECT_THUNK) || IS_ENABLED(CONFIG_SHADOW_PAGING) ) + if ( IS_ENABLED(CONFIG_INDIRECT_THUNK) || IS_ENABLED(CONFIG_SHADOW_PAGING) || + 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"); From patchwork Mon Feb 26 11:07:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13571975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27D06C48BF6 for ; Mon, 26 Feb 2024 11:08:28 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 The current logic to handle the BRANCH_HARDEN option will report it as enabled even when build-time disabled. Fix this by only allowing the option to be set when support for it is built into Xen. Fixes: 2d6f36daa086 ('x86/nospec: Introduce CONFIG_SPECULATIVE_HARDEN_BRANCH') Signed-off-by: Roger Pau Monné 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 = -1; int8_t __ro_after_init opt_ibpb_ctxt_switch = -1; int8_t __read_mostly opt_eager_fpu = -1; int8_t __read_mostly opt_l1d_flush = -1; -static bool __initdata opt_branch_harden = true; +static bool __initdata opt_branch_harden = + IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH); 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 = parse_boolean("l1d-flush", s, ss)) >= 0 ) opt_l1d_flush = val; else if ( (val = parse_boolean("branch-harden", s, ss)) >= 0 ) - opt_branch_harden = val; + { + if ( IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH) ) + opt_branch_harden = val; + else + { + no_config_param("SPECULATIVE_HARDEN_BRANCH", "spec-ctrl", s, + ss); + rc = -EINVAL; + } + } else if ( (val = parse_boolean("srb-lock", s, ss)) >= 0 ) opt_srb_lock = val; else if ( (val = parse_boolean("unpriv-mmio", s, ss)) >= 0 ) From patchwork Mon Feb 26 11:07:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13571976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0061C54E49 for ; Mon, 26 Feb 2024 11:08:33 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 Attempt to provide a more helpful error message when the user attempts to set spec-ctrl=bti-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é 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=ibpb-entry`. -If Xen was compiled with INDIRECT_THUNK support, `bti-thunk=` can 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` gadget, minimal overhead), and -`lfence` (an `lfence; jmp *%reg` gadget). +If Xen was compiled with `CONFIG_INDIRECT_THUNK` support, `bti-thunk=` can 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` gadget, +minimal overhead), and `lfence` (an `lfence; jmp *%reg` gadget). On hardware supporting IBRS (Indirect Branch Restricted Speculation), the `ibrs=` option can be used to force or prevent Xen using the feature itself. 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 += 10; - if ( !cmdline_strcmp(s, "retpoline") ) + if ( !IS_ENABLED(CONFIG_INDIRECT_THUNK) ) + { + no_config_param("INDIRECT_THUNK", "spec-ctrl=bti-thunk", s, ss); + rc = -EINVAL; + } + else if ( !cmdline_strcmp(s, "retpoline") ) opt_thunk = THUNK_RETPOLINE; else if ( !cmdline_strcmp(s, "lfence") ) opt_thunk = THUNK_LFENCE; From patchwork Mon Feb 26 11:07:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13571977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B067AC48BF6 for ; Mon, 26 Feb 2024 11:08:36 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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é 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"); /* 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 == THUNK_NONE ? "N/A" : - thunk == THUNK_RETPOLINE ? "RETPOLINE" : - thunk == THUNK_LFENCE ? "LFENCE" : - thunk == THUNK_JMP ? "JMP" : "?", + printk(" Xen settings: %s%sSPEC_CTRL: %s%s%s%s%s, Other:%s%s%s%s%s%s\n", + thunk != THUNK_NONE ? "BTI-Thunk: " : "", + thunk == THUNK_NONE ? "" : + thunk == THUNK_RETPOLINE ? "RETPOLINE, " : + thunk == THUNK_LFENCE ? "LFENCE, " : + thunk == 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-",