All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Zhang <yang.zhang.wz@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Xiao Guangrong <guangrong.xiao@linux.intel.com>,
	Huaitong Han <huaitong.han@intel.com>,
	gleb@kernel.org
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH V4 7/7] KVM, pkeys: disable PKU feature without ept
Date: Wed, 9 Mar 2016 14:24:06 +0800	[thread overview]
Message-ID: <56DFC186.6020604@gmail.com> (raw)
In-Reply-To: <56DE91BD.4010502@redhat.com>

On 2016/3/8 16:47, Paolo Bonzini wrote:
>
>
> On 08/03/2016 06:54, Xiao Guangrong wrote:
>>
>>
>> On 03/07/2016 04:32 AM, Paolo Bonzini wrote:
>>>
>>>
>>> On 06/03/2016 10:28, Xiao Guangrong wrote:
>>>>> This patch disables CPUID:PKU without ept, because pkeys is not yet
>>>>> implemented for shadow paging.
>>>>
>>>> Does the PKRU is loaded/saved during vm-enter/vm-exit?
>>>
>>> Yes, through XSAVE/XRSTOR (which uses eager mode when PKE is active).
>>
>> You mean eager fpu? however, eager-fpu depends on 'eagerfpu' which is a
>> kernel parameter and this patchset did not force it on.
>
> Some XSAVE features (currently only MPX, but in the future PKRU too)
> will force eagerfpu on, see fpu__init_system_ctx_switch:
>
>          if (xfeatures_mask & XFEATURE_MASK_EAGER) {
>                  if (eagerfpu == DISABLE) {
>                          xfeatures_mask &= ~XFEATURE_MASK_EAGER;
>                  } else {
>                          eagerfpu = ENABLE;
>                  }
>          }
>
>          if (eagerfpu == ENABLE)
>                  setup_force_cpu_cap(X86_FEATURE_EAGER_FPU);
>
> KVM only exposes a subset of the host XSAVE features so the FPU is
> always eager if KVM exposes MPX and PKRU.
>
>> However, even if we use eager-fpu kvm still can lazily save/load due to
>> some fpu optimizations in kvm.
>
> KVM will use eager FPU if the host uses it.  See arch/x86/kvm/cpuid.c:

Why KVM needs to uses eager FPU if the host uses it? I remember the 
prerequisite for eager FPU is guest has MPX feature. Besides, i noticed 
the original patch only enable eager_fpu whe guest has it:

vcpu->arch.eager_fpu = guest_cpuid_has_mpx(vcpu);

Is there any discussion around this changes? I cannot find it through 
google. :(

>
> 	vcpu->arch.eager_fpu =
> 		use_eager_fpu() || guest_cpuid_has_mpx(vcpu);
>
> But the guest_cpuid_has_mpx(vcpu) check is unnecessary.  The guest CPUID
> cannot have MPX if the host doesn't have the BNDREGS and BNDCSR
> features...  Another patch to send. :)
>
>>>> BTW, I just very quickly go through the spec, it seems VMX lacks the
>>>> ability to intercept the access to PKRU. Right?
>>>
>>> Indeed RDPKRU/WRPKRU cannot be intercepted.
>>
>> Er, i was thinking using this feature to speedup write-protection for
>> shadow page table and dirty-logging... it seems not easy as PKRU can not
>> be intercepted. :(
>
> Also it only works on U=1 pages.
>
> Paolo
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


-- 
best regards
yang

      parent reply	other threads:[~2016-03-09  6:24 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-05 11:27 [PATCH V4 0/7] KVM, pkeys: add memory protection-key support Huaitong Han
2016-03-05 11:27 ` [PATCH V4 1/7] KVM, pkeys: expose CPUID/CR4 to guest Huaitong Han
2016-03-06  7:15   ` Xiao Guangrong
2016-03-06 23:20     ` Paolo Bonzini
2016-03-08  7:39       ` Xiao Guangrong
2016-03-08  7:58         ` Paolo Bonzini
2016-03-05 11:27 ` [PATCH V4 2/7] KVM, pkeys: disable pkeys for guests in non-paging mode Huaitong Han
2016-03-06  7:19   ` Xiao Guangrong
2016-03-08 12:09   ` Yang Zhang
2016-03-08 12:11     ` Paolo Bonzini
2016-03-08 13:02       ` Yang Zhang
2016-03-05 11:27 ` [PATCH V4 3/7] KVM, pkeys: update memeory permission bitmask for pkeys Huaitong Han
2016-03-06  7:42   ` Xiao Guangrong
2016-03-06 23:14     ` Paolo Bonzini
2016-03-08  7:35       ` Xiao Guangrong
2016-03-08  8:29         ` Paolo Bonzini
2016-03-08  9:19           ` Xiao Guangrong
2016-03-08 10:01             ` Paolo Bonzini
2016-03-09  5:03               ` Xiao Guangrong
2016-03-09  8:10                 ` Paolo Bonzini
2016-03-05 11:27 ` [PATCH V4 4/7] KVM, pkeys: add pkeys support for permission_fault logic Huaitong Han
2016-03-06  8:00   ` Xiao Guangrong
2016-03-06 20:36     ` Paolo Bonzini
2016-03-06 23:29       ` Paolo Bonzini
2016-03-08  5:57       ` Xiao Guangrong
2016-03-05 11:27 ` [PATCH V4 5/7] KVM, pkeys: Add pkeys support for gva_to_gpa funcions Huaitong Han
2016-03-06  8:01   ` Xiao Guangrong
2016-03-06 21:33     ` Paolo Bonzini
2016-03-05 11:27 ` [PATCH V4 6/7] KVM, pkeys: add pkeys support for xsave state Huaitong Han
2016-03-06  8:27   ` Xiao Guangrong
2016-03-05 11:27 ` [PATCH V4 7/7] KVM, pkeys: disable PKU feature without ept Huaitong Han
2016-03-06  9:28   ` Xiao Guangrong
2016-03-06 20:32     ` Paolo Bonzini
2016-03-08  5:54       ` Xiao Guangrong
2016-03-08  8:47         ` Paolo Bonzini
2016-03-08  9:32           ` Xiao Guangrong
2016-03-08 10:02             ` Paolo Bonzini
2016-03-09  5:51               ` Xiao Guangrong
2016-03-09  6:37                 ` Yang Zhang
2016-03-09  7:21                   ` Xiao Guangrong
2016-03-09  7:41                     ` Yang Zhang
2016-03-09  7:50                       ` Xiao Guangrong
2016-03-09  8:00                         ` Yang Zhang
2016-03-09  8:05                           ` Xiao Guangrong
2016-03-09  8:18                             ` Paolo Bonzini
2016-03-09  8:13                 ` Paolo Bonzini
2016-03-09  6:24           ` Yang Zhang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56DFC186.6020604@gmail.com \
    --to=yang.zhang.wz@gmail.com \
    --cc=gleb@kernel.org \
    --cc=guangrong.xiao@linux.intel.com \
    --cc=huaitong.han@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.