mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] x86: fix small LDT allocation for Xen
@ 2015-09-02 15:45 Jan Beulich
  2015-09-14 12:20 ` [tip:x86/urgent] x86/ldt: Fix " tip-bot for Jan Beulich
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2015-09-02 15:45 UTC (permalink / raw)
  To: mingo, tglx, hpa
  Cc: David Vrabel, luto, Boris Ostrovsky, Konrad Rzeszutek Wilk, linux-kernel

While commit 37868fe113 ("x86/ldt: Make modify_ldt synchronous") added
a nice comment explaining that Xen needs page-aligned whole page chunks
for guest descriptor tables, it then nevertheless used kzalloc() on the
small size path. As I'm unaware of guarantees for kmalloc(PAGE_SIZE, )
to return page-aligned memory blocks, I believe this needs to be
switched back to __get_free_page() (or better get_zeroed_page()).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
v3: Use get_zeroed_page() and free_page() respectively.
---
 arch/x86/kernel/ldt.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- 4.2/arch/x86/kernel/ldt.c
+++ 4.2-x86-LDT-alloc/arch/x86/kernel/ldt.c
@@ -58,7 +58,7 @@ static struct ldt_struct *alloc_ldt_stru
 	if (alloc_size > PAGE_SIZE)
 		new_ldt->entries = vzalloc(alloc_size);
 	else
-		new_ldt->entries = kzalloc(PAGE_SIZE, GFP_KERNEL);
+		new_ldt->entries = (void *)get_zeroed_page(GFP_KERNEL);
 
 	if (!new_ldt->entries) {
 		kfree(new_ldt);
@@ -95,7 +95,7 @@ static void free_ldt_struct(struct ldt_s
 	if (ldt->size * LDT_ENTRY_SIZE > PAGE_SIZE)
 		vfree(ldt->entries);
 	else
-		kfree(ldt->entries);
+		free_page((unsigned long)ldt->entries);
 	kfree(ldt);
 }
 




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-14 12:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-02 15:45 [PATCH v3] x86: fix small LDT allocation for Xen Jan Beulich
2015-09-14 12:20 ` [tip:x86/urgent] x86/ldt: Fix " tip-bot for Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®