From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.6 required=3.0 tests=BAYES_00,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,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87988C433DB for ; Mon, 1 Feb 2021 10:08:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C36760295 for ; Mon, 1 Feb 2021 10:08:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233103AbhBAKHp (ORCPT ); Mon, 1 Feb 2021 05:07:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:30064 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233083AbhBAKGz (ORCPT ); Mon, 1 Feb 2021 05:06:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612173928; 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=hnrqm+5Orx/lAieV+sFAve7SQJvuYv/3WsI5oCSpaDs=; b=i3PHw8NXNtY1k6bM13rQtbgYMY+ebeYbmo5AM8s9KJY4/Ur3Fnw4ybHiScYL9B3yezgovu xzuawSxT4Uzt0L5fPI3uN+7AO7o7Tb/casE47oB6C0swMVrXQXZDLeGnXBYUXdVlgEPgRM mCPadSFe/LEqVnKYdFSJKOcp1P1x1TU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-160-RO_MAhQ7NXOvtJX3m46gcw-1; Mon, 01 Feb 2021 05:05:27 -0500 X-MC-Unique: RO_MAhQ7NXOvtJX3m46gcw-1 Received: by mail-wr1-f72.google.com with SMTP id x7so10071962wrp.9 for ; Mon, 01 Feb 2021 02:05:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hnrqm+5Orx/lAieV+sFAve7SQJvuYv/3WsI5oCSpaDs=; b=P8DHAXBxd2yCozsS8Gs0hJ1a+oGHQCckLhSH/OY3OwPdgMXBV43lod0uCuPsfK62hM KbAU4+GxMSFmGpIyRnp7M9SZ6ZVX+HHgnxN7BIWaeOhUVRK25XlvYsgtAR7RfDsAslR7 JJaqCqvHdw/UolhpYOuJS1v+x2+R/L4NQlR/3L5gcbTRT2kgOeLApsktLnSVst+CebhL AJd9GK5hD63udbJdMOFsx9G6fSRDvHHVXRJagKu0fgd9XN/1TTR10+vOY6wIdeCWqdSv nt7Jg+tYafq8y5gPffTSxl0igDKKzBoGG5EvDeoMdkxzPHBdAJ8hRAsNMelQ3+AZ1fhJ SRRw== X-Gm-Message-State: AOAM531+P6P/MdaMpd0KUqAASAGfOEjv9452d6yREzaVfuDUIZvqXwzl 6KWPn0nvtvaHA/eLHN/C914qNUhMsx5P/2FpjrdoUXpzCeEonlaioVQKQaVXPCJa0bBoMmLkm4Q /beYDHPViNN1SgYo4wq/TVw3EA9m4RNKjR0suifetEUqaUZkstm5Crw54xM7ikICjcU7tECXeeY eh X-Received: by 2002:a5d:4b8e:: with SMTP id b14mr16835041wrt.130.1612173925783; Mon, 01 Feb 2021 02:05:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHqEKDZMztc6oYFmsWJE7+DzZDMGYfZt6wGifS7Lt1RNnM9xp9h2TviiF5fV0KuUXfhhESXw== X-Received: by 2002:a5d:4b8e:: with SMTP id b14mr16835008wrt.130.1612173925582; Mon, 01 Feb 2021 02:05:25 -0800 (PST) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id d5sm26108824wrs.21.2021.02.01.02.05.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Feb 2021 02:05:24 -0800 (PST) Subject: Re: [RFC 2/7] KVM: VMX: Expose IA32_PKRS MSR To: Chenyi Qiang , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Xiaoyao Li Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200807084841.7112-1-chenyi.qiang@intel.com> <20200807084841.7112-3-chenyi.qiang@intel.com> <62f5f5ba-cbe9-231d-365a-80a656208e37@redhat.com> From: Paolo Bonzini Message-ID: <192cfa2c-e54a-c7c1-30dd-7077e07e4af1@redhat.com> Date: Mon, 1 Feb 2021 11:05:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/02/21 10:53, Chenyi Qiang wrote: >>> >> >> Is the guest expected to do a lot of reads/writes to the MSR (e.g. at >> every context switch)? >> >> Even if this is the case, the MSR intercepts and the entry/exit >> controls should only be done if CR4.PKS=1.  If the guest does not use >> PKS, KVM should behave as if these patches did not exist. >> > > Hi Paolo, > > Per the MSR intercepts and entry/exit controls, IA32_PKRS access is > independent of the CR4.PKS bit, it just depends on CPUID enumeration. If > the guest doesn't set CR4.PKS but still has the CPUID capability, > modifying on PKRS should be supported but has no effect. IIUC, we can > not ignore these controls if CR4.PKS=0. Understood, I wanted to avoid paying the price (if any) of loading PKRS on vmentry and vmexit not just if CPUID.PKS=0, but also if CR4.PKS=0. If CR4.PKS=0 it would be nicer to enable the MSR intercept and disable the vmentry/vmexit controls; just run the guest with the host value of IA32_PKRS. Paolo