[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e70af22a-f09f-aadb-8353-35b29d2def61@gmail.com>
Date: Sun, 7 May 2023 15:32:21 +0800
From: Robert Hoo <robert.hoo.linux@...il.com>
To: Mathias Krause <minipli@...ecurity.net>, kvm@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
Sean Christopherson <seanjc@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>
Subject: Re: [PATCH v4 2/6] KVM: x86: Do not unload MMU roots when only
toggling CR0.WP with TDP enabled
On 3/22/2023 9:37 AM, Mathias Krause wrote:
> There is no need to unload the MMU roots with TDP enabled when only
> CR0.WP has changed -- the paging structures are still valid, only the
> permission bitmap needs to be updated.
>
> One heavy user of toggling CR0.WP is grsecurity's KERNEXEC feature to
> implement kernel W^X.
>
> The optimization brings a huge performance gain for this case as the
> following micro-benchmark running 'ssdd 10 50000' from rt-tests[1] on a
> grsecurity L1 VM shows (runtime in seconds, lower is better):
>
> legacy TDP shadow
> kvm-x86/next@...08b 8.43s 9.45s 70.3s
> +patch 5.39s 5.63s 70.2s
>
> For legacy MMU this is ~36% faster, for TTP MMU even ~40% faster.
TTP --> TDP
> void kvm_post_set_cr0(struct kvm_vcpu *vcpu, unsigned long old_cr0, unsigned long cr0)
> {
> + /*
> + * CR0.WP is incorporated into the MMU role, but only for non-nested,
> + * indirect shadow MMUs. If TDP is enabled, the MMU's metadata needs
> + * to be updated, e.g. so that emulating guest translations does the
> + * right thing, but there's no need to unload the root as CR0.WP
> + * doesn't affect SPTEs.
> + */
> + if (tdp_enabled && (cr0 ^ old_cr0) == X86_CR0_WP) {
Curiously, this patch only affects tdp_enabled, why does legacy MMU also
see comparable performance gains?
Powered by blists - more mailing lists