Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3481567pxj; Tue, 11 May 2021 05:37:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTCKOL7nZ4bhPnOV94+F9JyPgSJXTiBM+yBz45H6tTgDj68j/xo8aG8ODdLGd+n26dx1kx X-Received: by 2002:a6b:f606:: with SMTP id n6mr21865061ioh.142.1620736627484; Tue, 11 May 2021 05:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620736627; cv=none; d=google.com; s=arc-20160816; b=HzTZvWV9C/0NtpxyBsVIj9Tt3m1FZv+7uvAFRCe+bjPuka2EA4lXDgsFoRi8uVNXtB kyGkgOT0hQ7bcRbNeOXo2yjgiPByD+gQA3DacSxk0y5sSaeNctRP/gFfP+37d+BHDLjt bcqeBnqxO4pRNc8Aj+zbizJcjfkYEovPLvcEiq1AwzL82oKyz/3Wh/q+WltWKTE4Q1Cp MSmp4HonVTDn/FXJur6FJdxTsUyGj/LPSqRh3IE7R8F+toxJaemKKMi3zTZAIN8a1ZBp 7duu/le5fM701w/nu9d3oIgM0F/X7914puL3xkKz7qKU5I29NeNQXmaLf9NtiWSfU3Sp HDlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=2QPkbbSWG9Bctna+DKSZ7C9IAc+76gV5dRWVuVO49Zw=; b=DS+zKWh+dqs5ZEoDVc4eGKvRujRUBunqNIydGWITWhdG3TU8bU9Y0BtwN7qvLdM1A6 IOHK2gCGawLnmrpKut/bB3ApoaJBk4lE04YdHp2uT+XuVU/mabvPMHH+2Q2GLggNeHKR 0Zvkb2z8Zzz0jWXm7I7spP57q4y5fmZjgy01gNQwlMwPvoGz8Ib8qQzgqeBDygzca+qv TRPcbCuV6cV03vGUh8RQ8xZ9RtFrYdp5MT1nkgHFU1W3YoZWDVeYgkV8+Cfz2F3M/ajG +8aja2P64jfk/5kJIOKVmWoDjruL0dHOcAvJLfJPJEuVXBECqYBzMX3krv4GTizj6GSd P+/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bSxXhSwd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r2si20536169ilj.25.2021.05.11.05.36.54; Tue, 11 May 2021 05:37:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bSxXhSwd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231597AbhEKMf7 (ORCPT + 99 others); Tue, 11 May 2021 08:35:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37255 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231569AbhEKMfx (ORCPT ); Tue, 11 May 2021 08:35:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620736485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2QPkbbSWG9Bctna+DKSZ7C9IAc+76gV5dRWVuVO49Zw=; b=bSxXhSwd0IwJ8cLn5jFduOeN4+4V8b/WRJIldKxNewiT58etnN5ZPGtoPbaM7NPMkdxODW 21EZnqGelAIdWiPhLuPWCATMQgL/ybOUeJCm+HBAK0bxUgjuswLy0C+fGfh2DI2wqj0KaF aW+CF5zkzO8ygXYpLOr6QDB+2zfQqSM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-130-K4tGLFgBMwSuO3t-yg36EA-1; Tue, 11 May 2021 08:34:43 -0400 X-MC-Unique: K4tGLFgBMwSuO3t-yg36EA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A299B803620; Tue, 11 May 2021 12:34:42 +0000 (UTC) Received: from starship (unknown [10.40.194.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id B122D5D6D1; Tue, 11 May 2021 12:34:39 +0000 (UTC) Message-ID: Subject: Re: [PATCH 14/15] KVM: x86: Tie Intel and AMD behavior for MSR_TSC_AUX to guest CPU model From: Maxim Levitsky To: Jim Mattson , Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm list , LKML , Xiaoyao Li , Reiji Watanabe Date: Tue, 11 May 2021 15:34:38 +0300 In-Reply-To: References: <20210504171734.1434054-1-seanjc@google.com> <20210504171734.1434054-15-seanjc@google.com> <7e75b44c0477a7fb87f83962e4ea2ed7337c37e5.camel@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2021-05-10 at 10:11 -0700, Jim Mattson wrote: > On Mon, May 10, 2021 at 9:50 AM Sean Christopherson wrote: > > On Mon, May 10, 2021, Maxim Levitsky wrote: > > > On Tue, 2021-05-04 at 10:17 -0700, Sean Christopherson wrote: > > > > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > > > > index de921935e8de..6c7c6a303cc5 100644 > > > > --- a/arch/x86/kvm/svm/svm.c > > > > +++ b/arch/x86/kvm/svm/svm.c > > > > @@ -2663,12 +2663,6 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) > > > > msr_info->data |= (u64)svm->sysenter_esp_hi << 32; > > > > break; > > > > case MSR_TSC_AUX: > > > > - if (tsc_aux_uret_slot < 0) > > > > - return 1; > > > > - if (!msr_info->host_initiated && > > > Not related to this patch, but I do wonder why do we need > > > to always allow writing this msr if done by the host, > > > since if neither RDTSPC nor RDPID are supported, the guest > > > won't be able to read this msr at all. > > > > It's an ordering thing and not specific to MSR_TSC_AUX. Exempting host userspace > > from guest CPUID checks allows userspace to set MSR state, e.g. during migration, > > before setting the guest CPUID model. > > I thought the rule was that if an MSR was enumerated by > KVM_GET_MSR_INDEX_LIST, then KVM had to accept legal writes from the > host. The only "ordering thing" is that KVM_GET_MSR_INDEX_LIST is a > device ioctl, so it can't take guest CPUID information into account. This makes sense. Thanks! Best regards, Maxim Levitsky > > > > > - !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP) && > > > > - !guest_cpuid_has(vcpu, X86_FEATURE_RDPID)) > > > > - return 1; > > > > msr_info->data = svm->tsc_aux; > > > > break; > > > > /*