Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp420722ybt; Wed, 17 Jun 2020 04:40:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxADH04IKXXBQz1qfMIV4N+XZlm6pK0vTfjBRNIkYyNhQ6Hrmz2nKDBikc7Q/PsLpx+nlTr X-Received: by 2002:a17:906:32d4:: with SMTP id k20mr6760471ejk.364.1592394036006; Wed, 17 Jun 2020 04:40:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592394036; cv=none; d=google.com; s=arc-20160816; b=WUYiGlycr+4d1T6sY4lk+lMO3XxR//hKXTN+pE3ROiuDC1E3Soea9DgG2B2/iEg2Ib mQ5nlH0dGy6c84N1+z/Zx0iPcBZB7UUK1HO0SWwsptVYgdEbB2+sIq11Nk6twYdBTI+B PHTrzurn5/BeFG2pTTr0PH4uia9XRGaKLSz/eUE+gvAJbB41KyDKooZ7E+pczG2JJzro d4cybtlHwg22NOK74uQdMV2FNY8paHJItSUqmpYpmIFzgQm3NZ+YvpgP0jvZtJabFs2M 1BGidBlmdR+GIu8KR8BmVjJvaMxSrUlipCvlGbVXboNltUig85V/ggbA8IHJFjxlM3Ww 2B6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=oS2sHeOWkDi5/NnXrNwUVCA9Ew0qnl4Cg+hQYeorxVM=; b=AtdfxhkoctD39xnZTNBOqtHwxfgEafJXyDUy16rmRZc2bAy9zCt8CoSZlzfK8r0C6e KFBdN5KVKnpY5jVsZpqvAYt+HmbADhWL7lo5JtXapY6xKIr2u3Lzk0INVVEMnlsL5vbz IYiSFFqka740jCygL8jKjGAQM77tWkmJaXKCGxPt+yIcxKQ9yU4rofnTndhbDvcxnyPr 5rLyypq2TgV3RSxZ0S3Um/6vgv8qwHp7fXQpkGDWCvXbOtVLWO0mqaWx7QoNSA3UQrAO VTQoejk0QCAX89usKg5Y08mXJbQSs0autk6T9POKxPNzVegE0U7Ag6WikuKXO+2KLjpw y/uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hi+jKuFX; 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 gv16si13072223ejb.437.2020.06.17.04.40.13; Wed, 17 Jun 2020 04:40:35 -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=hi+jKuFX; 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 S1726857AbgFQLiL (ORCPT + 99 others); Wed, 17 Jun 2020 07:38:11 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:37303 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726879AbgFQLiI (ORCPT ); Wed, 17 Jun 2020 07:38:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592393886; 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: in-reply-to:in-reply-to:references:references; bh=oS2sHeOWkDi5/NnXrNwUVCA9Ew0qnl4Cg+hQYeorxVM=; b=hi+jKuFXEx7wcmDZxxEWD6G0Vfl0Ama/z523llu6qHix6K94zWGwVdk8TIz+K7KaKmNl+s 8Spv6CYdFhKuWoq5Cz2LHl7zYgkED1fRpN1VPrA6urIhQ6jxQDw2x8Y+0TwZv08GdOQRg4 EuFCvfMs9++FCC6CB/NMHOGqZ96XsBs= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-103-m2dfZQHAO5KuHX4b0HuHNA-1; Wed, 17 Jun 2020 07:38:04 -0400 X-MC-Unique: m2dfZQHAO5KuHX4b0HuHNA-1 Received: by mail-ej1-f71.google.com with SMTP id op14so898132ejb.15 for ; Wed, 17 Jun 2020 04:38:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=oS2sHeOWkDi5/NnXrNwUVCA9Ew0qnl4Cg+hQYeorxVM=; b=slrMPy+iDDEZWYN/dMEin/bbZ9f4ai7htN94ieZ7WEDKYGNJKfm1yefxq7qigolWnJ VQ/5Czt4D9tf0pmaaRwiYcT07O/CweCacBgWw9Yx7U936SbBJvJOSOhw8iR20iEEq901 ZJl95gDaH0Q+6bLw+WLoLlHRku1+B5kc98XoxZr2Jh2238bp0ztq+L/mN9hy3W8hKs9P YV2L4Ut11vjXmwMyoMMEuBUL5XPtGBkGCAV4oTWQxk2FzNuTdgRth1VWq1vYxmjOo8WF m5BV+9ad2KqiJTzRGV2MVYWSs8LlBaQX5psivTzQHWPqDbcXdMzvnCUdS9xI7UrGpsdq qubA== X-Gm-Message-State: AOAM531Zp9Ay+K84j7S7VtdH5v43pOR2rXXBxZevbuii8Pf70dEfgFXW vrPP3huiRE1g6SMd9VUgdEnAfEhCRaMuxGrumLn9beMIzX2Y0qbGisUfCf0BlLZMlyGsP4FAi9X DuBeanNZlziBJsU6CWxjagD8Y X-Received: by 2002:a05:6402:1512:: with SMTP id f18mr7008261edw.101.1592393883362; Wed, 17 Jun 2020 04:38:03 -0700 (PDT) X-Received: by 2002:a05:6402:1512:: with SMTP id f18mr7008246edw.101.1592393883098; Wed, 17 Jun 2020 04:38:03 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id v5sm11829338edl.51.2020.06.17.04.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 04:38:02 -0700 (PDT) From: Vitaly Kuznetsov To: Jim Mattson Cc: kvm list , Paolo Bonzini , Sean Christopherson , Wanpeng Li , Like Xu , LKML Subject: Re: [PATCH] KVM: SVM: drop MSR_IA32_PERF_CAPABILITIES from emulated MSRs In-Reply-To: References: <20200616161427.375651-1-vkuznets@redhat.com> <87366vhscx.fsf@vitty.brq.redhat.com> Date: Wed, 17 Jun 2020 13:38:01 +0200 Message-ID: <87wo45hqhy.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jim Mattson writes: > On Tue, Jun 16, 2020 at 9:45 AM Vitaly Kuznetsov wrote: >> >> Jim Mattson writes: >> >> > On Tue, Jun 16, 2020 at 9:14 AM Vitaly Kuznetsov wrote: >> >> >> >> state_test/smm_test selftests are failing on AMD with: >> >> "Unexpected result from KVM_GET_MSRS, r: 51 (failed MSR was 0x345)" >> >> >> >> MSR_IA32_PERF_CAPABILITIES is an emulated MSR indeed but only on Intel, >> >> make svm_has_emulated_msr() skip it so it is not returned by >> >> KVM_GET_MSR_INDEX_LIST. >> > >> > Do we need to support this MSR under SVM for cross-vendor migration? >> > Or, have we given up on that? >> >> To be honest I'm not sure about the status of cross-vendor migration in >> general and PMU implications in particular, hope Paolo/Sean can shed >> some light. In this particular case my shallow understanding is that >> MSR_IA32_PERF_CAPABILITIES has only one known feature bit which unlocks >> an MSR range with additional counters. If the feature bit is not set >> this, I guess, can easily be migrated (basically, let's allow writing >> '0' there on AMD and return '0' on read). But what if the feature was >> enabled? We'll have to support the new MSR range and do something with >> it after migration (run intel_pmu in fully emulated mode?). >> >> Anyway, the immediate issue I'm trying to fix here is: whatever is >> returned by KVM_GET_MSR_INDEX_LIST can be successfully queried with >> KVM_GET_MSRS as some userspaces count on that. > > That's a nice property. Is it documented somewhere? > Hm, good question. Documentation/virt/kvm/api.rst says: "KVM_GET_MSR_INDEX_LIST returns the guest msrs that are supported. The list varies by kvm version and host processor, but does not change otherwise. [...] KVM_GET_MSR_FEATURE_INDEX_LIST returns the list of MSRs that can be passed to the KVM_GET_MSRS system ioctl. This lets userspace probe host capabilities and processor features that are exposed via MSRs (e.g., VMX capabilities)." Side note: MSR_IA32_PERF_CAPABILITIES can be returned by both KVM_GET_MSR_INDEX_LIST and KVM_GET_MSR_FEATURE_INDEX_LIST as we have it both as an emulated MSR filtered by kvm_x86_ops.has_emulated_msr() and a feature msr filtered by kvm_x86_ops.get_msr_feature(). But the later is a whitelist so MSR_IA32_PERF_CAPABILITIES won't appear on AMD and the promise "can be passed to the KVM_GET_MSRS" is kept. For KVM_GET_MSR_INDEX_LIST, the promise is "guest msrs that are supported" and I'm not exactly sure what this means. Personally, I see no point in returning MSRs which can't be read with KVM_GET_MSRS (as this also means the guest can't read them) and KVM selftests seem to rely on that (vcpu_save_state()) but this is not a documented feature. > Reviewed-by: Jim Mattson > Thanks! -- Vitaly