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 C7C5FECAAD8 for ; Wed, 14 Sep 2022 06:36:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.406768.649133 (Exim 4.92) (envelope-from ) id 1oYM0K-0000r1-0G; Wed, 14 Sep 2022 06:36:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 406768.649133; Wed, 14 Sep 2022 06:36:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oYM0J-0000qu-Sy; Wed, 14 Sep 2022 06:36:11 +0000 Received: by outflank-mailman (input) for mailman id 406768; Wed, 14 Sep 2022 06:36:10 +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 1oYM0I-0000qo-N4 for xen-devel@lists.xenproject.org; Wed, 14 Sep 2022 06:36:10 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2059.outbound.protection.outlook.com [40.107.21.59]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8238a1ca-33f7-11ed-9761-273f2230c3a0; Wed, 14 Sep 2022 08:36:05 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by GV1PR04MB9056.eurprd04.prod.outlook.com (2603:10a6:150:1f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.18; Wed, 14 Sep 2022 06:36:04 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::59bc:901a:98a7:76d4]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::59bc:901a:98a7:76d4%5]) with mapi id 15.20.5612.022; Wed, 14 Sep 2022 06:36:04 +0000 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: 8238a1ca-33f7-11ed-9761-273f2230c3a0 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SiVXfZTxJ0mLOmrWlEhA9DwainaDbclgwpx3XMs976KLC85JrprKOaD5VA6JIREQnd2BRy1RrRUmDTwFE27Haw6NPfi40Bd2URcn7vuQ3/lf4w01rjO8o8bmSMh1YPmiIopTZ6L0G7XBLCzJpxhNgwEvdztNRmLCLh1AfNF7nxbGG/8vV31KpThGu5TolnGSlVEZfXxjJrcRfdp4zSu/qNoytLbzaG7uYJP1/mwBBJzNXLTevesYnsf2gqY1Tf/sCVKEPpMH2THEoZi7R9kVyl0TCsFbp6lXFzrDpz0xRXkT9wLM7IMHjAog5yZKmF4dPYZMMOrE8AjfoDhoPd5X5g== 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=T8zMGW22NDvpi1glwglzXZuSQ6YwiL37WMVMl2GTCPk=; b=UbHjm+8mLu6y6ujQFdPdjN3R5G6YRShBi3zsOSuTHLt17t4AyIZnoJ45PBz02haaW7umRmZrTzxJ5sAm1tcRFJ5o3oIex7JRMUHhqlSgjG0VN56jXHs0oncMiVnCbg7Nxry0p4b+9zcM9X4PRSExEKfB5rXytAnXFDXQIpvUSIq2hU2KJwVeSRRgIhSDGMG1VJzXFP3TNmClfpSQU3zxwqx5BRA0x7xgNSCSh1hvkI5mNSwWOm4vlwfkGsiLJ8wLNgFRt5ChcNYd//gnNHZ2PklbSJvXDzRar/SU4jBPfYBSEUKZLEXsoZCxEGesqlk+CpowrjevrDAPzvzxsi6NrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T8zMGW22NDvpi1glwglzXZuSQ6YwiL37WMVMl2GTCPk=; b=CARlDPpw6fGTEh0BUMYhi1eaQkGHFNOSrZ9eCt2F/M9PjpGWsVTO1ZEGqiOngvm0dFuXN79zBq9sKIf6EIn8hYUcB2/aHwqvV5YxhpWqJ4Xiv/SuNVzYMe32S24nl4VAB5DTBNhUDZcMsQALMCv/4a5b3h7o1hUTFfpqU+CIikWLIxtNNoI17QeF5jgA9qIc6d05F2676EqNXDY6juAjIKi+40pkfOSDEN1wQ+Lg3CX9y2k2RDG7tGT8SldiOf+oc8u60wnLJIm11cv4IumGe223KLBUK+TQkr4TgnmntBB2zilPNR0FWgY5TUSjanjD+JksbKoGGP/OIc1wTns1qw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <61f083c8-34c7-563b-b010-8d8d0286da6a@suse.com> Date: Wed, 14 Sep 2022 08:36:02 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: Setting constant-time mode CPU flag Content-Language: en-US To: Demi Marie Obenour Cc: =?UTF-8?Q?Marek_Marczykowski-G=c3=b3recki?= , Simon Gaiser , Xen developer discussion , Andrew Cooper References: <1d7b9e30-975b-b49f-fe09-e2aeda9e2af6@suse.com> <1b85702f-7efd-b13f-40d4-615750e20f4c@citrix.com> <037151d0-0920-5d99-9932-df044729c00a@suse.com> From: Jan Beulich In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: AS9PR06CA0264.eurprd06.prod.outlook.com (2603:10a6:20b:45f::9) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|GV1PR04MB9056:EE_ X-MS-Office365-Filtering-Correlation-Id: bc7bcfcd-657b-4ac6-a517-08da961b6599 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kkPCR2a38o8evTUKRDsHPBtxCUkTMfFn7LYkYQ7YQ2U/fbhh37GwhYMTeE9eR2u54B5ixoa8qUjuPQBM6b/9btmSbkK9dVfoZDNgnHo07RmbPvgJk0mJudoGFasZHb64SZReobeQ3MbRt8n45gQaU6Tdb4rFqSu6CaOSdQrDgtMQDtkCvFzS1Pg/XabSC8zPbSCSWabUti2T5i445HBZstabno3+qJsP84wI/r1PAdG3K9eVRdUDfADOIG6arwcqyozsV2LaWtjGVeT7v+0X7TP3nUV79kAuqMEBcXcv3v57GLzO8IeOX8N/A2TjMvnjXaBFmBqFFhUZfakTwM7UY1RK5U7LH7YY3hdBVemp393rYjNZEQfRNPoOxMDWh0RJrCQW27EF9c0FfBjXCQVvgkF1ewZWonIKOMcRBdj7haNdES9UP6Z9Vcx4YPV8pT74+YbHtudU/C0Qo/0oolD4w4bWJtSLy+0GJhT85vw57DIkII8tZkkPdW3s5bSxdpMR6Ky2704lYZUu2w5+UB3BF6Q+CbibbfcNUq7p8HoS5U+Z4yDhzHsgnurED2tBnWbKnqQ+0JkOCB7V1dTkGId3Ms/7j4BZJMnnFBF+Z88Z1wmiJgDYQoSDPgMpIJjxQh/8ZuKf8+vE6zn/F+E1LctSD2TB9Z++AK1tc5dN4i8bBg24+0TrLPW55aGh/HDZBH4bYEX1Cbuj2DiOPj+Rbs+MGGpaoPwzgVWiaNzyMMn2vm9ilyq3wIlvT2tHCKi2LGFTHQqVJqgpdnAbscVGbf1PHEM/uQNwOOc+vLYyJWpd680ZK+SwGrsPK5x/Mm6WoFD6gkmMmovqz/Kr/sZw4rl01A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(396003)(39860400002)(346002)(136003)(366004)(451199015)(53546011)(86362001)(966005)(66946007)(2616005)(83380400001)(5660300002)(6512007)(6506007)(316002)(4326008)(6916009)(54906003)(478600001)(26005)(8676002)(41300700001)(186003)(38100700002)(31696002)(31686004)(66476007)(8936002)(66556008)(36756003)(6486002)(2906002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZTA3ckVOQUlISVQ5b1prc24yb1VJWVpndzBvMHZvUFcyMjRLMkFiK3EvUEVZ?= =?utf-8?B?MVZheU1EUGFLQ0xxa0dJcWhrZUFCZlZMaFgvVTBqbDF0ZXRZZzAwWjIrZ250?= =?utf-8?B?Q1NNUkEvWU05czFzbS9NNSt6d3FGSTYxVHpkdHZRWTNDbFZVK0wvWXFVR2NE?= =?utf-8?B?d0VaZE81NDIvSkNKdUNyZDlYWTBPdlRlSWdJTWdQbGdwbUtFS2cvTDFkaEU1?= =?utf-8?B?MnJCNXZyK0M3N1VrWTkyRlNqUEVPZG9jNE93OUdaWlBWRTZETFRMeXc3N0VR?= =?utf-8?B?YVg0V25JUHNvNnJ0eTdDdWFDZlRrWENaV2xaL3o5anRpL01YWGdycXE1aCtK?= =?utf-8?B?TmZOam1wTkt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ange-CrossTenant-Network-Message-Id: bc7bcfcd-657b-4ac6-a517-08da961b6599 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2022 06:36:04.0760 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: T2+jaoHqwDAHvs681p6oyfiIjA61/IE+M8f+yHxtmyhsQ0yYKuwf7iBzZzuDBQKdja+Si6+Ip5s/3ulB/s1mhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9056 On 13.09.2022 19:22, Demi Marie Obenour wrote: > On Tue, Sep 13, 2022 at 04:47:24PM +0200, Jan Beulich wrote: >> On 13.09.2022 16:22, Demi Marie Obenour wrote: >>> On Tue, Sep 06, 2022 at 10:01:00AM +0000, Andrew Cooper wrote: >>>> On 06/09/2022 10:52, Jan Beulich wrote: >>>>> On 02.09.2022 04:05, Demi Marie Obenour wrote: >>>>>> On Intel chips (Ice Lake and later) and ARM64, a bit needs to be set in >>>>>> a CPU register to enforce constant-time execution. Linux plans to set >>>>>> this bit by default; Xen should do the same. See >>>>>> https://lore.kernel.org/lkml/YwgCrqutxmX0W72r@gmail.com/T/ for details. >>>>>> I recommend setting the bit unconditionally and ignoring guest attempts >>>>>> to change it. >>>>> I don't think we ought to set it by default; I can see reasons why kernels >>>>> may want to set it by default (providing a way to turn it off). In Xen >>>>> what I think we need is exposure of the bit to be guest-controllable. >>>> >>>> We absolutely should not have it set by default.  It's a substantial >>>> overhead for something that is only applicable to code which otherwise >>>> crafted to be constant-time. >>> >>> Either Xen needs to set the bit by default, or guests need to both know >>> the bit needs to be set and be able set it. Otherwise code that *is* >>> intended to be constant-time has no way to protect itself. >>> >>>> As for why Xen doesn't enumerate/virtualise it, that's because >>>> virtualising MSR_ARCH_CAPS for guests is still not working yet, so the >>>> feature can't be enumerated yet even if we did support context switching it. >>> >>> Intel and ARM64 guarantee that CPUs that do not enumerate this flag >>> behave as if it is set unconditionally. >> >> I'm not qualified to talk about the Arm side, but may I ask what you've >> derived this statement from for Intel? The doc page referenced by the >> link you did provide (still in context above) specifically further links >> to a page listing instruction with data operand independent timing. All >> other instructions, as I conclude, have variable timing unless the bit >> in ARCH_CAPS enumerates DOITM and then the new MSR bit (of the same name) >> is set. > > My understanding is that only instructions in the constant-time subset > are ever guaranteed to be constant time. Hmm, yes, I did overlook respective wording in the doc. > On architectures where DOITM > is not enumerated, this guarantee is unconditional. I have to admit I'm suspicious of this "guarantee". > On architectures > where DOITM is enumerated, this guarantee only holds when DOITM is set. > Therefore, it is critical that on CPUs that enumerate DOITM, Xen does > one of the following: > > - Ensure that all vCPUs enumerate DOITM, and virtualize the DOITM MSR > bit for use by guests. > > - Set DOITM by default. > > Since Xen does not support virtualizing MSR_ARCH_CAPS, vCPUs cannot > enumerate DOITM. Therefore, the only secure option is to set DOITM by > default, so that guests do not need to be aware of it. I can see where you're coming from, but I also agree with Andrew that the resulting loss of performance is a counter-indication to making this the (universal) default. What I could see us doing is make this both Kconfig and command line controllable. Jan