Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4291222rwb; Tue, 8 Nov 2022 15:05:53 -0800 (PST) X-Google-Smtp-Source: AMsMyM4c4dp0NjPqbQejwmqonje2YiLpPhVlDACNH2MytCd5ZWIZuovj6cly5bIN/7Ynkgm7yzo+ X-Received: by 2002:a05:6402:2685:b0:462:73aa:c23d with SMTP id w5-20020a056402268500b0046273aac23dmr56260223edd.390.1667948753565; Tue, 08 Nov 2022 15:05:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667948753; cv=pass; d=google.com; s=arc-20160816; b=O7PWWjsoTT6QM6mw8zujjOghd5zcLRJbBJuWCAc40lF7Xpxus1Q3G09XnWYfC3TklZ pFAnDcB2kGPmp8a+C991QvR+9PDscCHQyXHtbq9f1heeLWsvixfZm3QK2OVAMXC8ZS/t U8yQVNzGa+hRU/CISRSV9XDM3VHIkyT2H2r7E7Eqr/hUMImQdfD8nPwuDReSAC0QnGOz wPb5URAw2iVERbJTRW45bvHn93ewfKwxiknFszxZ6m47X2htlHcp0RP9iecYGhbDcosV TJmp6AxxMipEp6IV16ERxCeFzRWJESuF4Fbc6Mg+Tg8K9W060hyVcy//cQycgq5LuDeT Z57w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:organization:from:references:cc:to:content-language :subject:user-agent:date:message-id:dkim-signature; bh=+/Jx34ECwwWQHLbUbXYSYxvvpWsiHRDpsjjdt/eia5s=; b=diFrw+VgpHqYmmw9RWeps7SMns8OsEtFtWzNG6QG00cEWopkvWLb9J7uT7iNPaScX4 EJexWJRpCnLHnxJB+5uqLYmxp7W8en15ekSYPKYplQkL9uttkGuoQSbDgt5WT4NOIY5V AXDa4siV2P0Tlg/GuxznfO8n6Ua17clLPzp2y+HocNZbbyD5lDl/apDFKhHo4ogWbc+7 5EOnHlfMwq+pbwOW0kDgJvXszewgQ/M+9083ZiiBF0QcTkuwezUc+rQct6YAG79NiPSj PxAXu07Ut+GKaitunKMjI8Dho9zTguBWBXVXyyx2xCc3wSoZS6zczbkC4CS17A4QPnDn 5TUw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=SYxZZzgf; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020a056402321000b0046277d2cb0csi14084712eda.470.2022.11.08.15.05.31; Tue, 08 Nov 2022 15:05:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=SYxZZzgf; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230116AbiKHWsY (ORCPT + 92 others); Tue, 8 Nov 2022 17:48:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229492AbiKHWsW (ORCPT ); Tue, 8 Nov 2022 17:48:22 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2049.outbound.protection.outlook.com [40.107.94.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1AE464A1F; Tue, 8 Nov 2022 14:48:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fj9pbWlHLQmYLSG7h/e3jAEFVH6Jzp+CCAtdFs+62SHLd67LZK0tYG3FdqGae/CgK0evRRaAZmju+aqXZUjlpA6c8EwQ1TL61BLUHrFIb1guCmBUeNpMRwgNVz/llxykHmUkelw6h9B0lirFziETEFKmnQS3a0GOV+UHjmpR2ObLLbgeV/kjy17f4m52AVsYm0ScfV8tdCsiKF75y7CNWk/6hHTi3YbJ6IhyFKME88a4dUZgVa6cwSbGarbxmd0ushph6Tjw0FseOii+jXFJ0BbVQUvtWjwK1N5zHlfvKlwkczZVtek0eAwDuEuAxpAkfCMfub4rFD9BGHPWhUuTmg== 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=+/Jx34ECwwWQHLbUbXYSYxvvpWsiHRDpsjjdt/eia5s=; b=O96ack4F9L38hLEPneFabKwy7FKB2XuF6HIjGTh1Ow892CsmLj0EZlb4VJUyW06xVjEzUAOyMlnJf3BkrAokL9+tFQWh7+uV6abyjbNrPMwQIpQW1PC5KvKWw+lfOLmQDNxDBTEWPSyi+UVWkkWZo2QoeBioSGj6MtcgGq2v6pED1HrbaaIeCjK/9XV8poTOiYiWfCV65Y2AYv47+949NHurQKRpsuHpIyfMT5xlQwipwCW8Dtt9g/Vdeycf3hPYc952z4EC9lcAXz4JUd+G+o569fZxKly4XAsduahaA0ZkZgdenAa29yVdOsgGnQONgSmAQbwXVCb40lhSnkJmbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+/Jx34ECwwWQHLbUbXYSYxvvpWsiHRDpsjjdt/eia5s=; b=SYxZZzgfivV/Zny/SMX4VXgNB2QTVKFl8zhS0k3MJwEzEHLV1c8h19zeT1scS/lOgFd/oZ/VKVYHx6j8JKvJVlWcxKi3GrbDJVio0Us+/uNjc0g3BimMb/9A/gr41xFVOmfwfw8k+QPrO6VYN+ngNpByXv0OA0x1Cn9jM91+YgQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DS7PR12MB6263.namprd12.prod.outlook.com (2603:10b6:8:95::17) by DM4PR12MB6541.namprd12.prod.outlook.com (2603:10b6:8:88::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Tue, 8 Nov 2022 22:48:19 +0000 Received: from DS7PR12MB6263.namprd12.prod.outlook.com ([fe80::6f5:7c8f:32d9:e72c]) by DS7PR12MB6263.namprd12.prod.outlook.com ([fe80::6f5:7c8f:32d9:e72c%3]) with mapi id 15.20.5791.026; Tue, 8 Nov 2022 22:48:19 +0000 Message-ID: <4c8945ae-62c4-7550-dc75-068cca99e678@amd.com> Date: Tue, 8 Nov 2022 16:48:12 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH 3/3] x86/speculation: Support Automatic IBRS under virtualization Content-Language: en-US To: Jim Mattson Cc: x86@kernel.org, Borislav Petkov , Boris Ostrovsky , Dave Hansen , "H. Peter Anvin" , Ingo Molnar , Joao Martins , Jonathan Corbet , Konrad Rzeszutek Wilk , Paolo Bonzini , Sean Christopherson , Thomas Gleixner , David Woodhouse , Greg Kroah-Hartman , Juergen Gross , Peter Zijlstra , Tony Luck , Babu Moger , Tom Lendacky , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20221104213651.141057-1-kim.phillips@amd.com> <20221104213651.141057-4-kim.phillips@amd.com> From: Kim Phillips Organization: AMD In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SA9PR13CA0015.namprd13.prod.outlook.com (2603:10b6:806:21::20) To DS7PR12MB6263.namprd12.prod.outlook.com (2603:10b6:8:95::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB6263:EE_|DM4PR12MB6541:EE_ X-MS-Office365-Filtering-Correlation-Id: 104dc1f7-87d2-4d83-7c2d-08dac1db54ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /kgUeDa0IUqXuCYRgRU3QjHKb19iRzicC2MgTiElbNMG8xgnTMYcxefy2JN8lNYy6XjtnFfgryQ1CqiTOqTSewO4262nDvVTIMA1RJF42zja/z7/uGcB+kXAnx8+cF+8ovAf+2umPAjIw/EdiIUaNJjpou/VB5mgnnlVk0SXb6BLKBCrd8oJd+nvQ7U7gWGyOsvnH58MifXtwS3vL7rraT1glWleuN0MgvlWMqukgcqru7lj6dU4SKxaunLh0Xh0XO0uxiCtqvT+K0XizLBpnCbJ8fH3EsuElKNMQeItXq1oPoUOLCHpm0p58pw55zYAV7jIFHccezzWje53l4vb3/kSHOhlCB5WTwWTyedvV3/mT74LYqmOYs6ZoOFLAf+tLORDQNmW6uUTzITnj0oc6ocwB1vUBj/yLcC7OE07dK99vi4YUoMfWrge1+KAg5/5VuBvYZomVyWx4ABck6i6EJYgANJhOk3P9Ub/nyRHLtLXS+hp7cxxTPIf0eqk+yLmGZMFO+Yt2bZntCs2j0qGGigg2prxQf4chMW6R4CW9IB1MCEcXJvi5cfZUWFvFTRQ5RPRa0hFwEpwHlae6OW9+4wDwNyPX3QL0+rtARv53QZDI/mQZLsEAG++Zh4Rvb1oF6akdu9nvVwtu9yHQZaAQTC01bqfnUWjXSppJsCDZJWjYHx8DPsvctbYdjzZQ/3/x8Bl5M1QPST0scoeoQo+KaXtbhvOjy7d/BfIiUf5E+LB4/YV2XuKmE0NVnW/x0x8VuPTlokD7zzTzPSF9GF5svzBsPkHPBxtlt3IEHf59Xo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR12MB6263.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(39860400002)(136003)(376002)(366004)(346002)(451199015)(6486002)(5660300002)(7416002)(36756003)(478600001)(6666004)(41300700001)(2906002)(44832011)(66556008)(8936002)(66946007)(66476007)(4326008)(6916009)(316002)(8676002)(54906003)(38100700002)(186003)(2616005)(31686004)(86362001)(6506007)(53546011)(36916002)(6512007)(31696002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RXlpRER0NjZldHZKbFZRaU1vcVhDUWxZaFphL0ZUdzdWeGh2RGhEdlA1Z2Ex?= =?utf-8?B?bFdKSmJETFBDU0kvMG1UUDRybjNFcm9rOXIzOUJadkNzelNoZXc2MjIvSnFE?= =?utf-8?B?b1BvUzZZbmo5QlhGa0I0cGIrS3BrcU1xb0RTT0c5TlV3U0phazh0OTRCTElP?= =?utf-8?B?Vlhaa0FEdE5JVzRKSjlNbU5KaXF2NjB2Ym1Ub05oR25CTWEwRG9lL2JKMFg3?= =?utf-8?B?ekVqcVZjMEhIb054cCs4eTlCTXVCUHlIK0t0Y1VrdGVISG42MzRDRzBoWjhC?= =?utf-8?B?RGtZZHlubHpHSTM2Z1BuOTF2SU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-8?B?emV6dkFnaGdIYUo1MjZNdWZGTUlDZnBuejlobjFFRHVYbmpSd1o0UFVRODhE?= =?utf-8?Q?wJWAx62ndFRZYS9Vfg6po5ddfXIuQY/t5TiAs8O1BL2M?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 104dc1f7-87d2-4d83-7c2d-08dac1db54ac X-MS-Exchange-CrossTenant-AuthSource: DS7PR12MB6263.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2022 22:48:19.0341 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Vytip/eyd81I+X+fRNYbphLfKgiMCWB6/lte9ALLzWc2/ywZaZqEgBKP0EPLjjWoMW8PmFSC+9N/0UDtdRt3BQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6541 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/7/22 4:42 PM, Jim Mattson wrote: > On Mon, Nov 7, 2022 at 2:29 PM Kim Phillips wrote: >> >> On 11/4/22 5:00 PM, Jim Mattson wrote: >>> On Fri, Nov 4, 2022 at 2:38 PM Kim Phillips wrote: >>>> >>>> VM Guests may want to use Auto IBRS, so propagate the CPUID to them. >>>> >>>> Co-developed-by: Babu Moger >>>> Signed-off-by: Kim Phillips >>> >>> The APM says that, under AutoIBRS, CPL0 processes "have IBRS >>> protection." I'm taking this to mean only that indirect branches in >>> CPL0 are not subject to steering from a less privileged predictor >>> mode. This would imply that indirect branches executed at CPL0 in L1 >>> could potentially be subject to steering by code running at CPL0 in >>> L2, since L1 and L2 share hardware predictor modes. >> >> That's true for AMD processors that don't support Same Mode IBRS, also >> documented in the APM. >> >> Processors that support AutoIBRS also support Same Mode IBRS (see >> CPUID Fn8000_0008_EBX[IbrsSameMode] (bit 19)). >> >>> Fortunately, there is an IBPB when switching VMCBs in svm_vcpu_load(). >>> But it might be worth noting that this is necessary for AutoIBRS to >>> work (unless it actually isn't). >> >> It is needed, but not for kernel/CPL0 code, rather to protect one >> guest's user-space code from another's. > > The question is whether it's necessary when switching between L1 and > L2 on the same vCPU of the same VM. > > On the Intel side, this was (erroneously) optimized away in commit > 5c911beff20a ("KVM: nVMX: Skip IBPB when switching between vmcs01 and > vmcs02"). Then why hasn't it been reverted? Does its rationale not make sense?: The IBPB is intended to prevent one guest from attacking another, which is unnecessary in the nested case as it's the same guest from KVM's perspective. Thanks, Kim