* [PATCH] kvm: x86: Adjust the location of pkru_mask of kvm_mmu to reduce memory
@ 2022-02-28 3:07 Peng Hao
2022-02-28 16:10 ` Sean Christopherson
2022-04-08 16:46 ` Paolo Bonzini
0 siblings, 2 replies; 3+ messages in thread
From: Peng Hao @ 2022-02-28 3:07 UTC (permalink / raw)
To: pbonzini; +Cc: kvm, linux-kernel
From: Peng Hao <flyingpeng@tencent.com>
Adjust the field pkru_mask to the back of direct_map to make up 8-byte
alignment.This reduces the size of kvm_mmu by 8 bytes.
Signed-off-by: Peng Hao <flyingpeng@tencent.com>
---
arch/x86/include/asm/kvm_host.h | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index e5d8700319cc..73dcb09abd5d 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -433,14 +433,6 @@ struct kvm_mmu {
u8 shadow_root_level;
u8 ept_ad;
bool direct_map;
- struct kvm_mmu_root_info prev_roots[KVM_MMU_NUM_PREV_ROOTS];
-
- /*
- * Bitmap; bit set = permission fault
- * Byte index: page fault error code [4:1]
- * Bit index: pte permissions in ACC_* format
- */
- u8 permissions[16];
/*
* The pkru_mask indicates if protection key checks are needed. It
@@ -450,6 +442,15 @@ struct kvm_mmu {
*/
u32 pkru_mask;
+ struct kvm_mmu_root_info prev_roots[KVM_MMU_NUM_PREV_ROOTS];
+
+ /*
+ * Bitmap; bit set = permission fault
+ * Byte index: page fault error code [4:1]
+ * Bit index: pte permissions in ACC_* format
+ */
+ u8 permissions[16];
+
u64 *pae_root;
u64 *pml4_root;
u64 *pml5_root;
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kvm: x86: Adjust the location of pkru_mask of kvm_mmu to reduce memory
2022-02-28 3:07 [PATCH] kvm: x86: Adjust the location of pkru_mask of kvm_mmu to reduce memory Peng Hao
@ 2022-02-28 16:10 ` Sean Christopherson
2022-04-08 16:46 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2022-02-28 16:10 UTC (permalink / raw)
To: Peng Hao; +Cc: pbonzini, kvm, linux-kernel
On Mon, Feb 28, 2022, Peng Hao wrote:
> From: Peng Hao <flyingpeng@tencent.com>
>
> Adjust the field pkru_mask to the back of direct_map to make up 8-byte
> alignment.This reduces the size of kvm_mmu by 8 bytes.
I'd prefer we just burn the extra 8 bytes, at least for now. 'prku' and 'permissions'
are related fields, IMO splitting them to save 24 bytes per vCPU isn't a good tradeoff.
And in the not-too-distant future, all of the 1-byte fields will hopefully go
away, at which point were "wasting" 4 bytes no matter where 'pkru' is defined. 'ept_ad'
can be dropped immediately, I'll send a patch for that. We should be able to drop
'root_level', 'shadow_root_level', and 'direct_map' once Paolo's clean up of the role
stuff lands.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kvm: x86: Adjust the location of pkru_mask of kvm_mmu to reduce memory
2022-02-28 3:07 [PATCH] kvm: x86: Adjust the location of pkru_mask of kvm_mmu to reduce memory Peng Hao
2022-02-28 16:10 ` Sean Christopherson
@ 2022-04-08 16:46 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2022-04-08 16:46 UTC (permalink / raw)
To: Peng Hao; +Cc: pbonzini, kvm, linux-kernel
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-08 16:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-28 3:07 [PATCH] kvm: x86: Adjust the location of pkru_mask of kvm_mmu to reduce memory Peng Hao
2022-02-28 16:10 ` Sean Christopherson
2022-04-08 16:46 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox