Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4247081pxb; Tue, 26 Jan 2021 17:00:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyY2IZYH6czjs7stk+96fZ38hm2kGdaLq+GFJJEhomGjsO/svA4C/VKlo3OMLbdfTpfRGXh X-Received: by 2002:a17:906:b74f:: with SMTP id fx15mr4938446ejb.257.1611709222167; Tue, 26 Jan 2021 17:00:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611709222; cv=none; d=google.com; s=arc-20160816; b=ERzV4Ley6hKAJgfbm1qTXnj+/c74FvGoe49oc805MRtPAwbgrzgMAcYCFK+KTf8Lsh LUu0M3Sy3ArKPHqTuk8MQwmfvieWZJzjiZK80bV+t5nZZVqXsUEXn3xsFbjRYZjDwxx9 dkte01dOGzvuehiGRHF4H1AF4H9qa4E70+LQfF6VCBbUq8ljQkiTyQDlSNwaZZB5nY3t efeQpzvFWUGQQ41+L7bji5EPm5x0GQIlbEVerVfOtCU4TqF0u8/S/WxX9IlMOT3D/Zgb BsVDRkohtka5b/fbEb6JMtU3qv8MrWYDsZSshOBUu8CObFf03ylRNETzVfRuHwrZyRKb KOoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=MdWP0uQnXXkXJZHH0rQndsx8DUDi4/ani+vrBbllukg=; b=kVydvkLlKUIKZzyvay2EkjU9Gb0VHPtNl87G/gP+XMhrfvlj5XFaCaxkBmzon6E2pf 7X6uhf60lon2RFPFmQRHUJU08fU8SW5BMZnmOd/pA252tQ93gW9QNOsNrA345ayuYZ11 V5gPejIt92uV6Ptw389/pOFHDdJB8Z2WpYZCsYYCx3HJJjcXTvVT3ylYjbCKWwVGczVf 9buyYdTIm3gxOc5ji8Bzd1sD7pMq+ElypZIv45HkhcUc8dt57DdfM0lH9jKu07gyKo5t FvqqEEeHyx3C6ZeN2UaA228J9wZ8nPxPEOJbrSYPtk1jAZhIXE2RQqNCivwnEPrDf1PZ 0WTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KFnglcPj; 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 z2si131780eju.570.2021.01.26.16.59.44; Tue, 26 Jan 2021 17:00:22 -0800 (PST) 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=KFnglcPj; 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 S2404647AbhA0Axr (ORCPT + 99 others); Tue, 26 Jan 2021 19:53:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51038 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393978AbhAZSDa (ORCPT ); Tue, 26 Jan 2021 13:03:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611684121; 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=MdWP0uQnXXkXJZHH0rQndsx8DUDi4/ani+vrBbllukg=; b=KFnglcPjKf+yj0GIvQedVixzdiDt12I2bqNEk1HqnQl4V9xf6KuK78y7CY2SrTkrkr9Q2X O3Whl2VcNLvHSwQD2P+b+BflPVJnOXJ1s5x8qlLVQwiG2KaRvcIht9xTvN9KDEYYeepoVC 7qjK50x9jMKrLnXqiLEoDO3tqVWssgM= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-499-KBjijCPpMRa4mYFgTrJ_RA-1; Tue, 26 Jan 2021 13:01:59 -0500 X-MC-Unique: KBjijCPpMRa4mYFgTrJ_RA-1 Received: by mail-ed1-f72.google.com with SMTP id y6so9787388edc.17 for ; Tue, 26 Jan 2021 10:01:59 -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=MdWP0uQnXXkXJZHH0rQndsx8DUDi4/ani+vrBbllukg=; b=QmaFvZUXSRWXXGXN+TkGRuIeRi6jPO9TuH44XK4hyUSqmb5BDYgr5WH8EqK/WiScKy lE+WYUGMK9dmpxnqv5ewTEutb3sdKh4ccYR0xUBOv4BI5QJWhB8n1IeADl1nMS+zL0eT CRPlWKPkVVw9infLV9/JFRy7LS2BD2Qfp5mG3MwIuBk+GMwAge3IlBqjGEl74/XPoWb8 pXWE27hEM1dPKtEq2CfzRP/LvPy6/iRVZ5CfGMl9Xhp8qWgFo3yCiq2plcLF28htZePR xR8SXTTF4ZAFx7bdNBd/1rfkhIUaeOeLxSxn5PDbw2KQh5tDqN4Q1l/G31bNnUcinYFo v0uA== X-Gm-Message-State: AOAM530ke6SJDDx7DcNoSpFhnrAdgMlB8hPSrfLBqNzXxSqkg2xvTz1G Vj5wYiPwkENdCTDuhJlwtDyt6WWZOQefwZkRxtVU94Mh/04EDuoRXfW7YSgJLY16id+IG2h1j8a kiN668lp/291ml0DlZ5olboCVdzMAEEWP+GNHMChUTE6KIWb5e1k/preccFKJFeatN/XA6KeGi8 DI X-Received: by 2002:a05:6402:254b:: with SMTP id l11mr5464498edb.202.1611684117724; Tue, 26 Jan 2021 10:01:57 -0800 (PST) X-Received: by 2002:a05:6402:254b:: with SMTP id l11mr5464468edb.202.1611684117441; Tue, 26 Jan 2021 10:01:57 -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 s2sm8187970edx.77.2021.01.26.10.01.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Jan 2021 10:01:56 -0800 (PST) Subject: Re: [RFC 2/7] KVM: VMX: Expose IA32_PKRS MSR To: Chenyi Qiang , Sean Christopherson , 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> From: Paolo Bonzini Message-ID: <62f5f5ba-cbe9-231d-365a-80a656208e37@redhat.com> Date: Tue, 26 Jan 2021 19:01:55 +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: <20200807084841.7112-3-chenyi.qiang@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/08/20 10:48, Chenyi Qiang wrote: > +{ > + struct vcpu_vmx *vmx = to_vmx(vcpu); > + unsigned long *msr_bitmap = vmx->vmcs01.msr_bitmap; > + bool pks_supported = guest_cpuid_has(vcpu, X86_FEATURE_PKS); > + > + /* > + * set intercept for PKRS when the guest doesn't support pks > + */ > + vmx_set_intercept_for_msr(msr_bitmap, MSR_IA32_PKRS, MSR_TYPE_RW, !pks_supported); > + > + if (pks_supported) { > + vm_entry_controls_setbit(vmx, VM_ENTRY_LOAD_IA32_PKRS); > + vm_exit_controls_setbit(vmx, VM_EXIT_LOAD_IA32_PKRS); > + } else { > + vm_entry_controls_clearbit(vmx, VM_ENTRY_LOAD_IA32_PKRS); > + vm_exit_controls_clearbit(vmx, VM_EXIT_LOAD_IA32_PKRS); > + } 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. Paolo