x86: move more stuff to lib/
v3 cover x86: move more stuff to lib/
1: move / split usercopy.c to / into arch-specific library 2: move mem{cpy,set}.S to arch-specific library
3: move {clear_,copy_,scrub-}page.S to arch-specific library
Jan
PATCH v3 1/3 x86: move / split usercopy.c to / into arch-specific library
The file wasn't correctly named for our purposes anyway. Split it into its "guest" and "unsafe" parts, thus allowing the latter to not be linked in at all (for presently having no caller). The building of the "guest" part can then (later) become conditional upon PV=y.
---
v3: Retain xen/sched.h #include.
---
xen/arch/x86/Makefile | 4 ----
xen/arch/x86/lib/Makefile | 2 ++
xen/arch/x86/{usercopy.c => lib/copy-guest.c} | 12 ++--------
xen/arch/x86/lib/copy-unsafe.c | 22 +++++++++++++++++++
4 files changed, 26 insertions(+), 14 deletions(-)
rename xen/arch/x86/{usercopy.c => lib/copy-guest.c} (94%)
create mode 100644 xen/arch/x86/lib/copy-unsafe.cxen/arch/x86/Makefile +0 -4
@@ -72,7 +72,6 @@ obj-y += time.o obj-y += traps-setup.o obj-y += traps.o obj-$(CONFIG_INTEL) += tsx.o -obj-y += usercopy.o obj-y += x86_emulate.o obj-$(CONFIG_TBOOT) += tboot.o obj-y += hpet.o
@@ -93,9 +92,6 @@ hostprogs-y += efi/mkreloc $(obj)/efi/mkreloc: HOSTCFLAGS += -I$(srctree)/include -# Allows usercopy.c to include itself -$(obj)/usercopy.o: CFLAGS-y += -iquote . - ifneq ($(CONFIG_HVM),y) $(obj)/x86_emulate.o: CFLAGS-y += -Wno-unused-label endif
xen/arch/x86/lib/Makefile +2 -0
@@ -1 +1,3 @@ +lib-y += copy-guest.o +lib-y += copy-unsafe.o lib-y += generic-hweightl.o
xen/arch/x86/lib/copy-guest.c renamed from xen/arch/x86/usercopy.c +2 -10
@@ -1,4 +1,4 @@ -/* +/* * User address space access functions. * * Copyright 1997 Andi Kleen <[email protected]>
@@ -6,8 +6,8 @@* Copyright 2002 Andi Kleen <[email protected]> */ -#include <xen/lib.h> #include <xen/sched.h> +#include <asm/uaccess.h> #ifndef GUARD
@@ -139,14 +139,6 @@ unsigned int copy_from_guest_pv(void *to, const void __user *from, return n; } -# undef GUARD -# define GUARD UA_DROP -# define copy_to_guest_ll copy_to_unsafe_ll -# define copy_from_guest_ll copy_from_unsafe_ll -# undef __user -# define __user -# include __FILE__ -#endif /* GUARD(1) */ /*
xen/arch/x86/lib/copy-unsafe.c new file +22 -0
@@ -0,0 +1,22 @@ +/* +* "Unsafe" access functions. +*/ + +#include <asm/uaccess.h> + +#define GUARD UA_DROP +#define copy_to_guest_ll copy_to_unsafe_ll +#define copy_from_guest_ll copy_from_unsafe_ll +#undef __user +#define __user +#include "copy-guest.c" + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
Re: [PATCH v3 1/3] x86: move / split usercopy.c to / into arch-specific library
Hi Jan,
Quoted 93 lines · Jan Beulich
The file wasn't correctly named for our purposes anyway. Split it into its "guest" and "unsafe" parts, thus allowing the latter to not be linked in at all (for presently having no caller). The building of the "guest" part can then (later) become conditional upon PV=y.
Signed-off-by Jan Beulich <[email protected]>---
v3: Retainxen/sched.h#include.--- xen/arch/x86/Makefile | 4 ---- xen/arch/x86/lib/Makefile | 2 ++ xen/arch/x86/{usercopy.c => lib/copy-guest.c} | 12 ++-------- xen/arch/x86/lib/copy-unsafe.c | 22 +++++++++++++++++++ 4 files changed, 26 insertions(+), 14 deletions(-)rename
xen/arch/x86/{usercopy.c=>lib/copy-guest.c} (94%) create mode 100644xen/arch/x86/lib/copy-unsafe.cxen/arch/x86/Makefile +0
-4@@ -72,7 +72,6 @@ obj-y += time.o obj-y += traps-setup.o obj-y += traps.o obj-$(CONFIG_INTEL) += tsx.o -obj-y += usercopy.o obj-y += x86_emulate.o obj-$(CONFIG_TBOOT) += tboot.o obj-y += hpet.o@@ -93,9 +92,6 @@ hostprogs-y += efi/mkreloc $(obj)/efi/mkreloc: HOSTCFLAGS += -I$(srctree)/include -# Allows usercopy.c to include itself -$(obj)/usercopy.o: CFLAGS-y += -iquote . - ifneq ($(CONFIG_HVM),y) $(obj)/x86_emulate.o: CFLAGS-y += -Wno-unused-label endifxen/arch/x86/lib/Makefile +2
-0@@ -1 +1,3 @@ +lib-y += copy-guest.o +lib-y += copy-unsafe.o lib-y += generic-hweightl.oxen/arch/x86/lib/copy-guest.c renamed from xen/arch/x86/usercopy.c +2
-10@@ -1,4 +1,4 @@ -/* +/* * User address space access functions. * * Copyright 1997 Andi Kleen <[email protected]> @@ -6,8 +6,8 @@* Copyright 2002 Andi Kleen <[email protected]> */ -#include <xen/lib.h> #include <xen/sched.h> +#include <asm/uaccess.h> #ifndef GUARD @@ -139,14 +139,6 @@ unsigned int copy_from_guest_pv(void *to, const void __user *from, return n; } -# undef GUARD -# define GUARD UA_DROP -# define copy_to_guest_ll copy_to_unsafe_ll -# define copy_from_guest_ll copy_from_unsafe_ll -# undef __user -# define __user -# include __FILE__ -#endif /* GUARD(1) */ /* xen/arch/x86/lib/copy-unsafe.c new file +2
-0@@ -0,0 +1,22 @@ +/* +* "Unsafe" access functions.
xen/arch/x86/lib/copy-unsafe.c line 12
Quoted 10 lines
xen/arch/x86/lib/copy-unsafe.c new file +10
-0+*/ + +#include <asm/uaccess.h> + +#define GUARD UA_DROP +#define copy_to_guest_ll copy_to_unsafe_ll +#define copy_from_guest_ll copy_from_unsafe_ll +#undef __user +#define __user +#include "copy-guest.c"
Thank you for doing this.
Signature · 2 lines
Best regards, -grygorii
PATCH v3 2/3 x86: move mem{cpy,set}.S to arch-specific library
In reply to Jan BeulichIf not these, what else are library functions.
---
v3: New.
---
xen/arch/x86/Makefile | 2 --
xen/arch/x86/lib/Makefile | 2 ++
xen/arch/x86/{ => lib}/memcpy.S | 0
xen/arch/x86/{ => lib}/memset.S | 0
4 files changed, 2 insertions(+), 2 deletions(-)
rename xen/arch/x86/{ => lib}/memcpy.S (100%)
rename xen/arch/x86/{ => lib}/memset.S (100%)xen/arch/x86/Makefile +0 -2
@@ -48,8 +48,6 @@ obj-$(CONFIG_RETURN_THUNK) += indirect-thunk.o obj-$(CONFIG_PV) += ioport_emulate.o obj-y += irq.o obj-$(CONFIG_KEXEC) += machine_kexec.o -obj-y += memcpy.o -obj-y += memset.o obj-y += mm.o x86_64/mm.o obj-$(CONFIG_VM_EVENT) += monitor.o obj-y += mpparse.o
xen/arch/x86/lib/Makefile +2 -0
@@ -1,3 +1,5 @@ lib-y += copy-guest.o lib-y += copy-unsafe.o lib-y += generic-hweightl.o +lib-y += memcpy.o +lib-y += memset.o
xen/arch/x86/lib/memcpy.S renamed from xen/arch/x86/memcpy.S +0 -0
xen/arch/x86/lib/memset.S renamed from xen/arch/x86/memset.S +0 -0
PATCH v3 3/3 x86: move {clear_,copy_,scrub-}page.S to arch-specific library
In reply to Jan BeulichThese are pretty similar to the standard library memset() / memcpy().
Switch to building scrub-page.S unconditionally; the linker will simply not pick it up when not needed.
---
v3: New.
---
While moving I noticed that the files here have .file at the top, while mem{cpy,set}.S don't. There not being any static symbols, likely we could omit the directives here, too? Or should mem{cpy,set}.S gain them?
---
xen/arch/x86/Makefile | 3 ---
xen/arch/x86/lib/Makefile | 3 +++
xen/arch/x86/{clear_page.S => lib/clear-page.S} | 0
xen/arch/x86/{copy_page.S => lib/copy-page.S} | 0
xen/arch/x86/{ => lib}/scrub-page.S | 0
5 files changed, 3 insertions(+), 3 deletions(-)
rename xen/arch/x86/{clear_page.S => lib/clear-page.S} (100%)
rename xen/arch/x86/{copy_page.S => lib/copy-page.S} (100%)
rename xen/arch/x86/{ => lib}/scrub-page.S (100%)xen/arch/x86/Makefile +0 -3
@@ -17,8 +17,6 @@ obj-y += apic.o obj-y += bhb-thunk.o obj-y += bitops.o obj-bin-y += bzimage.init.o -obj-bin-y += clear_page.o -obj-bin-y += copy_page.o obj-y += cpu-policy.o obj-y += cpuid.o obj-$(CONFIG_PV) += compat.o
@@ -57,7 +55,6 @@ obj-y += pci.o obj-y += physdev.o obj-$(CONFIG_COMPAT) += x86_64/physdev.o obj-$(CONFIG_X86_PSR) += psr.o -obj-bin-$(CONFIG_DEBUG) += scrub-page.o obj-y += setup.o obj-y += shutdown.o obj-y += smp.o
xen/arch/x86/lib/Makefile +3 -0
@@ -1,5 +1,8 @@ +lib-y += clear-page.o lib-y += copy-guest.o +lib-y += copy-page.o lib-y += copy-unsafe.o lib-y += generic-hweightl.o lib-y += memcpy.o lib-y += memset.o +lib-y += scrub-page.o
xen/arch/x86/lib/clear-page.S renamed from xen/arch/x86/clear_page.S +0 -0
xen/arch/x86/lib/copy-page.S renamed from xen/arch/x86/copy_page.S +0 -0
xen/arch/x86/lib/scrub-page.S renamed from xen/arch/x86/scrub-page.S +0 -0
Quoted 3 lines · Jan Beulich
1: move / split
usercopy.cto / into arch-specific library 2: move mem{cpy,set}.S to arch-specific library
3: move {clear_,copy_,scrub-}page.S to arch-specific library