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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8980FC6379F for ; Mon, 20 Feb 2023 19:57:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232191AbjBTT5n (ORCPT ); Mon, 20 Feb 2023 14:57:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231340AbjBTT5k (ORCPT ); Mon, 20 Feb 2023 14:57:40 -0500 Received: from esa3.hc3370-68.iphmx.com (esa3.hc3370-68.iphmx.com [216.71.145.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6B1B1DB9E for ; Mon, 20 Feb 2023 11:57:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1676923058; h=message-id:date:from:subject:to:cc:references: in-reply-to:content-transfer-encoding:mime-version; bh=+4j0qYjE5ACobqntXCEKVy1ii6VK0RadWIpCTtHlPME=; b=Lcgx5GSH2BXo5ghAj81Zo36rDNlLY7SFdhPW3NfszeD06ARHPewS7KSw NdEjEFCo7JIdhVe2kTLz6lOImbgLxs/Q1dKNwTGdKnyzQZPhKvGUdTjly 3D3LUPraNJHsbSmrSmYQhhIBhU8egFwTLhkt185yooxtlCb5zzApOzmFl o=; X-IronPort-RemoteIP: 104.47.57.41 X-IronPort-MID: 97797752 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:qc+xwqDG9syVphVW/5Ljw5YqxClBgxIJ4kV8jS/XYbTApDt2gjRSz TQaWj+CO6veMTTxKdt+YNm3/RtVvcDTmN9rQQY4rX1jcSlH+JHPbT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eoep46c3dJYte7Qjsut5wpZcQ /AbdoOAC/JURzLv/zUbcIm7rYp+eRDtjgWLVwKnZTEjY4VnQSTG/djregap/y4LZhdbruM7q rykkxjdGJwKQlw4CN6MMK72iVSsoXIaheR+GVPSJcVec1nt944sLDHtivgwIIcHLhCrKiam6 jt6yCww/YHly7LZOvGQ7UxYh+9Fy9dDI3c= IronPort-HdrOrdr: A9a23:O/0Oj6k7Tg1QRRnGQE2+QdV52d3pDfLr3DAbv31ZSRFFG/Fxl6 iV7ZImPH7P6Ar5PUtKpTnuAsi9qB/nhPtICOoqTM6ftWvdyROVxehZhOOMrQEIcxeOjdK1vp 0QF5SWZueAamRSvILW2iT9NfAKqePqzEmvv43j5kYody1RL4tHyChYJDqhOnBXYi4DP7YFfa DshfZvln6ueXEadMSpCmNtZYX+jtfWjo/hZRIcJzNP0njtsQ+V X-IronPort-AV: E=Sophos;i="5.97,313,1669093200"; d="scan'208";a="97797752" Received: from mail-sn1nam02lp2041.outbound.protection.outlook.com (HELO NAM02-SN1-obe.outbound.protection.outlook.com) ([104.47.57.41]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 20 Feb 2023 14:57:36 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UyzB/dVTSnYCvp9xHtTIiKNfMBmEXe/tR7Vx7NHSFO5W5DJg2lGqZilHipB6ynKIExeH7LMhvVy9O2XPa35LReEzEMWYUo5abD3NSatV4V8E16VwTOo4c2S0l2oIcidSRGKPERvrgQjKitK0jAbv2YHI/5uLFSXCqEsVfgi+IDGMaZb2Z0wW9NgWoXbI4op2xDY6OiIZ6ytNNzIFWG+8c+dxwck4a5gxjIniyOyNGdA7EHUXnlGi3YbvbCq9OsRKw90gNvDQHG2PowVxUY/TTE0FQOzca6W5nc2IyF0RH5b4mUYlEDPxe5EHAhA8jgIif7VcSPqDhAg90mE/k9wPwg== 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=THeAvxxeHi4KQbpunRQ/pptGZ6NujxLJfw1a5vIpRu4=; b=LqNLYfrj2tPI7deybXES6Ks6ey3ISAubN5XBSSEjAMNNcQzda2OXVQvwxgENxpkDImWTLYuY2nodDcCrxfD95c16VQ49gViy3lsgaOuVjGnOw5C2luLu/K0iKIuMXIZofkvNTYMH0sYnzwiy3SzvgPNHgLtsfWe8Y5jgsoF+eDwIOQipMfa8owrFewwkOCefF6CkA3ed1yQ/MzIIbfKODt1Q4ITo80IAbojvniUz+vNzcSavj6Cj6RFfWv2C44BVy2omAG7QQFa3DpdFraT2mZSgZX3+Mv15n8GVDe799xzIimg8dfllFFAjAz88HYdRUwfD5t19mqC4epyNNDZwGA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=THeAvxxeHi4KQbpunRQ/pptGZ6NujxLJfw1a5vIpRu4=; b=FD/4FRjPLJ/UvZ616/xesFmaZy3cu4PWoo9Zl9E5s+VS8nh1p0YJUQYpfJOtNseEkecwZ6uRRVmUE5uCRp4y+1e9MQK9UyvPnBFAmBVbm/g5eask/rqsVsGTLl3ywYvRUQ7FcdoBynfvlMveN1asyUH2ltVZlHz5hK4gT2PecNg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; Received: from BYAPR03MB3623.namprd03.prod.outlook.com (2603:10b6:a02:aa::12) by SJ0PR03MB5775.namprd03.prod.outlook.com (2603:10b6:a03:2d4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Mon, 20 Feb 2023 19:57:34 +0000 Received: from BYAPR03MB3623.namprd03.prod.outlook.com ([fe80::8299:f95f:934b:29e8]) by BYAPR03MB3623.namprd03.prod.outlook.com ([fe80::8299:f95f:934b:29e8%7]) with mapi id 15.20.6111.020; Mon, 20 Feb 2023 19:57:34 +0000 Message-ID: <3a65d18f-b218-60e7-4748-f1609eb76fd5@citrix.com> Date: Mon, 20 Feb 2023 19:57:25 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 From: Andrew Cooper Subject: Re: [PATCH RESEND] x86/speculation: Fix user-mode spectre-v2 protection with KERNEL_IBRS Content-Language: en-GB To: Borislav Petkov , KP Singh , Dave Hansen Cc: Josh Poimboeuf , linux-kernel@vger.kernel.org, pjt@google.com, evn@google.com, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, peterz@infradead.org, pawan.kumar.gupta@linux.intel.com, kim.phillips@amd.com, alexandre.chartre@oracle.com, daniel.sneddon@linux.intel.com, =?UTF-8?Q?Jos=c3=a9_Oliveira?= , Rodrigo Branco , Alexandra Sandulescu , Jim Mattson References: <20230220120127.1975241-1-kpsingh@kernel.org> <20230220121350.aidsipw3kd4rsyss@treble> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0445.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a9::18) To BYAPR03MB3623.namprd03.prod.outlook.com (2603:10b6:a02:aa::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR03MB3623:EE_|SJ0PR03MB5775:EE_ X-MS-Office365-Filtering-Correlation-Id: 4be72e16-0260-4158-cbeb-08db137cb501 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +egAGk+yCapAnkLeZ31vq1pOS00Pqzgffp+TWcd3CDVr0ydkxMkxzn+LqwdpLSFUDFeWmtOCibdTzWBH2i0QM8p/JvoyD0Cq/NOwhEosITf/4zyZs4TkEGdDqGFWF1dPSuUljGbz21Lj2J91VeBS5Km8gQvwzfEjip+2DmNGiDU6iH2PS53s7FEKMAvOQ4qBPioQSB6QhgTr99/HUlsgOo//Z2mkO6lSmZZ0UXDZWqyMumYWSDwj6v/FVT/f5jv60uEqhUXLR5tVGfc/1p/njKEcEIuxp9AqV/n+9EtZnfeNUJ9/r9seG2uI2VsKxJtK43+eelkLAXFvqeNrRPilB+tzjO6ShupkEAf976WdGJ9wEAeoYd9P1WxvJYTKOLVmJdXg12OTWaMelOz8z6AyStFyeDU8NSHN6B9PnRgnbWsJuqEj1/bh1dfO+O6yPmAmFQd0GFMVL+B4R4nYpUBFHcb660oFlLkel5C2ZLGG/chXqienYvmLlYCIZ9UstD0AAuIw5m+0Wa1mQ5JSnWZNHWKDjZiy7NayHRy7ywK21xY10fxAfT44YNV5rqgXFjCwdk39l04D+KoJtJwxLDUx/GgGjNddELXD4NPQ8nQuWY3wpErQ2Pm9Zighm9yCEbNHkRiZaaCnCFUc9/6yMykbF8mzxewpdSYjI4FxQZOyASA20zHdqFsx22RWxqKa085SyG93Q3spoOU40U0HtGyMw9s7qFzCRhHs8Wvu0e26QIY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR03MB3623.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(136003)(366004)(346002)(396003)(376002)(451199018)(8936002)(2616005)(7416002)(5660300002)(31686004)(478600001)(31696002)(4326008)(8676002)(86362001)(66946007)(66476007)(66556008)(110136005)(83380400001)(36756003)(54906003)(316002)(966005)(6486002)(41300700001)(6512007)(186003)(26005)(2906002)(38100700002)(82960400001)(53546011)(6506007)(6666004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cTAxc1N6WnlKODdnQXFKaGkzK1VxdVBZZ2JKR1hmMTFHQ3ZTbE5aTWt2OWd2?= =?utf-8?B?THBzV0p2WllQc2xnWU5GcWtvZTM5aUtIbHlBSGNDTUJhQ2dZdnppbkJQK2FF?= =?utf-8?B?OSsvN3FOVFFpczVNUkpHaUIyOHgrU3dySEVNMHFrdXg0eDJTZjBpTXAvVkVk?= =?utf-8?B?RDVRUS9HdnhUemRWaElGZXBQV08xYjVzOHhZMkpzZERjN1paY2EycEhhbC9v?= =?utf-8?B?T2IxMWsvN2h6dlViYm1JVVVtNEpmQXkyc0lrZjNtMFVxMEFJL3lEWTgzRlZN?= =?utf-8?B?TDg4cmdmM0srQUlTeVZieWZrOHJyUnpYR0JJSm1DRXQ0clU2anQ2L0NtNlMz?= =?utf-8?B?RHNHNE1Yd09ubkpXNmdaS0l2L2hSOWYrLzlkdnI5QU54MXh3MkVjUVFpOURG?= =?utf-8?B?czdwVm5GQUVIMlJKMFhVYXJPcEZrR29BUW80M1I2aVdacm5nK3RqYnhaSTY2?= =?utf-8?B?MHNEbkZ6NjlndXZieVptQ0lJWkNBV2QzS3BQTDl5TGtPMXNVQWsxZUZia2tm?= =?utf-8?B?WHNSR0tzNFhHWFE1YkgyQk9RU0diWEI4akc2Z1czbG1XT3prMVVPODI4K2FU?= =?utf-8?B?RjJ0VWpDa1lTbksyOVhuMUJQZ2Y0NGoxRlc2SjZLWlZjRVFDTmxlZDlnZHVT?= =?utf-8?B?UTV1emZVaHdBNDlFR3gvT0NlbDVzWjM0cnFuMFpBY1NIOUVtK3JFNjhZMlpM?= =?utf-8?B?Qi9KVnhMRnVtWXlOYzVL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OYUxCaGJ4VjBVdC9IVmxBZ0xJS2NHcmpuVnhFdy9QNHc1MmtwQ3lWS3hL?= =?utf-8?B?UStBUkZuNEVSakhsaG9uaVoyYndGaEpqTzJ5NW9ucmFpdkF2VmlUWW9va2g1?= =?utf-8?B?UmV3Ny80VnM3TElXOE53emkyRE9Ld2tlR0VDaG82MHNaZmxXaWZnVHl5Rmhy?= =?utf-8?B?R0kwUnR6NTAwdUZzSmVOeTZVMVNzNDlCQTFITGE3eHJsWDdFd3hSVVl6dHRm?= =?utf-8?B?T1J5MHF3MTgrazFwNmJRTkhsdFVUR3lySDdBbTZlc3NtOGdtQnVYTlpsSklO?= =?utf-8?B?YTQ1ZkJjUjRHNDJ6SzMxTVJIcXZtNHg3ZE1CZ3NXTnlPZVk0QVJwVHhlalZI?= =?utf-8?B?UW0yQ2tBckxtdUhkQzdsYnRYVkNRbjlBVFV3ckxLNjN1REc2U0ZWRlo0SzZG?= =?utf-8?Q?guup3YwaQl42jyx+hUxR911Cg=3D?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4be72e16-0260-4158-cbeb-08db137cb501 X-MS-Exchange-CrossTenant-AuthSource: BYAPR03MB3623.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 19:57:34.1098 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2uN95YM+Sv2bVktIjL3VEYMYU3lJSx4EoZp9Mr6hDbHTwy3xzYQSFItBgjEAizPY0YpKsce47Ojfbk3fZPwTifIM3RnzT3nP2T5NsYbm/ys= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR03MB5775 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20/02/2023 2:31 pm, Borislav Petkov wrote: > Drop stable@. > > On Mon, Feb 20, 2023 at 04:34:02AM -0800, KP Singh wrote: >>>> On Mon, Feb 20, 2023 at 01:01:27PM +0100, KP Singh wrote: >>>>> +static inline bool spectre_v2_user_no_stibp(enum spectre_v2_mitigation mode) >>>>> +{ >>>>> + /* When IBRS or enhanced IBRS is enabled, STIBP is not needed. >>>>> + * >>>>> + * However, With KERNEL_IBRS, the IBRS bit is cleared on return >>>>> + * to user and the user-mode code needs to be able to enable protection >>>>> + * from cross-thread training, either by always enabling STIBP or >>>>> + * by enabling it via prctl. >>>>> + */ >>>>> + return (spectre_v2_in_ibrs_mode(mode) && >>>>> + !cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS)); >>>>> +} >>>> The comments and code confused me, they both seem to imply some >>>> distinction between IBRS and KERNEL_IBRS, but in the kernel those are >>>> functionally the same thing. e.g., the kernel doesn't have a user IBRS >>>> mode. >>>> >>>> And, unless I'm missing some subtlety here, it seems to be a convoluted >>>> way of saying that eIBRS doesn't need STIBP in user space. >> Actually, there is a subtlety, STIBP is not needed in IBRS and eIBRS >> however, with KERNEL_IBRS we only enable IBRS (by setting and >> unsetting the IBRS bit of SPEC_CTL) in the kernel context and this is >> why we need to allow STIBP in userspace. If it were for pure IBRS, we >> would not need it either (based on my reading). Now, with >> spectre_v2_in_ibrs_mode, as per the current implementation implies >> that KERNEL_IBRS is chosen, but this may change. Also, I would also >> prefer to have it more readable in the sense that: >> >> "If the kernel decides to write 0 to the IBRS bit on returning to the >> user, STIBP needs to to be allowed in user space" > From: > > https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/technical-documentation/indirect-branch-restricted-speculation.html > > "If IA32_SPEC_CTRL.IBRS is already 1 before a transition to a more > privileged predictor mode, some processors may allow the predicted > targets of indirect branches executed in that predictor mode to be > controlled by software that executed before the transition. Software can > avoid this by using WRMSR on the IA32_SPEC_CTRL MSR to set the IBRS bit > to 1 after any such transition, regardless of the bit’s previous value. > It is not necessary to clear the bit first; writing it with a value of > 1 after the transition suffices, regardless of the bit’s original > value." > > I'd love it if we could simplify our code by not caring of the IBRS bit > when returning to user but I'm afraid that it ain't that simple. > > This above probably wants to say that you need to write 1 on CPL change > because it has a flushing behavior of killing user prediction entries. > > Lemme add Andy and dhansen for clarification. > "When IBRS or enhanced IBRS is enabled, STIBP is not needed." This is misleading, if not strictly wrong.  The IBRS bit being set implies STIBP, which reads differently to "not needed". Now - eIBRS is "set once at start of day" which ends up becoming a global implicit STIBP. I think we're discussing the legacy IBRS case here.  i.e. what was retrofitted in microcode for existing parts? The reason why it is "write 1 on each privilege increase, 0 on privilege decrease" is because on some CPUs its an inhibit control, and on some CPUs is a flush (i.e. its actually IBPB). But these same CPUs don't actually have an ability to thread-tag the indirect predictor nicely so STIBP is also horribly expensive under the hood - so much so that we were firmly recommended to clear STIBP/IBRS when going idle so as to reduce the impact on the sibling. IMO the proper way to do this is to set STIBP uniformly depending on whether you want it in userspace or not, and treat it logically separately to IBRS.  It doesn't hurt (any more) to have both bits set. ~Andrew