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 0BE14C6FD1D for ; Wed, 15 Mar 2023 05:06:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbjCOFGS (ORCPT ); Wed, 15 Mar 2023 01:06:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbjCOFGO (ORCPT ); Wed, 15 Mar 2023 01:06:14 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2068.outbound.protection.outlook.com [40.107.243.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4EB511176; Tue, 14 Mar 2023 22:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c9Nytmbu2yGB/U80h3mnNoyT7GckIVFxszplFmOt+qG2MlTy+A8a5hKjk1pA4BVu6unlo4BvsQey2Cz7TY00u4fshpUpOiTT9oR+Y0Cz25SUhQf2QRmiqcou3uxlD+AdJHsO4TltPRFvfOzo5wqwImx6+27P8NgOPxMqKLFLcR0E0+CqMyD5J3MA1mZx+w+VHkPJFfzNBQR8t7ZSAoPhA0VFVPJwYIPzqQ1Bbqx7WwaB8VZ0dxkvwJCaKFEOPVZZrXI1KW9rAyGOHBKcGAf+EBLmle6he3h/k5e8N61vU2FQr66xxOLNx9HJs6sY1kLNDQ2MdsIn3Mt7gZqA/InkAw== 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=B6g46H+QqGDxOf4bnECMo38C4vDqn48y+lK+PQtUroU=; b=WmXzb99HFtzUaxLxHT7ebB3vagYhJIP2/qixhYEIRzGHo1PweWXFUq3aofVy0AC0kO1etctYXSqNOXpbio1fac2zvyW4TR3h9O0Et0gDj4Z+qhwxsDyUbMzPIIQoiOOS5IPBwRpW7jBMcxBwOybGjqQgpHdAU8JplkjTEho/LTBL0KaZO7iZCKRWaUIWLB0muaj/8hWgfV5YMHtaACyz5XkFj5AKmM7bumNdFmF1tDXpB03gx/XubdEvY1zSv2L8K6E5UOb/PXKUcE+Bn43jzejySbDy35R9WXNxPSj0O8y4OkRVS9KlEqMHNmyDcgu4PABgWGKCh17PPra+Igm2GQ== 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=B6g46H+QqGDxOf4bnECMo38C4vDqn48y+lK+PQtUroU=; b=2Mq1Z/Hss3IULfhXl5LL4rDTgQkrlwVl7sQh/ZSKGMXnFvHqJYHQ1dnON2CQWbw33pw9zqW4moRL7dVRFbVlo5o0RApYV8EsEo07GblR/pzMSdbTiSXrHdEWgQ3pMp3RM1ZqpVPSzwPFFXNYxrSI8pD5JZUVb8QZoHDdD5lHC3Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DS7PR12MB6309.namprd12.prod.outlook.com (2603:10b6:8:96::19) by CH2PR12MB4120.namprd12.prod.outlook.com (2603:10b6:610:7b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.26; Wed, 15 Mar 2023 05:06:10 +0000 Received: from DS7PR12MB6309.namprd12.prod.outlook.com ([fe80::6c34:2aaf:bf7:c349]) by DS7PR12MB6309.namprd12.prod.outlook.com ([fe80::6c34:2aaf:bf7:c349%5]) with mapi id 15.20.6178.029; Wed, 15 Mar 2023 05:06:10 +0000 Message-ID: <1b6740e6-677a-fbad-e7ed-a9cf89badfec@amd.com> Date: Wed, 15 Mar 2023 10:35:52 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [RFC PATCH kernel 2/2] KVM: SEV: PreventHostIBS enablement for SEV-ES and SNP guest To: Manali Shukla , linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, jolsa@kernel.org, namhyung@kernel.org, tglx@linutronix.de, bp@alien8.de, dave.hansen@linux.intel.com, seanjc@google.com, pbonzini@redhat.com, jpoimboe@kernel.org, pawan.kumar.gupta@linux.intel.com, babu.moger@amd.com, sandipan.das@amd.com, jmattson@google.com, thomas.lendacky@amd.com, ravi.bangoria@amd.com, eranian@google.com, irogers@google.com, kvm@vger.kernel.org, x86@kernel.org, linux-perf-users@vger.kernel.org References: <20230206060545.628502-1-manali.shukla@amd.com> <20230206060545.628502-3-manali.shukla@amd.com> Content-Language: en-US From: "Nikunj A. Dadhania" In-Reply-To: <20230206060545.628502-3-manali.shukla@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PN2PR01CA0122.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:6::7) To DS7PR12MB6309.namprd12.prod.outlook.com (2603:10b6:8:96::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB6309:EE_|CH2PR12MB4120:EE_ X-MS-Office365-Filtering-Correlation-Id: a6baf065-166b-4396-f446-08db2512fda7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 43909T0PlIRU94f0ekO7YGmsP4O9wl2Oz1MzQnxRyERjyTm+EO9zO60nfbbdz4V5cAlrcf1IMyTaZxiz6sPmK1G0lkxhUWLbkdfk9j5HMzZhmmrkKjwZAaYOxSfhObl6Qyl7YhHz0moDklbNgbJMliXP8qdF1N/pdEx3znyWwH5sXGvUuIa3CY2GgECZKq+R+I/Of9kx55JBO1sOYe4+sgfPOg0DQF4mZ5ky0hRFxV6+ewzXONPrQsljgf9lXSldB3mcKclT5d/aqsWVpPJ2C/CN2gHHU1XQyo9L7SPVRh54imw7aGDsdSX+286M1T/HbbkjP7/b3phO7S3VYQWmAtl15XZO856PmKH9X0NZQUWmLvVHqaSwhc7yL6M1VWyii7EwbWGlCyz3KTXrrRcyrL3lGzYmjWLodu7bFQz6xTfBGGzwXs00xVLeTfFV7manqQuVPrfLsPffJuccXdB7G0YxVRKkjRE0trcfFxErClozrKCU0EfrWBWmzvNrxRzeY5qPuKupVLjTNtK1N69degHi1TAvka0NblTCBpiyyfMvQCBeDNzIAE0djPxMMLeKx/+v3/TMVJ/uVdPKlMaVkXQSCnOFL7zsYGUvrCnaAJtu38AfbUCXvQYAO6yM4wA18FP75DlK+NYzMjYIUr2hsEj6LS0LJ4gfAVK7P9SmkIm7ZjJEuqlwCUhkG9wFyGNXCth/PMCC+Ft+aatQYmCo4H/bC6D5kjHcWUvFz1Krq7I= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR12MB6309.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(396003)(376002)(39860400002)(136003)(451199018)(31686004)(41300700001)(7416002)(4744005)(8936002)(5660300002)(2906002)(31696002)(38100700002)(36756003)(478600001)(66556008)(8676002)(6486002)(66476007)(6666004)(66946007)(4326008)(83380400001)(316002)(2616005)(53546011)(26005)(186003)(6512007)(6506007)(45980500001)(43740500002);DIR:OUT;SFP:1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tIeS9HS3Awdkhvci9wTFRYWHUwOCtC?= =?utf-8?B?SlpCL0VKaTRKMHRCaG9vdXVPdjhrZU1mWWVYc2VLbS8zSXVQemdaWHEva0Yx?= =?utf-8?B?OWpDNS9SbTNodWF0dy9RMlp0V2poMnROQ3ZFWjRTcDdFZVR3azF6M0JxSTU2?= =?utf-8?B?VzF5a2tOVHU5NzNHcGp5c0tmTzhBYWVnNGljekt0QVgrckFUUTFqMTlROWY2?= =?utf-8?B?cFVUOHI2Um85N3pyN1dyc29ybDZLMytRcUtZUWN1YXk5dnNwR0I2V3FhZktS?= =?utf-8?B?M2tNL2Y1elNRUkhONWJTV1ZFdGNwdE1FL0ZTVEs2TjhkZnprSHFxNnhlMG0x?= =?utf-8?B?M2RoZjlNTDYrazFNOTlIbU8wdkUxaGNYUWIyS0cxc0JYK3R1YjdXSEJFWVlG?= =?utf-8?Q?4wid3qqFGxNtxC4zo2bcJIhep?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6baf065-166b-4396-f446-08db2512fda7 X-MS-Exchange-CrossTenant-AuthSource: DS7PR12MB6309.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2023 05:06:10.2911 (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: +DH9K4r4oNxnc3SxdlxrTvpx5kgoPd6TggAe8Aec90fGYQKgKjYQGXxyyvyp9V6XEQ/8Qxq+krHDXI5vZppz6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4120 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/02/23 11:35, Manali Shukla wrote: > Currently, the hypervisor is able to inspect instruction based samples > from a guest and gather execution information. SEV-ES and SNP guests > can disallow the use of instruction based sampling by hypervisor by > enabling the PreventHostIBS feature for the guest. (More information > in Section 15.36.17 APM Volume 2) > > The MSR_AMD64_IBSFETCHCTL[IbsFetchEn] and MSR_AMD64_IBSOPCTL[IbsOpEn] > bits need to be disabled before VMRUN is called when PreventHostIBS > feature is enabled. If either of these bits are not 0, VMRUN will fail > with VMEXIT_INVALID error code. > > Because of an IBS race condition when disabling IBS, KVM needs to > indicate when it is in a PreventHostIBS window. Activate the window > based on whether IBS is currently active or inactive. > > Signed-off-by: Manali Shukla Looks good. Reviewed-by: Nikunj A Dadhania