Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4959513rdb; Fri, 15 Sep 2023 19:17:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH89Q8bjTVxOYlQ/P8c6NcV6k8wjLCtWfy5fEsyMrbNDPn1hm+bwXQNlhYDYTB1ywjaQo7l X-Received: by 2002:a17:90a:1c16:b0:274:b4ce:7040 with SMTP id s22-20020a17090a1c1600b00274b4ce7040mr1837512pjs.23.1694830668372; Fri, 15 Sep 2023 19:17:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1694830668; cv=pass; d=google.com; s=arc-20160816; b=mroY5opjF5/qkrSVq6Wa5ki6tIU25J6Yr499w2ySUd+RdTTOPh6SzXQY5wDlSTtR4w 9r3a8+rR+fCpd4fLGRBxHKMXMA2VHv100tifk6MflHUS4gHDYmyw01bZAcusB58hEWrQ yCEUcFUNhheDZo3irgc0cOQmA7IFzRYT0cWpvaEpyy5zM8wBqiK4hK7qEpMusWnUiOnC MSSfJPShZlXnGnX+HVSmWofepyLRchPmHOh5cenraFo5fxM0bvrZ36rHRDXxINxOUdDK Ev5Od9PocEHcwxZgY75P4KtXPrrjpRVTNU+taVBRnZ75URv5wUZK6wQFUecMn3r+DokF b/4g== 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:references:cc:to:from:content-language:subject :user-agent:date:message-id:dkim-signature; bh=LkLhbhcNBOjE5xR36P2hAmPn7otCTBFMC7+3gkKs+xU=; fh=+m+7WRVZTvuO0jiBL2LFLYNr1CKgIDdFdkEi9mliCBE=; b=Em+BtBam9ptoNb4MIuiOXh6BXVP8dIhRVEP4dC0fZnqBTD7Ys54khBPVKSpMPXMLVG 5EC4edc+YLpJPWRRWm/JDxPsBtP4dnmuA8C0zdhzImhB3S82LRKRlOKt8OFqOEBVWKyN flIlLXSFA/klmmwe8gGXjdFHGEqlI54JzCy5wKc4y6dr/xsls615VofxG5E9ADzEgMrk uKe65La3Y/CZpPh4SjTYJeAEXcXgzO8oMZEKodZ7/8zA2Hz1m/MJ2J/x/FrKZPYUaRu8 sbY9dYEHllXoF+rFzTxmdn8JK7RJhoM2YHGSbmUVV/ZAT/s+TSeza7V/fZHFcETTvgpG ugLg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=dUJ4LxHf; 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::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id oj14-20020a17090b4d8e00b00263d559dbf1si6629937pjb.55.2023.09.15.19.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 19:17:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=dUJ4LxHf; 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::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 53C3C83EDE68; Fri, 15 Sep 2023 09:53:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234803AbjIOQwt (ORCPT + 99 others); Fri, 15 Sep 2023 12:52:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235142AbjIOQwr (ORCPT ); Fri, 15 Sep 2023 12:52:47 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2078.outbound.protection.outlook.com [40.107.93.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E826A19BC; Fri, 15 Sep 2023 09:52:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lHE1cIaemuEcYXl/JD8ul48C7HDABmnhJZx6sACMYFipQUBDsOorcDQibgYKLatQf3UaBYDjrHXAHHgdt40+AnUW8IQRmtr3furWJt6fs9CzgmBT7baqkGtY2OUn3Q6P16CVQOQIWFBdof2WJSm1BapXnknK25TEOxpjDHfo0+6utxgZ/BASlZ5KHMS8bsNZno1m+ygF6FM8JRqmHmHnLCPjXxxi1Qc+HPzEIpoXA8e5LVjTE5FQU9El4y6OfO6dyyHBco05VrwL8SULdXgxsQkTv0/duL8CSiZzw5XvvkMXpDxMZpM7uIlskDy3/jivBjnzKelrRwQcvmNK3Ru3VQ== 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=LkLhbhcNBOjE5xR36P2hAmPn7otCTBFMC7+3gkKs+xU=; b=Telqxj6lVXfIqvur5yk96+rGwxn5vptPB8c/3ixhKtBXUD4sp2JmRSC+oPuu4U3Hcg5LiIUNKFGR42EbiFieLPJECmmydiXxf+M63dGq0A0FU5v8BkaI0NzpNwxoWPmhD23jc2E9y9wVP8oocaDOzaWlQbTIvgmS+TTCVS29YdxGvQZGZOxqz7K25lyT9vj1PbtccJeHsB30cOXfWLXuNNb3c+hJECq6gqo5I/trfbQtHH5ZytxCxtD5KZ9Bz05w89E4bfMDCJkxhyLk6pbNoeTvZCdKeNzQ2IMoWNsfm06GhCttEZi7ZTtcm25K/iD3EjbP/G/nrUmcAryAalVajw== 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=LkLhbhcNBOjE5xR36P2hAmPn7otCTBFMC7+3gkKs+xU=; b=dUJ4LxHfIB5pirvNVFcC64BPLGgH30yTldDUYdLq3EEWcOzV3jXZSgExkh5mv8Qsw5HZT6PMwktwl4cW8vvLhbY0BJIm+WxNK8nNp40ZNtQx58ZRS4ncCCkvhnmXAgccDMxhtwIx2IEvC4JspvmVsJlIykOgCV0bgGcCU+OGeos= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) by DS0PR12MB6414.namprd12.prod.outlook.com (2603:10b6:8:cd::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35; Fri, 15 Sep 2023 16:52:39 +0000 Received: from DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::d267:7b8b:844f:8bcd]) by DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::d267:7b8b:844f:8bcd%7]) with mapi id 15.20.6792.021; Fri, 15 Sep 2023 16:52:39 +0000 Message-ID: <8b047dad-84ac-69f9-3875-38bca92d7534@amd.com> Date: Fri, 15 Sep 2023 11:52:35 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH 1/2] KVM: SVM: Fix TSC_AUX virtualization setup Content-Language: en-US From: Tom Lendacky To: Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Paolo Bonzini , Borislav Petkov , Dave Hansen , Ingo Molnar , Thomas Gleixner , Babu Moger References: <8a5c1d2637475c7fb9657cdd6cb0e86f2bb3bab6.1694721045.git.thomas.lendacky@amd.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SA9PR13CA0035.namprd13.prod.outlook.com (2603:10b6:806:22::10) To DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR12MB5229:EE_|DS0PR12MB6414:EE_ X-MS-Office365-Filtering-Correlation-Id: 9aa38bac-c58c-4a95-1703-08dbb60c2ba1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ccqC6HY2FLZUw4vpiMucwNZI8HNYwXvn2mFqLhSIPgxIviO6AUmEainq11FQa43nihocE+Pqbqwvz24dteZioW8C2fCj9KxiqoMVXFtvS3lm2Ct7ru+DRTyG7kStHCBXNCagWQEGbN6I7quhHSF+gG5L7fNUZfrGAm8EvU5dv1fupIa0j52tCoBsrtBSBhV/o6OKlSRP4B05Ggn81ayq3SIlEJ43wAUkupSGFkEclCH4A+TUOuSaYHdrVUNnyrSqAkaDYalY1b05zqPGqVF9iU1MEfa8rArk/wPOhtOGUeqkvH8/QXidb3TUk49QxCFFUIjz65qB3TSXsKB/DTiNArncTr0M369saHYvUnu1S/sTsbfIvkWQNvLU0rnJa2KiCexcxsqn5rSzQfs+BPV5shcckhpG8nbJP+HMRawQ/xNgZQo08MXedJ0CYrLM+HJ7/jAY44rCxBS6952r/ryr+mEefXj31dJLhuK/YxHIslwnQmlYPdQKKfQEwYoeCgh5e55m//vr+dKbTuSOXGhtVxNGUykdg59cuH+Td3WQA+hyEu46mKh47Pq4PEWI6eT14Hcodk7gGKXNbURWxFaZNrP3/WwUx0B9AJDw+4iyzyK/MmTzphCwwk36NdYVAxF/EB/I5FFqupbSSn1jIgX6xA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR12MB5229.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(366004)(346002)(39860400002)(136003)(396003)(451199024)(1800799009)(186009)(5660300002)(4326008)(8676002)(86362001)(54906003)(41300700001)(316002)(66476007)(31686004)(8936002)(6916009)(66556008)(66946007)(31696002)(66899024)(36756003)(478600001)(2906002)(2616005)(6486002)(6506007)(26005)(53546011)(6666004)(6512007)(38100700002)(4744005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MFJ4bXZCRERnL0J6TlJjWHZBZlRUWlNySFVERmlKNjdOVFk4R2xYZjZDbitv?= =?utf-8?B?TDF6MkNZKzgzOXVoN2VHemNJeWhHYUZ3ZGd4NW1MaFpCVkxieHZWY284QkVT?= =?utf-8?B?QzVrUGxWdnpNQ1lDK2RGajJHa1BQT2Uwcnl6NzFCekZ3cTJUTUwwZXpCQm9T?= =?utf-8?B?VkFNSzRLejFtbXZxK29ZVlo5Ymp4ZXlselRJQUlCb3FzUHcxdEZLOThaNHdo?= =?utf-8?B?MCtFejFvaUV5b3NJYmgxV3BiQzFMVk8xUDQxRS9RTnlRVndqanBLZXM5aTFy?= =?utf-8?B?R3hDSktvMTJkdURINWt0Y1NkNWhadndTYWEvTHhNT0pSUktsL05CKzkvNmx1?=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rg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9aa38bac-c58c-4a95-1703-08dbb60c2ba1 X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5229.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2023 16:52:39.2497 (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: EHeFKAfIOPLQVj2d0rivlifkzJsbXMgRC3HJ8vmOBnWFudoVcKq3hyZfmZ4BHcWVp3txwjDqkGueN0DojVOw7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6414 X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 15 Sep 2023 09:53:21 -0700 (PDT) On 9/14/23 15:48, Tom Lendacky wrote: > On 9/14/23 15:28, Sean Christopherson wrote: >> On Thu, Sep 14, 2023, Tom Lendacky wrote: > >> >>> +        if (guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP)) >>> +            svm_clr_intercept(svm, INTERCEPT_RDTSCP); >> >> Same thing here. > > Will do. For RDTSCP, svm_recalc_instruction_intercepts() will set/clear the RDTSCP intercept as part of the svm_vcpu_set_after_cpuid() path, but it will only do it based on kvm_cpu_cap_has(X86_FEATURE_RDTSCP) being true, which is very likely. Do you think that is good enough and we can drop the setting and clearing of the RDTSCP intercept in the sev_es_vcpu_set_after_cpuid() function and only deal with the TSC_AUX MSR intercept? On a side note, it looks like RDTSCP would not be intercepted if the KVM cap X86_FEATURE_RDTSCP feature is cleared, however unlikely, in kvm_set_cpu_caps() and RDTSCP is not advertised to the guest (assuming the guest is ignoring the RDTSCP CPUID bit). Thanks, Tom > > Thanks, > Tom > >> >>> +    } >>> +}