From patchwork Fri Feb 23 12:06:14 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: 13568968 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 6E87DC5478C for ; Fri, 23 Feb 2024 12:06:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.684817.1064962 (Exim 4.92) (envelope-from ) id 1rdUK1-0007A9-MW; Fri, 23 Feb 2024 12:06:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 684817.1064962; Fri, 23 Feb 2024 12:06:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rdUK1-00079y-JZ; Fri, 23 Feb 2024 12:06:33 +0000 Received: by outflank-mailman (input) for mailman id 684817; Fri, 23 Feb 2024 12:06:32 +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 1rdUK0-0006xc-B7 for xen-devel@lists.xenproject.org; Fri, 23 Feb 2024 12:06:32 +0000 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [2a00:1450:4864:20::12e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fae8aaf4-d243-11ee-8a57-1f161083a0e0; Fri, 23 Feb 2024 13:06:31 +0100 (CET) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-51197ca63f5so1247513e87.1 for ; Fri, 23 Feb 2024 04:06:30 -0800 (PST) Received: from localhost ([213.195.118.74]) by smtp.gmail.com with ESMTPSA id kf3-20020a056214524300b0068fe3170b0esm88772qvb.11.2024.02.23.04.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 04:06:29 -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: fae8aaf4-d243-11ee-8a57-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1708689990; x=1709294790; 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=jp86iadmfvDn3kY5s/NcHvROQQfc/eEcQpXnyfCy0t8=; b=KJhAtRRhazOY55NyMGHBOdbs6ygrXx1bV746XYR78n0cdBDHgF07du3mwcOZwQUBuq 9KvFaOEe0Q8UDpIzflWzBScbmdrr0cOd3A7EVsrzIalnfzF5rUy/SaOdISVy+j4I+NVP gSaLTTUVF7M8Xj34OAPZMilwzOZIKCLEyoJU0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708689990; x=1709294790; 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=jp86iadmfvDn3kY5s/NcHvROQQfc/eEcQpXnyfCy0t8=; b=lgTvdhFV0PFsjXyhIXTy2hKZTmtGZ03/VUXVLFa7sHiCuLXWQ5RdDvzxSVcndrWiGF FJ5FPcID8sq2pmYXO7eoCjy5p4r83cXdKhqJSyd/wiySGMvgq5/PAfO7GdHPdlgL1BG4 xA6vb+htrVyJE/t8LmvMqsPFfkasjxhaw0TZzazQyY4wE2Rb5ufqIHU5oarhUgHsELMq zyZNaLod5lIy1hSv0xs9NSH18aHpCHivHV+hTnnrpXiYEt4V+JXFoppPSGJ6zrcHmRXW PqH63gFbawCg/rYHZq1Q6OJwDR/EKizTqh0HE2vEoAiicjA8galM/w2WB5AYwCeGHLJf jNTg== X-Gm-Message-State: AOJu0YxcuXItC0qoOPvsJMyTbdjVxaqc2xLFvKfF2s6ZObhyqAdxgc97 iQNaqYw3NDzvZtY/q2eRrSSmX7wDL4jKFoA/6ZrNB4/ZNsob0VC+d4hvCITp4N6nw5KmAWKLs3y C X-Google-Smtp-Source: AGHT+IGsFXYkQjVxuWz/a4tHq/rp5C8ES+MZ65o6SqjJB1Uhw3VOCrsFHqjMlvc4Rg8ZC/gh6YiWPw== X-Received: by 2002:a05:6512:3194:b0:512:b90f:fc4e with SMTP id i20-20020a056512319400b00512b90ffc4emr1603543lfe.46.1708689990023; Fri, 23 Feb 2024 04:06:30 -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 v2 1/3] xen/cmdline: fix printf format specifier in no_config_param() Date: Fri, 23 Feb 2024 13:06:14 +0100 Message-ID: <20240223120616.73503-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240223120616.73503-1-roger.pau@citrix.com> References: <20240223120616.73503-1-roger.pau@citrix.com> MIME-Version: 1.0 '*' sets the width field, which is the minimum number of characters to output, but what we want in no_config_param() is the precision instead, which is '.*' as it imposes a maximum limit on the output. Fixes: 68d757df8dd2 ('x86/pv: Options to disable and/or compile out 32bit PV support') Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Changes since v1: - New in this version. --- xen/include/xen/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/xen/param.h b/xen/include/xen/param.h index 9170455cde5c..6442a92aff8e 100644 --- a/xen/include/xen/param.h +++ b/xen/include/xen/param.h @@ -191,7 +191,7 @@ static inline void no_config_param(const char *cfg, const char *param, { int len = e ? ({ ASSERT(e >= s); e - s; }) : strlen(s); - printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%*s' setting\n", + printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%.*s' setting\n", cfg, param, len, s); } From patchwork Fri Feb 23 12:06:15 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: 13568969 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 CAD83C54798 for ; Fri, 23 Feb 2024 12:06:45 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.684818.1064972 (Exim 4.92) (envelope-from ) id 1rdUK4-0007Rz-Vw; Fri, 23 Feb 2024 12:06:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 684818.1064972; Fri, 23 Feb 2024 12:06:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rdUK4-0007Rs-Qt; Fri, 23 Feb 2024 12:06:36 +0000 Received: by outflank-mailman (input) for mailman id 684818; Fri, 23 Feb 2024 12:06:35 +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 1rdUK3-0006di-36 for xen-devel@lists.xenproject.org; Fri, 23 Feb 2024 12:06:35 +0000 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [2a00:1450:4864:20::22c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fc67deed-d243-11ee-98f5-efadbce2ee36; Fri, 23 Feb 2024 13:06:33 +0100 (CET) Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2d2505352e6so7990361fa.3 for ; Fri, 23 Feb 2024 04:06:33 -0800 (PST) Received: from localhost ([213.195.118.74]) by smtp.gmail.com with ESMTPSA id d4-20020a056214184400b0068f97928376sm4150972qvy.17.2024.02.23.04.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 04:06:31 -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: fc67deed-d243-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1708689992; x=1709294792; 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=/ja3agDhYaU4Xo2ppsREM/G2NT1u2hAe6akh+/GuxDM=; b=Dx95aEgYlAbBARDUcKB6d7uEqiRX2L8I2wOMelk01Ajl/Y/LJKoy6vcPZ6nqI++VDm B0YmeGJPTiBfvTa/ig71JzN0vixWxgbt5ylY5bK/veZ85S8h+AfgK8RFuPwj6h2Hars/ 2v684NRfXATlbIsNk36tz0bWFitnKnc11fT1g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708689992; x=1709294792; 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=/ja3agDhYaU4Xo2ppsREM/G2NT1u2hAe6akh+/GuxDM=; b=tmD8EYunH32SQuQOnr+DYy5Bv9NDB/2VDmmCCR3W6myXCBbrOL42VzV8sF/vBITBNm CDPyl8UQq/VwUMrhht7xRDHqWgam5BDpOelYFv5wVUmpCRYQlRWEtY+gf9cVrnJu9lWL YkzVZBDKVs9Mn2+/pKiXL9ao9U0IBI41wpV5fTx94UAbcHkXOCRR2ymiu9gWL5CTCpPl 0JuTuIdWnTcWubDOdJWzB/Bbm6OGrB+mnOfyVC6D/+QJzvK4DsF6YcZS4K+KWUUupG1R 6SJGUwKTcwtdHgfrdXKKiErz3A68mHFxh35SFZpiwA7XPEQZQPiQ8yz/WxibptTgbADu UbdQ== X-Gm-Message-State: AOJu0YyxM6poQZ0slfM5QpXnZH/nX8S5pKeWyBJA1o97aP504BqMOdTv BSHwpcjsW7U4z3LuByAvPoXFcR0BZda064q2y3Q+YHqmd/vOONk+eB8s+MCF+/5Ffp4gGPiFbjX Q X-Google-Smtp-Source: AGHT+IF0k4Kr9lbT9FetBX+abq3S57WnQWAFi/UWuRO0TO+qnTkBGj9QAvYwkgJaW9/nk/eZloIAOQ== X-Received: by 2002:ac2:4ece:0:b0:512:e051:ac2c with SMTP id p14-20020ac24ece000000b00512e051ac2cmr1167099lfr.3.1708689992373; Fri, 23 Feb 2024 04:06:32 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v2 2/3] x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled Date: Fri, 23 Feb 2024 13:06:15 +0100 Message-ID: <20240223120616.73503-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240223120616.73503-1-roger.pau@citrix.com> References: <20240223120616.73503-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é --- Changes since v1: - Use no_config_param(). --- xen/arch/x86/spec_ctrl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c index 421fe3f640df..4ce8a7a0b8ef 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,14 @@ 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 ) + { +#ifdef CONFIG_SPECULATIVE_HARDEN_BRANCH opt_branch_harden = val; +#else + no_config_param("SPECULATIVE_HARDEN_BRANCH", "spec-ctrl", s, ss); + rc = -EINVAL; +#endif + } 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 Fri Feb 23 12:06:16 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: 13568970 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 F0A20C5478C for ; Fri, 23 Feb 2024 12:06:45 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.684819.1064982 (Exim 4.92) (envelope-from ) id 1rdUK7-0007jV-64; Fri, 23 Feb 2024 12:06:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 684819.1064982; Fri, 23 Feb 2024 12:06: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 1rdUK7-0007jJ-3G; Fri, 23 Feb 2024 12:06:39 +0000 Received: by outflank-mailman (input) for mailman id 684819; Fri, 23 Feb 2024 12:06:37 +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 1rdUK5-0006di-Pc for xen-devel@lists.xenproject.org; Fri, 23 Feb 2024 12:06:37 +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 fdef2b12-d243-11ee-98f5-efadbce2ee36; Fri, 23 Feb 2024 13:06:36 +0100 (CET) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-512bde3d197so210620e87.0 for ; Fri, 23 Feb 2024 04:06:36 -0800 (PST) Received: from localhost ([213.195.118.74]) by smtp.gmail.com with ESMTPSA id da35-20020a05620a362300b007854018044bsm6336939qkb.134.2024.02.23.04.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 04:06:34 -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: fdef2b12-d243-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1708689995; x=1709294795; 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=5cdfP1drv1LQ9YGslYJKltpSCLlPkSQYqQfve8zYol4=; b=WzJmNMYr1BCm1TZv+pfQ6eJYyox7xB7bTNJP7rUZskBurArWF4jllYZoEZWUvCIdpN RdhvrTJqNQQQl7wUGdFqbFwI9XgEFLJCqIX7I3B/HgL/2rgv0W32zUwX6kVOkoeOenum RL82WESEaMu/47eUo1R5KUOPzINgJ/v/xeLbk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708689995; x=1709294795; 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=5cdfP1drv1LQ9YGslYJKltpSCLlPkSQYqQfve8zYol4=; b=e8+8SNnST+zyTmWp4D2bttlPCkudrecNMD2zXbzYtJwHgehVvVMPDfsnatkNQEWv/r oq+B14tQr9DnZYv6YKWXHo0UdDboVD1Qtj44GwctKe8w/7KbQzlbXaFS+YvIaGjzrnx1 ByCRwlNvIV6C9cuoKCUi2ETbzg8wx6byuQE96DaUQ36RPg68CifXrhggFLaaCa0KCOv/ Efo7rb4EqNb5xx2H/dRQYwR6us3TWl9fYL0Uqz3+RiLSnTfpqZS2VexSyeXek7tbx7EP wOVfUqu36hGZzsX/WQN1N9rfvnKK9QKsotTQCwslwu03NaaDhYoBQdRpFZlh/DG1cAmd BIPw== X-Gm-Message-State: AOJu0YxJTH1aBuuAeamw18EwEVAic0DkHeT85nPJUpncYP1UhZ/u8Rye fCLWPwegedebUlNfquXRGTC+IyFyvZFXPkq3naV4As01yl+fQaTQ9vzOcjktR3Mb/cuCdOjKsFL Y X-Google-Smtp-Source: AGHT+IHpeNl7z21jCtIKBCr1pJW/x8CWDv/TpSnAFd34Glij7WpFsufIBx3xHtkP91uwcHGLYJlfrw== X-Received: by 2002:a19:5f08:0:b0:512:d689:51cb with SMTP id t8-20020a195f08000000b00512d68951cbmr1104193lfb.26.1708689994947; Fri, 23 Feb 2024 04:06:34 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v2 3/3] x86/spec: fix INDIRECT_THUNK option to only be set when build-enabled Date: Fri, 23 Feb 2024 13:06:16 +0100 Message-ID: <20240223120616.73503-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240223120616.73503-1-roger.pau@citrix.com> References: <20240223120616.73503-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. Reported-by: Andrew Cooper Signed-off-by: Roger Pau Monné --- Changes since v1: - New in this version. --- xen/arch/x86/spec_ctrl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c index 4ce8a7a0b8ef..f3432f1a6c80 100644 --- a/xen/arch/x86/spec_ctrl.c +++ b/xen/arch/x86/spec_ctrl.c @@ -239,6 +239,7 @@ static int __init cf_check parse_spec_ctrl(const char *s) /* Xen's speculative sidechannel mitigation settings. */ else if ( !strncmp(s, "bti-thunk=", 10) ) { +#ifdef CONFIG_INDIRECT_THUNK s += 10; if ( !cmdline_strcmp(s, "retpoline") ) @@ -249,6 +250,10 @@ static int __init cf_check parse_spec_ctrl(const char *s) opt_thunk = THUNK_JMP; else rc = -EINVAL; +#else + no_config_param("INDIRECT_THUNK", "spec-ctrl", s, ss); + rc = -EINVAL; +#endif } /* Bits in MSR_SPEC_CTRL. */