[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] x86: Activate Data Operand Invariant Timing Mode by default
- To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Wed, 5 Oct 2022 12:20:20 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tqfDtY1zyJirZeBvXhIJQBhuWBd58J1TjVocdM9ECA0=; b=cuoklVYa/2utu7GvFyGayFDdow6QKiJIHAHny5qY8wojzklf6/iPFKbpZhnhvQGHp6HXax1olS+0gIDx529fYg2gEq/18NFRjaYC1AjX8OjFIX9jQOjuVC0AKhhLofsKKrSuJXOQ+3yCpZJqB0zrZz229enLNvFkurmZMVgvu2Kw1qyKmut91nkJ8aoKY/jWxVrZKsny859ufpBZGNMVQ4QhJkCe2Yws8f45CW77NwjyWTUlHyi/kSAAKD+SyGLkH8RXbGRX/se/oyNlB+doyqMqclSZPuNh84vaZ1DFB8WK7zDzHA4xmXsql9AkVhwQUm2QG2jUNM2wO5rG657UlA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ak1s+zygFGg9jAXsm8NAhPXsBpqHU5ve20HVBalcGHTT/2urm4RWpRUx4Orz89L1LBF+5vHD5jePBKUcPbsssx5cV/ogtNRuyHHWSjr9thqurKItw1wqmNk++gtDCsIne2Ez7NuLEZc3EKVpUBEF1jSpbbps17KTqguyyLbMFKNPH0WDydyz8BJo4Q4vra6aCUkJ93QST+AKQDrlcMs4qHflwEZhDV1/KeR8UsgCBPiMp5eO2Tz/f+8J3JfMaGETKPyRAisOfjq+Oxmu5GN4tucRQBXKYb7YHhqQKCD9bnt0cX/vElTgDLx7+0z5qiVt/Cf50NjpzS8cvP3fqXNOvw==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Wed, 05 Oct 2022 10:20:47 +0000
- Ironport-data: A9a23:QLOMPK9iXOTiKbOxBUk5DrUDdX+TJUtcMsCJ2f8bNWPcYEJGY0x3y WoeXjyGP62KM2TxfdB1Po2y9hxQu5DTm9dgHlM4qns8E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOC6UIYoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGj9Suv/rRC9H5qyo4mpA5gFmPJingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0tpIJ3NL9 6MJEhpXMQzciL2EzqC/SuY506zPLOGzVG8ekldJ6GmDSM0AGNXESaiM4sJE1jAtgMwIBezZe 8cSdTtoalLHfgFLPVAUTpk5mY9EhFGmK2Ee9A3T+PVxvzG7IA9ZidABNPLPfdOHX4NNl1uwr WPa5WXpRBodMbRzzBLVqyv32rWRxUsXXqoCGoTmy8Axn2HQ5WYjEzdKfAuch7623xvWt9V3b hZ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WncrmV9uWDIbRMF8fKxDC6z 04LXXOGPk=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Tue, Oct 04, 2022 at 05:08:10PM +0100, Andrew Cooper wrote:
> Intel IceLake and later CPUs have microarchitectural behaviours which cause
> data-dependent timing behaviour. This is not an issue for 99% of software,
> but it is a problem for cryptography routines. On these CPUs, a new
> architectural feature, DOITM, was retrofitted in microcode.
>
> For now, Xen can't enumerate DOITM to guest kernels; getting this working is
> still in progress. The consequence is that guest kernels will incorrectly
> conclude that they are safe.
>
> To maintain the safety of current software, activate DOITM unilaterally. This
> will be relaxed in the future when we can enumerate the feature properly to
> guests.
>
> As an emergency stopgap, this behaviour can be disabled by specifying
> `cpuid=no-doitm` on Xen's command line, but is not guaranteed ABI moving
> forward.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> ---
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> CC: Wei Liu <wl@xxxxxxx>
> CC: Henry Wang <Henry.Wang@xxxxxxx>
> CC: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> CC: Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>
> ---
> xen/arch/x86/cpu/common.c | 29 +++++++++++++++++++++++++++++
> xen/arch/x86/cpuid.c | 5 +++++
> xen/arch/x86/include/asm/processor.h | 2 ++
> xen/tools/gen-cpuid.py | 2 ++
> 4 files changed, 38 insertions(+)
>
> diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
> index 0412dbc915e5..8c46a4db430a 100644
> --- a/xen/arch/x86/cpu/common.c
> +++ b/xen/arch/x86/cpu/common.c
> @@ -209,6 +209,34 @@ void ctxt_switch_levelling(const struct vcpu *next)
> alternative_vcall(ctxt_switch_masking, next);
> }
>
> +bool __ro_after_init opt_doitm = true;
> +
> +static void doitm_init(void)
> +{
> + uint64_t val;
> +
> + if ( !opt_doitm || !cpu_has_arch_caps )
> + return;
> +
> + rdmsrl(MSR_ARCH_CAPABILITIES, val);
> + if ( !(val & ARCH_CAPS_DOITM) )
> + return;
> +
> + /*
> + * We are currently unable to enumerate MSR_ARCH_CAPS to guest. As a
> + * consequence, guest kernels will believe they're safe even when they
> are
> + * not.
> + *
> + * Until we can enumerate DOITM properly for guests, set it unilaterally.
> + * This prevents otherwise-correct crypto from becoming vulnerable to
> + * timing sidechannels.
> + */
> +
> + rdmsrl(MSR_UARCH_MISC_CTRL, val);
> + val |= UARCH_CTRL_DOITM;
> + wrmsrl(MSR_UARCH_MISC_CTRL, val);
Is it possible for the firmware to have enabled DOITM and Xen needing to
clear it if !opt_doitm?
Thanks, Roger.
|